Linked Lists CSC 171 FALL 2001 LECTURE 20

  • Slides: 23
Download presentation
Linked Lists CSC 171 FALL 2001 LECTURE 20

Linked Lists CSC 171 FALL 2001 LECTURE 20

COURSE EVALUATIONS l Tuesday, December 11 th, in Lecture

COURSE EVALUATIONS l Tuesday, December 11 th, in Lecture

Gentle Start BA in CSC Freshman Sophomore Junior Senior FALL SPRING MTH 150 CSC

Gentle Start BA in CSC Freshman Sophomore Junior Senior FALL SPRING MTH 150 CSC 108 CSC 171 MTH 142 CSC 173 CSC 282 CSC 240 W CSC 254(UL) MTH 141 CSC 170 CSC 172 MTH 143 CSC 280 CSC 252 CSC 284(UL) CSC 248(UL)

OTHELLO WINNERS 4. 5. 6. 7. 8. 9. 10. Rotem Cohen Matthew Pelmear Andrew

OTHELLO WINNERS 4. 5. 6. 7. 8. 9. 10. Rotem Cohen Matthew Pelmear Andrew Regan Justin Moore Tyler Berry Aaron Gallant Dave Chapman 11. 12. 13. 14. 15. 16. 17. 18. Jonathan Pearson Kristin Robinson Steve Carlton Matthew Vukman Preethum Prithviraj Gregory Rubin Benjamin Margolis Lee Frankel. Goldwater

OTHELLO WINNERS 1. Micha Elsner 2. Liam Rafferty 3. Shonda Ranson

OTHELLO WINNERS 1. Micha Elsner 2. Liam Rafferty 3. Shonda Ranson

History: Moore’s Law 1968 Dr. Gordon E. Moore, co-founded Intel in 1968 Made his

History: Moore’s Law 1968 Dr. Gordon E. Moore, co-founded Intel in 1968 Made his famous observation in 1965 Moore predicted that the number of transistors per integrated circuit would double every 18 months. He forecast that this trend would continue through 1975.

Moore’s Law

Moore’s Law

Intel 4004 November 15, 1971 Clock speed: 108 kilohertz Number of transistors: 2, 300

Intel 4004 November 15, 1971 Clock speed: 108 kilohertz Number of transistors: 2, 300 (10 microns) Bus width: 4 bits Addressable memory: 640 bytes Pentium® III Oct. 25, 1999 Clock speed (600, 667, and 733 MHz) Number of transistors: 28 million (0. 18 micron) Bus Width: 64 bit Addressable Memory: 64 Gigabytes If automobile speed had increased similarly over the same period, you could now drive from San Francisco to New York in about 13 seconds

COMPUTE POWER REQUIREMENTS (MOREVIC)

COMPUTE POWER REQUIREMENTS (MOREVIC)

COMPUTE POWER PROJECTION (MOREVIC)

COMPUTE POWER PROJECTION (MOREVIC)

Self-referential data types class Node { private Object data; private Node next; } data

Self-referential data types class Node { private Object data; private Node next; } data next // the “data” // the “link”

Linked List l. A linked list “has-a” reference to a node – The “head”

Linked List l. A linked list “has-a” reference to a node – The “head” of the list – The ending node has “null” for the next head data next data Next null

Adding a first node

Adding a first node

Adding a first node public void add. First(Object obj){ Link new. Link = new

Adding a first node public void add. First(Object obj){ Link new. Link = new Link(); new. Link. data = obj; new. Link. next = first; first = new. Link; }

Deleting a first node

Deleting a first node

Deleting a first node public Object remove. First(){ if (first == null) throw new

Deleting a first node public Object remove. First(){ if (first == null) throw new No. Such. Element. Exception(); Object obj = first. data; first = first. next; return obj; }

A List Iterator

A List Iterator

Iterator Functionality

Iterator Functionality

Iterator next public Object next() { if (position == null){ position = first; return

Iterator next public Object next() { if (position == null){ position = first; return get. First(); } else { if (position. next == null) throw new No. Such. Element. Exception(); previous = position; // remember for remove position = position. next; return position. data; } }

Adding to middle

Adding to middle

Adding to middle public void add(Object obj){ if (position == null) add. First(obj); else

Adding to middle public void add(Object obj){ if (position == null) add. First(obj); else { Link new. Link = new Link(); new. Link. data = obj; new. Link. next = position. next; position. next = new. Link; position = new. Link; previous = null; } }

Removing from middle

Removing from middle

Removing from middle public void remove(){ if (position == first) remove. First(); else{ if

Removing from middle public void remove(){ if (position == first) remove. First(); else{ if (previous == null) throw new Illegal. State. Exception(); previous. next = position. next; position = previous; } previous = null; } }