Wednesday Questions How do I debug? We love to teach this at IPL/OH!

Slides:



Advertisements
Similar presentations
CSE 143 Lecture 22: Advanced List Implementation (ADTs; interfaces; abstract classes; inner classes; generics; iterators)
Advertisements

Building Java Programs Inner classes, generics, abstract classes reading: 9.6, 15.4,
CSE 143 Lecture 14 Interfaces; Abstract Data Types (ADTs) reading: 9.5, 11.1; 16.4 slides created by Marty Stepp
CSE 143 Lecture 20 Binary Search Trees continued; Tree Sets read slides created by Marty Stepp and Hélène Martin
CSE 143 Lecture 10 Linked List Basics reading: slides created by Marty Stepp
CSE 143 Lecture 24 Advanced collection classes (ADTs; abstract classes; inner classes; generics; iterators) read 11.1, 9.6, , slides.
Building Java Programs Bonus Slides Hashing. 2 Recall: ADTs (11.1) abstract data type (ADT): A specification of a collection of data and the operations.
Chapter 6 Linked Structures © 2006 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved.
slides adapted from Marty Stepp and Hélène Martin
Building Java Programs Interfaces reading: , 16.4.
Week 15 – Monday.  What did we talk about last time?  Tries.
Lecture 16 Stacks and Queues Richard Gesick. Sample test questions 1.Write a definition for a Node class that holds a number. 2.Write a method that sums.
Building Java Programs Chapter 16
CSE 143 Lecture 20 Binary Search Trees continued; Tree Sets
LinkedIntList(int n) Write a constructor for LinkedIntList that accepts an int n parameter and makes a list of the number from 0 to n new LinkedIntList(3)
Building Java Programs
University of Central Florida COP 3330 Object Oriented Programming
A tree set Our SearchTree class is essentially a set.
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
Linked node problem 3 What set of statements turns this picture:
structures and their relationships." - Linus Torvalds
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
LinkedIntList(int n) Write a constructor for LinkedIntList that accepts an int n parameter and makes a list of the number from 0 to n new LinkedIntList(3)
structures and their relationships." - Linus Torvalds
CSE 143 Lecture 9 References and Linked Nodes reading: 16.1
Linked Lists: Implementation of Queue & Deque
Chapter 13 Collections.
slides created by Marty Stepp and Ethan Apter
Building Java Programs
CSE 143 Lecture 6 Interfaces; Complexity (Big-Oh)
Building Java Programs
Java Collections Framework
CSE 143 Lecture 27: Advanced List Implementation
Lecture 26: Advanced List Implementation
A tree set Our SearchTree class is essentially a set.
CSE 143 Lecture 6 References and Linked Nodes reading: 16.1
Lecture 7: Linked List Basics reading: 16.2
changing a list There are only two ways to change a linked list:
Building Java Programs
slides created by Marty Stepp and Hélène Martin
Building Java Programs
Building Java Programs
Shapes Consider the task of writing classes to represent 2D shapes such as Circle, Rectangle, and Triangle. Certain operations are common to all shapes:
Recall: stacks and queues
Binary Search Trees continued; Tree Sets
Building Java Programs
slides created by Marty Stepp
LinkedIntList(int n) Write a constructor for LinkedIntList that accepts an int n parameter and makes a list of the number from 0 to n new LinkedIntList(3)
Road Map CS Concepts Data Structures Java Language Java Collections
1.4 ทบทวน JAVA OO Programming Concepts Declaring and Creating Objects
Building Java Programs
slides created by Marty Stepp
Recall: stacks and queues
slides adapted from Marty Stepp
Building Java Programs
slides created by Marty Stepp
Lecture 7: Linked List Basics reading: 16.2
CSE 143 Lecture 7 References and Linked Nodes reading: 16.1
slides created by Marty Stepp
Linked Lists and Loops based on slides by Ethan Apter
CSE 143 Lecture 21 Advanced List Implementation
slides created by Ethan Apter
slides created by Marty Stepp
structures and their relationships." - Linus Torvalds
slides created by Marty Stepp
slides created by Marty Stepp and Hélène Martin
Presentation transcript:

Wednesday Questions How do I debug? We love to teach this at IPL/OH! HW specs are complicated HWs in 143 are generally tougher than 142. The IPL/OH are helpful resources to discuss starting points if you’re lost. Are Stack/Queues more basic than arrays? What is the next programming language to learn? Python, Javascript (maybe)

Wednesday Questions

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

data next 10 data next 20 data next 30 list1 current

Abstract data types (ADTs) abstract data type (ADT): A specification of a collection of data and the operations that can be performed on it. Describes what a collection does, not how it does it Java's collection framework describes several ADTs: Queue, List, Collection, Deque, List, Map, Set An ADT can be implemented in multiple ways: ArrayList and LinkedList implement List HashSet and TreeSet implement Set LinkedList, ArrayDeque, etc. implement Queue The same external behavior can be implemented in many different ways, each with pros and cons.

Linked List vs. Array Similar to array code: Print list values: int[] a = ...; int i = 0; while (i < a.length) { System.out.println(a[i]); i++; } Print list values: ListNode list= ...; ListNode current = list; while (current != null) { System.out.println(current.data); current = current.next; } Description Array Code Linked List Code Go to front of list int i = 0; ListNode current = list; Test for more elements i < size current != null Current value elementData[i] current.data Go to next element i++; current = current.next;

Before/After Before After data next 10 data next 20 data next 30 front 40 front

changing a list There are only two ways to change a linked list: Change the value of front (modify the front of the list) Change the value of <node>.next (modify middle or end of list to point somewhere else) Implications: To add in the middle, need a reference to the previous node Front is often a special case