DSUsf 231110 202919
DSUsf 231110 202919
Micro Project
Report on
Computer Engineering.
Submitted by
Guided By
DEPARTMENT OF COMPUTER
ENGINEERING
M.I.T POLYTECHNIC DHANORE,YEOLA
M.S.B.T.E MUMBAI
2022-23
MAHARASHTRA STATE BOARD OF TECHNICAL
EDUCATION,MUMBAI.
CERTIFICATE
This is to certify that Mr. Sahil Sunil Abak satisfactorily carried out the
investigation/experimentation and micro project work Entitled.
“Employee Record Maintaining Application”.
Semester: - 3rd
Pos:-
Cos:-
Roll Name Of Student Marks Out of ( )For Marks Out of #( Total Marks out
no performance in group )For performance in of( )
activity oral
presentation
1.
Introduction.
2.
Implementing a stack with a linked list:
3. Implementation
4.
Data Type Of Stack
7.
Output
8. Conclusion
9.
Reference
Introduction
• The linked list data structure is one of the fundamental data structures in
computer science.
• Think of the linked list data structure as your ABCs. Without learning the
ABCs, it is difficult to conceptualize words, which are made up by stringing
alphabetical characters together.
• Therefore, you want to know the ins and outs of the linked list data
structures.
• In this article, we will explore the linked list data structure’s key features
and operations. Afterwards, we will begin by implementing our own singly
linked list.
• Another separate post will be dedicated towards the doubly linked list,
which is a variant of the linked list data structure.
2. Implementing a stack with a linked list:
Using a linked list is one way to implement a stack so that it can handle
essentially any number of elements.
Here is what a linked list implementing a stack with 3 elements might look
like:
list
|
v
-------- -------- --------- |
C | -+-->| B | -+-->| A | 0 |
-------- -------- ---------
3. implementation
Now, think about how to actually implement this stack of characters in C.
It is usually convenient to put a data structure in its own module, thus, we'll
want to create files stack.h and a stack.c.
The operations needed for our stack are mainly determined by the
operations provided by an abstract stack, namely:
StackPush()
StackPop() StackIsEmpty()
4. Data types for a stack
In order to determine what data types we'll need, let's think about how
someone will use our stack:
First, stack variables must be defined (e.g., stack1 and stack2). Then, stack
operations may be called. Those operations will need to know which stack
to operate on.
Thus, our goal is to get some kind of type that we can use to keep track of
a stack.
Let's start bottom-up from the simplest type and work our way up through
types that use the simpler types...
First, we want to write a stack that is very generic. The fact that this stack
holds a character is only particular to this program. It should be easy to
change the type of things held in the stack.
Let's introduce a type name for the type of thing held in the stack:
Finally, we need something that holds all the information needed to keep
track of the stack. Since elements will be held in nodes, we only need a
pointer to keep track of the beginning of the list (which will be our top of
the stack).
We suggest that this single pointer be put in a structure, so that we can give
it a descriptive field name and so that we can add more fields easily in the
future (if needed):
typedef struct
{ stackNodeT
*top; }
stackT;
5. Filling in stack operations
Now that we've decided on the data types for a stack, we think we'd like to
add 2 extra operations:
StackInit()
StackDestroy()
They are not part of the abstract concept of a stack, but they are necessary
for setup and cleanup when writing the stack in C.
Now, let's think about the StackInit() function. It will need to set up a stack
stackT structure, so that we have an empty stack.
What does the prototype for StackInit() look like? What do we do in its
body?
Now, what about putting an element in the stack. What should the
prototype for StackPush() look like?
The major problem with the stack implemented using array is, it works only for
fixed number of data values. That means the amount of data must be specified at
the beginning of the implementation itself. Stack implemented using array is not
suitable, when we don't know the size of data which we are going to use. A stack
data structure can be implemented by using linked list data structure. The stack
implemented using linked list can work for unlimited number of values. That
means, stack implemented using linked list works for variable size of data. So,
there is no need to fix the size at the beginning of the implementation. The Stack
implemented using linked list can organize as many data values as we want.
Example
Operations
To implement stack using linked list, we need to set the following things before
implementing actual operations.
Step 1: Include all the header files which are used in the program. And declare
all the user defined functions.
Step 2: Define a 'Node' structure with two members data and next.
Step 3: Define a Node pointer 'top' and set it to NULL.
Step 4: Implement the main method by displaying Menu with list of operations
and make suitable function calls in the main method.
*ptr; }*top,*top1,*temp;
printf("\n 1 - Push");
printf("\n 2 - Pop");
printf("\n 3 - Top");
printf("\n 4 - Empty");
printf("\n 5 - Exit");
printf("\n 6 - Dipslay");
printf("\n 7 - Stack
Count"); printf("\n 8 -
Destroy stack"); create();
case
3:
: %d", e);
} break; case
4: empty();
break; case
5: exit(0);
case 6:
display();
break; case
7: stack_co
unt(); break;
case 8:
destroy() ;
break;
default :
printf("
Wrong
"); break;
} } void create()
top = NULL; }
void stack_count()
{ printf("\n No. of
elements in stack :
%d", count); }
void push(int
data)
{ if (top ==
NULL)
== NULL)
{ printf("Stack is empty");
return; } while
(top1 != NULL) {
printf("%d ",
top1>info); top1 =
{ top1 = top; if
(top1 == NULL)
(top1 != NULL)
count = 0;
}
Output
Conclusion
• In this lesson we learned how to traverse, append, prepend, insert and delete
nodes from a linked list. These operations are quite useful in many practical
applications.
• Suppose you are the programmer responsible for an application like
Microsoft PowerPoint. We can think of a PowerPoint presentation as a list,
whose nodes are the individual slides. In the process of creating and
managing slides we can use the concepts such as inserting and deleting
nodes learned in this lesson.
Reference
• http://btechsmartclass.com/downloads.html
• https://www.programmingsimplified.com/c/datastructures/cprogramimple
ment-linked-list
• https://www.hackerearth.com/practice/datastructures/linkedlist/singlylink
ed-list/tutorial/
• https://www.geeksforgeeks.org/linked-list-set-1-introduction/
https://www.geeksforgeeks.org/data-structures/linked-list/