1 / 5

STACK & QUEUE

Learn the algorithm and procedures for implementing stack and queue data structures using lists in Python. Understand the basic operations of insertion, deletion, and display for both stack and queue.

ernestinam
Download Presentation

STACK & QUEUE

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. STACK & QUEUE By Tanmay Jain

  2. STACK Algorithm/Procedure Procedure for Stack using List1. STACK: Stack is a linear data structure which works under the principle of last in first out. Basic operations: push, pop, display.2. PUSH: if (top==MAX), display Stack overflow. Otherwise reading the data and making stack[top] =data and incrementing the top value by doing top++. 3. Pop: if (top==0), display Stack underflow. Otherwise printing the element at the top of the stack and decrementing the top value by doing the top. 4. DISPLAY: If (top==0), display Stack is empty. Otherwise printing the elements in the stackfrom stack [0] to stack [top].

  3. QUEUE Algorithm/Procedure Procedure for Queue using List1. QUEUE: Queue is a linear data structure which works under the principle of first in first out.Basic operations: Insertion, deletion, display.2. Insertion: if (rear==MAX), display Queue is full. Else reading data and inserting at queue [rear],and doing rear++.3. Deletion: if (front==rear), display Queue is empty .Else printing element at queue [front] anddoing front++.4. Display: if (front==rear) ,display No elements in the queue .Else printing the elements fromqueue[front] to queue[rear].

  4. Order of Operations python

More Related