csse 220
play

CSSE 220 Linked List Implementation and Project Preparation - PowerPoint PPT Presentation

CSSE 220 Linked List Implementation and Project Preparation Checkout LinkedListSimple project from git Quiz Get into pairs Look at/run the code in LinkedList.java main Draw a box-and- pointer diagram of whats happening in the


  1. CSSE 220 Linked List Implementation and Project Preparation Checkout LinkedListSimple project from git

  2. Quiz • Get into pairs • Look at/run the code in LinkedList.java main • Draw a box-and- pointer diagram of what’s happening in the main code. • To figure it out, you’ll have to look at the LinkedList constructor and addAtBeginning. • If you’ve forgotten how to do box -and-pointer diagrams, checkout the handout on Day 5 of the schedule Q1

  3. Solve the Other Problems in LinkedListSimple • Look at toString to get an idea of how to do size, then go from there • They are in approximate difficulty order • Get help if you get stuck! • Hold on to your quiz today, we will finish it next class period.

  4. Shorthand Notation • Using pictures will be extremely helpful • Can use System.out.println( this ) to see what the current list looks like (does it match diagram?)

  5. Loops in Arrays vs. LinkedLists int[] nums = …… LinkedList list = …… for (int i=0; i< nums.length; ++) { //Another Day! //do stuff with //arbitrary element nums[i] } Equivalent in while loop int i=0; Node current = this.head; while ( ? ) { while ( ? ) { //do stuff with //do stuff with //arbitrary element nums[i] //arbitrary element ? ? } }

  6. Loops in Arrays vs. LinkedLists int[] nums = …… LinkedList list = …… for (int i=0; i< nums.length; ++) { //Another Day! //do stuff with //arbitrary element nums[i] } Equivalent in while loop int i=0; Node current = this.head; while ( i < nums.length ) { while ( ? ) { //do stuff with //do stuff with //arbitrary element nums[i] //arbitrary element i++; ? } }

  7. Loops in Arrays vs. LinkedLists int[] nums = …… LinkedList list = …… for (int i=0; i< nums.length; ++) { //Another Day! //do stuff with //arbitrary element nums[i] } Equivalent in while loop int i=0; Node current = this.head; while ( i < nums.length ) { while ( ? ) { //do stuff with //do stuff with //arbitrary element nums[i] //arbitrary element i++; current = current.next; } }

  8. Loops in Arrays vs. LinkedLists int[] nums = …… LinkedList list = …… for (int i=0; i< nums.length; ++) { //Another Day! //do stuff with //arbitrary element nums[i] } Equivalent in while loop int i=0; Node current = this.head; while ( i < nums.length ) { while ( current != null ) { //do stuff with //do stuff with //arbitrary element nums[i] //arbitrary element i++; current = current.next; } }

  9. Solve the Other Problems in LinkedListSimple • Look at toString to get an idea of how to do size, then go from there • They are in approximate difficulty order • Get help if you get stuck! – size() – add… – remove…

  10. Shorthand Notation

  11. Homework • SinglyLinkedList – Requires you to implement a SinglyLinkedList – Additional algorithm questions which make use of the SinglyLinkedList – Will give time in next class to work on it

  12. TEAM PROJECT WORK TIME • Move into your groups if not already • Review comments from Milestone 0 feedback • Be prepared to ask question of the grader • You will have ~5 minutes, so use it well

Recommend


More recommend