Showing posts with label Data Structure MCQ. Show all posts
Showing posts with label Data Structure MCQ. Show all posts

Tuesday, 7 March 2017

Data structures & Algorithms - Multiple Choice Questions (MCQs) - Objective Set 3

1. The memory address of the first element of an array is called
 a. floor address
 b. foundation address
 c. First address
 d. base address

Answer
 d. base address
 


2. The memory address of fifth element of an array can be calculated by the formula
a. LOC(Array[5]=Base(Array)+w(5-lower bound), where w is the number of words per memory cell for the array
b. LOC(Array[5])=Base(Array[5])+(5-lower bound), where w is the number of words per memory cell for the array
c. LOC(Array[5])=Base(Array[4])+(5-Upper bound), where w is the number of words per memory cell for the array
d. None of above
Answer
a. LOC(Array[5]=Base(Array)+w(5-lower bound), where w is the number of words per memory cell for the array
 



3. Which of the following data structures are indexed structures?
a. linear arrays
b. linked lists
c. both of above
d. none of above
 Answer
a. linear arrays

4. Which of the following is not the required condition for binary search algorithm?
a. The list must be sorted
b. there should be the direct access to the middle element in any sublist
c. There must be mechanism to delete and/or insert elements in list
d. none of above
 Answer
 c. There must be mechanism to delete and/or insert elements in list

5. Which of the following is not a limitation of binary search algorithm?
a. must use a sorted array
b. requirement of sorted array is expensive when a lot of insertion and deletions are needed
c. there must be a mechanism to access middle element directly
d. binary search algorithm is not efficient when the data elements are more than 1000.
 Answer
d. binary search algorithm is not efficient when the data elements are more than 1000

6. Two dimensional arrays are also called
a. tables arrays
b. matrix arrays
c. both of above
d. none of above
Answer
c. both of above


7. A variable P is called pointer if
a. P contains the address of an element in DATA.
b. P points to the address of first element in DATA
c. P can store only memory addresses
d. P contain the DATA and the address of DATA
 Answer
a. P contains the address of an element in DATA.



8. Which of the following data structure can't store the non-homogeneous data elements?
a. Arrays
b. Records
c. Pointers
d. None
 Answer
a. Arrays

9. Which of the following data structure store the homogeneous data elements?
a. Arrays
b. Records
c. Pointers
d. None
 Answer
b. Records

10. Each data item in a record may be a group item composed of sub-items; those items which are indecomposable are called
a. elementary items
b. atoms
c. scalars
d. all of above
 Answer
d. all of above

11. The difference between linear array and a record is
a. An array is suitable for homogeneous data but hte data items in a record may have different data type
b. In a record, there may not be a natural ordering in opposed to linear array.
c. A record form a hierarchical structure but a lienear array does not
d. All of above
 Answer
d. All of above


12. Which of the following statement is false?
a. Arrays are dense lists and static data structure
b. data elements in linked list need not be stored in adjecent space in memory
c. pointers store the next data element of a list
d. linked lists are collection of the nodes that contain information part and next pointer
 Answer
 c. pointers store the next data element of a list

13. Binary search algorithm can not be applied to
a. sorted linked list
b. sorted binary trees
c. sorted linear array
d. pointer array
 Answer
a. sorted linked list

14. When new data are to be inserted into a data structure, but there is no available space; this situation is usually called
a. underflow
b. overflow
c. housefull
d. saturated
 Answer
b. overflow
 


15. The situation when in a linked list START=NULL is
a. underflow
b. overflow
c. housefull
d. saturated
 Answer
a. underflow

16. Which of the following is two way list?
a. grounded header list
b. circular header list
c. linked list with header and trailer nodes
d. none of above
 Answer
d. none of above

17. Which of the following name does not relate to stacks?
a. FIFO lists
b. LIFO list
c. Piles
d. Push-down lists
 Answer
a. FIFO lists

18. The term "push" and "pop" is related to the
a. array
b. lists
c. stacks
d. all of above
 Answer
c. stacks

19. A data structure where elements can be added or removed at either end but not in the middle
a. Linked lists
b. Stacks
c. Queues
d. Deque
 Answer
Deque


20. When inorder traversing a tree resulted E A C K F H D B G; the preorder traversal would return
a. FAEKCDBHG
b. FAEKCDHGB
c. EAFKHDCBG
d. FEAKDCHBG
Answer
b. FAEKCDHGB


















Data structures & Algorithms - Multiple Choice Questions (MCQs) - Objective Set 2




1. Which of the following is not the type of queue?

A) Ordinary queue

B) Single ended queue

C) Circular queue

D) Priority queue


2. The property of binary tree is

A) The first subset is called left subtree

B) The second subtree is called right subtree

C) The root cannot contain NULL

D) The right subtree can be empty


3. State true or false.

i) The degree of root node is always zero.

ii) Nodes that are not root and not leaf are called as internal nodes.


A) True, True

B) True, False

C) False, True

D) False, False


4. Any node is the path from the root to the node is called

A) Successor node

B) Ancestor node

C) Internal node

D) None of the above


5. State true of false.

i) A node is a parent if it has successor nodes.

ii) A node is child node if out degree is one.

A) True, True

B) True, False

C) False, True

D) False, False


6. ………………. is not an operation performed on linear list

a) Insertion b) Deletion c) Retrieval d) Traversal

A) only a,b and c

B) only a and b

C) All of the above

D) None of the above


7. Which is/are the application(s) of stack

A) Function calls

B) Large number Arithmetic

C) Evaluation of arithmetic expressions

D) All of the above


8. A …………… is an acyclic digraph, which has only one node with indegree 0, and other nodes have in-degree 1.

A) Directed tree

B) Undirected tree

C) Dis-joint tree

D) Direction oriented tree


9. …………………. Is a directed tree in which outdegree of each node is less than or equal to two.

A) Unary tree

B) Binary tree

C) Trinary tree

D) Both B and C


10. State true or false.

i) An empty tree is also a binary tree.

ii) In strictly binary tree, the out-degree of every node is either o or 2.

A) True, False

B) False, True

C) True, True

D) False, False


11. Which of the following data structures are indexed structures?

A. Linear arrays

B. Linked lists

C. Queue

D. Stack


12. Which of the following data structure store the homogeneous data elements?

A. Arrays

B. Records

C. Pointers

D. Lists


13. When new data are to be inserted into a data structure, but there is not available space; this situation is usually called ....

A. Underflow

B. overflow

C. houseful

D. saturated


14. A data structure where elements can be added or removed at either end but not in the middle is called ...

A. linked lists

B. stacks

C. queues

D. dequeue


15. Operations on a data structure may be .....

A. creation 

B. destruction

C. selection

D. all of the above


16. The way in which the data item or items are logically related defines .....

A. storage structure

B. data structure

C. data relationship

D. data operation 


17. Which of the following are the operations applicable an primitive data structures?

A. create

B. destroy

C. update

D. all of the above


18. The use of pointers to refer elements of a data structure in which elements are logically adjacent is ....

A. pointers

B. linked allocation

C. stack 

D. queue


19. Arrays are best data structures

A. for relatively permanent collections of data

B. for the size of the structure and the data in the structure are constantly changing

C. for both of above situation

D. for non of above situation


20. Which of the following statement is false?

A. Arrays are dense lists and static data structure.

B. Data elements in linked list need not be stored in adjacent space in memory

C. Pointers store the next data element of a list.

D. Linked lists are collection of the nodes that contain information part and next pointer.



Answers:


1. B) Single ended queue
2. D) The right ..... empty
3. C) False, True
4. B) Ancestor node
5. B) True, False 
6. D) None of the above
7. D) All of the above
8. A) Directed tree
9. B) Binary tree
10. C) True, True
11. A. Linear arrays 
12. B. Records
13. B. overflow 
14. D. dequeue
15. D. all of the above 
16. B. data structure
17. D. all of the above 
18. B. linked allocation
20. C. Pointers store the next data element of a list. 

Thursday, 2 March 2017

Data structures & Algorithms - Multiple Choice Questions (MCQs) - Objective Set 1

Data structures & Algorithms - Multiple Choice Questions (MCQs) - Objective Set 1
1. Two main measures for the efficiency of an algorithm are
a. Processor and memory
b. Complexity and capacity
c. Time and space
d. Data and space
 Answer (C)


2. The time factor when determining the efficiency of algorithm is measured by
a. Counting microseconds
b. Counting the number of key operations
c. Counting the number of statements
d. Counting the kilobytes of algorithm

 Answer (B)
 

3. The space factor when determining the efficiency of algorithm is measured by
a. Counting the maximum memory needed by the algorithm
b. Counting the minimum memory needed by the algorithm
c. Counting the average memory needed by the algorithm
d. Counting the maximum disk space needed by the algorithm

  Answer (A)

4. Which of the following case does not exist in complexity theory
a. Best case
b. Worst case
c. Average case
d. Null case

  Answer (D)

5. The Worst case occur in linear search algorithm when 
a. Item is somewhere in the middle of the array
b. Item is not in the array at all
c. Item is the last element in the array
d. Item is the last element in the array or is not there at all

  Answer (D)

6. The Average case occur in linear search algorithm
a. When Item is somewhere in the middle of the array
b. When Item is not in the array at all
c. When Item is the last element in the array
d. When Item is the last element in the array or is not there at all

  Answer (A)

7. The complexity of the average case of an algorithm is 
a. Much more complicated to analyze than that of worst case
b. Much more simpler to analyze than that of worst case
c. Sometimes more complicated and some other times simpler than that of worst case
d. None or above
 Answer (A)

 

8. The complexity of linear search algorithm is
a. O(n)
b. O(log n)
c. O(n2)
d. O(n log n)

  Answer (A)

9. The complexity of Binary search algorithm is 
a. O(n)
b. O(log n )
c. O(n2)
d. O(n log n)

  Answer (B)

10. The complexity of Bubble sort algorithm is 
a. O(n)
b. O(log n)
c. O(n2)
d. O(n log n)

  Answer (C)

11. The complexity of merge sort algorithm is
a. O(n)
b. O(log n)
c. O(n2)
d. O(n log n)

  Answer (D)

12. The indirect change of the values of a variable in one module by another module is called
a. internal change
b. inter-module change
c. side effect
d. side-module update

  Answer (C)

13. Which of the following data structure is not linear data structure?
a. Arrays
b. Linked lists
c. Both of above
d. None of above

 Answer (D) 

14. Which of the following data structure is linear data structure?
a. Trees
b. Graphs
c. Arrays
d. None of above
 Answer (C)

 

15. The operation of processing each element in the list is known as
a. Sorting
b. Merging
c. Inserting
d. Traversal

  Answer (D)

16. Finding the location of the element with a given value is:
a. Traversal
b. Search
c. Sort
d. None of above

  Answer (B)

17. Arrays are best data structures
a. for relatively permanent collections of data
b. for the size of the structure and the data in the structure are constantly changing
c. for both of above situation
d. for none of above situation

  Answer (A)

18. Linked lists are best suited
a. for relatively permanent collections of data
b. for the size of the structure and the data in the structure are constantly changing
c. for both of above situation
d. for none of above situation

  Answer (B)

19. Each array declaration need not give, implicitly or explicitly, the information about
a. the name of array
b. the data type of array
c. the first data from the set to be stored
d. the index set of the array

  Answer (C)

20. The elements of an array are stored successively in memory cells because
a. by this way computer can keep track only the address of the first element and the addresses of other elements can be calculated
b. the architecture of computer memory does not allow arrays to store other than serially
c. both of above
d. none of above
 Answer (A)

Q 21 - Which of the following usees FIFO method
A - Queue
B - Stack
C - Hash Table
D - Binary Search Tree
Answer (A)

Q 22 - Queue data structure works on
A - LIFO
B - FIFO
C - FILO
D - none of the above
Answer (A)


Q 23 - Minimum number of moves required to solve a Tower of Hanoi puzzle is
A - 2n2
B - 2n-1
C - 2n - 1
D - 2n - 1
Answer(C)


Q 24 - What is not true about insertion sort?
A - Exhibits the worst case performance when the initial array is sorted in reverse order.
B - Worst case and average case performance is Ο(n2)
C - Can be compared to the way a card player arranges his card from a card deck.
D - None of the above!
Answer(D)

All given options are true about insertion sort.

Q 25 - Which of the following is example of in-place algorithm?
A - Bubble Sort
B - Merge Sort
C - Insertion Sort
D - All of the above
Answer(B)

Only Merge sort requires extra space
Q 26 - Which of the below mentioned sorting algorithms are not stable?
A - Selection Sort
B - Bubble Sort
C - Merge Sort
D - Insertion Sort
Answer(A)

Except selection sort, all other soring algorithms are stable.

Q 27 - Which of these algorithmic approach tries to achieve localized optimum solution −
A - Greedy approach
B - Divide and conquer approach
C - Dynamic approach
D - All of the above
Answer(A)

Q 28 - If there's no base criteria in a recursive program, the program will
A - not be executed.
B - execute until all conditions match.
C - execute infinitely.
D - obtain progressive approach.
Answer(C)

Q 29 - A balance factor in AVL tree is used to check
A - what rotation to make.
B - if all child nodes are at same level.
C - when the last rotation occured.
D - if the tree is unbalanced.
 Answer(D)
The balance factor (BalanceFactor = height(left-sutree) − height(right-sutree)) is used to check if the tree is balanced or unbalanced.


Q 30 - If the data collection is in sorted form and equally distributed then the run time complexity of interpolation search is −
A - Ο(n)
B - Ο(1)
C - Ο(log n)
D - Ο(log (log n))
Answer(D)
Runtime complexity of interpolation search algorithm is Ο(log (log n)) as compared to Ο(log n) of BST in favourable situations.