Linked List Big O Worksheet.docx

advertisement
Linked List Big O
Operation
Return an element at an
arbitrary index (worst case)
Set an element at an arbitrary
index (worst case)
Iterate through each element of
the list and do something (e.g.
find the largest element in the
list)
Insert an element at the
beginning
Insert an element at the end
(assume the linked list does not
keep a pointer to its last
element)
Insert an element at the end
(assume the linked list does keep
a pointer to its last element)
Remove an element at the
beginning
Remove an element at the end
(assume the linked list does keep
a pointer to its last element)
Remove an element at the end
(assume the linked list does not
keep a pointer to its last
element)
Insert k elements in an arbitrary
place (worst case). Express your
answer in terms of n and k
Hand signals
1.
2.
3.
4.
5.
6.
O(1)
O(log n)
O(n)
O(n2)
O(nk)
O(n + k)
LinkedList
ArrayList
Download