Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 15 Lists Objectives

Similar presentations


Presentation on theme: "Chapter 15 Lists Objectives"— Presentation transcript:

1 Chapter 15 Lists Objectives
❏ To introduce the basic concepts of linked lists ❏ To introduce the basic concepts of stacks ❏ To introduce the basic concepts of queues ❏ To introduce the basic concepts of tree structures ❏ To introduce the basic concepts of graph structures Computer Science: A Structured Programming Approach Using C

2 FIGURE Lists Computer Science: A Structured Programming Approach Using C

3 Topics discussed in this section:
List Implementations The C language does not provide any list structures or implementations. When we need them, we must provide the structures and functions for them. Traditionally, two data types, arrays and pointers, are used for their implementation. Topics discussed in this section: Array Implementation Linked List Implementation Pointers to Linked Lists Computer Science: A Structured Programming Approach Using C

4 FIGURE Linked Lists Computer Science: A Structured Programming Approach Using C

5 FIGURE Nodes Computer Science: A Structured Programming Approach Using C

6 FIGURE 15-4 Linked List Node Structures
Computer Science: A Structured Programming Approach Using C

7 Topics discussed in this section:
General Linear Lists A general linear list is a list in which operations, such as retrievals, insertions, changes, and deletions, can be done anywhere in the list, that is, at the beginning, in the middle, or at the end of the list.. Topics discussed in this section: Insert a Node Delete a Node Locating Data in Linear Lists Traversing Linear Lists Building a Linear List Computer Science: A Structured Programming Approach Using C

8 FIGURE 15-5 Pointer Combinations for Insert
Computer Science: A Structured Programming Approach Using C

9 FIGURE 15-6 Insert Node to Empty List
Computer Science: A Structured Programming Approach Using C

10 FIGURE 15-7 Insert Node at Beginning
Computer Science: A Structured Programming Approach Using C

11 FIGURE 15-8 Insert Node in Middle
Computer Science: A Structured Programming Approach Using C

12 FIGURE 15-9 Insert Node at End
Computer Science: A Structured Programming Approach Using C

13 PROGRAM 15-1 Insert a Node Computer Science: A Structured Programming Approach Using C

14 PROGRAM 15-1 Insert a Node Computer Science: A Structured Programming Approach Using C

15 FIGURE 15-10 Delete First Node
Computer Science: A Structured Programming Approach Using C

16 FIGURE 15-11 Delete—General Case
Computer Science: A Structured Programming Approach Using C

17 PROGRAM 15-2 Delete a Node Computer Science: A Structured Programming Approach Using C

18 Linear List Search Results
Table 15-1 Linear List Search Results Computer Science: A Structured Programming Approach Using C

19 FIGURE 15-12 Search Results
Computer Science: A Structured Programming Approach Using C

20 PROGRAM 15-3 Search Linear List
Computer Science: A Structured Programming Approach Using C

21 PROGRAM 15-3 Search Linear List
Computer Science: A Structured Programming Approach Using C

22 FIGURE 15-13 Linear List Traversal
Computer Science: A Structured Programming Approach Using C

23 PROGRAM 15-4 Print Linear List
Computer Science: A Structured Programming Approach Using C

24 PROGRAM 15-5 Average Linear List
Computer Science: A Structured Programming Approach Using C

25 FIGURE 15-14 Design for Inserting a Node in a List
Computer Science: A Structured Programming Approach Using C

26 PROGRAM 15-6 Build List Computer Science: A Structured Programming Approach Using C

27 PROGRAM 15-6 Build List Computer Science: A Structured Programming Approach Using C

28 FIGURE 15-15 Design for Remove Node
Computer Science: A Structured Programming Approach Using C

29 PROGRAM 15-7 Delete Key Computer Science: A Structured Programming Approach Using C

30 PROGRAM 15-7 Delete Key Computer Science: A Structured Programming Approach Using C

31 FIGURE 15-16 Link List Test Driver
Computer Science: A Structured Programming Approach Using C

32 Test Driver for Link List
PROGRAM 15-8 Test Driver for Link List Computer Science: A Structured Programming Approach Using C

33 Test Driver for Link List
PROGRAM 15-8 Test Driver for Link List Computer Science: A Structured Programming Approach Using C

34 Test Driver for Link List
PROGRAM 15-8 Test Driver for Link List Computer Science: A Structured Programming Approach Using C

35 Test Driver for Link List
PROGRAM 15-8 Test Driver for Link List Computer Science: A Structured Programming Approach Using C

36 Test Driver for Link List
PROGRAM 15-8 Test Driver for Link List Computer Science: A Structured Programming Approach Using C

37 Topics discussed in this section:
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

38 to one end, called the top.
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

39 FIGURE Stack Computer Science: A Structured Programming Approach Using C

40 FIGURE 15-18 Conceptual and Physical Stack Implementations
Computer Science: A Structured Programming Approach Using C

41 FIGURE 15-19 Stack Data Structure
Computer Science: A Structured Programming Approach Using C

42 FIGURE Streams Computer Science: A Structured Programming Approach Using C

43 PROGRAM 15-9 Push Stack Computer Science: A Structured Programming Approach Using C

44 PROGRAM 15-9 Push Stack Computer Science: A Structured Programming Approach Using C

45 FIGURE 15-21 Pop Stack Example
Computer Science: A Structured Programming Approach Using C

46 PROGRAM 15-10 Pop Stack Computer Science: A Structured Programming Approach Using C

47 PROGRAM 15-10 Pop Stack Computer Science: A Structured Programming Approach Using C

48 FIGURE 15-22 Design for Basic Stack Program
Computer Science: A Structured Programming Approach Using C

49 Simple Stack Application Program
Computer Science: A Structured Programming Approach Using C

50 Simple Stack Application Program
Computer Science: A Structured Programming Approach Using C

51 Simple Stack Application Program
Computer Science: A Structured Programming Approach Using C

52 PROGRAM 15-12 Insert Data Computer Science: A Structured Programming Approach Using C

53 PROGRAM 15-12 Insert Data Computer Science: A Structured Programming Approach Using C

54 PROGRAM 15-13 Print Stack Computer Science: A Structured Programming Approach Using C

55 Topics discussed in this section:
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

56 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

57 FIGURE Queue Concept Computer Science: A Structured Programming Approach Using C

58 Enqueue inserts an element at the rear of the queue.
Note Enqueue inserts an element at the rear of the queue. Computer Science: A Structured Programming Approach Using C

59 FIGURE Enqueue Computer Science: A Structured Programming Approach Using C

60 Dequeue deletes an element at the front of the queue.
Note Dequeue deletes an element at the front of the queue. Computer Science: A Structured Programming Approach Using C

61 FIGURE Dequeue Computer Science: A Structured Programming Approach Using C

62 FIGURE 15-26 Conceptual and Physical Queue Implementations
Computer Science: A Structured Programming Approach Using C

63 FIGURE 15-27 Queue Data Structure
Computer Science: A Structured Programming Approach Using C

64 FIGURE 15-28 Enqueue Example
Computer Science: A Structured Programming Approach Using C

65 PROGRAM 15-14 Enqueue Computer Science: A Structured Programming Approach Using C

66 PROGRAM 15-14 Enqueue Computer Science: A Structured Programming Approach Using C

67 FIGURE 15-29 Dequeue Examples
Computer Science: A Structured Programming Approach Using C

68 PROGRAM 15-15 Dequeue Computer Science: A Structured Programming Approach Using C

69 PROGRAM 15-15 Dequeue Computer Science: A Structured Programming Approach Using C

70 Simple Queue Demonstration
PROGRAM 15-16 Simple Queue Demonstration Computer Science: A Structured Programming Approach Using C

71 Simple Queue Demonstration
PROGRAM 15-16 Simple Queue Demonstration Computer Science: A Structured Programming Approach Using C

72 Simple Queue Demonstration
PROGRAM 15-16 Simple Queue Demonstration Computer Science: A Structured Programming Approach Using C

73 PROGRAM 15-17 Insert Data Computer Science: A Structured Programming Approach Using C

74 PROGRAM 15-17 Insert Data Computer Science: A Structured Programming Approach Using C

75 PROGRAM 15-18 Print Queue Computer Science: A Structured Programming Approach Using C


Download ppt "Chapter 15 Lists Objectives"

Similar presentations


Ads by Google