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: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:00
You need a reliable network for about twenty-five computers that will be distributed across a large building. it is important that the network be relatively cheap. which topology should you use?
Answers: 1
question
Computers and Technology, 23.06.2019 05:00
Acompany is inviting design for its new corporate logo from its users. this is an example of ? a. crowdfunding b. crowdvoting c. crowdsourced design d. crowdtracking
Answers: 3
question
Computers and Technology, 23.06.2019 21:00
Which set of steps will organize the data to only show foods with more than 100 calories and rank their sugar content from greatest to least?
Answers: 1
question
Computers and Technology, 24.06.2019 00:00
Afashion designer wants to increase awareness about her brand. which network can she use and why she can use the blank to blank her products online. answers for the first blank: internet, extranet, or intranet answers for the second blank: market, design, and export
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
Biology, 01.09.2020 23:01
Questions on the website: 13722361