Take Test Exam 2-SR28 x tps//learn.vccs.edu/webapps/ bookmarks here on the bookm
ID: 3723780 • Letter: T
Question
Take Test Exam 2-SR28 x tps//learn.vccs.edu/webapps/ bookmarks here on the bookmarks bar. Import bookmarks now... launch,jsp?course assessment id- 3483718.18icourse id- 1093406 1&icontent; id-_11 Question Completion Status: QUESTIONT 3 poi When implementing a customArraylist class by implementing the List interface. we store the values of the customArraylist in an array instance variable. When the array instance variable is full, we replace the array with a larger one. We can use either the Incremental strategy or the Doubling strategy. Which strategy should we choose? (i.e. which strategy is more algorithmically efficient) O Incremental strategy Doubling strategy QUESTION 2 S points in the List interface, what is the worst case efficiency of the get method? QUESTION 3 5 points in the List interface. What is the worst case efficiency of the remove method? QUESTION 4 5 points Which of the following operations operations are avalable: no add tional additional temporary queue) has the least running time in a Queue (assume that only Queue interface l instance variables are used: some operations may require use of an Deleting the element at the rear of the queue. O Swapping the front two elements of the queue O checking if an element x is present in the queue. Finding the number of elements in the queue. all of the above have identical worst case running time Click Sove and Submit to sove and submit. Click Sove All Answers to sove allExplanation / Answer
1. If we double the size of the array when we need more space then after copying n elements to an array of size 2n, the next n pushes to the array will become cheaper and will take O(n) time whereas in Incremental strategy, if we increase the size of array by p elements and have an array of size 100p then you can make the 100p operations fast, but after doing these p operations at a cheaper cost we will need to increase the size for 101p which will take O(n*n) time. Hence Doubling strategy is better.
2. The worst case efficiency of the get method is O(n), in case of linked list, since search is faster in case of arraylist compared to a linked list.
3. The worst case efficiency of the remove method is O(n) while removing the first element.
4. Swapping the first two elements will take the least time since it will not need to visit each element in the queue, perform dequeue and again perform enqueue when the condition has met.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.