# csis

## 20. What is the Big-O time complexity for an algorithm to display the nth integer in an array of integers? a. O(n) b. O(n2) c. O(log n) d. O(1)

EXPERT ANSWER What is the Big-O time complexity for an algorithm to display the nth integer in an array of integers? O(n) O(n2) O(log n) O(1)

## 18. When adding an entry to an array-based implementation of the ADT List at the end of the list a. no shift is necessary b. all of the previous elements must be shifted toward the front of the array c. only one element is shifted toward the end of the array to make room d. only one element is shifted toward the beginning of the array to make room 19. When inserting a node between two adjacent nodes in a chain you must locate a. the first node and the node before the insertion position b. the first node and the node after the insertion position c. the last node and the node after the insertion position d. the node before the insertion position and the node after the insertion position

EXPERT ANSWER When adding an entry to an array-based implementation of the ADT List at the end of the list no shift is necessary all of the previous elements must be shifted toward the front of the array only one element is shifted toward the end of the array to make room only one element …

## In an array-based implementation of the ADT List, what is the performance of adding an entry at the end of the list when the array is resized? a. O(n2) b. O(log n) c. O(n) d. O(1)

EXPERT ANSWER In an array-based implementation of the ADT List, what is the performance of adding an entry at the end of the list when the array is resized? O(n2) O(log n) O(n) O(1)

## Assume array size is 50 in a circular array implementation of a Queue; Assume frontIndex is 49 and backIndex is 46; After dequeueing three, ie removing 3 elements, what will the values of backIndex and FrotnIndex be: a. FrontIndex: 49 BackIndex: 46 b. FrontIndex: 47 BackIndex: 46 c. FrontIndex: 49 BackIndex: 44 d. FrontIndex: 2 BackIndex: 46 Answer: 16. In an array-based implementation of a Queue, if waitingList is the name of the array, and the index to the last entry in the queue is called backIndex, which assignment statement updates backIndex to add an entry to the queue: a. backIndex = (backIndex + 2) % waitingList.length; b. backIndex = (backIndex + 1) % waitingList.length; c. backIndex = (backIndex – 1) % waitingList.length; d. backIndex = (backIndex – 2) % waitingList.length;

EXPERT ANSWER Assume array size is 50 in a circular array implementation of a Queue; Assume frontIndex is 49 and backIndex is 46; After dequeueing three, ie removing 3 elements, what will the values of backIndex and FrotnIndex be: a. FrontIndex: 49 BackIndex: 46 b. FrontIndex: 47 BackIndex: 46 c. FrontIndex: 49 BackIndex: 44 d. …

## 10. What is the entry returned by the peek method after the following stack operations. push(A), push(R), pop(), push(D), pop(), push(L), pop(), push(J), push(S), pop(), pop() a. A b. S c. L d. D Answer: 11. In an efficient array-based chain implementation of a Stack ADT, the entry peek returns may be found at a. the last location in the array b. the first location in the array c. the last occupied location in the array d. none of the above

EXPERT ANSWER What is the entry returned by the peek method after the following stack operations. push(A), push(R), pop(), push(D), pop(), push(L), pop(), push(J), push(S), pop(), pop() A S L D In an efficient array-based chain implementation of a Stack ADT, the entry peek returns may be found at the last location in the array …

## Activation records in recursion are stored in which data structure? a. Queue b. List c. Stack d. Tree Answer: 9. In a linked-chain implementation of a Stack ADT, the performance of pushing an entry onto the stack is a. O(2) b. O(n) c. O(n2) d. O(1)

EXPERT ANSWER Activation records in recursion are stored in which data structure? Queue List Stack Tree In a linked-chain implementation of a Stack ADT, the performance of pushing an entry onto the stack is O(2) O(n) O(n2) O(1)

## What is the output of the following recursive program when the method is called with 4? public void unknown(int n) { System.out.print(“?”); if (n > 0) unknown(n-1); } a. ????? b. ???? c. ??? d. none of the above

EXPERT ANSWER What is the output of the following recursive program when the method is called with 4? public void unknown(int n) { System.out.print(“?”); if (n > 0) unknown(n-1); } ????? ???? ??? none of the above

## What is the value returned from the following recursive method when it is called with the value 9? public int mystery (int n) { if (n < 1) return 0; else if (n % 2 == 0) return mystery(n-1); else return 1 + mystery(n-1); } a. 6 b. 5 c. 4 d. 0

EXPERT ANSWER What is the value returned from the following recursive method when it is called with the value 9? public int mystery (int n) { if (n < 1) return 0; else if (n % 2 == 0) return mystery(n-1); else return 1 + mystery(n-1); } 6 5 4 0