Data Structures, Search and Sort Algorithms: Kar-Hai Chu Karhai@hawaii - Edu
Data Structures, Search and Sort Algorithms: Kar-Hai Chu Karhai@hawaii - Edu
Algorithms
Kar-Hai Chu
[email protected]
Data structures
Storage
Insertion,
deletion
Searching
Sorting
Big O
Stacks
LIFO
Push,
pop
O(1) operations
lists:
Resizable
Insertion/deletion
Arrays:
Faster index
O(1) lookup
Preset size
Hash tables
Keys
and values
O(1) lookup
Hash function
Good v fast
Clustering
Databases
space
Great with small number of elements
(becomes relevant later)
Algorithm:
Move element from unsorted to sorted list
every item
a sorted list
n)
Divide and conquer
Trees
Almost
Binary trees
0,
Balanced binary
trees
Minimizes
Heaps (binary)
Complete:
Heapsort
O(nlogn)
Algorithm:
Build a heap
deleteMax (or Min) repeatedly
O(1)
overhead
Why bother?
Tries
(say trees)
Long strings..
Complex algorithms
Chess!
Minimax:
B: B1
B: B2
B: B3
A: A1
+3
-2
+2
A: A2
-1
+4
A: A3
-4
-3
+1
Useful
http://www.cs.pitt.edu/~kirk/cs1501/anim
ations/Sort3.html