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:30
1.the index finger on your right hand types the f r v 4 j u m 7 h y 6 n lo.9 j u 7 m g t 5 b 2.if you need to multiply 400, 2, and 1 Ā½, what would you type on the numeric keypad? 400*2*1.5 400/2*1.5 400/2/1.5 400*2*1Ā½ 3.select all examples of proper keyboarding technique. rest your fingers gently on the home row or home keys. slouch in your chair. rest your palms on the keyboard. relax your fingers. keep your hands lower than your elbows.
Answers: 1
question
Computers and Technology, 22.06.2019 17:40
Write a modular program (no classes yet, just from what you learned last year), that allows two players to play a game of tic-tac-toe. use a two-dimensional char array with 3 rows and 3 columns as the game board. each element of the array should be initialized with an asterisk (*). the program should display the initial board configuration and then start a loop that does the following: allow player 1 to select a location on the board for an x by entering a row and column number. then redisplay the board with an x replacing the * in the chosen location. if there is no winner yet and the board is not yet full, allow player 2 to select a location on the board for an o by entering a row and column number. then redisplay the board with an o replacing the * in the chosen location. the loop should continue until a player has won or a tie has occurred, then display a message indicating who won, or reporting that a tie occurred. player 1 wins when there are three xs in a row, a column, or a diagonal on the game board. player 2 wins when there are three ox in a row, a column, or a diagonal on the game board. a tie occurs when all of the locations on the board are full, but there is no winner. input validation: only allow legal moves to be entered. the row must be 1, 2, or 3. the column must be 1, 2 3. the (row, column) position entered must currently be empty (i.e., still have an asterisk in it).
Answers: 1
question
Computers and Technology, 23.06.2019 13:30
Select the correct answer from each drop-down menu. which types of computer networks are bigger as well as smaller than a man? a man is a network of computers that covers an area bigger than a , but smaller than a .
Answers: 1
question
Computers and Technology, 23.06.2019 18:40
Johnson enterprises uses a computer to handle its sales invoices. lately, business has been so good that it takes an extra 3 hours per night, plus every third saturday, to keep up with the volume of sales invoices. management is considering updating its computer with a faster model that would eliminate all of the overtime processing.
Answers: 2
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, 20.07.2019 21:00
question
Mathematics, 20.07.2019 21:00
Questions on the website: 13722363