Reminders: Exam II is next Tuesday.

advertisement
Reminders:
Exam II is next Tuesday.
There are review questions and a key for them on the course website (schedule
page under Apr. 27) and on the Blackboard site.
The TAs will have a review session in the labs.
If you have any questions about the course material before Exam II, please email
us.
There is no Final Exam. (If you look on the Class Policies page, you'll see that the
final exam period is used for a makeup exam for those who had prior permission to
miss one of the other exams; you know who are!)
Turn in robot kits!!
Linked Lists:
Linked lists are an example of a useful data structure in computer science. Although
they are useful, they are just an example.
A data structure is some way of arranging data to make processing the data
convenient or efficient. So whether something is a good data structure depends on
what you intend to do with the data.
"Pick the right data structure, and the algorithm will design itself."
In other words, if you are careful and intelligent in picking or designing the right
data structure, then it will be straight-forward to design a clear and efficient
algorithm, for whatever it is you intend to do.
There are several ways to be creative in programming:
(1) designing new data structures,
(2) designing new algorithms,
(3) or both together.
Consider the linked list:
It's based on the idea that it's very efficient to follow a pointer.
Therefore, if each item (node) in a list is linked to the next, then it's easy and
efficient to go from each item to the next.
Furthermore, it's easy and efficient to insert/delete items into a list, because we
just have to change the pointers at the insertion/deletion point.
The pointers, not the physical position in the computer's memory, establish the
logical relationships among the items.
Compare vectors and linked lists:
They are both sequences of values or objects.
Vectors:
* efficient random access because I can compute the address of any item in a
constant amount of time.
* inefficient insertion/deletion because I may have a move a lot of the vector's
elements.
Linked lists:
* inefficient random access; they are are sequential data structures and I have to
count my way down to any element I want.
* efficient insertion/deletion, because I just need to change a couple pointers.
Which do you use? It depends on what you are trying to do, and how frequent you
think the different operations will be.
Recursive (linked) list processing is one of the most powerful programming
techniques there is. In fact you can do anything that can be done in any
programming language on any digital computer with recursive list processing (but
not necessarily efficiently).
Some programming languages are based on this idea, for example LISP (LISt
Processing). This (old) language is still widely used in AI.
Download