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 11:30
To hide gridline when you display or print a worksheet
Answers: 1
question
Computers and Technology, 22.06.2019 15:00
Which of the following has not been attributed at least in part to social media a. drug addiction b. depression c. kidnapping d. murder
Answers: 2
question
Computers and Technology, 23.06.2019 04:10
2pointswho was mikhail gorbachev? oa. a russian leader who opposed a coupob. a polish leader who founded the labor union "solidarityoc. a soviet leader who called for a closer relationship with the unitedstates, economic reform, and a more open societyd. a soviet leader who called for more oppression in the soviet union
Answers: 3
question
Computers and Technology, 24.06.2019 10:00
Each time you save a document, you will need to type in the file type in which it should be saved you can select the save button to save it with the same file name if it has been previously saved you will need to select the location to save the file you will need to use the save as dialog box
Answers: 1
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, 26.02.2021 06:30
question
Mathematics, 26.02.2021 06:30
question
Mathematics, 26.02.2021 06:30
question
Mathematics, 26.02.2021 06:30
question
Health, 26.02.2021 06:30
Questions on the website: 13722367