Workshop on Academic Credit Courses Course Additions, Deletions and Changes PPS 2.01.
Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in...
Transcript of Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in...
![Page 1: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/1.jpg)
Computer Science: A Structured Programming Approach Using C 1
15-3 Stacks
A A stackstack is a linear list in which all additions and is a linear list in which all additions and deletions are restricted to one end, called the deletions are restricted to one end, called the toptop. . Stacks are known as the last in–first out (LIFO) data Stacks are known as the last in–first out (LIFO) data structure.structure.
Stack StructuresStack AlgorithmsStack Demonstration
Topics discussed in this section:Topics discussed in this section:
![Page 2: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/2.jpg)
Computer Science: A Structured Programming Approach Using C 2
A stack is a last in–first out (LIFO) data structure in which all insertions and deletions are restricted
to one end, called the top.
NoteNote
![Page 3: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/3.jpg)
Computer Science: A Structured Programming Approach Using C 3
FIGURE 15-17 Stack
![Page 4: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/4.jpg)
Computer Science: A Structured Programming Approach Using C 4
FIGURE 15-18 Conceptual and Physical Stack Implementations
![Page 5: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/5.jpg)
Computer Science: A Structured Programming Approach Using C 5
FIGURE 15-19 Stack Data Structure
![Page 6: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/6.jpg)
Computer Science: A Structured Programming Approach Using C 6
FIGURE 15-20 Streams
![Page 7: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/7.jpg)
Computer Science: A Structured Programming Approach Using C 7
PROGRAM 15-9 Push Stack
![Page 8: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/8.jpg)
Computer Science: A Structured Programming Approach Using C 8
PROGRAM 15-9 Push Stack
![Page 9: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/9.jpg)
Computer Science: A Structured Programming Approach Using C 9
FIGURE 15-21 Pop Stack Example
![Page 10: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/10.jpg)
Computer Science: A Structured Programming Approach Using C 10
PROGRAM 15-10 Pop Stack
![Page 11: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/11.jpg)
Computer Science: A Structured Programming Approach Using C 11
PROGRAM 15-10 Pop Stack
![Page 12: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/12.jpg)
Computer Science: A Structured Programming Approach Using C 12
FIGURE 15-22 Design for Basic Stack Program
![Page 13: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/13.jpg)
Computer Science: A Structured Programming Approach Using C 13
PROGRAM 15-11 Simple Stack Application Program
![Page 14: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/14.jpg)
Computer Science: A Structured Programming Approach Using C 14
PROGRAM 15-11 Simple Stack Application Program
![Page 15: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/15.jpg)
Computer Science: A Structured Programming Approach Using C 15
PROGRAM 15-11 Simple Stack Application Program
![Page 16: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/16.jpg)
Computer Science: A Structured Programming Approach Using C 16
PROGRAM 15-12 Insert Data
![Page 17: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/17.jpg)
Computer Science: A Structured Programming Approach Using C 17
PROGRAM 15-12 Insert Data
![Page 18: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/18.jpg)
Computer Science: A Structured Programming Approach Using C 18
PROGRAM 15-13 Print Stack
![Page 19: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/19.jpg)
Computer Science: A Structured Programming Approach Using C 19
15-4 Queues
A A queuequeue is a linear list in which data can be inserted is a linear list in which data can be inserted only at one end, called the only at one end, called the rearrear, and deleted from the , and deleted from the other end, called the other end, called the frontfront..
Queue OperationsQueue Linked List DesignQueue FunctionsQueue Demonstration
Topics discussed in this section:Topics discussed in this section:
![Page 20: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/20.jpg)
Computer Science: A Structured Programming Approach Using C 20
A queue is a linear list in which data can be inserted at one end, called the rear, and deleted from the other end,
called the front. It is a first in–first out(FIFO) restricted data structure.
NoteNote
![Page 21: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/21.jpg)
Computer Science: A Structured Programming Approach Using C 21
FIGURE 15-23 Queue Concept
![Page 22: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/22.jpg)
Computer Science: A Structured Programming Approach Using C 22
Enqueue inserts an element at the rear of the queue.
NoteNote
![Page 23: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/23.jpg)
Computer Science: A Structured Programming Approach Using C 23
FIGURE 15-24 Enqueue
![Page 24: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/24.jpg)
Computer Science: A Structured Programming Approach Using C 24
Dequeue deletes an element at the front of the queue.
NoteNote
![Page 25: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/25.jpg)
Computer Science: A Structured Programming Approach Using C 25
FIGURE 15-25 Dequeue
![Page 26: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/26.jpg)
Computer Science: A Structured Programming Approach Using C 26
FIGURE 15-26 Conceptual and Physical Queue Implementations
![Page 27: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/27.jpg)
Computer Science: A Structured Programming Approach Using C 27
FIGURE 15-27 Queue Data Structure
![Page 28: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/28.jpg)
Computer Science: A Structured Programming Approach Using C 28
FIGURE 15-28 Enqueue Example
![Page 29: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/29.jpg)
Computer Science: A Structured Programming Approach Using C 29
PROGRAM 15-14 Enqueue
![Page 30: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/30.jpg)
Computer Science: A Structured Programming Approach Using C 30
PROGRAM 15-14 Enqueue
![Page 31: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/31.jpg)
Computer Science: A Structured Programming Approach Using C 31
FIGURE 15-29 Dequeue Examples
![Page 32: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/32.jpg)
Computer Science: A Structured Programming Approach Using C 32
PROGRAM 15-15 Dequeue
![Page 33: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/33.jpg)
Computer Science: A Structured Programming Approach Using C 33
PROGRAM 15-15 Dequeue
![Page 34: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/34.jpg)
Computer Science: A Structured Programming Approach Using C 34
PROGRAM 15-16 Simple Queue Demonstration
![Page 35: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/35.jpg)
Computer Science: A Structured Programming Approach Using C 35
PROGRAM 15-16 Simple Queue Demonstration
![Page 36: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/36.jpg)
Computer Science: A Structured Programming Approach Using C 36
PROGRAM 15-16 Simple Queue Demonstration
![Page 37: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/37.jpg)
Computer Science: A Structured Programming Approach Using C 37
PROGRAM 15-17 Insert Data
![Page 38: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/38.jpg)
Computer Science: A Structured Programming Approach Using C 38
PROGRAM 15-17 Insert Data
![Page 39: Computer Science: A Structured Programming Approach Using C1 15-3 Stacks A stack is a linear list in which all additions and deletions are restricted to.](https://reader035.fdocuments.in/reader035/viewer/2022081518/551c258b5503469e4f8b5d81/html5/thumbnails/39.jpg)
Computer Science: A Structured Programming Approach Using C 39
PROGRAM 15-18 Print Queue