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 21:40
Develop a function to create a document in the mongodb database “city” in the collection “inspections.” be sure it can handle error conditions gracefully. a. input -> argument to function will be set of key/value pairs in the data type acceptable to the mongodb driver insert api call b. return -> true if successful insert else false (require a screenshot)
Answers: 2
question
Computers and Technology, 23.06.2019 22:30
Janice usually works on a particular workbook that contains all business related data. she decides to keep a backup of all the data in a separate workbook. she opens a new workbook to transfer the data. which option should she use to copy all the data from one workbook to another workbook?
Answers: 1
question
Computers and Technology, 24.06.2019 10:30
Which of the following types of software is most applicable to the promotion of new products through advertising? a.databases b. spreadsheets c. web design programs d. word processing tools
Answers: 2
question
Computers and Technology, 24.06.2019 15:00
In excel, what happens to the cell contents when you click and drag a cell into multiple cells?
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