Sem :- 3 SUBJECT :- Data structure Presenting by:PIYUSH ahIR Guided by:- Stacks Queue Data Structure Primitive Data Structure Non-Primitive Data Structure Arrays Integer Lists Files Characters Floating Point Pointers Non-linear List Linear List Stack Queue Graphs Trees STACKS (definition) • Things are on top of another • LIFO (Life In First Out) 1. Push () Adding something to stack 2. Pop() Removing something from stack Adding (pushing) Removing (popping) 𝑃5 𝑃4 𝑃3 𝑃2 𝑃1 Pointer :- Is something that pointing to particular address. TOP Notes :Points always to the top of the stacks. We can remove only that things that are present at the top of the stacks. IMPLEMENTATION OF STACK • There are 2 ways to implement (execute) stack. 1. Array (Fixed size) 5 4 9 Top 12 Pointer Advantage Using array is easy to implement Disadvant age The array is of fixed size thus stack is not dynamic Conditions 1. Stack overflow Adding an element to the stack which is already filled. 2. Stack underflow Removing an element from the empty stack. 2. Linked list Push () -> add at head Pop () -> remove from head Stack overflow Stack underflow QUEUE (definition) First in first out (FIFA) Came first will go first Operations 1. Enqueue () 2. Dequeue () Adding something to the queue removing something from the queue Example • Enqueue(4) • Enqueue(9) 4 9 12 • Enqueue(12) • Dequeue(12) • Enqueue() • Enqueue() We can also add the example of Customer care IMPLEMENTATION OF queue • There are 4 ways to implement (execute) queue. 1. 2.Array Circular array 3. Linked list 4. Using stack Front pointer Enqueue () -> Add at head Dequeue () -> Remove from head Front pointer