linked lists csc 171 fall 2001 lecture 20 course evaluations tuesday, december 11 th, in lecture

23
Linked Lists Linked Lists CSC 171 FALL 2001 LECTURE 20

Post on 21-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Linked ListsLinked Lists

CSC 171 FALL 2001

LECTURE 20

COURSE EVALUATIONSCOURSE EVALUATIONS

Tuesday, December 11th, in Lecture

Gentle Start BA in CSCGentle Start BA in CSC

FALL SPRING

Freshman MTH 150CSC 108

MTH 141CSC 170

Sophomore CSC 171MTH 142

CSC 172MTH 143

Junior CSC 173CSC 282

CSC 280CSC 252

Senior CSC 240WCSC 254(UL)

CSC 284(UL)CSC 248(UL)

OTHELLO WINNERSOTHELLO WINNERS

4. Rotem Cohen

5. Matthew Pelmear

6. Andrew Regan

7. Justin Moore

8. Tyler Berry

9. Aaron Gallant

10. Dave Chapman

11. Jonathan Pearson

12. Kristin Robinson

13. Steve Carlton

14. Matthew Vukman

15. Preethum Prithviraj

16. Gregory Rubin

17. Benjamin Margolis

18. Lee Frankel-Goldwater

OTHELLO WINNERSOTHELLO WINNERS

1. Micha Elsner

2. Liam Rafferty

3. Shonda Ranson

History: Moore’s LawHistory: Moore’s Law1968 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 LawMoore’s Law

If automobile speed had increased If automobile speed had increased similarly over the same period, you could similarly over the same period, you could

now drive from San Francisco to New now drive from San Francisco to New York in about 13 secondsYork in about 13 seconds

Intel 4004November 15, 1971Clock speed: 108

kilohertzNumber of transistors:

2,300 (10 microns)Bus width: 4 bitsAddressable memory:

640 bytes

Pentium® IIIOct. 25, 1999 Clock speed (600, 667,

and 733MHz)Number of transistors:

28 million (0.18-micron)

Bus Width: 64 bit Addressable Memory:

64 Gigabytes

COMPUTE POWER REQUIREMENTS (MOREVIC)COMPUTE POWER REQUIREMENTS (MOREVIC)

COMPUTE POWER PROJECTION (MOREVIC)COMPUTE POWER PROJECTION (MOREVIC)

Self-referential data typesSelf-referential data types

class Node {

private Object data; // the “data”

private Node next; // the “link”

}

data next

Linked ListLinked List

A linked list “has-a” reference to a node – The “head” of the list– The ending node has “null” for the next

data next data Next

null

head

Adding a first nodeAdding a first node

Adding a first nodeAdding a first node

public void addFirst(Object obj){

Link newLink = new Link();

newLink.data = obj;

newLink.next = first;

first = newLink;

}

Deleting a first nodeDeleting a first node

Deleting a first nodeDeleting a first node

public Object removeFirst(){

if (first == null)

throw new NoSuchElementException();

Object obj = first.data;

first = first.next;

return obj;

}

A List IteratorA List Iterator

Iterator FunctionalityIterator Functionality

Iterator nextIterator nextpublic Object next() {

if (position == null){ position = first;return getFirst();

} else { if (position.next == null) throw new NoSuchElementException();previous = position; // remember for removeposition = position.next;return position.data;}

}

Adding to middleAdding to middle

Adding to middleAdding to middlepublic void add(Object obj){

if (position == null)addFirst(obj);

else { Link newLink = new Link();newLink.data = obj;newLink.next = position.next;position.next = newLink;position = newLink;previous = null;

}}

Removing from middleRemoving from middle

Removing from middleRemoving from middlepublic void remove(){

if (position == first) removeFirst();

else{

if (previous == null)

throw new IllegalStateException();

previous.next = position.next;

position = previous;

}

previous = null;

}

}