1 Chapter 17 – Data Structures Outline Introduction Self-Referential Classes Dynamic Memory Allocation Linked Lists Stacks Queues Trees.

Slides:



Advertisements
Similar presentations
Stacks, Queues, and Linked Lists
Advertisements

Chapter 24 Lists, Stacks, and Queues
Linked List 1. Introduction to Linked List 2. Node Class 3. Linked List 4. The Bag Class with Linked List.
Lecture Stacks. A stack is a Last-In-First-Out (LIFO) or a First-In-Last-Out (FILO) abstract data type E.g. a deck of cards in which cards may be added.
CS Data Structures II Review COSC 2006 April 14, 2017
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.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 20 – Data Structures Outline 20.1 Introduction 20.2 Self-Referential Classes 20.3 Dynamic Memory.
 2009 Pearson Education, Inc. All rights reserved Data Structures Many slides modified by Prof. L. Lilien (even many without an explicit message).
Chapter 12 C Data Structures Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
COMP 110 Introduction to Programming Mr. Joshua Stough.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 12 – Data Structures Outline 12.1Introduction.
 2006 Pearson Education, Inc. All rights reserved Data Structures.
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.
Linked List (I) Ying Wu Electrical & Computer Engineering Northwestern University ECE230 Lectures Series.
Self Referential Structure. A structure may not contain a member of its own type. struct check { int item; struct check n; // Invalid };
Chapter 12 Data Structure Associate Prof. Yuh-Shyan Chen Dept. of Computer Science and Information Engineering National Chung-Cheng University.
Data Structures Outline Introduction Self-Referential Classes Dynamic Memory Allocation Linked Lists Stacks Queues Trees.
Review 1 Introduction Representation of Linear Array In Memory Operations on linear Arrays Traverse Insert Delete Example.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Custom Templatized Data Structures.
Chapter 8 Data Abstractions Introduction to CS 1 st Semester, 2015 Sanghyun Park.
 2006 Pearson Education, Inc. All rights reserved Data Structures.
 Pearson Education, Inc. All rights reserved Data Structures.
 2007 Pearson Education, Inc. All rights reserved C Data Structures.
Dr. Salah Hammami KSU-CCIS-CS Ahmad Al-Rjoub CSC 113 King Saud University College of Computer and Information Sciences Department of Computer Science Chapter.
Introduction to Data Structures Systems Programming.
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.
Lecture 14 Linked Lists 14-1 Richard Gesick. Linked Lists Dynamic data structures can grow and shrink at execution time. A linked list is a linear collection.
 2002 Prentice Hall, Inc. All rights reserved. Chapter 19 – Data Structures Outline 19.1 Introduction 19.2 Self-Referential Classes 19.3 Dynamic Memory.
Self-Referential Classes A Self-referential class is a class that contains a reference to an object that has the same class type. –A self-referential class.
Dynamic Data Structures and Generics Chapter 10. Outline Vectors Linked Data Structures Introduction to Generics.
Foundation of Computing Systems Lecture 3 Stacks and Queues.
Slide 1 Linked Data Structures. Slide 2 Learning Objectives  Nodes and Linked Lists  Creating, searching  Linked List Applications  Stacks, queues.
1 Linked-list, stack and queue. 2 Outline Abstract Data Type (ADT)‏ Linked list Stack Queue.
Copyright © 2012 Pearson Education, Inc. Chapter 17: Linked Lists.
Programming Practice 3 - Dynamic Data Structure
Copyright © 2002 Pearson Education, Inc. Slide 1.
Final Exam –Date: Aug 27 th –Time: 9:00am – 12:00pm –Location: TEL 0014.
Chapter 16 – Data Structures and Recursion. Data Structures u Built-in –Array –struct u User developed –linked list –stack –queue –tree Lesson 16.1.
Java How to Program, 9/e © Copyright by Pearson Education, Inc. All Rights Reserved.
DATA STRUCTURE Presented By: Mahmoud Rafeek Alfarra Using C# MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE.
Introduction Dynamic Data Structures Grow and shrink at execution time Linked lists are dynamic structures where data items are “linked up in a chain”
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Linked Lists Outline Introduction Self-Referential Structures.
Linked Lists Chapter Introduction To The Linked List ADT Linked list: set of data structures (nodes) that contain references to other data structures.
Copyright © 2012 Pearson Education, Inc. Chapter 17: Linked Lists.
STACKS & QUEUES for CLASS XII ( C++).
Data Structures: Linked Lists
Pointers and Linked Lists
Data Structure By Amee Trivedi.
17 Data Structures.
Chapter 12 – Data Structures
5.13 Recursion Recursive functions Functions that call themselves
UNIT – I Linked Lists.
12 C Data Structures.
12 C Data Structures.
Chapter 22 Custom Generic Data Structures
Chapter 15 Lists Objectives
CISC181 Introduction to Computer Science Dr
Stacks and Queues CMSC 202.
Stack and Queue APURBO DATTA.
8-1.
Pointers and Linked Lists
8-1.
Chapter 19 – Data Structures
Arrays and Linked Lists
Chapter 18: Linked Lists.
Review & Lab assignments
Chapter 17: Linked Lists.
Recall: stacks and queues
Intro to OOP with Java, C. Thomas Wu By : Zanariah Idrus
Recall: stacks and queues
Presentation transcript:

1 Chapter 17 – Data Structures Outline Introduction Self-Referential Classes Dynamic Memory Allocation Linked Lists Stacks Queues Trees

2 Introduction Dynamic data structures –Grow and shrink at execution time –Several types Linked lists Stacks Queues Binary trees

3 Self-Referential Classes Self-referential class –Contains instance variable referring to object of same class class Node { private int data; private Node nextNode; // reference to next linked node } Member nextNode is a link –nextNode “links” a Node object to another Node object

4 Self-Referential Classes (cont.) Self-referential-class objects linked together. 1510

5 Dynamic Memory Allocation Dynamic memory allocation –Obtain more memory at execution time to store new objects Declaration and class-instance creation expression Node nodeToAdd = new Node ( 10 );

6 Linked Lists Linked list –Linear collection of self-referential classes (nodes) –Connected by reference links –Nodes can be inserted and deleted anywhere in linked list –Last node is set to null to mark end of list..\..\week14\linkedlist

7 Linked Lists (cont.) Linked list graphical representation. firstNode... HD Q lastNode

8 Linked Lists (cont.) Graphical representation of operation insertAtFront. firstNode new Listnode firstNode new Listnode (a) (b)

9 Linked Lists (cont.) Graphical representation of operation insertAtBack. firstNode 12 new Listnode (a) (b) firstNodenew Listnode lastNode

10 Linked Lists (cont.) Graphical representation of operation removeFromFront. firstNode 12 (a) (b) lastNode firstNode removeItem

11 Linked Lists (cont.) Graphical representation of operation removeFromBack. 12 (a) (b) lastNode lastNode firstNode removeItem firstNodecurrent

12 Stacks Stack –Constrained version of a linked list Add and remove nodes only to and from the top of the stack –Push method adds node to top of stack –Pop method removes node from top of stack..\..\week14\linkedlist

13 Queues Queue –Similar to a supermarket checkout line –Nodes inserted only at tail (back) Method enqueue –Nodes removed only from head (front) Method dequeue..\..\week14\queue