COMP 110 Introduction to Programming Mr. Joshua Stough.

Slides:



Advertisements
Similar presentations
Chapter 25 Lists, Stacks, Queues, and Priority Queues
Advertisements

Chapter 24 Lists, Stacks, and Queues
CS Data Structures II Review COSC 2006 April 14, 2017
Lecture 8 CS203. Implementation of Data Structures 2 In the last couple of weeks, we have covered various data structures that are implemented in the.
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.
Unit 11 1 Unit 11: Data Structures H We explore some simple techniques for organizing and managing information H This unit focuses on: Abstract Data Types.
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.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L12 (Chapter 20) Lists, Stacks,
1 Data Structures  We can now explore some advanced techniques for organizing and managing information  Chapter 12 of the book focuses on: dynamic structures.
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.
Chapter 12 Collections. © 2004 Pearson Addison-Wesley. All rights reserved12-2 Collections A collection is an object that helps us organize and manage.
COMPSCI 125 Spring 2005 ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Odds and Ends Strings (from Chapter 9) StringTokenizer.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 26 Implementing Lists, Stacks,
ADT Stacks and Queues. Stack: Logical Level “An ordered group of homogeneous items or elements in which items are added and removed from only one end.”
C o n f i d e n t i a l Developed By Nitendra NextHome Subject Name: Data Structure Using C Title: Overview of Data Structure.
Copyright © Wondershare Software Introduction to Data Structures Prepared by: Eng. Ahmed & Mohamed Taha.
Chapter 12 Data Structure Associate Prof. Yuh-Shyan Chen Dept. of Computer Science and Information Engineering National Chung-Cheng University.
Review C++ exception handling mechanism Try-throw-catch block How does it work What is exception specification? What if a exception is not caught?
90-723: Data Structures and Algorithms for Information Processing Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 5: Stacks and Queues.
CHAPTER 05 Compiled by: Dr. Mohammad Omar Alhawarat Stacks & Queues.
ISOM MIS 215 Module 3 – Stacks and Queues. ISOM Where are we? 2 Intro to Java, Course Java lang. basics Arrays Introduction NewbieProgrammersDevelopersProfessionalsDesigners.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Custom Templatized Data Structures.
© 2006 Pearson Education Chapter 12: Data Structures Presentation slides for Java Software Solutions for AP* Computer Science A 2nd Edition by John Lewis,
Lists ADT (brief intro):  Abstract Data Type  A DESCRIPTION of a data type  The data type can be anything: lists, sets, trees, stacks, etc.  What.
 2007 Pearson Education, Inc. All rights reserved C Data Structures.
Stacks and Queues Introduction to Computing Science and Programming I.
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.
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.
Introduction to Data Structures Fall 2008 Dr. David A. Gaitros
Information and Computer Sciences University of Hawaii, Manoa
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 20 Lists, Stacks,
CMSC 202 Stacks and Queues. What’s a Queue? A queue is a linear collection of homogeneous data in which items added to the queue must be placed at the.
Data Structures (part 2). Stacks An Everyday Example Your boss keeps bringing you important items to deal with and keeps saying: “Put that last ‘rush’
Data structures Abstract data types Java classes for Data structures and ADTs.
1 Chapter 17 Object-Oriented Data Structures. 2 Objectives F To describe what a data structure is (§17.1). F To explain the limitations of arrays (§17.1).
Chapter 12 Collections. © 2004 Pearson Addison-Wesley. All rights reserved12-2 Collections A collection is an object that helps us organize and manage.
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.
CSCI 62 Data Structures Dr. Joshua Stough September 2, 2008.
A data structure is a type of data storage ….similar to an array. There are many data structures in Java (Stacks, Queues, LinkedList, Sets, Maps, HashTables,
Data Structures: Advanced Damian Gordon. Advanced Data Structure We’ll look at: – Linked Lists – Trees – Stacks – Queues.
Understanding Data Types and Collections Lesson 2.
Chapter 12: Collections by Lewis and Loftus (Updated by Dan Fleck) Coming up: Collections.
Foundation of Computing Systems Lecture 3 Stacks and Queues.
Data Structures Types of Data Structure Data Structure Operations Examples Choosing Data Structures Data Structures in Alice.
CS102 – Data Structures Lists, Stacks, Queues, Trees & HashTables. David Davenport.
AITI Lecture 18 Introduction to Data Structure, Stack, and Queue Adapted from MIT Course 1.00 Spring 2003 Lecture 23 and Tutorial Note 8 (Teachers: Please.
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.
ITEC 2620M Introduction to Data Structures Instructor: Prof. Z. Yang Course Website: ec2620m.htm Office: Tel 3049.
Data Structures. Abstract Data Type A collection of related data is known as an abstract data type (ADT) Data Structure = ADT + Collection of functions.
Data-structure-palooza Checkout DataStructures from SVN.
Linear Data Structures
Stacks Queues Introduction to Trees. Stacks An Everyday Example Your boss keeps bringing you important items to deal with and keeps saying: “Put that.
CSCI 62 Data Structures Dr. Joshua Stough October 7, 2008.
Lecture 21 Data Structures, Algorithms and Complexity Stacks and Queues GRIFFITH COLLEGE DUBLIN.
CS6045: Advanced Algorithms Data Structures. Dynamic Sets Next few lectures will focus on data structures rather than straight algorithms In particular,
CPS120: Introduction to Computer Science Nell Dale John Lewis Abstract Data Types.
Data Structure By Amee Trivedi.
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
Lecture 7 Queues Stacks Trees.
12 C Data Structures.
Introduction to Data Structure
Chapter 17 Object-Oriented Data Structures
ITEC 2620M Introduction to Data Structures
Introduction to Data Structure
Presentation transcript:

COMP 110 Introduction to Programming Mr. Joshua Stough

What are Data Structures? Abstract data types –data that is “more” (quantity and complexity) than a primitive –dynamic –ADT encapsulates data and related services –same as a class? yes, classes with the special purpose of primarily maintaining data Example: String class

Data UNC COMP 410 –prereq: COMP 401 (after 110) Research –researchers develop new data structures for efficiently storing and retrieving data Data structures are used in all areas of computer science. Knowledge of efficient ways of storing information is essential.

What Do We Want? Example Maintain a collection of addresses (Strings) –first, middle, and last name –telephone number – address Services –new, find, insert, delete, read, replace, sort “Infinite” (unspecified) length

Arrays? Perhaps but… –need to specify the length at some point once specified, can’t change need to create a new array, copy, etc. –insertion is “impossible” (hard) –deletion is wasteful

Linked Lists Three classes (typically) working together –an “item” class one atomic unit of the aggregate data e.g., a “Name” class (item) might have two instance variables String first, last; –a “node” class one “item” and a reference to the next “node” the next reference is the “link” in “linked list” –a “list” class reference to the first “node”—head of the list

Linked Lists data Item nextNode Node List head Node

Linked Lists New List head Node List head Node

Linked Lists Find List head Node

Linked Lists Insert Node List head Node

Linked Lists Delete List head Node

Stacks Like a stack of paper (or cafeteria trays) –“last-in first-out” (LIFO) can only add to the top - push can only remove from the top - pop Why? –Often used to keep track of execution in a program when returning from a method call, the computer has to remember where it last was

Stack top Node Only have access to the top of the stack May be implemented as a linked list

Stacks Example 10 public shuffle() { 11 int ind1 = nextInt(NUM_CARDS); } 1 public static void main (String[] args) { 2 deck = new Deck(); 3 deck.shuffle(); 4 System.out.println (deck); } 20 public int nextInt (int num) { 21 return 0; } Call Stack top

Stack Applet

Queues Standing in line –“first-in first-out” (FIFO) add to the “tail” of the list (back of line) - enqueue remove from the “head” (head of line) - dequeue Why? –often used to keep things in the order that they arrived –processes to be scheduled on the CPU –packets arriving to a router

Queue head Node Only have access to the head and tail of the queue May be implemented as a linked list tail

Queue Applet QueuesImplementationView/applet.html

Trees Nodes can have more than one link Links are bi-directional –forward link points to children –backward link points to parent Why? –keeping items in sorted order easy to add things in sorted order –fast search –also often used to parse arithmetic expressions (order of operations)

Binary Trees Every node has a parent, except head Every node has at most two children root - has no parent leaf - has no children root leaves

Binary Trees And Expressions (3 + 2) * 5 * Called a parse tree * 5 + * Evaluate deepest expressions first.

Binary Search Tree The first item added is the root Items less than the root go on the left branch Items greater than the root go on the right branch Makes searches very efficient possible order added:

Binary Search Tree Applet

What To Expect in COMP 401 Learn more about object-oriented programming –inheritance, interfaces Learn to use 2D arrays Learn to program sorting algorithms Learn to program data structures