Mark Floryan (mrf8t@virginia.edu)
Aaron Bloomfield (aaron@virginia.edu)
@github | ↑ |
Data Representation | Program Representation | |||||
string int x[3] char x 0x9cd0f0ad 01101011 |
![]() |
Objects Arrays Primitive types Addresses bits |
Java code C++ code C code x86 code IBCM hexadecimal |
![]() |
High-level language Low-level language Assembly language Machine code |
ADTs Covered So Far
Hash Tables
Separate Chaining
Open Addressing
Miscellaneous
Array (vector) | Linked List | |
---|---|---|
find | Θ(n) | Θ(n) |
insert | Θ(n) worst case, but often Θ(1) |
Θ(1) |
remove | Θ(n) | Θ(n) |
findKth | Θ(1) | Θ(n) |
Array (vector) | Linked List | |
---|---|---|
push | Θ(n) worst case, but often Θ(1) |
Θ(1) |
pop | Θ(1) | Θ(1) |
top | Θ(1) | Θ(1) |
Array (vector) | Linked List | |
---|---|---|
enqueue | Θ(n) worst case, but often Θ(1) |
Θ(1) |
dequeue | Θ(1) | Θ(1) |
BST | AVL | Red-black | Splay | |
---|---|---|---|---|
find | Θ(h), where log n < *h* ≤ *n*-1; worst case is Θ(n) |
Θ(log n) | Θ(log n) | Θ(log n) amortized |
insert | Θ(h), where log n < *h* ≤ *n*-1; worst case is Θ(n) |
Θ(log n) | Θ(log n) | Θ(log n) amortized |
remove | Θ(h), where log n < *h* ≤ *n*-1; worst case is Θ(n) |
Θ(log n) | Θ(log n) | Θ(log n) amortized |
|
|
|
"Hello" ['H','i',\0] 3.14 'x' 0x42381a 01001010 |
![]() |
Objects Arrays Primitive types Addresses bits |
hash(key) | key |
---|---|
000000 | "red" |
000001 | "orange" |
000010 | "blue" |
000011 | null |
000100 | "green" |
000101 | ... |
This can work, unless the key space is sparse, or we don't know the keys ahead of time. But it's slow to look up a value in a table!
|
|
|
|
firstletter
(key)Location | Key | Value |
---|---|---|
0 | "Alice" | "red" |
1 | "Bob" | "orange" |
2 | "Colleen" | "blue" |
3 | null |
null |
4 | "Eve" | "green" |
... | ... | ... |
m-1 | "Zeus" | "purple" |
|
|
|
|
|
|
|
|
|
|
float
)