Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. In the AList implementation, when an array-based list is empty Select one or

ID: 3801268 • Letter: 1

Question

1. In the AList implementation, when an array-based list is empty
Select one or more:
A. the numberOfEntries field contains 0
B. the array is set to null
C. the array is re-sized to have no elements (meaning list.length = 0)

2. In the LinkedBag implementation, when a bag implemented with linked nodes is empty

Select one or more:
A. the numberOfEntries field contains 0
B. firstNode is set to null
C. firstNode.data is set to null

3. Which of the following are advantages of using linked nodes to implement bags and lists?
Select one or more:
A. linked chains require shifting under certain conditions
B. linked lists only use as much memory as needed
C. linked nodes allow direct access to any element
D. adding an element to the front of a chain is easy

4. What is the order of growth of T( n ) = 3n2 + 4n3 +3 n

5. Which property of recursion does the following method violate?
public int callIt (Node r) {
if (r != null)
return r.next;
else
return r;
}
Select one:
A. The method does not call itself
B. There is no base case (escape clause)
C. The base case exists but might never be executed
D. None of the above

6. Which property of recursion does the following method violate?
public Node callIt(Node r) {
if (r != null)
return callIt(r.next);
else
return r;
}
Select one:
A. The method does not call itself
B. There is no base case (escape clause)
C. The base case exists but will never be executed
D. The method shouldn't return a value
F. None of the above

Explanation / Answer

1. AList implementation, when an array-based list is empty

A. the numberOfEntries field contains 0

2. LinkedBag implementation, when a bag implemented with linked nodes is empty

  B. firstNode is set to null