The data structure name indicates itself by organizing the data in memory. There are many ways of organizing the data in the memory as we have already seen one of the data structures.

The data structure is not any programming language like C, C++, java, etc. It is a set of algorithms that we can use in any programming language to structure the data in the memory.

### Data Structures and Algorithms MCQs

*Before moving on to the Data Structures and Algorithms MCQs you can Test your Data Structure skills by taking this Data Structures and Algorithms Mock Test designed by experienced mentors at PrepBytes.*

**1. 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

**Answer**: 3

Explanation: The answer is Queue. Queue is a data structure in which insertion takes place from one end, and deletion takes place from one end.

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

- rear = front
- rear = front+1
- rear=MAX_SIZE -1
- rear = MAX_SIZE

**Answer**: 3

**Explanation**: The answer is c, i.e., rear=MAX_SIZE-1. As the size of the array is MAX_SIZE, we can insert the elements till MAX_SIZE-1. If we try to insert the elements of size MAX_SIZE or more than MAX_SIZE in a queue, then it leads to the overflow condition.

**3. 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

**Answer**: 3

**Explanation**: The answer is c. If the queue is implemented using a linked list, then the new element will be inserted at the tail position of the linked list as Queue follows FIFO principle in which a new element will always be added at the end of the Queue.

**4. How many Queues are required to implement a Stack?**

- 3
- 2
- 1
- 4

Answer: 2

Explanation: The answer is b because one queue is required to perform the push operation while the other queue is used to perform the pop operation.

**5. The necessary condition to be checked before deletion from the Queue is___**

- Overflow
- Underflow
- Rear value
- Front value

**Answer**: 2

**Explanation**: The answer is b, i.e., Underflow. Before deleting an element from the Queue, we first need to check whether the Queue is empty or not.

**6. 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

**Answer**: 2

**Explanation**: The answer is b because Stack does not follow FIFO. It follows LIFO.

**7. 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

**Answer**: 2

**Explanation**: The answer is b because the size of int type data is 4 bytes. The array stores 9 elements, so the size of the array is 9*4=36 bytes.

**8. Which one of the following is the process of inserting an element in the stack?**

- Insert
- Add
- Push
- None of the above

**Answer**: 3

**Explanation**: The answer is c. In stack, the process of inserting an element is known as a push operation.

**9. Which data structure is required to convert the infix to prefix notation?**

- Stack
- Linked list
- Binary tree
- Queue

**Answer**: 1

**Explanation**: The answer is a, i.e., stack. Stack is a data structure used to reverse the order of the operators in the expression. It is also used as a storage structure that stores all the operators and prints all the operators when all the operands have appeared.

*Data Structures and Algorithms is an important part of Programming. Get a better understanding of problems by watching these video tutorials created by expert mentors at Prepbytes.*

**10. Which of the following determines the need for the Circular Queue?**

- Avoid wastage of memoryPrepBytes Mock Test
- Access the Queue using priority
- Follows the FIFO principle
- None of the above

**Answer**: 1

**Explanation**: The answer is, i.e., Avoid wastage of memory. In a linear queue, there are chances of wastage of memory because if the rear is pointing to the last element whereas the front is pointing to the element other than the first element; it means that spaces allocated before the front are free, but it cannot be reused as rear cannot be incremented. In contrast, the last element is connected to the first element in a circular queue; if initial spaces are vacant, then the rear can be incremented by using the statement (rear+1) mod max where max is the size of the array. Therefore, we conclude that the circular queue avoids wastage of memory.

**11. Which of the following data structures allows you to insert the elements from both the ends while deleting from only one end?**

- Input-restricted queue
- Output-restricted queue
- Priority queue
- None of the above

**Answer**: b

**Explanation**: The answer is b. The output-restricted queue is one of the types of the Deque data structure in which insertion is allowed from both ends but deletion is allowed from only one end.

**12. What would be the time complexity if the 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)

**Answer**: 2

**Explanation**: The answer is b, i.e., O(n). As it is mentioned in the above question that the head pointer is known, so to insert the node at the end of the linked list; we have to traverse till the nth node. Therefore, the time complexity would be O(n).

**13. Consider the following code**

```
struct node
{
int data;
struct node *next;
}
node ptr;
```

**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

**Answer**: 3

**Explanation**: The answer is c, i.e., ptr=(node * )malloc(sizeof(node)). In this statement, we have used a malloc() function for allocating the memory to the node and ptr is a pointer variable that will point to the newly created node.

**14. Which one of the following techniques is not used in the Binary tree?**

- Randomized traversal
- Preorder traversal
- Postorder traversal
- Inorder traversal

**Answer**: a

**Explanation**: The answer is a. The binary tree contains three traversal techniques, preorder, postorder and inorder traversal.

**15. Quick sort running time depends on the selection of**

- Size of array
- Pivot element
- Sequence of values
- None of the above!

**Answer**: 2

**Explanation**:

If the pivot element is balanced, quick sort running time will be less.

We tried to discuss Data Structures and Algorithms MCQs. We hope this article gives you a better understanding of the above question. Prepbytes also provides a good collection of Foundation Courses that can help you enhance your coding skills. Want to make sure you ace the interview in one go? Join our Placement Program that will help you get prepared and land your dream job at MNCs. Mentors of Prepbytes are highly experienced and can provide you with basic, in-depth subject knowledge for better understanding.

Hy, This article have written in good manner and it also fabulous. Through this we can learn many things without wasting our time to searching the Explanation.