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)

Slides:



Advertisements
Similar presentations
For(int i = 1; i
Advertisements

Chapter 17 Linked List Saurav Karmakar Spring 2007.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Sixth Edition Chapter 17: Linked Lists.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 17 Linked.
1 CSE1301 Computer Programming: Lecture 30 Linked Lists (Part 2)
Selection Sort
CSE 131 Computer Science 1 Module 9: Linked Lists Using references to link objects Basic operations on linked lists Implementing a linked list of integers.
CSE 143 Lecture 10 Linked List Basics reading: slides created by Marty Stepp
1 Data Structures CSCI 132, Spring 2014 Lecture 20 Linked Lists.
Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy Walters, and Godfrey Muganda Chapter 17: Linked Lists.
“When we quit thinking primarily about ourselves and our own self-preservation, we undergo a truly heroic transformation of consciousness.” – Joseph Campbell.
Selection Sort
APS105 Lists. Structures Arrays allow a collection of elements –All of the same type How to collect elements of different types? –Structures; in C: struct.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
slides adapted from Marty Stepp and Hélène Martin
Review Linked List Insertion Description Deletion Description Basic Node Implementation Conclusion 1.
Chapter 4 Linked Structures.
Building Java Programs Chapter 16
[Chapter 4; Chapter 6, pp ] CSC 143 Linked Lists (cont) [Chapter 4; Chapter 6, pp ]
CMSC202 Computer Science II for Majors Lecture 12 – Linked Lists
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
Doubly Linked List Review - We are writing this code
slides created by Marty Stepp
Notes on Assignment 1 Your code will have several classes, most notably the class that represents the entire list data structure, and the class.
Wednesday Questions How do I debug? We love to teach this at IPL/OH!
Linked node problem 3 What set of statements turns this picture:
Prof. Neary Adapted from slides by Dr. Katherine Gibson
Linked node problem 3 What set of statements turns this picture:
Linked Lists.
Linked Lists: Implementation of Queue & Deque
slides created by Marty Stepp and Ethan Apter
Linked List Intro CSCE 121 J. Michael Moore.
Building Java Programs
Building Java Programs
[Chapter 4; Chapter 6, pp ] CSC 143 Linked Lists [Chapter 4; Chapter 6, pp ]
Chapter 17: Linked Lists Starting Out with C++ Early Objects
Lecture 7: Linked List Basics reading: 16.2
More Linked Lists and Loops Based on slides by Ethan Apter
11-3 LINKED LISTS A linked list is a collection of data in which each element contains the location of the next element—that is, each element contains.
Just define the prefixes somewhere.
changing a list There are only two ways to change a linked list:
Building Java Programs
slides adapted from Marty Stepp and Hélène Martin
slides created by Marty Stepp and Hélène Martin
Building Java Programs
Building Java Programs
Linked List and Selection Sort
slides created by Marty Stepp
Lecture 8: Complex Linked List Code reading: 16.2 – 16.3
Linked Lists Adapted from Dr. Mary Eberlein, UT Austin.
Lecture 14 Linked Lists CSE /26/2018.
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)
Linked Lists.
Building Java Programs
slides created by Marty Stepp
slides adapted from Marty Stepp
Building Java Programs
Lecture 7: Linked List Basics reading: 16.2
slides adapted from Marty Stepp
Linked List Intro CSCE 121.
Linked Lists.
Wednesday Questions How do I debug? We love to teach this at IPL/OH!
slides created by Marty Stepp
slides created by Ethan Apter
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
slides created by Marty Stepp
slides created by Marty Stepp
slides created by Marty Stepp and Hélène Martin
Data Structures & Programming
Presentation transcript:

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) : front = data next 3 data next 2 data next 1 data next

addSorted Write a method addSorted that accepts an int as a parameter and adds it to a sorted list in sorted order. Before addSorted(17) : After addSorted(17) : front = data next -4 data next 8 data next 22 element 0 element 1 element 2 front = data next -4 data next 8 data next 17 data next 22 element 0 element 1 element 2 element 3

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

Common cases middle: "typical" case in the middle of an existing list back: special case at the back of an existing list front: special case at the front of an existing list empty: special case of an empty list