Aoa MCQS
Aoa MCQS
Aoa MCQS
In
the slow-start algorithm,
A. 0
B. n-1
C. Threshold
D. n+1
E. none of these
F. both a&b
a) 22
b) 17
c) 15
d) 20
How many printable characters does the ASCII character set consists of?
a) 120
b) 128
c) 100
d) 98
a) 111
b) 101
c) 110
d) 011
This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs)
focuses on “Fractional Knapsack Problem”.
Fractional knapsack problem is solved most efficiently by which of the following algorithm?
a) Divide and conquer
b) Dynamic programming
c) Greedy algorithm
d) Backtracking
Which of the following statement about 0/1 knapsack and fractional knapsack problem is
correct?
a) In 0/1 knapsack problem items are divisible and in fractional knapsack items are
indivisible
b) Both are the same
c) 0/1 knapsack is solved using a greedy algorithm and fractional knapsack is solved using
dynamic programming
d) In 0/1 knapsack problem items are indivisible and in fractional knapsack items are
divisible
Which method of encoding does not consider the probability of occurrence of symbols?
a. Static Huffman coding
b. Variable length coding
c. Adaptive Huffman coding
d. Fixed length coding
For converting recursive algorithm to non-recursive algorithm, store the values of all ___
parameters in
the stack.
a. Negative
b. Global
c. Pass by reference
d. Pass by value
Which of the following algorithms is used to find the maximum clique in a graph?
a) Dijkstra’s algorithm
b) Bellman-Ford algorithm
c) Depth First Search
d) Bron-Kerbosch algorithm
Minimum number of unique colors required for vertex coloring of a graph is called?
a) vertex matching
b) chromatic index
c) chromatic number
d) color number
5. How many unique colors will be required for proper vertex coloring of an empty graph
having n vertices?
a) 0
b) 1
c) 2
d) n
How many unique colors will be required for proper vertex coloring of a bipartite graph
having n vertices?
a) 0
b) 1
c) 2
d) n
2. Which of the following sorting algorithm is best suited if the elements are already sorted?
a) Heap Sort
b) Quick Sort
c) Insertion Sort
d) Merge Sort
3. The worst case time complexity of insertion sort is O(n2). What will be the worst case time
complexity of insertion sort if the correct position for inserting element is calculated using
binary search?
a) O(nlogn)
b) O(n2)
c) O(n)
d) O(logn)
Depth First Search is equivalent to which of the traversal in the Binary Trees?
a) Pre-order Traversal
b) Post-order Traversal
c) Level-order Traversal
d) In-order Traversal
The Data structure used in standard implementation of Breadth First Search is?
a) Stack
b) Queue
c) Linked List
d) Tree
left and right subtree differ in height by unit 1 are BST known as?
A. AVL tree B. red-black tree
C. lemma tree D. none of these
4. Define the value of r in a circular queue?
A. r=r+1
B
. r=(r+1)%[QUEUE_SIZE=1]
C. r=(r+1)% QUEUE_SIZE
D.r=(r-1)% QUEUE_SIZE
The basic operation of the ___ algorithm is the comparison between the element and the
array given.
a. Binary search b. Greedy
A person wants to visit some places. He starts from a vertex and then wants to visit every
vertex till it finishes from one vertex, backtracks and then explore other vertex from same
vertex. What algorithm he should use?
a) Depth First Search
b) Breadth First Search
c) Trim’s algorithm
d) Kruskal’s Algorithm
Which of the following is/are property/properties of a dynamic programming problem?
a) Optimal substructure
b) Overlapping subproblems
c) Greedy approach
d) Both optimal substructure and overlapping subproblems
If an optimal solution can be created for a problem by constructing optimal solutions for its
subproblems, the problem possesses ____________ property.
a) Overlapping subproblems
b) Optimal substructure
c) Memoization
d) Greedy
If a problem can be broken into subproblems which are reused several times, the problem
possesses ____________ property.
a) Overlapping subproblems
b) Optimal substructure
c) Memoization
d) Greedy
When dynamic programming is applied to a problem, it takes far less time as compared to
other methods that don’t take advantage of overlapping subproblems.
a) True
b) False
A greedy algorithm can be used to solve all the dynamic programming problems.
a) True
b) False
a) FIFO
c) LRU replacement
a) one
b) three
c) two
d) four
__________ has the lowest fault rate of all the page replacement algorithms.
a) Optimal page replacement algorithm
b) LRU replacement algorithm
c) FIFO
d) Counting based
A page that is not going to be used for the next 7 seconds will be swapped out over a page
that is going to be used within the next 0.7 seconds.
a) True
b) False
In a stack algorithm, the set of pages in a k-frame memory is always a subset of pages in a
__________ frame memory.
a) k-1
b) k
c) k+1
d) k(k+1)
When all software that runs on a system is known beforehand, optimal page replacement
algorithm can be used in a general-purpose operating system.
a) True
b) False
a) 7
b) 9
c) 8
d) 6
a) 12
b) 16
c) 14
d) 15
For which of the following inputs would Kadane’s algorithm produce the INCORRECT
output?
a) {0,1,2,3}
b) {-1,0,1}
c) {-1,-2,-3,0}
d) {-4,-3,-2,-1}
For which of the following inputs would Kadane’s algorithm produce a WRONG output?
a) {1,0,-1}
b) {-1,-2,-3}
c) {1,2,3}
d) {0,0,0}
Complete the following code for Kadane’s algorithm
#include<stdio.h>
int max_num(int a, int b)
{
if(a > b)
return a;
return b;
}
int kadane_algo(int *arr, int len)
{
int ans, sum, idx;
ans =0;
sum =0;
for(idx =0; idx < len; idx++)
{
sum = max_num(0,sum + arr[idx]);
ans = ___________;
}
return ans;
}
int main()
{
int arr[] = {-2, -3, 4, -1, -2, 1, 5, -3},len=7;
int ans = kadane_algo(arr,len);
printf("%d",ans);
return 0;
}
a) 6
b) 7
c) 8
d) 9
#include<stdio.h>
int max_num(int a, int b)
{
if(a > b)
return a;
return b;
}
int kadane_algo(int *arr, int len)
{
int ans, sum, idx;
ans =0;
sum =0;
for(idx =0; idx < len; idx++)
{
sum = max_num(0,sum + arr[idx]);
ans = max_num(sum,ans);
}
return ans;
}
int main()
{
int arr[] = {-2, -3, -3, -1, -2, -1, -5, -3},len = 8;
int ans = kadane_algo(arr,len);
printf("%d",ans);
return 0;
}
a) 1
b) -1
c) -2
d) 0
Which of the following is called the “ultimate planar convex hull algorithm”?
a) Chan’s algorithm
b) Kirkpatrick-Seidel algorithm
c) Gift wrapping algorithm
d) Jarvis algorithm
Which of the following factors account more to the cost of Chan’s algorithm?
a) computing a single convex hull
b) locating points that constitute a hull
c) computing convex hull in groups
d) merging convex hulls