You are on page 1of 20

DATABASE AND DATA STRUCTURE ASSIGNMENT

ASSIGNMENT TYPE: GROUP ASSIGNMENT


ASSIGNMENT CODE: AAPP001-3-2
ASSIGNMENT TITLE: LINKED LIST AND STACKS
NAME: TINAGARAJ A/L MORGAN (TP025931)
TULASINATAN A/L MUTHUALAGU (TP026049)
SRI SARANGGA RAJA A/L VELAN (TP025845)
YEHKHARAJ A/L TAMILARASU (TP025637)
INTAKE: UCD2F1209-DIT (SE)
LECTURER: MADAM. SEETHA LECTHUMI
DATE: 13/05/2013

1|Page

WORKLOAD MATRIX

Group Member (Effort (%))

Topic
Tinagaraj
(TP025931)

Tulasinatan
(TP026049)

Yehkharaj
(TP025637)

25%

Sri Sarangga
Raja
(TP025845)
25%

25%

25%

2. Workload Matrix

25%

25%

25%

25%

3. Source-Codes

25%

25%

25%

25%

4.Screen design

25%

25%

25%

25%

5. Testing

25%

25%

25%

25%

6. Reference

25%

25%

25%

25%

7. Group Effort

25%

25%

25%

25%

1. Introduction to the project

2|Page

CONTENTS
WORKLOAD MATRIX ..................................................................................................................................... 2
ACKNOWLEDGEMENT ................................................................................................................................... 4
INTRODUCTION ............................................................................................................................................. 5
SECTION A: LINKED LIST ............................................................................................................................ 5
SECTION B: STACKS ................................................................................................................................... 6
DATA STRUCTURE ......................................................................................................................................... 7
PART A - LINKED LIST................................................................................................................................. 7
PART B - STACKS ...................................................................................................................................... 11
SCREEN SHOTS ............................................................................................................................................ 12
PART A - LINKED LIST............................................................................................................................... 12
PART B - STACKS ...................................................................................................................................... 16
CONCLUSION............................................................................................................................................... 17
REFERENCE .................................................................................................................................................. 18
ASSIGNMENT MARKING SCHEME ............................................................................................................... 19

3|Page

ACKNOWLEDGEMENT

We would like to express our deepest appreciation to all those who provided me the possibility to
complete this assignment. A special gratitude we give to our DBDS Lecturer, Madam.Seetha
Lecthumi whose contribution in stimulating suggestions and encouragement helped us to
coordinate our assignment especially in the system part.
Finally, an honorable mention goes to our families and friends for their understandings and
supports me in completing this assignment. Without helps of the particular that mentioned above,
we could face many difficulties while doing this.

Tulasinatan Muthualagu
Tinagaraj Morgan
Sri Sarangga Raja Velan
Yehkharaj Tamilarasu

4|Page

INTRODUCTION

This project includes of two parts, Part A (Linked list) and Part B (Stack). This introduction
portion will debate concerning these two cases in finished and the rest of the documentation will
debate what the assignment is all about.

SECTION A: LINKED LIST


Stack is an abstract data type and data structure based on the principle of Last in First
Out(LIFO). Stack is used in computer science such as algorithms, compilers, keeping track of
procedure calls and operating systems.
Stacks have some useful terminology associated with them:

Push To add an element to the stack

Pop To remove an element from the stock

Peek To look at elements in the stack without removing them

LIFO Refers to the last in, first out behavior of the stack

FILO Equivalent to LIFO

5|Page

SECTION B: STACKS

Link List
Linked list is one of the frank data constructions, and can be utilized to implement
supplementary data structures.Data structures can be added to or removed from the linked
list during execution. There several types of linked list operations append a node to the
end of the list; insert a node within the list; traverse the linked list; delete a node.

6|Page

DATA STRUCTURE
PART A - LINKED LIST
Source File

#include <stdio.h>
#include<stdlib.h>
#include <conio.h>
#include<string.h>

struct Transaction
{
char name[50];
char numb[50];
char more[99];
int prev;
int next;
}
trans[100]={0};
int count = 0;
int start = 0;
int terma = 0;
#include "Methods.h"
int main() {
int choice; populate();
printf("Welcome to Our System\n\n\n");
do {
system("pause && cls");
printf("Main Menu\n\n\n");
printf("1. Add to Start\n");
printf("2. Add to End\n");
printf("3. Print List\n");
printf("4. Remove a Node\n");
printf("\n0. Quit System\n");
printf("\n\n Enter choice: ");
scanf("%d", &choice);
fflush(stdin);
system("cls");
switch (choice)
{
case 1: addToStart(); break;

7|Page

case 2: addToEnd(); break;


case 3: printList(); break;
case 4: removeNodeAt(); break;
default: choice=0; break;
}
fflush(stdin);
} while(choice>0);
printf("Thanks\n\n");
system("pause");
return 0;
}

Header File
void
void
void
void
void

populate();
addToStart();
addToEnd();
printList();
removeNodeAt();

void addToStart() {
if (count>0) {
trans[start].prev = count;
}
trans[count].next
=
start;
trans[start=count].prev = -1;
printf("----------------------------\n");
printf("Add to Start\n");
printf("----------------------------\n");
printf("\n\t Customer name: ");
scanf("%s", trans[count].name);
printf("\n\t Customer number: ");
scanf("%s", trans[count].numb);
fflush(stdin);
printf("\n\t Trans.details: ");
gets(trans[count].more);
count++;
}

void addToEnd() {
if (count>0) {
trans[terma].next = count;
}
trans[count].prev
=
terma;
trans[terma=count].next = -1;
printf("----------------------------\n");
printf("Add to End\n");
printf("----------------------------\n");
printf("\n\t Customer name: ");
scanf("%s", trans[count].name);
printf("\n\t Customer number: ");
scanf("%s", trans[count].numb);

8|Page

fflush(stdin);
printf("\n\t Trans.details: ");
gets(trans[count].more);
count++;
}

void printList() { int i;


printf("----------------------------\n");
printf("Customer Records : name\tNumber\tTrans. details\n\n");
printf("----------------------------\n");
if (count<1)
{
printf("There are no more transactions\n\n");
return;
}
for (i = start; i != terma; i=trans[i].next)
{
printf("%13s\t%6s\t%s\n\n", trans[i].name,
trans[i].numb, trans[i].more);
}
printf("%13s\t%6s\t%s\n\n", trans[terma].name,
trans[terma].numb, trans[terma].more);
}

void removeNodeAt() {
int i, j, k=0;
printf("----------------------------\n");
printf("Remove Node\n");
printf("----------------------------\n");
printf("Node number: ");
scanf("%d", &j);
printf("\n\n");
if (j<0 || j>=count)
{
printf("Invalid number\n\n");
return;
}
for (i = start; i != terma; i=trans[i].next)
{
if (j==k++)
{
trans[trans[j].prev].next=trans[j].next;
trans[trans[j].next].prev=trans[j].prev;
for (k = j; k < count; k++)
{
trans[k]=trans[k+1];
trans[trans[k+1].prev].next=k;
trans[trans[k+1].next].prev=k;
}
count--; return;
}
}
printf("This node is already removed!");
}

9|Page

void populate() {char conti;


printf("----------------------------\n");
printf("Populate the records\n\n");
printf("----------------------------\n");
do { fflush(stdin); printf("\n\n");
printf("\n\t Customer name: ");
//scanf("%s",trans[count].nam);
gets(trans[count].name);
printf("\n\t Customer number: ");
scanf("%s", trans[count].numb);
fflush(stdin);
printf("\n\t Trans.details: ");
gets(trans[count].more);
trans[count].prev =
count-1;
printf("\n\n Another [Y/N]: ");
if (count>0) {
trans[count-1].next =count;
}
conti=_getch();
trans[1+(terma=count++)].next=-1;
}
while (conti=='y' || conti=='Y');

10 | P a g e

PART B - STACKS
#include <stdio.h>
#include<stdlib.h>
#include <conio.h>
#include<string.h>
struct Stacker
{
int item[5];
int at;
} box[5]={0};
int main() { int i, j, bin, item;
printf("Welcome to Our System\n\n");
printf("bin item. E.g.: 2 111\n");
do {
fflush(stdin); //printf("\n");
//printf(" \n \t Customer: ");
scanf("%d %d", &bin, &item);
if (bin<0 || bin>=5)
{
printf("Invalid bin\n\n");
return -1;
}
else if (item>0)
{
int *at
= &box[bin].at;
*at = *at>3 ? 0 : *at+1;
box[bin].item[*at] = item;
}
}
while(item>0);
system("cls"); printf("Bin\tItem\n\n");
for (i=0; i<5; i++)
{
for (j=0; j<5; j++)
{
if (box[i].item[j]>0)
{
printf("%d\t%d\n\n",i,
box[i].item[j]);
}
}
}
printf("Thanks\n\n");
system("pause");
return 0;
}

11 | P a g e

SCREEN SHOTS
PART A - LINKED LIST

Figure 1: Customer Entry Form


This is the customer entry form of the Part A program, which is Customer Transaction Application. This
form is where the users who want to enter the program.

12 | P a g e

Figure 2: Customer Data


This form is where the user enters the customer data in to the program.

Figure 3: Main Menu


This is the main menu which provides option to users who want to use the program.

13 | P a g e

Figure 4: Add Customer Node to Start


In this section, customer transaction will be added in front of the node.

Figure 5: Add Customer to End


In this section, customer transaction will be added in back of the node.

14 | P a g e

Figure 6: Print Data of All Customers


In this section, customer transaction will printed out.

Figure 5: Remove Customer Node


In this section, customer transaction will be deleted from the node.

15 | P a g e

PART B - STACKS

Figure 6: Items and Bins Entries


In this section, bin item and bin entries will be entered.

Figure 7: Stack Concept Applied to Process items in Bins


This is the output part after all the bin items have been entered.

16 | P a g e

CONCLUSION
The project has been finished successfully within the time frame that was allocated for the
system. The project reserved with the given specifications that we mentioned in the scope of the
project.
The team managed to work together with a great efficiency where each would cover the other
members weakness and therefore helping the finished team member to complete this project.
We have been able to considerably benefit from the strengths that the other team members
processed and thus helping us individually also to do well in the subject. We have been given a
chance across this project to all the theoretical knowledge that we obtained across the class
sessions and apply them in a useful sense by doing this assignment.

17 | P a g e

REFERENCE
Cprogramming.com (2011) Linked Lists in C++ Tutorial - Cprogramming.com. [online]
Available at: http://www.cprogramming.com/tutorial/lesson15.html [Accessed: 10 April 2013].
Cs.auckland.ac.nz (1998) Data Structures and Algorithms: Stacks. [online] Available at:
http://www.cs.auckland.ac.nz/software/AlgAnim/stacks.html [Accessed: 13 April 2013].
Greenteapress.com (n.d.) Chapter 17: Linked lists. [online] Available at:
http://www.greenteapress.com/thinkpython/thinkCSpy/html/chap17.html [Accessed: 17 April
2013].
Unknown. (2013) Untitled. [online] Available at:
http://cslibrary.stanford.edu/103/LinkedListBasics.pdf [Accessed: 20 April 2013].
Unknown. (2013) Untitled. [online] Available at:
http://www.dauniv.ac.in/downloads/EmbsysRevEd_PPTs/Chap_5Lesson04EmsysNewstacks.pdf
[Accessed: 26 April 2013].
wiziq (n.d.) STACKS IN DATA STRUCTURE. [online] Available at:
http://www.wiziq.com/tutorial/13556-STACKS-IN-DATA-STRUCTURE [Accessed: 10 May
2013].

18 | P a g e

ASSIGNMENT MARKING SCHEME


Group:
Student Name/ ID: Tinagaraj A/L Morgan (TP025931)
Tulasinatan A/L Muthualagu (TP026049)
Sri Sarangga Raja A/L Velan (TP025845)

Criteria

Marks

Comments

Implementation (11 marks)

Program logic
(3)
Validation checks (3)
Expected results (3)
Workable system (2)

Efficiency of code (6 marks)


Efficient memory utilisation (2)
Modular/Compact program (2)
No use of unnecessary global
vars, goto statements etc
(2)

Comprehension (9 marks)
Explanation of code
(3)
Capability to debug errors (3)
Logic justification
(3)

.
.
.

Assignment contribution (4 marks)

Workload distribution (2)


Initiative taken
(2)

Total: 30 marks

.
.

..

19 | P a g e

Additional Comments:

20 | P a g e

You might also like