Midterm exam 2 review Sp2005: What's My Data Structure?
Back to Midterm Exam 2 Review Sp2005
Questions, comments, answers, etc.
a. array: [_][_][_][_]
b. linked list: [_] -> [_] -> [_] -> [_]
c. matrices?: ?
d. graphs?: ?
e. circular: ?
f. tree:
[_]
V V
[_] [_]
V V V
[_] [_] [_]
not sure how b-e look :-\
for circular, the last entry points to the first (hard to draw with text)
A graph can have nodes that point to more than one other node, kind of like the strings of a net.
A matrix is just like in math...or rather, it's got two indices...rows and columns
1 2 3
1 [][][]
2 [][][]
3 [][][]
A. "Right, so it takes a while to insert or delete in my middle, but you can't possibly get to a specific piece of me faster!"
array
B. "Insert and delete into the middle are really fast with me, but I don't DO complexity – no hierarchy for me!"
linked list
C. "I'm like my sister that you met early, but she's so one-dimensional, while twice as sophisticated, er, complex!"
matrix
D. "Got a bunch of streets and highways you're modeling? I'm your data structure!"
graph
E. "You can insert and delete in me, but don't try to find all of me. I'm well-rounded."
circular
F. "Organization chart? Sentence diagrams? Verses and chorus in a song? Structure of a scene? I'm your structure!"
tree
Link to this Page