Download Chap-15-2

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
15-3 Stacks
A stack is a linear list in which all additions and
deletions are restricted to one end, called the top.
Stacks are known as the last in–first out (LIFO) data
structure.
Topics discussed in this section:
Stack Structures
Stack Algorithms
Stack Demonstration
Computer Science: A Structured Programming Approach Using C
1
Note
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.
Computer Science: A Structured Programming Approach Using C
2
FIGURE 15-17 Stack
Computer Science: A Structured Programming Approach Using C
3
FIGURE 15-18 Conceptual and Physical Stack Implementations
Computer Science: A Structured Programming Approach Using C
4
FIGURE 15-19 Stack Data Structure
Computer Science: A Structured Programming Approach Using C
5
FIGURE 15-20 Streams
Computer Science: A Structured Programming Approach Using C
6
PROGRAM 15-9 Push Stack
Computer Science: A Structured Programming Approach Using C
7
PROGRAM 15-9 Push Stack
Computer Science: A Structured Programming Approach Using C
8
FIGURE 15-21 Pop Stack Example
Computer Science: A Structured Programming Approach Using C
9
PROGRAM 15-10
Pop Stack
Computer Science: A Structured Programming Approach Using C
10
PROGRAM 15-10
Pop Stack
Computer Science: A Structured Programming Approach Using C
11
FIGURE 15-22 Design for Basic Stack Program
Computer Science: A Structured Programming Approach Using C
12
PROGRAM 15-11 Simple Stack Application 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-12
Insert Data
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-13
Print Stack
Computer Science: A Structured Programming Approach Using C
18
15-4 Queues
A queue is a linear list in which data can be inserted
only at one end, called the rear, and deleted from the
other end, called the front.
Topics discussed in this section:
Queue Operations
Queue Linked List Design
Queue Functions
Queue Demonstration
Computer Science: A Structured Programming Approach Using C
19
Note
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.
Computer Science: A Structured Programming Approach Using C
20
FIGURE 15-23 Queue Concept
Computer Science: A Structured Programming Approach Using C
21
Note
Enqueue inserts an element at the rear of the queue.
Computer Science: A Structured Programming Approach Using C
22
FIGURE 15-24 Enqueue
Computer Science: A Structured Programming Approach Using C
23
Note
Dequeue deletes an element at the front of the queue.
Computer Science: A Structured Programming Approach Using C
24
FIGURE 15-25 Dequeue
Computer Science: A Structured Programming Approach Using C
25
FIGURE 15-26 Conceptual and Physical Queue Implementations
Computer Science: A Structured Programming Approach Using C
26
FIGURE 15-27 Queue Data Structure
Computer Science: A Structured Programming Approach Using C
27
FIGURE 15-28 Enqueue Example
Computer Science: A Structured Programming Approach Using C
28
PROGRAM 15-14
Enqueue
Computer Science: A Structured Programming Approach Using C
29
PROGRAM 15-14
Enqueue
Computer Science: A Structured Programming Approach Using C
30
FIGURE 15-29 Dequeue Examples
Computer Science: A Structured Programming Approach Using C
31
PROGRAM 15-15
Dequeue
Computer Science: A Structured Programming Approach Using C
32
PROGRAM 15-15
Dequeue
Computer Science: A Structured Programming Approach Using C
33
PROGRAM 15-16 Simple Queue Demonstration
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-17
Insert Data
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-18
Print Queue
Computer Science: A Structured Programming Approach Using C
39
Related documents