Which statement is the correct declaration and initialization of an ArrayList of String values?
ArrayList<String> name;
name = new ArrayList<String>();
What best describes the stack paradigm?
FIFO
Part of a linked list that points to the first node if that list isn't empty
What method do you use to add a key-value pair into a HashMap?
put
What is the term for inserting into a full queue known as?
Which of these is a key difference between arrays and ArrayLists?
Arrays are fixed size
ArrayLists can change in size.
Which method looks at the top element??
Peak()
Four basic linked list operations:
Traverse / Delete / Insert / IsEmpty
In which of the following cases, binary search algorithm is used?
To search an element in any ordered list with large number of elements.
If the character 'V', 'I', 'V', 'A' are placed in queue (in order), and being removed one at a time, choose the order for the character after that
VIVA
What is the ArrayList nums if it is initially [5, 3, 1] and the following code is executed?
nums.add(6);
nums.add(0, 4);
nums.remove(1);
[4, 3, 1, 6]
public class StackTest{
public static void main(String[] args){ Stack<Integer> stack = new Stack<Integer>(); for(int i = 0; i < 10; i++)
stack.push(i);
stack.pop();
stack.pop();
stack.pop(); }
}
6
In a(n) __________ list, each node has a pointer to the one before it and the one after it.
doubly
Draw figure below represent the binary tree of the following values: { 25, 18, 6, 12, 30, 27, 22, 32 }
A Queue can only store 6 data items. The Queue is sent 4 data items: Bert, Cynthia, Cedric and Albert. Where does the "Front" pointer point?
Bert
What is the correct code to retrieve the first element in the nums ArrayList?
nums.get(0)
How many calls to pop() is need to determine the size of a stack? Answer in terms of n where n is the number of elements in the stack.
n(linear)
Appending vs inserting a node
Appending puts the node at the end / inserting can happen anywhere in the list
An array with 32 elements is input to a binary search algorithm. How many maximum number of comparisons are performed?
5
In linked list implementation of a queue, from where is the item deleted?
At the head of link list
What is printed after executing code on the nums ArrayList with the values [3, 2, 4, 5, 7]?
7
Which data structures can easily represent a stack?
Choose all that apply.
link list
Array
A data structure that points to an object of the same type as itself is known as a(n) __________ data structure.
Self-referential
Post order traversal :
1abc*+de*f+g*+
A queue of characters currently contained a,b,c,d. What would be the contents of queue after the following operationDELETE, ADD W, ADD X, DELETE, ADD Y.
C,D,W,X,Y