Chapter 15 Lists Objectives

Slides:



Advertisements
Similar presentations
STACKS & QUEUES. Stacks Abstract data types An abstract data type (ADT) is an abstraction of a data structure An ADT specifies : –Data stored –Operations.
Advertisements

Data Structure HKOI training /4/2010 So Pak Yeung.
Computer Science: A Structured Programming Approach Using C Stacks A stack is a linear list in which all additions and deletions are restricted to.
Ceng-112 Data Structures I Chapter 5 Queues.
ADVANCED DATA STRUCTURES AND ALGORITHM ANALYSIS Chapter 3 Lists, Stacks, and Queues.
CS 206 Introduction to Computer Science II 03 / 04 / 2009 Instructor: Michael Eckmann.
©Brooks/Cole, 2003 Chapter 12 Abstract Data Type.
Advanced Data Structures
©Brooks/Cole, 2003 Chapter 12 Abstract Data Type.
Data Structures & Algorithms
Lists A list is a finite, ordered sequence of data items. Two Implementations –Arrays –Linked Lists.
CS 104 Introduction to Computer Science and Graphics Problems Data Structure & Algorithms (4) Data Structures 11/18/2008 Yang Song.
CS 106 Introduction to Computer Science I 12 / 11 / 2006 Instructor: Michael Eckmann.
©Brooks/Cole, 2003 Chapter 12 Abstract Data Type.
CS 206 Introduction to Computer Science II 10 / 26 / 2009 Instructor: Michael Eckmann.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 12 – Data Structures Outline 12.1Introduction.
CS 106 Introduction to Computer Science I 12 / 13 / 2006 Instructor: Michael Eckmann.
1 Stack Data : a collection of homogeneous elements arranged in a sequence. Only the first element may be accessed Main Operations: Push : insert an element.
12 Abstract Data Types Foundations of Computer Science ã Cengage Learning.
Chapter 12 Data Structure Associate Prof. Yuh-Shyan Chen Dept. of Computer Science and Information Engineering National Chung-Cheng University.
Computer Science Department Data Structures and Algorithms Lecture 1.
ECE 103 Engineering Programming Chapter 61 Abstract Data Types Herbert G. Mayer, PSU CS Status 6/4/2014 Initial content copied verbatim from ECE 103 material.
9-1 Abstract Data Types Abstract data type A data type whose properties (data and operations) are specified independently of any particular implementation.
Foundation of Computing Systems Lecture 3 Stacks and Queues.
Stacks And Queues Chapter 18.
Data Structures: A Pseudocode Approach with C1 Chapter 4 Objectives Upon completion you will be able to: Explain the design, use, and operation of a queue.
Data Structures Chapter 6. Data Structure A data structure is a representation of data and the operations allowed on that data. Examples: 1.Array 2.Record.
Chapter 12 Abstract Data Type. Understand the concept of an abstract data type (ADT). Understand the concept of a linear list as well as its operations.
Data Structures for Midterm 2. C++ Data Structure Runtimes.
Chapter 12 Abstract Data Type. Understand the concept of an abstract data type (ADT). Understand the concept of a linear list as well as its operations.
ITEC 2620M Introduction to Data Structures Instructor: Prof. Z. Yang Course Website: ec2620m.htm Office: Tel 3049.
Give Eg:? Queues. Introduction DEFINITION: A Queue is an ordered collection of element in which insertions are made at one end and deletions are made.
Computer Engineering Rabie A. Ramadan Lecture 6.
Data Structures David Kauchak cs302 Spring Data Structures What is a data structure? Way of storing data that facilitates particular operations.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To introduce the basic concepts of linked lists ❏ To introduce the basic concepts.
Data Structures: A Pseudocode Approach with C 1 Chapter 5 Objectives Upon completion you will be able to: Explain the design, use, and operation of a linear.
CPS120: Introduction to Computer Science Nell Dale John Lewis Abstract Data Types.
STACKS & QUEUES for CLASS XII ( C++).
Cpt S 122 – Data Structures Abstract Data Types
Chapter 12 Abstract Data Type.
Data Structure By Amee Trivedi.
G64ADS Advanced Data Structures
Set Collection A Bag is a general collection class that implements the Collection interface. A Set is a collection that resembles a Bag with the provision.
Chapter 12 – Data Structures
Chapter 4 The easy stuff.
COSC160: Data Structures: Lists and Queues
Stacks – review A Last-In First-Out (LIFO) structure Basic Operations:
Copy Constructor / Destructors Stacks and Queues
CS 1114: Implementing Search
Stacks and Queues.
Introduction to Data Structure
Data Structures and Database Applications Queues in C#
CMSC 341 Lecture 5 Stacks, Queues
structures and their relationships." - Linus Torvalds
Principles of Computing – UFCFA3-30-1
Stacks – review A Last-In First-Out (LIFO) structure Basic Operations:
Chapter 15 Lists Objectives
Data Structures and Database Applications Stacks in C#
DATA STRUCTURE QUEUE.
Data Structures – Stacks and Queus
ITEC 2620M Introduction to Data Structures
Lesson 6. Types Equality and Identity. Collections.
Cs212: Data Structures Computer Science Department Lecture 7: Queues.
Stack A data structure in which elements are inserted and removed only at one end (called the top). Enforces Last-In-First-Out (LIFO) Uses of Stacks Evaluating.
Chapter 11 Data Structures 1.
Chapter 8 Queues © 2006 Pearson Addison-Wesley. All rights reserved.
Stacks and Queues.
Multiway Trees Chapter 10 Objectives
17CS1102 DATA STRUCTURES © 2016 KL University – The contents of this presentation are an intellectual and copyrighted property of KL University. ALL RIGHTS.
structures and their relationships." - Linus Torvalds
Presentation transcript:

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

FIGURE 15-1 Lists Computer Science: A Structured Programming Approach Using C

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

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

FIGURE 15-3 Nodes Computer Science: A Structured Programming Approach Using C

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

FIGURE 15-17 Stack Computer Science: A Structured Programming Approach Using C

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

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

FIGURE 15-20 Streams Computer Science: A Structured Programming Approach Using C

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

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

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

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

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

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

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

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

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

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

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

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

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

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

FIGURE 15-23 Queue Concept Computer Science: A Structured Programming Approach Using C

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

FIGURE 15-24 Enqueue Computer Science: A Structured Programming Approach Using C

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

FIGURE 15-25 Dequeue Computer Science: A Structured Programming Approach Using C

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

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

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

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

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

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

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

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

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

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

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

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

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

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