## Data Structure MCQ1) How can we describe an array in the best possible way? - The Array shows a hierarchical structure.
- Arrays are immutable.
- Container that stores the elements of similar types
- The Array is not a data structure
2) Which of the following is the correct way of declaring an array? - int javatpoint[10];
- int javatpoint;
- javatpoint{20};
- array javatpoint[10];
3) How can we initialize an array in C language? - int arr[2]=(10, 20)
- int arr(2)={10, 20}
- int arr[2] = {10, 20}
- int arr(2) = (10, 20)
4) Which of the following is the advantage of the array data structure? - Elements of mixed data types can be stored.
- Easier to access the elements in an array
- Index of the first element starts from 1.
- Elements of an array cannot be sorted
5) Which of the following highly uses the concept of an array? - Binary Search tree
- Caching
- Spatial locality
- Scheduling of Processes
6) Which of the following is the disadvantage of the array? - Stack and Queue data structures can be implemented through an array.
- Index of the first element in an array can be negative
- Wastage of memory if the elements inserted in an array are lesser than the allocated size
- Elements can be accessed sequentially.
7) What is the output of the below code? - Garbage value
- 10
- 50
- None of the above
8) Which one of the following is the size of int arr[9] assuming that int is of 4 bytes? - 9
- 36
- 35
- None of the above
9) Which one of the following is the process of inserting an element in the stack? - Insert
- Add
- Push
- 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 ____ - Underflow
- Garbage collection
- Overflow
- 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___ - Underflow
- Garbage collection
- Overflow
- None of the above
12) Which one of the following is not the application of the stack data structure - String reversal
- Recursion
- Backtracking
- Asynchronous data transfer
13) Which data structure is mainly used for implementing the recursive algorithm? - Queue
- Stack
- Binary tree
- Linked list
14) Which data structure is required to convert the infix to prefix notation? - Stack
- Linked list
- Binary tree
- Queue
15) Which of the following is the infix expression? - A+B*C
- +A*BC
- ABC+*
- None of the above
16) Which of the following is the prefix form of A+B*C? - A+(BC*)
- +AB*C
- ABC+*
- +A*BC
To convert the infix expression into a prefix expression, we will move the operator to the left of the parenthesis as shown in the below figure. 17) Which of the following is not the correct statement for a stack data structure? - Arrays can be used to implement the stack
- Stack follows FIFO
- Elements are stored in a sequential manner
- 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? - 1234
- 2134
- 4321
- None of the above
19) What is the outcome of the prefix expression +, -, *, 3, 2, /, 8, 4, 1? - 12
- 11
- 5
- 4
The infix expression of the above prefix expression is: (2*3) - (8/4) +1 6 -2 +1 = 5 20) The minimum number of stacks required to implement a stack is __ - 1
- 3
- 2
- 5
21) Which one of the following node is considered the top of the stack if the stack is implemented using the linked list? - First node
- Second node
- Last node
- None of the above
22) Consider the following stack implemented using stack. What would be the maximum value of the top that does not cause the overflow of the stack? - 8
- 9
- 11
- 10
23) What is another name for the circular queue among the following options? - Square buffer
- Rectangle buffer
- Ring buffer
- 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? - 1234
- 4321
- 3241
- 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__ - Binary tree
- Stack
- Queue
- Linked list
26) Which of the following principle does Queue use? - LIFO principle
- FIFO principle
- Linear tree
- Ordered array
27) Which one of the following is not the type of the Queue? - Linear Queue
- Circular Queue
- Double ended Queue
- 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? - rear = front
- rear = front+1
- rear=MAX_SIZE -1
- rear = MAX_SIZE
29) Which one of the following is the overflow condition if a circular queue is implemented using array having size MAX? - rear= MAX-1
- rear=MAX
- front=(rear+1) mod max
- None of the above
30) The time complexity of enqueue operation in Queue is __ - O(1)
- O(n)
- O(logn)
- O(nlogn)
31) Which of the following that determines the need for the Circular Queue? - Avoid wastage of memory
- Access the Queue using priority
- Follows the FIFO principle
- None of the above
32) Which one of the following is the correct way to increment the rear end in a circular queue? - rear =rear+1
- (rear+1) % max
- (rear % max) + 1
- None of the above
33) Consider the following code. Which operation does the above code perform? - Enqueue
- Dequeue
- Return the front element
- Both b and c
34) In the linked list implementation of queue, where will the new element be inserted? - At the middle position of the linked list
- At the head position of the linked list
- At the tail position of the linked list
- None of the above
35) How many Queues are required to implement a Stack? - 3
- 2
- 1
- 4
36) Which one of the following is not the application of the Queue data structure? - Resource shared between various systems
- Data is transferred asynchronously
- Load balancing
- Balancing of symbols
The answer is d. The options a, b, and c are the applications of the Queue data structure while option d, i.e., balancing of symbols is not the application of the Queue data structure. The option a, i.e., resource shared between various system is the application of the Queue data structure as it allows to align all the requests for the resource in a queue. The option b, i.e., data is transferred asynchronously is a application of the Queue data structure. Here asynchronously means that the data received at the different rate as sent. The option c, i.e., load balancing is also an application of the Queue data structure because all the requests from the client are stored in the Queue, and it distributes the requests to the client one by one. The option d, i.e., balancing of symbols is an application of the stack data structure. 37) Which of the following option is true if implementation of Queue is from the linked list? - In enqueue operation, new nodes are inserted from the beginning and in dequeue operation, nodes are removed from the end.
- In enqueue operation, new nodes are inserted from the end and in dequeue operation, nodes are deleted from the beginning.
- In enqueue operation, new nodes are inserted from the end and in dequeue operation, nodes are deleted from the end.
- Both a and b
38) The necessary condition to be checked before deletion from the Queue is__ - Overflow
- Underflow
- Rear value
- Front value
39) Which data structure is the best for implementing a priority queue? - Stack
- Linked list
- Array
- Heap
40) Which of the following principle is used if two elements in the priority queue have the same priority? - LIFO
- FIFO
- Linear tree
- None of the above
41) Which of the following statement is not true regarding the priority queue? - Processes with different priority can be easily handled
- Easy to implement
- Deletion is easier
- None of the above
42) A linear data structure in which insertion and deletion operations can be performed from both the ends is___ - Queue
- Deque
- Priority queue
- 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? - O(1)
- O(n
^{2}) - O(n)
- 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? - Input-restricted queue
- Output-restricted queue
- Priority queue
- None of the above
45) What would be the output after performing the following operations in a Deque? - 10, 20, 30
- 50, 10, 30
- 40, 20, 30
- None of the above
The answer is b. Let's dry run the above code. When insertfront(10) is called, deque would be: 10 When insertfront(20) is called, the deque would be: 20 10 When insertrear(30) is called, the deque would be: 20 10 30 When insertrear(40) is called, the deque would be: 20 10 30 40 When deletefront() is called, the deque would be: 10 30 40 When insertfront(50) is called, the deque would be: 50 10 30 40 When deleterear() is called, the deque would be: 50 10 30 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. - 5
- 0
- 1
- 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? - Front=rear= -1
- Front=rear=0
- Front=rear+1
- 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
- both ii and iii
- both i and iv
- 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)? - O(1)
- O(n)
- O(logn)
- O(nlogn)
50) Which of the following is the time complexity to search an element in the linked list? - O(1)
- O(n)
- O(logn)
- O(nlogn)
51) Consider the following code Which one of the following is the correct option to create a new node? - ptr= (node*)malloc(sizeof(node*))
- ptr=(node)malloc(sizeof(node))
- ptr=(node*)malloc(sizeof(node))
- None of the above
52) Which of the following statement is not true about the doubly linked list? - We can traverse in both the directions.
- It requires extra space
- Implementation of doubly linked list is easier than the singly linked list
- 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? - 3
- 1
- 4
- 2
54) Which one of the following techniques is not used in the Binary tree? - Randomized traversal
- Preorder traversal
- Postorder traversal
- Inorder traversal
55) Which of the following options is not true about the Binary Search tree? - The value of the left child should be less than the root node
- The value of the right child should be greater than the root node.
- The left and right sub trees should also be a binary search tree
- None of the above
56) How can we define a AVL tree? - A tree which is binary search tree and height balanced tree.
- A tree which is a binary search tree but unbalanced tree.
- A tree with utmost two children
- A tree with utmost three children
57) Why do we prefer Red Black tree over AVL tree? - Red Black trees are not strictly balanced
- Red black tree requires lesser rotations than AVL tree.
- AVL tree needs more space to store the balance factor.
- Both b and c
58) Which of the following satisfies the property of the Red Black tree? - A tree which is a binary search tree but not strictly balanced tree.
- A node must be either Red or Black in color and root node must be black.
- A tree with maximum three children
- Both a and b
59) What would be the color of newly created node while inserting a new element in a Red black tree? - Black, if the new node is not a root node
- Red, if the new node is not a root node
- Black, if the new node is a root node
- Both b and c
60) Identify the AVL tree among the following options? - A
- C
- Both A and C
- B
Next TopicDS Tutorial |