You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it has an order
ex) To Do list, ceremony order, ...
List vs. Set
common: a collection of things (Data collection structure)
difference
List: Order O, Duplicate O
Set: Order X, Duplicate X
List work
data +: insert / add
data -: delete / remove
data lookup: read / get
is_empty?
count?
where? front / rear / between
insert_head, insert_tail, delete_head, delete_tail, insert(i, x), delete(i, x)
List implementation using Array
A variable is simply a pointer to a position
Array
advantage: Index allows you to view any location immediately (using byte size)
disadvantage: Difficult to dynamically scale
# ex) list: a b c d e f g none none# cnt = 7# list.get(Third) => return list[2] (index: 2) => c# Time Complexity: O(1)# insert_tail('z') => list[7] = 'z', cnt = 8# Time Complexity: O(1)# insert_head('h') => list[0] = 'h',cnt = 9# The remaining elements should be moved to the right one space (right-shifted by one)# Time Complexity: O(n), if we put n elements => O(n^2)# delete_tail => cnt = 8# Time Complexity: O(1)# delete_head => cnt = 7# The remaining elements should be moved to the left one space (left-shifted by one)# Time Complexity: O(n)# tail - good, get - good# head - bad