0% found this document useful (0 votes)
49 views

DataStrustures MCQ Sample With Answerkey

Uploaded by

coverdrive48
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

DataStrustures MCQ Sample With Answerkey

Uploaded by

coverdrive48
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 13

Data Structure MCQ

1) How can we describe an array in the best possible way?

a) The Array shows a hierarchical structure.


b) Arrays are immutable.
c) Container that stores the elements of similar types
d) The Array is not a data structure

2) Which of the following is the correct way of declaring an array?

a) int javatpoint[10];
b) int javatpoint;
c) javatpoint{20};
d) array javatpoint[10];

3) How can we initialize an array in C language?

a) int arr[2]=(10, 20)


b) int arr(2)={10, 20}
c) int arr[2] = {10, 20}
d) int arr(2) = (10, 20)

4) Which of the following is the advantage of the array data structure3Apple Watch Series 7

a) Elements of mixed data types can be stored.


b) Easier to access the elements in an array
c) Index of the first element starts from 1.
d) Elements of an array cannot be sorted

5) Which of the following highly uses the concept of an array?

a) Binary Search tree


b) Caching
c) Spatial locality
d) Scheduling of Processes

6) Which of the following is the disadvantage of the array?

a) Stack and Queue data structures can be implemented through an array.


b) Index of the first element in an array can be negative
c) Wastage of memory if the elements inserted in an array are lesser than the allocated size
d) Elements can be accessed sequentially.

7) What is the output of the below code?


1. #include <stdio.h>
2. int main()
3. {
4. int arr[5]={10,20,30,40,50};
5. printf("%d", arr[5]);
6.
7. return 0;
8. }
0. Garbage value
a. 10
b. 50
c. None of the above

8) Which one of the following is the size of int arr[9] assuming that int is of 4 bytes?

a) 9
b) 36
c) 35
d) None of the above

9) Which one of the following is the process of inserting an element in the stack?

a) Insert
b) Add
c) Push
d) None of the above

10) When the user tries to delete the element from the empty stack then the condition is said to be
a ____

a) Underflow
b) Garbage collection
c) Overflow
d) None of the above

11) If the size of the stack is 10 and we try to add the 11th element in the stack then the condition
is known as___

a) Underflow
b) Garbage collection
c) Overflow
d) None of the above

12) Which one of the following is not the application of the stack data structure

a) String reversal
b) Recursion
c) Backtracking
d) Asynchronous data transfer

13) Which data structure is mainly used for implementing the recursive algorithm?

a) Queue
b) Stack
c) Binary tree
d) Linked list

14) Which data structure is required to convert the infix to prefix notation?

a) Stack
b) Linked list
c) Binary tree
d) Queue

15) Which of the following is the infix expression?

a) A+B*C
b) +A*BC
c) ABC+*
d) None of the above

16) Which of the following is the prefix form of A+B*C?

a) A+(BC*)
b) +AB*C
c) ABC+*
d) +A*BC

17) Which of the following is not the correct statement for a stack data structure?

a) Arrays can be used to implement the stack


b) Stack follows FIFO
c) Elements are stored in a sequential manner
d) Top of the stack contains the last inserted element

18) If the elements '1', '2', '3' and '4' are added in a stack, so what would be the order for the
removal?

a) 1234
b) 2134
c) 4321
d) None of the above

19) What is the outcome of the prefix expression +, -, *, 3, 2, /, 8, 4, 1?

a) 12
b) 11
c) 5
d) 4

20) The minimum number of stacks required to implement a stack is __


a) 1
b) 3
c) 2
d) 5

21) Which one of the following node is considered the top of the stack if the stack is implemented
using the linked list?

a) First node
b) Second node
c) Last node
d) None of the above

22) Consider the following stack implemented using stack.


1. #define SIZE 11
2. struct STACK
3. {
4. int arr[SIZE];
5. int top=-1;
6. }
What would be the maximum value of the top that does not cause the overflow of the stack?
a) 8
b) 9
c) 11
d) 10

23) What is another name for the circular queue among the following options?

a) Square buffer
b) Rectangle buffer
c) Ring buffer
d) None of the above

24) If the elements '1', '2', '3' and '4' are inserted in a queue, what would be order for the removal?

a) 1234
b) 4321
c) 3241
d) None of the above

25) A list of elements in which enqueue operation takes place from one end, and dequeue
operation takes place from one end is__

a) Binary tree
b) Stack
c) Queue
d) Linked list
26) Which of the following principle does Queue use?

a) LIFO principle
b) FIFO principle
c) Linear tree
d) Ordered array

27) Which one of the following is not the type of the Queue?

a) Linear Queue
b) Circular Queue
c) Double ended Queue
d) Single ended Queue

28) Which one of the following is the overflow condition if linear queue is implemented using an
array with a size MAX_SIZE?

a) rear = front
b) rear = front+1
c) rear=MAX_SIZE -1
d) rear = MAX_SIZE

29) Which one of the following is the overflow condition if a circular queue is implemented using
array having size MAX?

a) rear= MAX-1
b) rear=MAX
c) front=(rear+1) mod max
d) None of the above

30) The time complexity of enqueue operation in Queue is __

a) O(1)
b) O(n)
c) O(logn)
d) O(nlogn)

31) Which of the following that determines the need for the Circular Queue?

a) Avoid wastage of memory


b) Access the Queue using priority
c) Follows the FIFO principle
d) None of the above

32) Which one of the following is the correct way to increment the rear end in a circular queue?

a) rear =rear+1
b) (rear+1) % max
c) (rear % max) + 1
d) None of the above

33) Consider the following code.


1. int fun()
2. {
3. if(isEmpty())
4. {
5. return -10;
6. }
7. else
8. {
9. int n;
10. n= q[front];
11. front++;
12. return n;
13. }
14.
15. }
Which operation does the above code perform?
a) Enqueue
b) Dequeue
c) Return the front element
d) Both b and c

34) In the linked list implementation of queue, where will the new element be inserted?

a) At the middle position of the linked list


b) At the head position of the linked list
c) At the tail position of the linked list
d) None of the above

35) How many Queues are required to implement a Stack?

a) 3
b) 2
c) 1
d) 4

36) Which one of the following is not the application of the Queue data structure?

a) Resource shared between various systems


b) Data is transferred asynchronously
c) Load balancing
d) Balancing of symbols

37) Which of the following option is true if implementation of Queue is from the linked list?

a) In enqueue operation, new nodes are inserted from the beginning and in dequeue operation,
nodes are removed from the end.
b) In enqueue operation, new nodes are inserted from the end and in dequeue operation, nodes
are deleted from the beginning.
c) In enqueue operation, new nodes are inserted from the end and in dequeue operation, nodes
are deleted from the end.
d) Both a and b

38) The necessary condition to be checked before deletion from the Queue is__

a) Overflow
b) Underflow
c) Rear value
d) Front value

39) Which data structure is the best for implementing a priority queue?

a) Stack
b) Linked list
c) Array
d) Heap

40) Which of the following principle is used if two elements in the priority queue have the same
priority?

a) LIFO
b) FIFO
c) Linear tree
d) None of the above

41) Which of the following statement is not true regarding the priority queue?

a) Processes with different priority can be easily handled


b) Easy to implement
c) Deletion is easier
d) None of the above

42) A linear data structure in which insertion and deletion operations can be performed from both
the ends is___

a) Queue
b) Deque
c) Priority queue
d) Circular queue

43) In the Deque implementation using singly linked list, what would be the time complexity of
deleting an element from the rear end?

a) O(1)
b) O(n2)
c) O(n)
d) O(nlogn)
44) Which of the following data structure allows you to insert the elements from both the ends
while deletion from only one end?

a) Input-restricted queue
b) Output-restricted queue
c) Priority queue
d) None of the above

45) What would be the output after performing the following operations in a Deque?
1. Insertfront(10);
2. Insertfront(20);
3. Insertrear(30);
4. Insertrear(40);
5. Deletefront();
6. Insertfront(50);
7. Deleterear();
8. Display();
a) 10, 20, 30
b) 50, 10, 30
c) 40, 20, 30
d) None of the above

46) In a circular queue implementation using array of size 5, the array index starts with 0 where
front and rear values are 3 and 4 respectively. Determine the array index at which the insertion of
the next element will take place.

a) 5
b) 0
c) 1
d) 2

47) If circular queue is implemented using array having size MAX_SIZE in which array index
starts with 0, front points to the first element in the queue, and rear points to the last element in
the queue. Which one of the following conditions used to specify that the circular queue is
empty?

a) Front=rear= -1
b) Front=rear=0
c) Front=rear+1
d) None of the above

48) Consider the implementation of the singly linked list having the head pointer only in the
representation. Which of the following operations can be performed in O(1) time?

i)Deletion of the last node in the linked list


ii)Insertion at the front of the linked list
iii)Deletion of the first node in the linked list
iv)Insertion at the end of the linked list
a) ii
b) both ii and iii
c) both i and iv
d) both i and ii

49) What would be the time complexity if user tries to insert the element at the end of the linked
list (head pointer is known)?

a) O(1)
b) O(n)
c) O(logn)
d) O(nlogn)

50) Which of the following is the time complexity to search an element in the linked list?

a) O(1)
b) O(n)
c) O(logn)
d) O(nlogn)

51) Consider the following code


1. struct node
2. {
3. int data;
4. struct node *next;
5. }
6. node ptr;
Which one of the following is the correct option to create a new node?
a) ptr= (node*)malloc(sizeof(node*))
b) ptr=(node)malloc(sizeof(node))
c) ptr=(node*)malloc(sizeof(node))
d) None of the above

52) Which of the following statement is not true about the doubly linked list?

a) We can traverse in both the directions.


b) It requires extra space
c) Implementation of doubly linked list is easier than the singly linked list
d) It stores the addresses of the next and the previous node

53) What is the maximum number of children that a node can have in a binary tree?

a) 3
b) 1
c) 4
d) 2

54) Which one of the following techniques is not used in the Binary tree?

a) Randomized traversal
b) Preorder traversal
c) Postorder traversal
d) Inorder traversal

55) Which of the following options is not true about the Binary Search tree?

a) The value of the left child should be less than the root node
b) The value of the right child should be greater than the root node.
c) The left and right sub trees should also be a binary search tree
d) None of the above

56) How can we define a AVL tree?

a) A tree which is binary search tree and height balanced tree.


b) A tree which is a binary search tree but unbalanced tree.
c) A tree with utmost two children
d) A tree with utmost three children

57) Why do we prefer Red Black tree over AVL tree?

a) Red Black trees are not strictly balanced


b) Red black tree requires lesser rotations than AVL tree.
c) AVL tree needs more space to store the balance factor.
d) Both b and c

58) Which of the following satisfies the property of the Red Black tree?

a) A tree which is a binary search tree but not strictly balanced tree.
b) A node must be either Red or Black in color and root node must be black.
c) A tree with maximum three children
d) Both a and b

59) What would be the color of newly created node while inserting a new element in a Red black
tree?

a) Black, if the new node is not a root node


b) Red, if the new node is not a root node
c) Black, if the new node is a root node
d) Both b and c

60) Identify the AVL tree among the following options?


a) A
b) C
c) Both A and C
d) B
Answers

1) C
2) A
3) C
4) B
5) C
6) C
7) A
8) B
9) C
10) A
11) C
12) D
13) B
14) A
15) A
16) D
17) B
18) C
19) C
20) 2
21) A
22) D
23) C
24) A
25) C
26) B
27) D
28) C
29) C
30) A
31) A
32) B
33) D
34) C
35) B
36) D
37) D
38) B
39) D
40) B
41) C
42) B
43) C
44) B
45) B
46) B
47) A
48) B
49) B
50) B
51) C
52) C
53) D
54) A
55) D
56) A
57) D
58) D
59) D
60) C

You might also like