Need BigO efficiencies for the following items depending on the list. Operation
ID: 3548622 • Letter: N
Question
Need BigO efficiencies for the following items depending on the list.
Operation
ArrayList
LinkedList
Construct Iterator at index
O(1)
Iterator.add
O(1)
Iterator.remove
O(n)
Add element at head
O(1)
Add element at tail
O(1)
Get at index
O(n)
Remove head element
O(n)
Remove tail element
O(1)
Search
Operation
ArrayList
LinkedList
Construct Iterator at index
O(1)
Iterator.add
O(1)
Iterator.remove
O(n)
Add element at head
O(1)
Add element at tail
O(1)
Get at index
O(n)
Remove head element
O(n)
Remove tail element
O(1)
Search
Explanation / Answer
Operation
ArrayList
LinkedList
Construct Iterator at index
O(1)
Iterator.add
O(1)
Iterator.remove
O(n)
Add element at head
O(1)
Add element at tail
O(1)
Get at index
O(n)
Remove head element
O(n)
Remove tail element
O(1)
Search
As far as I know Construct iterator at index means the time taken for it create(allocate memory) the linked list and if it is so the answer is O(n).
If construct iterator at index doesn't mean it please let me know.... I'll modify the Big-O efficiency accordingly.
Operation
ArrayList
LinkedList
Construct Iterator at index
O(1)
O(n)Iterator.add
O(n)O(1)
Iterator.remove
O(n)
O(1)Add element at head
O(n)O(1)
Add element at tail
O(1)
O(1)Get at index
O(n)O(n)
Remove head element
O(n)
O(1)Remove tail element
O(1)O(1)
Search
O(n) O(n)Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.