NEW
Font size
WorksheetsWorksheet Extraction
Total questions: 73
Worksheet time: 37mins
Queue is also called as
Last In First Out
First In Last Out
Last In Last Out
First In First Out
When sorting an already ordered sequence, what is the time complexity of the bubble sort algorithm
O(n)
O(n2)
O(nlogn)
All is incorrect
If we sort the sequence of numbers 47, 891, 3, 11, 27, 69, 26, 8 using the Radix sort algorithm, then after step 1 (sorting by units), what is the resulting sequence
3, 8, 11, 26, 27, 47, 69, 891
891, 11, 3, 26, 27, 47, 8, 69
891, 11, 3, 26, 47, 27, 8, 69
3, 8, 11, 26, 47, 27, 69, 891
The average-case time complexity of the Quick Sort algorithm is
O(n)
O(n2)
O(nlogn)
O(n3)
For a binary search algorithm to work, the array must be
Unsorted
Sorted
In a heap
Popped out of stack
To find an element in a matrix of size m×n , what is the time complexity of the algorithm
O(n2)
O(m2)
O(mn)
All is incorrect
The minimum number of comparisons required when searching in an ascending ordered sequence of 256 elements (using the binary search algorithm) is:
1
10
256
8
The postfix form of the expression A/X + B*C^F is:
A X + B C * F + ^
A X / B C F ^ * +
A X + B C * F ^ +
A X B + / C * F ^ +
The operation of processing each element in the list is known as ......
sorting
merging
inserting
traversal
Each node in a single linked list must contain at least .....
Three fields
Two fields
Four fields
Five fields
A doubly linked list has _____pointers with each node.
0
1
2
3
The correct order to permute a second and third note in list l has more than 3 elements [ (1) p=head; (2) head.next=q; (3) q= p.next; (4) p.next= q.next; (5) q.next=p; ]
(1), (5), (3), (4), (2)
(2), (3), (4), (5), (1)
(1), (3), (5), (4), (2)
(1), (3), (4), (5), (2)
The postfix form of the expression (M+N)∗(C∗D−E)∗F/G is
MN+ CD*E - FG /**
MN + CD* E - F **G /
MN + CD* E - *F *G /
MN + CDE * - * F *G /
What does the following function do for a given Linked List with first node as head? void fun1(Node head) { if(head == null) return; System.out.print(head.data + " " ); fun1(head.next); }
Prints all nodes of linked lists
Prints all nodes of linked list in reverse order
Prints alternate nodes of linked list
Prints alternate nodes in reverse order
What is the output of following function for start pointing to first node of following linked list? 1->2->3->4->5->6 void fun(Node start) { if(start == NULL) return; System.out.print (start.data + " "); if(start.next.next != null ) fun(start.next.next); System.out.print (start.data + " "); }
1 4 6 6 4 1
1 3 5 1 3 5
1 3 5
1 3 5 5 3 1
What algorithmic paradigm that consists of systematically enumerating all possible candidates for the solution and checking whether each candidate satisfies the problem's statement?
Divide and Conquer
Dynamic Programming
Greedy
Brute Force
The appropriate algorithm to solve the Knight Tour problem is:
Divide and Conquer
Dynamic Programming
Backtracking
Brute Force
The appropriate algorithm to solve the Merge n files into one file (trộn n file thành 1 file) problem is:
Divide and Conquer
Dynamic Programming
Greedy
Backtracking
The Merge Sort algorithm is an example for:
Divide and Conquer technique.
Dynamic Programming technique.
Backtracking technique.
Brute Force technique.
For the Travelling salesman problem, if the Brute Force technique is used and the number of the city is 30, the number of tests to find the result is:
30!
29!
302
292
In the function remove a node from the linked list, the right order for 3 statements: p= p->next =t (1); q=p (2); delete q (3); is:
(1), (2), (3)
(3), (1), (2)
(2), (3), (1)
(2), (1), (3)
The statement used in the function calculating the sum of all nodes in a linked list is:
p=NULL;
k= k+ p->data;
p->next->next!=NULL;
k= k+1;
The statement used in the function calculating the height of a binary tree is:
return 1 + max(cao(T->left), cao(T->right));
return max(cao(T->left), cao(T->right));
return 1 + cao(T->left) + cao(T->right);
All is correct.
In the Fibonacci problem, F(6) equals what?
5
8
13
1
Which one of the following is an application of Stack Data Structure?
Managing function calls
The stock span problem
Arithmetic expression evaluation
All of the above
The largest value in the Binary Search Tree is in position:
left most.
right most.
root.
None is correct.
The operation that reduces the size of the stack is:
popS();
pushS();
A and B is correct.
All is incorrect.
The operation that increases the size of the queue is:
addQ();
removeQ();
A and B is correct.
All is incorrect.
Let LCS(Xi,Yj) represent the length of longest common subsequence. The formula to calculate LCS(Xi,Yj) if X[i] <> Y[j] is:
LCS(Xi,Yj) = LCS(Xi-1,Yj-1)
LCS(Xi,Yj) = LCS(Xi-1,Yj-1) +1
LCS(Xi,Yj) = max(LCS(Xi,Yj-1), LCS(Xi-1,Yj))
LCS(Xi,Yj) = max(LCS(Xi-1,Yj-1), LCS(Xi-2,Yj-2))
Prints numbers from 0 to n-1
Prints numbers from n-1 to 0
Prints first n Fibonacci numbers
Prints first n Fibonacci numbers in reverse order
The largest value in the binary tree is in position:
Left most
Right most.
root.
None is correct.
The Karatsuba algorithm (procedure) for multiplication of two n-digit numbers requires a number of elementary operations proportional to:
O(n2)
O(n3)
O(n(log3)
O(nlogn)
Following is C like pseudo code of a function that takes a Queue as an argument, and uses a stack S to do processing. void fun(Queue *Q) { Stack S; while (!isEmpty(Q)) { // deQueue (lấy) an item from Q and push the dequeued item to S push(&S, deQueue(Q)); } while (!isEmpty(&S)) { // Pop an item from S and enqueue (thêm) the popped item to Q enQueue(Q, pop(&S)); } } What does the above function do in general?
Removes the last from Q
Keeps the Q same as it was before the call
Makes Q empty
Reverses the Q
To find the two numbers with the largest product (có tích lớn nhất) in an array of n integers, using Brute Force technique, the number of pairs to test is:
n*n
n*(n-1)
n*(n-1)/2
n*n/2
In order to get the information stored in a AVL Tree in the descending order, one should traverse it in which of the following order?
left, root, right.
root, left, right.
right, root, left.
None is correct.
The time required to insert a node x into a doubly linked list having n nodes is:
O (n)
O (log n)
O (1)
O (n log n)
Following is C like pseudo code of a function that takes a number as an argument, and uses a stack S to do processing. void fun(int n) { Stack S; while (n > 0) { push(&S, n%2); n = n/2; } while (! isEmpty(&S)) printf("%d ", pop(&S)); } What does the above function do in general?
Prints binary representation of n in reverse order
Prints the value of Logn
Prints the value of Logn in reverse order
Prints binary representation of n
Assume p point to the head of the linked list ==>3->2->5->7->6->9->NULL. What is the output of the code cout<
6
2
7
All is incorrect
Assume p point to the head of the linked list ==>3->2->5->7->6->9->NULL. What is the output of the segment code : Node *q=head->next; p->next= q->next; q->next=p; cout<
5
2
3
6
The size of matrix A is 4*5 and the size of matrix B is 5*7. The number of multiplication when calculating A*B is:
20
35
150
All is incorrect
The size of matrix A is 3*7, matrix B is 7*5 and matrix C is 5*2. The minimum of number of multiplication when calculating A*B*C is:
42
210
135
112
The statement used in the function calculating the sum of all nodes in a binary tree is:
return T->data + max(sum(T->left), sum(T->right));
return T->data + sum(T->left)+ sum(T->right);
return sum(T->left)+ sum(T->right);
All is correct
In the Hanoi Tower problem, if n=5, the number of moves required to solve is:
10
32
31
All is incorrect
When inserting the value 8,3,6 into the AVL tree, we will use rotation:
qL
qR
qLR
qRL
In the Hanoi Tower problem, if n=10, the number of moves required to solve is:
1024
10
1023
512
When inserting the values 10, 20, 15 into an AVL tree, which rotation is used?
qL
qR
qLR
qRL
The Merge Sort algorithm is an example of which algorithmic technique?
Dynamic Programming
Backtracking
Brute Force
Divide and Conquer
Which algorithmic paradigm systematically enumerates all possible candidates for a solution and checks whether each candidate satisfies the problem statement?
Divide and Conquer
Dynamic Programming
Greedy
Brute Force
Which algorithm is appropriate for finding a path in a maze?
Dynamic Programming
Divide and Conquer
Brute Force
Backtracking
Which algorithm is appropriate to solve the problem of merging n files into a single file?
Divide and Conquer
Greedy
Backtracking
Brute Force
For the Travelling Salesman Problem, if the Brute Force technique is used and the number of cities is 20, what is the number of tests required to find the result?
20!
202
19!
192
Matrix A has size 2×5 and matrix B has size 5×7 . What is the number of scalar multiplications when calculating A×B ?
10
35
70
All are incorrect
Which return statement is used in a function that counts the number of nodes in a binary tree?
return T->data + count(T->left) + count(T->right);
return 1 + count(T->left) + count(T->right);
return count(T->left) + count(T->right);
All are correct.
For the Travelling Salesman Problem, if the Brute Force technique is used and the number of cities is 5, what is the number of tests required to find the result?
5
10
20
24
The time complexity of binary search is:
O(n)
O(nlogn)
O(logn)
All are incorrect
To perform binary search on an array A, which condition must A satisfy?
A is sorted in ascending order
A does not need to be sorted
A is sorted in descending order
A or C are both correct
Given the code: int k=0, n=20; for(int i=1; i<=n; i++) { int j=i; while(j<=n) { k++; j=j*2; } } What is the value of k after the code executes?
400
30
40
All are incorrect
Backtracking solves problems by which approach?
Searching for solutions depth-first
Searching for solutions breadth-first
Trying multiple possibilities that can be accepted simultaneously
All are incorrect
In the 8-queens problem, after placing a queen in the first row, what is the minimum number of possibilities to place a queen in the second row?
6
5
7
All are incorrect
In the 8-queens problem, after placing a queen in the first row and one queen in the second row, what is the minimum number of possibilities to place a queen in the third row?
4
5
2
3
Using divide-and-conquer, how many multiplications are needed to compute x25 ?
25
5
6
7
According to the Russian peasant multiplication algorithm, when multiplying 13 by 17, what is the value of S after the second iteration?
0
13
39
81
In the helicopter patrol problem, suppose fuel can values are {3, 5, 1, 4} and the range k=2 . How many arrangements of the fuel cans satisfy the range constraint?
2
3
4
5
In the recursive definition of the binomial coefficient, when computing C(5,4) , how many times is C(3,3) computed as an intermediate call?
1
2
3
4
What is a similarity between the divide-and-conquer method and dynamic programming?
Used to solve optimization problems
Splitting a large problem into smaller subproblems
Using heuristics to solve problems
All of the above
In the rat-in-a-maze problem, a cell is considered safe when it satisfies how many conditions?
3
4
5
2
In Sudoku, when placing a number into a cell, how many conditions must be checked?
2
3
4
5
Which algorithmic approach can produce an incorrect result?
Greedy method
Divide and conquer
Exhaustive search
Probabilistic algorithm
Using the greedy method for optimal file merging, how many total reads occur when merging five files of sizes {13, 10, 4, 8, 3} into a single file?
83
123
122
38
Into how many groups can probabilistic algorithms be classified?
1
2
3
4
What is the time complexity of computing the longest palindromic subsequence using dynamic programming?
O(n)
O(n2)
O(n3)
None of the above
Which statement is not a characteristic of the brute-force method?
Having no strategy in searching for the solution
Trying all candidate solutions
Splitting a large problem into smaller subproblems
Usually not used for problems with large data sizes
Under divide-and-conquer exponentiation, how many multiplications are needed to compute x25 ?
25
5
6
7
