young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
Stack Data Structure with Static Implementation (2).pptx
1. 1
2
3
4
5
6
7
8
9
10
11
12
13
14
Stack ‘Data Structure’ {
< Name: Emroz Sardar
Roll no. 000XXX
Department : Electrical Engineering
Section:C Semester: 5th
Subject:DATA STRUCTURE AND ALGORITHM (OE-EE501A)
>
Data Structure And Algorithm
[with Static Implementation]
}
Stack.c Implementation.obj
Electrical Engineering Department
2. 1
2
3
4
5
6
7
8
9
10
11
12
13
14
Data Structure And Algorithm
Stack.c Implementation.obj
Electrical Engineering Department
Introduction; {
[STACK IN DATA STRUCTURE]
‘A stack is a conceptual structure consisting of a set of
homogeneous elements and is based on the principle of last
in first out (LIFO)’
<p> A pile of books, a stack of dinner plates, a box
of pringles potato chips can all be thought of
examples of stacks. The basic operating principle is
that last item you put in is first item you can take
out </p>
}
3. 1
2
3
4
5
6
7
8
9
10
11
12
13
14
Data Structure And Algorithm
Stack.c Implementation.obj
Electrical Engineering Department
PUSH Operation
POP Operation
<Push operation refers to inserting an element in the stack. Since
there’s only one position at which the new element can be inserted—Top of
the stack, the new element is inserted at the top of the stack.>
<Pop operation refers to the removal of an element. Again,
since we only have access to the element at the top of the
stack, there’s only one element that we can remove. We just
remove the top of the stack.>
Operation on Stack in ‘Data Structure’
{
}
4. 1
2
3
4
5
6
7
8
9
10
11
12
13
14
Data Structure And Algorithm
Stack.c Implementation.obj
Electrical Engineering Department
Stack ‘Implementation’ {
<Static array Parenthesis checker> <Dynamic arrays Graphical region fill>
Stack implementation in two way:
Static Implementation: these implementation uses arrays to create
stack. Static implementation though a very simple technique but
is not a flexible way of creation as the size of stack has to be
declared during program design after that can not be varied.
Static implementation is not too efficient with respect to memory
utilization.
Dynamic implementation: these implementation is also called link
list implementation and uses pointer to implement the stack type
of data structure.
}
5. 1
2
3
4
5
6
7
8
9
10
11
12
13
14
Working of Stack “Data Structure” {
Data Structure And Algorithm
Stack.c Implementation.obj
Electrical Engineering Department
The operations work as follows: A pointer called TOP is used to keep track of
the top element in the stack.
When initializing the stack, we set its value to -1 so that we can check if
the stack is empty by comparing TOP == -1.
On pushing an element, we increase the value of TOP and place the new element
in the position pointed to by TOP.
On popping an element, we return the element pointed to by TOP and reduce its
value. Before pushing, we check if the stack is already full
Before popping, we check if the stack is already empty
}
6. 1
2
3
4
5
6
7
8
9
10
11
12
13
14
Data Structure And Algorithm
Stack.c Implementation.obj
Electrical Engineering Department
Although stack is a simple data structure to implement, it is very
powerful. The most common uses of a stack are:
To reverse a word - Put all the letters in a stack and pop them
out. Because of the LIFO order of stack, you will get the letters
in reverse order.
In compilers - Compilers use the stack to calculate the value of
expressions like 2 + 4 / 5 * (7 - 9) by converting the expression
to prefix or postfix form.
In browsers - The back button in a browser saves all the URLs you
have visited previously in a stack. Each time you visit a new page,
it is added on top of the stack. When you press the back button,
the current URL is removed from the stack, and the previous URL is
accessed.
Stack ‘Application’ {
}
7. 1
2
3
4
5
6
7
8
9
10
11
12
13
14
Data Structure And Algorithm
Stack.c Implementation.obj
Electrical Engineering Department
Alternative ‘Resources’ {
● https://www.programiz.com/dsa/stack
● https://www.tutorialspoint.com/data_structures_algorithms/sta
ck_algorithm.htm
}