Aoa MCQS

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

Size of the congestion window increases exponentially until it reaches——.

In
the slow-start algorithm,
A. 0
B. n-1
C. Threshold
D. n+1
E. none of these
F. both a&b

In the binary search algorithm the complexity of searching for an element


from a set of n elements.
A. O(nlogn)
B. O(log n)
C. O(n2)
D. O(n)
E. none of these
F. both a&c

Does Ford- Fulkerson algorithm use the idea of?


a) Naïve greedy algorithm approach
b) Residual graphs
c) Minimum cut
d) Minimum spanning tree

The first step in the naïve greedy algorithm is?


a) analysing the zero flow
b) calculating the maximum flow using trial and error
c) adding flows with higher values
d) reversing flow if required
Find the maximum flow from the following graph.

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

In Huffman coding, data in a tree always occur?


a) roots
b) leaves
c) left sub trees
d) right sub trees
From the following given tree, what is the computed codeword for ‘c’?

a) 111
b) 101
c) 110
d) 011

What is the running time of the Huffman encoding algorithm?


a) O(C)
b) O(log C)
c) O(C log C)
d) O( N log C)

This set of Data Structures & Algorithms Multiple Choice Questions & Answers (MCQs)
focuses on “Fractional Knapsack Problem”.

Fractional knapsack problem is also known as __________


a) 0/1 knapsack problem
b) Continuous knapsack problem
c) Divisible knapsack problem
d) Non continuous 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

What is the objective of the knapsack problem?


a) To get maximum total value in the knapsack
b) To get minimum total value in the knapsack
c) To get maximum weight in the knapsack
d) To get minimum weight in the knapsack

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

Time complexity of fractional knapsack problem is ____________


a) O(n log n)
b) O(n)
c) O(n2)
d) O(nW)

Which of the following is not a type of graph in computer science?


a) undirected graph
b) bar graph
c) directed graph
d) weighted graph

What is vertex coloring of a graph?


a) A condition where any two vertices having a common edge should not have same color
b) A condition where any two vertices having a common edge should always have same
color
c) A condition where all vertices should have a different color
d) A condition where all vertices should have same color

How many edges will a tree consisting of N nodes have?


a) Log(N)
b) N
c) N – 1
d) N + 1

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

Which of the following is correct with regard to insertion sort?


a) insertion sort is stable and it sorts In-place
b) insertion sort is unstable and it sorts In-place
c) insertion sort is stable and it does not sort In-place
d) insertion sort is unstable and it does not sort In-place

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

Time Complexity of DFS is? (V – number of vertices, E – number of edges)


a) O(V + E)
b) O(V)
c) O(E)
d) O(V*E)

The Data structure used in standard implementation of Breadth First Search is?
a) Stack
b) Queue
c) Linked List
d) Tree

The Depth First Search traversal of a graph will result into?


a) Linked List
b) Tree
c) Graph with back edges
d) Array

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

If a problem can be solved by combining optimal solutions to non-overlapping problems, the


strategy is called _____________
a) Dynamic programming
b) Greedy
c) Divide and conquer
d) Recursion

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

. In dynamic programming, the technique of storing the previously calculated values is


called ___________
a) Saving value property
b) Storing value property
c) Memoization
d) Mapping

When a top-down approach of dynamic programming is applied to a problem, it usually


_____________
a) Decreases both, the time complexity and the space complexity
b) Decreases the time complexity and increases the space complexity
c) Increases the time complexity and decreases the space complexity
d) Increases both, the time complexity and the space complexity

Which of the following problems is NOT solved using dynamic programming?


a) 0/1 knapsack problem
b) Matrix chain multiplication problem
c) Edit distance problem
d) Fractional knapsack problem

Which of the following problems should be solved using dynamic programming?


a) Mergesort
b) Binary search
c) Longest common subsequence
d) Quicksort

Which of the following is the simplest page replacement algorithm?

a) FIFO

b) Optimal page replacement

c) LRU replacement

d) Counting based replacement

2. How many constraints does flow have?

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

Optimal page replacement algorithm is also called as __________


a) LIFO
b) NRU
c) Clairvoyant replacement algorithm
d) Page buffering

In a optimal page replacement algorithm, when a page is to be replaced, which of the


following pages is chosen?
a) Oldest page
b) Newest page
c) Frequently occurred page in the future
d) Not frequently occurred page in the future

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

Analysis of the optimal paging problem has been done through___________


a) Deterministic algorithm
b) Online algorithm
c) Euclid algorithm
d) Optimal algorithm

Optimal page replacement algorithm is implemented in __________


a) General-purpose operating system
b) Special-purpose operating system
c) In any kind of operating system
d) In Windows only

Optimal page replacement algorithm is said to satisfy __________


a) Online algorithm
b) Stack algorithm
c) Queue algorithm
d) Array algorithm

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

Consider a reference string 7,0,1,2,0,3,0,4,2,3,0,3,2,1,2,0,1,7,0,1 of frame size 3. Calculate


the number of page faults using optimal page replacement algorithm.
a) 10
b) 9
c) 8
d) 7

Consider a reference string 7,0,1,2,0,3,0,4,2,3,0,3,2,1,2,0,1,7,0,1 of frame size 4. Calculate


the number of page faults using optimal page replacement algorithm.

a) 7
b) 9
c) 8
d) 6

Consider a reference string 1,2,3,2,1,5,2,1,6,2,5,6,3,1,3,6,1,2,4,3 of frame size 3. Calculate


the number of page faults using optimal page replacement algorithm.

a) 12
b) 16
c) 14
d) 15

Kadane’s algorithm is used to find ____________


a) Longest increasing subsequence
b) Longest palindrome subsequence
c) Maximum sub-array sum
d) Longest decreasing subsequence

Kadane’s algorithm uses which of the following techniques?


a) Divide and conquer
b) Dynamic programming
c) Recursion
d) Greedy algorithm

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) max_num(sum, sum + arr[idx])


b) sum
c) sum + arr[idx]
d) max_num(sum,ans)

What is the time complexity of Kadane’s algorithm?


a) O(1)
b) O(n)
c) O(n2)
d) O(5)

What is the space complexity of Kadane’s algorithm?


a) O(1)
b) O(n)
c) O(n2)
d) None of the mentioned

What is the output of the following implementation of 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 = 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) 6
b) 7
c) 8
d) 9

What is the output of the following implementation of 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 = 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

Chan’s algorithm is used for computing _________


a) Closest distance between two points
b) Convex hull
c) Area of a polygon
d) Shortest path between two points

What is the running time of Chan’s algorithm?


a) O(log n)
b) O(n log n)
c) O(n log h)
d) O(log h)
Who formulated Chan’s algorithm?
a) Timothy
b) Kirkpatrick
c) Frank Nielsen
d) Seidel
The running time of Chan’s algorithm is obtained from combining two algorithms.
a) True
b) False

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 algorithms is the simplest?


a) Chan’s algorithm
b) Kirkpatrick-Seidel algorithm
c) Gift wrapping algorithm
d) Jarvis algorithm

. What is the running time of Hershberger algorithm?


a) O(log n)
b) O(n log n)
c) O(n log h)
d) O(log h)

Which of the following statements is not a part of Chan’s algorithm?


a) eliminate points not in the hull
b) recompute convex hull from scratch
c) merge previously calculated convex hull
d) reuse convex hull from the previous iteration

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

Chan’s algorithm can be used to compute the lower envelope of a trapezoid.


a) true
b) false

You might also like