November 27, 2019

Data Structures and Algorithms - MCQS

Note: We have tried to upload as much as we can, all the question and answers might be shuffled - Please find the answer below each question, some answers might be wrong please review on the last date(some answers might be changed) if you find any wrong answer please comment down below.

Question: 1
Experimental way of comparing two Algorithms involves
Select one:
A. All of the options
B. Measurement of runtime in same environment (H/w & S/w)
C. Execution with different input sizes
D. Using Implementation details
Correct Answer: All of the options

Question: 2
What will be the list after third iteration in case of insertion sort
            52, 23, 47, 66, 15, 39
Select one:
A. 15, 23, 39, 47, 52, 66
B. 15, 23, 39, 66, 52, 47
C. 23, 47, 52, 66, 15, 39
D. 23, 52, 47, 66, 15, 39
Correct Answer: 23, 47, 52, 66, 15, 39

Question: 3
Time complexity for following pseudo code is
Select one:
A. O(n)
B. O(n2)
C. O(n1/2)
D. O(n3)
Correct Answer: O(n3)

Question: 4
You have a sorted array with 1023 elements. You use binary search to determine whether number 239 is present in this array or not. How many elements of the array will you compare it with if number 239 is not present in this array?
Select one:
A. 32
B. 0
C. 239
D. 10
Correct Answer: 10

Question: 5
What do the leaves of an expression tree represent?
Select one:
A. All of the options
B. Operand
C. Operator
D. Operation
Correct Answer: Operand

Question: 6
The following operations are performed on a linear queue with maximum capacity to hold 5 integers: add(5), delete(), add(6), add(7), add(8), delete(). How many more integer elements can still be added to this queue?
Select one:
A. 3
B. 1
C. 2
D. 0
Correct Answer: 3

Question: 7
In a binary tree, if any element is at i, then its leftchild is at
Select one:
A. 2*i
B. 2-i
C. 2
D. None of the option
Correct Answer: 2*i

Question: 8
When the pop operation on Stack is leads to an error?
Select one:
A. When the stack is neither empty nor full
B. Only when the stack is empty
C. When there is an overflow in the stack
D. Only when the stack is full
Correct Answer: Only when the stack is empty

Question: 9
Which of the following points is/are true about Linked List data structure when it is compared with array
Select one:
A. It is easy to insert and delete elements in Linked List
B. Random access is not allowed in a typical implementation of Linked Lists
C. All the options
D. The size of array has to be pre-decided, linked lists can change their size any time.
Correct Answer: All the options

Question: 10
Ravi wants to implement an image viewer application to view images. The application will be able to display an image and will also know what its next and previous images are at any given point of time so that the user can view next/previous image by pressing right/left keys on the keyboard. Which data structure is appropriate for Ravi to use?
Select one:
A. Queue
B. Tree
C. Linked list
D. Stack
Correct Answer: Linked list

Question: 11
What is the smallest value of n such that an algorithm whose running time is 100n2 runs faster than an algorithm whose running time is 2n on the same machine?
Select one:
A. 100
B. 2
C. 14
D. 15
Correct Answer: 15

Question: 12
How many pointers are necessarily changed for the insertion in a Linked List?
Select one:
A. Five
B. One
C. Three
D. Two
Correct Answer: Two

Question: 13
The worst and best case performance of finding maximum element in an array of size n is (using brute-force algorithm)
Select one:
A. O(n)
B. O(log n)         
C. O(n log n)      
D. O(1)
Correct Answer: O(n)

Question: 14
The data structure required to check whether an expression contains balanced parenthesis is
Select one:
A. Tree
B. Queue
C. Stack
D. Array
Correct Answer: Stack

Question: 15
What will be the time complexity for this piece of code
int count = 0;
for (int i = 0; i < N; i++)
    for (int j = 0; j < i; j++)
Select one:
A. O(nlogn)
B. O(n)
C. O(logn)
D. O(n2)
Correct Answer: O(n2)

Question: 16
Which of the following is NOT a measure for  an Algorithm
Select one:
A. Data Structure
B. Size Complexity
C. Primitive operations
D. Runtime Complexity
Correct Answer: Primitive operations

Question: 17
You need to design a scheduler that to schedule a set of tasks. A number of the tasks need to wait for other previous tasks to complete prior to running themselves. What data structure would be suitable
Select one:
a. Stack
b. none of the options
c. queue
d. linked list
Correct Answer: queue

Question: 18
Ramu is developing a word processing software in which he wants to provide undo feature. The software will maintain all the sequential changes and at any point of time pressing control z will undo the latest change, what data structure should Ramu use for this?
Select one:
A. Queue
B. Array
C. Linked list
D. Stack
Correct Answer: Stack

Question: 19
From where does the insertion and deletion of elements get accomplished in Queues?
Select one:
A. Front & Rear ends respectively
B. Only from Front end
C. Rear & Front ends respectively
D. Only from Rear end
Correct Answer: Front & Rear ends respectively

Question: 20
The post-order traversal of a binary tree is 6 4 45 13 3. Then possible pre-order traversal will be ________
Select one:
A. 45 13 6 5 3
B. 3 13 4 6 45
C. 3 4 6 13 45
D. 45 6 13 3 5
Correct Answer: 3 13 4 6 45

1 comment:

  1. An endeavor information distribution center might be executed on customary centralized computers, UNIX super servers or parallel engineering stages.Data Analytics Courses