computer science: a structured programming approach using c1 15-3 stacks a stack is a linear list in...
TRANSCRIPT
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:
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
Computer Science: A Structured Programming Approach Using C 3
FIGURE 15-17 Stack
Computer Science: A Structured Programming Approach Using C 4
FIGURE 15-18 Conceptual and Physical Stack Implementations
Computer Science: A Structured Programming Approach Using C 5
FIGURE 15-19 Stack Data Structure
Computer Science: A Structured Programming Approach Using C 6
FIGURE 15-20 Streams
Computer Science: A Structured Programming Approach Using C 7
PROGRAM 15-9 Push Stack
Computer Science: A Structured Programming Approach Using C 8
PROGRAM 15-9 Push Stack
Computer Science: A Structured Programming Approach Using C 9
FIGURE 15-21 Pop Stack Example
Computer Science: A Structured Programming Approach Using C 10
PROGRAM 15-10 Pop Stack
Computer Science: A Structured Programming Approach Using C 11
PROGRAM 15-10 Pop Stack
Computer Science: A Structured Programming Approach Using C 12
FIGURE 15-22 Design for Basic Stack Program
Computer Science: A Structured Programming Approach Using C 13
PROGRAM 15-11 Simple Stack Application Program
Computer Science: A Structured Programming Approach Using C 14
PROGRAM 15-11 Simple Stack Application Program
Computer Science: A Structured Programming Approach Using C 15
PROGRAM 15-11 Simple Stack Application Program
Computer Science: A Structured Programming Approach Using C 16
PROGRAM 15-12 Insert Data
Computer Science: A Structured Programming Approach Using C 17
PROGRAM 15-12 Insert Data
Computer Science: A Structured Programming Approach Using C 18
PROGRAM 15-13 Print Stack
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:
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
Computer Science: A Structured Programming Approach Using C 21
FIGURE 15-23 Queue Concept
Computer Science: A Structured Programming Approach Using C 22
Enqueue inserts an element at the rear of the queue.
NoteNote
Computer Science: A Structured Programming Approach Using C 23
FIGURE 15-24 Enqueue
Computer Science: A Structured Programming Approach Using C 24
Dequeue deletes an element at the front of the queue.
NoteNote
Computer Science: A Structured Programming Approach Using C 25
FIGURE 15-25 Dequeue
Computer Science: A Structured Programming Approach Using C 26
FIGURE 15-26 Conceptual and Physical Queue Implementations
Computer Science: A Structured Programming Approach Using C 27
FIGURE 15-27 Queue Data Structure
Computer Science: A Structured Programming Approach Using C 28
FIGURE 15-28 Enqueue Example
Computer Science: A Structured Programming Approach Using C 29
PROGRAM 15-14 Enqueue
Computer Science: A Structured Programming Approach Using C 30
PROGRAM 15-14 Enqueue
Computer Science: A Structured Programming Approach Using C 31
FIGURE 15-29 Dequeue Examples
Computer Science: A Structured Programming Approach Using C 32
PROGRAM 15-15 Dequeue
Computer Science: A Structured Programming Approach Using C 33
PROGRAM 15-15 Dequeue
Computer Science: A Structured Programming Approach Using C 34
PROGRAM 15-16 Simple Queue Demonstration
Computer Science: A Structured Programming Approach Using C 35
PROGRAM 15-16 Simple Queue Demonstration
Computer Science: A Structured Programming Approach Using C 36
PROGRAM 15-16 Simple Queue Demonstration
Computer Science: A Structured Programming Approach Using C 37
PROGRAM 15-17 Insert Data
Computer Science: A Structured Programming Approach Using C 38
PROGRAM 15-17 Insert Data
Computer Science: A Structured Programming Approach Using C 39
PROGRAM 15-18 Print Queue