Sample Exam
Sample Exam
..................................................................
8. There may exist only one spanning tree for
a graph?
a) True
b) False
.................................................................
Test form no. 1 - Page 1/6
9. After 4 steps of the Selection Sort
algorithm in ascendant order, an array becomes
[21, 22, 23, 24, 30, 27, 29, 26, 28]. Rewrite the
values of this array after 3 next step(s).
.................................................................
10. Given two elements a and b in a linked list,
write the expression to check if a is the previous
element of b
.................................................................
11. Given a stack with the elements added in
the following order: <2, 7, 8, 3, 4, 7>. Rewrite ..................................................................
the elements of this stack after doing Pop 2
times, then Push 5 and 9 respectively. 17. What is the asymptotic complexity of
finding the next element (assumed existing) of
................................................................. a given element in a singly-linked list?
a) O(i^2)
12. Linked lists are more efficient than arrays
in accessing a random element? b) O(n)
a) True c) O(1)
b) False d) O(i)
13. What is the depth of the following tree? e) O(n+i)
f) O(n^2)
18. The linear complexity for a problem with
size of n is
a) O(1)
b) O(n^2)
c) O(n)
19. What is needed to traverse a graph using
the iterative DFS method?
a) A stack
.................................................................
b) A queue
14. The constant complexity for a problem
with size of n is c) A linked list
a) O(n^2) 20. Which one(s) of the following sequences
b) O(n) is/are possibly visited when traversing this
graph starting from D using BFS method?
c) O(1)
15. Write the expression to check if a given
element e is not the 2nd last element
.................................................................
16. Given a tree as in the figure. Which node is
visited right before node k when traversing the
tree with DFS method in LRV order?
..................................................................
30. Which one(s) of the following operations
are of a stack?
a) Enqueue
b) Push
.................................................................
c) Dequeue
24. At most, how many iterations are needed to d) Pop
find a value in an array of 200 elements using
the Binary Search algorithm? 31. Nút lá của cây là nút
a) Has the most number of children
................................................................. b) Does not have any child
25. What is the asymptotic complexity of c) Has the most number of parents
finding the previous element (assumed
existing) of a given element in a singly-linked d) Does not have parent
list? 32. Which complexity(-ies) does an algorithm
a) O(n) with 13n^2 + 14n operations satisfy?
b) O(n^2) a) O(2n^2)
c) O(n+i) b) O(n^2 + n)
d) O(i^2) c) O(n)
e) O(i) d) O(n^2)
f) O(1) e) O(2^n)
................................................................. ..................................................................
38. For a given array of values, there are many 45. List all the nodes that are reacheable from
Binary Search Trees that can be established? B
a) True
b) False
.................................................................
46. List the first 5 visited nodes in order when
traversing this graph starting from C using
Dijkstra algorithm
..................................................................