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.

Slides:



Advertisements
Similar presentations
Stack & Queues COP 3502.
Advertisements

Data Structures: A Pseudocode Approach with C
©Brooks/Cole, 2003 Chapter 12 Abstract Data Type.
1 Chapter 24 Lists Stacks and Queues. 2 Objectives F To design list with interface and abstract class (§24.2). F To design and implement a dynamic list.
Lists A list is a finite, ordered sequence of data items. Two Implementations –Arrays –Linked Lists.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
CS 104 Introduction to Computer Science and Graphics Problems Data Structure & Algorithms (4) Data Structures 11/18/2008 Yang Song.
©Brooks/Cole, 2003 Chapter 12 Abstract Data Type.
CS 206 Introduction to Computer Science II 10 / 26 / 2009 Instructor: Michael Eckmann.
Chapter 12 C Data Structures Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 12 – Data Structures Outline 12.1Introduction.
CS211 Data Structures Sami Rollins Fall 2004.
Data Structures from Cormen, Leiserson, Rivest & Stein.
Summary of lectures (1 to 11)
Chapter 12 Collections. © 2004 Pearson Addison-Wesley. All rights reserved12-2 Collections A collection is an object that helps us organize and manage.
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.
Important Problem Types and Fundamental Data Structures
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.
Data Structures Winter What is a Data Structure? A data structure is a method of organizing data. The study of data structures is particularly important.
Introduction to Data Structures. Definition Data structure is representation of the logical relationship existing between individual elements of data.
 2007 Pearson Education, Inc. All rights reserved C Data Structures.
Chapter 8: Data Abstractions Senem Kumova Metin. 8-2 Chapter 8: Data Abstractions 8.1 Basic Data Structures – Arrays – Lists, Stacks, Queues – Trees 8.2.
Adapted from instructor resources Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Course Review Midterm.
Data Structures Systems Programming. 22 Data Structures  Queues –Queuing System Models –Queue Data Structures –A Queue Example  Trees –Binary Trees.
ELC 310 Day 24. © 2004 Pearson Addison-Wesley. All rights reserved12-2 Agenda Questions? Problem set 5 Parts A & B Corrected  Good results  2 A’s, 1.
Chapter 8 Data Abstractions. © 2005 Pearson Addison-Wesley. All rights reserved 8-2 Chapter 8: Data Abstractions 8.1 Data Structure Fundamentals 8.2 Implementing.
CSE 326 Linear ADTs: Lists, Stacks and Queues David Kaplan Dept of Computer Science & Engineering Autumn 2001.
Chapter 12: Collections by Lewis and Loftus (Updated by Dan Fleck) Coming up: Collections.
Foundation of Computing Systems Lecture 3 Stacks and Queues.
Stacks And Queues Chapter 18.
1 Chapter 17 – Data Structures Outline Introduction Self-Referential Classes Dynamic Memory Allocation Linked Lists Stacks Queues Trees.
Programming Practice 3 - Dynamic Data Structure
Data Structures Systems Programming. Systems Programming: Data Structures 2 2 Systems Programming: 2 Data Structures  Queues –Queuing System Models –Queue.
Chapter 16 – Data Structures and Recursion. Data Structures u Built-in –Array –struct u User developed –linked list –stack –queue –tree Lesson 16.1.
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.
Heaps and basic data structures David Kauchak cs161 Summer 2009.
Data Structures. Abstract Data Type A collection of related data is known as an abstract data type (ADT) Data Structure = ADT + Collection of functions.
Linear Data Structures
2005MEE Software Engineering Lecture 7 –Stacks, Queues.
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.
Lecture 10 b Stacks b Queues. 2 Stacks b A stack ADT is linear b Items are added and removed from only one end of a stack b It is therefore LIFO: Last-In,
Data Structures and Algorithms Lists, Stacks, Queues, and Graphs Sorting and searching algorithms.
CPS120: Introduction to Computer Science Nell Dale John Lewis Abstract Data Types.
STACKS & QUEUES for CLASS XII ( C++).
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
Top 50 Data Structures Interview Questions
12 C Data Structures.
Data Structure Interview Question and Answers
12 C Data Structures.
Chapter 15 Lists Objectives
Programming Abstractions
Chapter 8: Data Abstractions
Introduction to Data Structure
Chapter 15 Lists Objectives
Arrays and Linked Lists
Lesson Objectives Aims
ECE 103 Engineering Programming Chapter 62 Stack Implementation
ECE 103 Engineering Programming Chapter 64 Tree Implementation
ECE 103 Engineering Programming Chapter 63 Queue Implementation
Important Problem Types and Fundamental Data Structures
Heaps Chapter 6 Section 6.9.
Presentation transcript:

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 developed by Professor Phillip PSU ECE

Syllabus Introduction Linear List Stack Queue Tree Implementation

2 Abstract Data Structures A data structure is a method or mechanism for representing and storing data in a computer. Data structure design depends on:  the type of data being stored  how the data is organized  how the data should be accessed Many commonly used data structures are examples of graphs.

3 Graph → abstract data structure in which a set of nodes (or vertices) are connected together by a set of links (or edges) Link connections represent node relationships. A node contains:  Data  Link(s) (i.e., which other nodes it is connected to)

4 Examples of different graph sub-classes: Abstract data structures are used to model:  Computer and communication networks (graphs)  Binary search and heaps (trees)  Stacks and queues (lists) General Graph Any node may connect to any other node and cycles are allowed General Tree A graph in which no cycles are allowed Hierarchical Tree (Binary version) Each node descends from one parent node and has zero or more child nodes Linear List A sequential set of nodes Ring A list that forms a closed loop

5 Operations on Abstract Data Structures Typical types of operations performed on an abstract data structure include:  Create node  Insert node  Remove node  Traverse nodes  Search nodes  Check if node is empty

6 Linear List Insert and remove operations can occur anywhere within the list. A B C list Linear List A B C “insert” operation list A B D C A D C D “remove” operation A B D C list

7 Stack – Last In, First Out (LIFO) Insert (“push”) and remove (“pop”) operations can only occur at the top of the stack. A B C top D A B C D A B C Stack A B C top “push” operation A B C D top “pop” operation

8 Queue – First In, First Out (FIFO) Insert (“enqueue”) operations occur at the tail, while remove (“dequeue”) operations occur at the head. A B C head D Queue tail A B C “enqueue” operation head tail A B C D head tail B C D head tail “dequeue” operation A B C head D tail

9 Graphs and Trees Insert and remove operations are more complicated, especially if a balanced structure is required.

10 Implementation of Abstract Data Structures The C language’s struct type is used to represent a node. The structure’s member variables contain:  Data  Link information

11 Ways to implement abstract data structures:  Array of nodes The maximum number of nodes is fixed at compile-time (though run-time allocation can get around this). Any node can be directly accessed via the array index. Link information is the array index of another node.  Nodes connected by pointers The maximum number of nodes is determined at runtime (can grow or shrink). Nodes must be accessed sequentially via pointer links. Link information is a pointer to another node.

12 Conceptual implementations of data structures: Singly-linked List (array) data next: 1 0 data next: 2 1 data next: 3 2 data next: -1 3 Singly-linked List (pointer) data next data next data next data next NULL p Doubly-linked List (pointer) data nextprev data nextprev data nextprev data nextprev NULL p data leftright data leftright Binary Tree (pointer) NULL data leftright NULL data leftright NULL p