subject

Suppose that you want to add an LLList constructor that takes a reference to an ArrayList as its only parameter and constructs an LLList object that represents the same list as the ArrayList - i. e., that has the same items in the same positions in the list. You have two versions to choose from, both of which are shown below. Algorithm A: lic LLList (ArrayList aList) { // initialize an empty list head = new Node (null, null); length = 0; // dummy hea // add the items from aList to this list for (int i = alist. length() - 1; i >= 0; i--) Object item = aList. getItem(i); addItem(item, 0);
Algorithm B: public LLList (ArrayList aList) { // initialize an empty list head = new Node (null, null); length = 0; // dummy // add the items from aList to this lis for (int i = 0; i < aList. length(); i++) Object item = aList. getItem(i); addItem (item, i);
1. (4 points) What is the big-O time efficiency of algorithm A in terms of the length n of the list? Explain your answer briefly.
2. (4 points) What is the big-o time efficiency of algorithm B in terms of the length n of the list? Explain your answer briefly.
3. (2 points) is one of the algorithms more efficient than the other? Explain briefly.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 08:40
What are the three parts to physical security standards for various types of army equipment and the risk level
Answers: 2
question
Computers and Technology, 22.06.2019 10:30
Dave has to create animations for a game. which tool can dave use?
Answers: 3
question
Computers and Technology, 22.06.2019 22:00
Discuss the ways in which electronic information associated with payments is addressed in terms of security. include encryption, secure sockets layers, and secure electronic transactions in your discussion. are there any other ways that consumers and businesses can keep their payment information secure in an electronic commerce environment? do you feel that your information is safe when conducting electronic business? why or why not?
Answers: 1
question
Computers and Technology, 23.06.2019 09:20
How to print: number is equal to: 1 and it is odd number number is equal to: 2 and it is even number number is equal to: 3 and it is odd number number is equal to: 4 and it is even number in the console using java using 1 if statement, 1 while loop, 1 else loop also using % to check odds and evens
Answers: 3
You know the right answer?
Suppose that you want to add an LLList constructor that takes a reference to an ArrayList as its onl...
Questions
question
Mathematics, 31.07.2019 01:30
Questions on the website: 13722363