Linked Lists - Colorado State University
Linked Lists
Chapter 12.3 in Savitch
Preliminaries
n Arrays are not always the optimal data structure:
q An array has fixed size ? needs to be copied to expand its capacity
q Adding in the middle of an array requires moving all subsequent elements
n ArrayLists have the same issues since they use arrays to store their data.
Objects and references
n Object variables do not actually store an object; they store the address of an object's location in the computer's memory (references / pointers).
n Example: int [] values = new int[5];
values
5 7 10 6 3
int x = 1;
x 1
Java References
q When one reference variable is assigned to another, the object is not copied; both variables refer to the same object.
int[] a1 = {4, 5, 2, 12, 14, 14, 9}; int[] a2 = a1; //refers to same array as a1 a2[0] = 7; System.out.println(a1[0]); // 7
a1
index 0 1 2 3 4 5 6
value 74 5 2 12 14 14 9 a2
Self references
n Consider the following class: public class Node { String name; Node next; } q Will this compile?
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- linked lists bu
- linked lists colorado state university
- singly linked list class carnegie mellon university
- linked list example snode class edu
- learning exercise c linked list baumann
- linked list basics stanford university
- linked lists csu
- lecture notes on linked lists carnegie mellon university
- linked lists edu
- linked list classes linked list example virginia tech
Related searches
- colorado state university calendar
- colorado state university calendar 2019 2020
- colorado state university single audit
- colorado state university cost breakdown
- colorado state university tuition fee
- colorado state university tuition 2020
- colorado state university tuition cost
- colorado state university price
- colorado state university tuition 2021
- colorado state university aar
- colorado state university career fair
- colorado state university 2019 schedule