Road Map CS Concepts Data Structures Java Language Java Collections

Slides:



Advertisements
Similar presentations
Data Structures A data structure is a collection of data organized in some fashion that permits access to individual elements stored in the structure This.
Advertisements

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 19 Java Data Structures
Java Collections. Collections, Iterators, Algorithms CollectionsIteratorsAlgorithms.
SEG4110 – Advanced Software Design and Reengineering TOPIC G Java Collections Framework.
Java Collections Framework A presentation by Eric Fabricant.
Information and Computer Sciences University of Hawaii, Manoa
Big Java Chapter 16.
Data structures Abstract data types Java classes for Data structures and ADTs.
CSS446 Spring 2014 Nan Wang  Java Collection Framework ◦ LinkedList ◦ Set ◦ Map 2.
HIT2037- HIT6037 Software Development in Java 22 – Data Structures and Introduction.
Stacks and Queues. 2 3 Runtime Efficiency efficiency: measure of computing resources used by code. can be relative to speed (time), memory (space), etc.
CSE 143 Lecture 10 Linked List Basics reading: slides created by Marty Stepp
Chapter 12: Collections by Lewis and Loftus (Updated by Dan Fleck) Coming up: Collections.
1 Java's Collection Framework Map and Sets. 2 Collection Framework  A collections framework is a unified architecture for representing and manipulating.
CS-2851 Dr. Mark L. Hornick 1 Stacks and Queues Behavior vs. Structure.
Stacks and Queues. 2 Abstract Data Types (ADTs) abstract data type (ADT): A specification of a collection of data and the operations that can be performed.
Collections ABCD ABCD Head Node Tail Node array doubly linked list Traditional Arrays and linked list: Below is memory representation of traditional.
Building Java Programs
Building Java Programs Chapter 16
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 19 Java Data Structures
Wednesday Notecards. Wednesday Notecards Wednesday Notecards.
Building Java Programs
Cinda Heeren / Geoffrey Tien
Week 15 – Monday CS221.
slides created by Marty Stepp
Wednesday Questions How do I debug? We love to teach this at IPL/OH!
Road Map CS Concepts Data Structures Java Language Java Collections
Building Java Programs
Road Map CS Concepts Data Structures Java Language Java Collections
Linked node problem 3 What set of statements turns this picture:
structures and their relationships." - Linus Torvalds
Road Map - Quarter CS Concepts Data Structures Java Language
Linked node problem 3 What set of statements turns this picture:
CSE 143 Lecture 9 References and Linked Nodes reading: 3.3; 16.1
Building Java Programs
Building Java Programs
structures and their relationships." - Linus Torvalds
CSE 143 Lecture 9 References and Linked Nodes reading: 16.1
CSE 142 vs CSE 143 CSE 142 CSE 143 You learned how to write programs and decompose large problems with: Print statements Methods Control Structures.
slides created by Marty Stepp and Ethan Apter
Building Java Programs
CSE 143 Lecture 6 References and Linked Nodes reading: 16.1
Lecture 7: Linked List Basics reading: 16.2
Road Map - Quarter CS Concepts Data Structures Java Language
Welcome to CSE 143! Go to pollev.com/cse143.
Stacks and Queues CLRS, Section 10.1.
Building Java Programs
Recall: stacks and queues
CSE 1020: The Collection Framework
slides created by Marty Stepp
CSE 143 Lecture 5 References and Linked Nodes
Road Map - Quarter CS Concepts Data Structures Java Language
1.4 ทบทวน JAVA OO Programming Concepts Declaring and Creating Objects
Recall: stacks and queues
slides adapted from Marty Stepp
Building Java Programs
Lecture 7: Linked List Basics reading: 16.2
Lecture 6: References and linked nodes reading: 16.1
CSE 143 Lecture 7 References and Linked Nodes reading: 16.1
CSE 373 Java Collection Framework reading: Weiss Ch. 3, 4.8
Wednesday Questions How do I debug? We love to teach this at IPL/OH!
CS 240 – Advanced Programming Concepts
structures and their relationships." - Linus Torvalds
Lecture 6: References and linked nodes reading: 16.1
Stack Implementations
slides created by Marty Stepp and Hélène Martin
Presentation transcript:

Road Map CS Concepts Data Structures Java Language Java Collections Client/Implementer Efficiency Recursion Regular Expressions Grammars Sorting Backtracking Hashing Huffman Compression Data Structures Lists Stacks Queues Sets Maps Priority Queues Java Language Exceptions Interfaces References Comparable Generics Inheritance/Polymorphism Abstract Classes Java Collections Arrays ArrayList 🛠 LinkedList 🛠 Stack TreeSet / TreeMap HashSet / HashMap PriorityQueue

Recall: stacks and queues stack: retrieves elements in reverse order as added queue: retrieves elements in same order as added push pop, peek top 3 2 bottom 1 front back 1 2 3 remove, peek add queue stack

Memory for a List Array (contiguous in memory) Spread in memory 42 -3 17 9 42 9 -3 17

A list node class Each list node object stores: public class ListNode { public int data; public ListNode next; } Each list node object stores: one piece of integer data a reference to another list node ListNodes can be "linked" into chains to store a list of values: data next 42 data next -3 data next 17 data next 9 end

pollev.com/cse143 Suppose we had the following ListNodes: What would the lists look like if we ran the code? list1.next = list2.next; data next 1 data next 2 data next 3 list1 data next 4 data next 5 list2

Linked node problem 3 What set of statements turns this picture: Into this? data next 10 data next 20 list1 data next 30 data next 40 list2 data next 10 data next 20 data next 30 list1 data next 40 list2

Linked node problem 3 How many ListNode variables? Which variables change? B C data next 10 data next 20 list1 A E F data next 30 data next 40 list2 D C E data next 10 data next 20 data next 30 list1 data next 40 list2 D

Linked node problem 3 How many ListNode variables? Which variables change? B C data next 10 data next 20 list1 list1.next.next = list2 A E F data next 30 data next 40 list2 D C E data next 10 data next 20 data next 30 list1 data next 40 list2 F

Linked node problem 3 How many ListNode variables? Which variables change? B C data next 10 data next 20 list1 list1.next.next = list2 A list2 = list2.next E F data next 30 data next 40 list2 D C E data next 10 data next 20 data next 30 list1 data next 40 list2 D

Linked node problem 3 How many ListNode variables? Which variables change? B C data next 10 data next 20 list1 list1.next.next = list2 A list2 = list2.next list1.next.next.next = null E F data next 30 data next 40 list2 D C E data next 10 data next 20 data next 30 list1 data next 40 list2 D

Reassigning references when you say: a.next = b.next; you are saying: "Make variable a.next refer to the same value as b.next." Or, "Make a.next point to the same place that b.next points." data next 10 data next 20 a data next 30 data next 40 b

References vs. objects variable = value; For the list at right: a variable (left side of = ) place to put a reference (where the phone number goes; where the base of the arrow goes) a value (right side of = ) is the reference itself (the phone number; the destination of the arrow) adjus For the list at right: a.next = value; means to t where points variable = a.next; means to make variable point at 2 data next 10 data next 20 a 1 1 2

Linked node problem 4 What set of statements turns this picture: Into this? data next 1 data next 2 data next 3 list1 list2 data next 1 data next 3 list1 data next 2 list2