Question: Given the size method of Exercise E16.6 and the get method of Exercise P16.1, what is the big-Oh efficiency of this loop: Data
Given the size method of Exercise • E16.6 and the get method of Exercise • P16.1, what is the big-Oh efficiency of this loop:
![]()
Data from exercise E16.6
Add an instance variable currentSize to our implementation of the LinkedList class.
Modify the add, addLast, and remove methods of both the linked list and the list iterator to update the currentSize variable so that it always contains the correct size. Change the size method of Exercise • E16.4 so that it simply returns the value of currentSize.
Data from exercise P16.1
Add methods Object get(int n) and void set(int n, Object newElement) to the LinkedList class. Use a helper method that starts at first and follows n links:
![]()
for (int i = 0; i < myList.size(); i++) { System.out.println(myList.get(i)); }
Step by Step Solution
3.46 Rating (156 Votes )
There are 3 Steps involved in it
To determine the bigOh efficiency of the loop in the provided snippet we need to analyze both the nu... View full answer
Get step-by-step solutions from verified subject matter experts
