subject

Consider the following method, which takes two unsorted lists, list1 and list2 – both instances of our LLList class from lecture – and creates a third list containing the intersection of list1 and list2:The lists are unsorted, so we take a nested-loop approach in which each item in list1 is compared to the items in list2; if a match is found in list2, the item is added to the intersection and we break out of the inner loop. (Note that this method will include duplicate values in the intersection when list1 itself has duplicates; doing so is acceptable for the purposes of this problem.)What is the worst-case running time of this algorithm as a function of the length m of list1 and the length n of list2? Don’t forget to take into account the time efficiency of the underlying list operations, getItem() and addItem(). Use big-O notation, and explain your answer briefly. Rewrite this method to improve its time efficiency. Your new method should notmodify the existing lists in any way, and it should use no more than a constant (O(1)) amount of additional memory. Make the new method as efficient time-wise as possible, given the constraints on memory usage. You should assume this method is not part of the LLList class, and therefore it doesn’t have direct access to the private LLListmembers. What is the worst-case running time of the improved algorithm? Use big-O notation, and explain your answer briefly.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 02:00
Which of the following is a way the operating system prevents unknown or unauthorized users from accessing the system?
Answers: 2
question
Computers and Technology, 22.06.2019 07:30
Events and conditions that happen within an organization that are somewhat easier to deal with when responding to change are called
Answers: 1
question
Computers and Technology, 23.06.2019 07:00
1. you have a small business that is divided into 3 departments: accounting, sales, and administration. these departments have the following number of devices (computers, printers, etc.): accounting-31, sales-28, and administration-13. using a class c private network, subnet the network so that each department will have their own subnet. you must show/explain how you arrived at your conclusion and also show the following: all available device addresses for each department, the broadcast address for each department, and the network address for each department. also, determine how many "wasted" (not usable) addresses resulted from your subnetting (enumerate them).
Answers: 3
question
Computers and Technology, 23.06.2019 10:30
Would a ps4 wired controller work on an xbox one
Answers: 1
You know the right answer?
Consider the following method, which takes two unsorted lists, list1 and list2 – both instances of o...
Questions
question
Mathematics, 17.02.2021 21:50
question
Mathematics, 17.02.2021 21:50
question
Mathematics, 17.02.2021 21:50
question
History, 17.02.2021 21:50
question
Mathematics, 17.02.2021 21:50
question
Mathematics, 17.02.2021 21:50