Professional Documents
Culture Documents
Advance Data Structure
Advance Data Structure
Test 2
Name:_____________________________
Integer
maxNum
new
15
Test 2
Name:_____________________________
6) In Java, every class is ultimately derived from the class _____ through
inheritance.
a. String
b. Object
c. Math
d. Exception
7) The last
a.
b.
c.
d.
To delete a node N from a linear linked list, you will need to ______.
a. set the reference next in the node that precedes N to reference
the node that follows N
b. set the reference next in the node that precedes N to reference
N
c. set the reference next in the node that follows N to reference the
node that precedes N
2 of 15
Test 2
Name:_____________________________
d. set the reference next in N to reference the node that follows N
12) Which of the following statements deletes the node that curr
references?
a. prev.setNext(curr);
b. curr.setNext(prev);
c. curr.setNext(curr.getNext());
d. prev.setNext(curr.getNext());
13) Which of the following statements deletes the first node of a linear
linked list that has 10 nodes?
a. head.setNext(curr.getNext());
b. prev.setNext(curr.getNext());
c. head = head.getNext();
d. head = null;
14)
16)
Test 2
Name:_____________________________
17)
18)
Which of the following is NOT true about all circular linked lists?
a. every node references a successor
b. the last node references the first node
c. the precede reference of each node references the node that
precedes it
d. no node contains null in its next reference
19)
20)
21) A _______ can be used to facilitate adding nodes to the end of a linear
linked list.
a. head record
b. dummy head node
c. tail reference
d. precede reference
Short Answer Questions:
22) What is the difference between a linked list and an array in terms of
their capacity to store data?
4 of 15
Test 2
Name:_____________________________
23)
24)
25)
26)
27) Write the code segment which is used to insert a new node, referenced
by the reference variable newNode, between the nodes referenced by the
reference variables prev and curr in a linear linked list.
28) Write the code segment that is used to insert a new node, referenced
by the reference variable newNode, at the beginning of a linear linked list.
30)
Test 2
Name:_____________________________
the list itself maintains a reference to a head node. What is wrong with
this loop header?
for (Node curr = head; curr != head.prev; curr = curr.next)
Recursion
Backtracking
Iteration
Inductio
33)
34)
35)
36)
Test 2
Name:_____________________________
37)
38)
What
a.
b.
c.
d.
39)
40)
41)
What
a.
b.
c.
d.
42)
What
a.
b.
c.
d.
7 of 15
Test 2
Name:_____________________________
43) Which of the following is the prefix form of the infix expression: (8 +
6) / (16 4)?
a. + 8 6 / 16 4
b. / 8 6 + 16 4
c. / + 8 6 16 4
d. / + 8 6 16 4
44) Which of the following is the postfix form of the infix expression: a * b
(c + d)?
a. a b c d + *
b. a b * c d +
c. a b c * d +
d. a b c d + *
45) Which of the following is the postfix form of the prefix expression: * +
a b c?
a. a + b * c
b. a + b c *
c. a b + c *
d. a b * c +
Chapter 7: Stacks
Multiple Choice Questions:
46) What is the corrected input if the following line is typed on a keyboard:
ywwdshrwde
(where represents the backspace character)?
a.
b.
c.
d.
ywdswe
ywwdwde
ywdshwe
ywdswd
Test 2
Name:_____________________________
a.
b.
c.
d.
6
2
5
4
48) The item that is removed first from a stack is called the ______ of the
stack.
a. front
b. top
c. base
d. prime
49) If the array:
6, 21, 35, 3, 6, 2, 13
is added to a stack, in the order given, which of the following is the top of
the stack?
a.
b.
c.
d.
e.
2
6
3
13
35
50) The ______ method of the ADT stack adds an item to the top of the
stack.
a. createStack
b. push
c. pop
d. peek
51) The ______ method of the ADT stack retrieves and then removes the
top of the stack.
a. createStack
b. push
c. pop
d. peek
52) The ______ method of the ADT stack retrieves the top of the stack, but
does not change the stack.
a. createStack
b. push
c. pop
9 of 15
Test 2
Name:_____________________________
d. peek
53)
54)
55)
56)
Test 2
Name:_____________________________
c. $
d. XYZ$ZXY
58)
59) Which of the following is the postfix form of the infix expression: (a +
b) * c / d
a. a b + c * d /
b. a b * c / d +
c. a + b * c / d
d. a b + c d * /
60)
What
a.
b.
c.
d.
What is the difference between the stack pop and peek operations?
62)
Suppose we begin with an empty stack, and perform the
following operations: push 7, push 2, push 9, push 6, pop, pop, peek,
push 1, push 3, peek, push 8, pop, peek, pop, pop, push 5, push 4, pop,
pop, pop, push 8. What is contained on the stack when we are done?
Write out the contents from top to bottom.
Chapter 8: Queues
Multiple Choice Questions:
63)
Test 2
Name:_____________________________
a)
b)
c)
d)
list
stack
queue
tree
64)
65)
66)
67)
The ______
a)
b)
c)
d)
68)
The ______
a)
b)
c)
d)
69)
The ______ operation retrieves the item that was added earliest to a queue,
but does not remove that item.
a) enqueue
b) dequeue
c) dequeueAll
d) peek
12 of 15
Test 2
Name:_____________________________
Which of the following operations leaves a queue unchanged?
a) enqueue
b) dequeue
c) dequeueAll
d) peek
71)
72)
73)
74)
In an implementation of a queue uses the ADT list, which of the following can
be used to implement the operation enqueue(newItem)?
a) list.add(list.size(), newItem)
b) list.add(list.size()+1, newItem)
c) list.add(newItem.size(), newItem)
d) list.add(newItem.size()+1, newItem)
75)
The ADT ______ allows you to insert into, delete from, and inspect the item at
any position of the ADT.
a) stack
b) queue
c) list
d) array
13 of 15
Test 2
Name:_____________________________
Which of the following is an operation of the ADT stack?
a) enqueue
b) push
c) add
d) get
.
77)
The pop operation of the ADT stack is similar to the ______ operation of the
ADT queue.
a) isEmpty
b) enqueue
c) dequeue
d) peek
78)
The enqueue operation of the ADT queue is similar to the ______ operation of
the ADT stack.
a) isEmpty
b) peek
c) push
d) pop
79)
In the ADT
a)
b)
c)
d)
80)
81)
The line of
a)
b)
c)
d)
drift in an array-based
14 of 15
Test 2
Name:_____________________________
83)
If an object is inserted into a queue, how soon can it be
removed?
15 of 15