For each of the methods associated with each data structure, classify it based on its worst-case runtime, using Big O notation.
-
What is the runtime complexity of
add_to_tail? constanta. What if our list implementation didn't have a reference to the tail of the list in its constructor? What would be the runtime of the
add_to_tailmethod? linear -
What is the runtime complexity of
remove_head? constant -
What is the runtime complexity of
contains? linear -
What is the runtime complexity of
get_max? linear
-
What is the runtime complexity of
enqueue? constant -
What is the runtime complexity of
dequeue? constant -
What is the runtime complexity of
len? constant
-
What is the runtime complexity of
insert? Avg: O(log n) Worst: O(n) -
What is the runtime complexity of
contains? O(log n) -
What is the runtime complexity of
get_max? O(log n)
-
What is the runtime complexity of
_bubble_up? -
What is the runtime complexity of
_sift_down? -
What is the runtime complexity of
insert? -
What is the runtime complexity of
delete? -
What is the runtime complexity of
get_max?
-
What is the runtime complexity of
ListNode.insert_after? -
What is the runtime complexity of
ListNode.insert_before? -
What is the runtime complexity of
ListNode.delete? -
What is the runtime complexity of
DoublyLinkedList.add_to_head? -
What is the runtime complexity of
DoublyLinkedList.remove_from_head? -
What is the runtime complexity of
DoublyLinkedList.add_to_tail? -
What is the runtime complexity of
DoublyLinkedList.remove_from_tail? -
What is the runtime complexity of
DoublyLinkedList.move_to_front? -
What is the runtime complexity of
DoublyLinkedList.move_to_end? -
What is the runtime complexity of
DoublyLinkedList.delete?a. Compare the runtime of the doubly linked list's
deletemethod with the worst-case runtime of the JSArray.splicemethod. Which method generally performs better?