banner



D All Of The Above

next → ← prev

Data Structure MCQ

i) How tin we describe an array in the all-time possible way?

  1. The Array shows a hierarchical structure.
  2. Arrays are immutable.
  3. Container that stores the elements of like types
  4. The Assortment is not a data construction

Answer: c

Caption: The answer is c because array stores the elements in a contiguous block of retention of similar types. Therefore, nosotros can say that array is a container that stores the elements of like types.


two) Which of the following is the right style of declaring an assortment?

  1. int javatpoint[x];
  2. int javatpoint;
  3. javatpoint{20};
  4. array javatpoint[10];

Answer: a

Explanation: The answer is a because int specifies the blazon of the assortment, javatpoint is the proper noun of the array, and ten is the size of the array enclosed within the foursquare brackets.


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

  1. int arr[2]=(x, 20)
  2. int arr(two)={10, twenty}
  3. int arr[2] = {10, 20}
  4. int arr(2) = (ten, 20)

Answer: c

Explanation: The answer is c because the values assigned to the array must be enclosed within a curly bracket.


four) Which of the following is the advantage of the array data construction?

  1. Elements of mixed data types can be stored.
  2. Easier to access the elements in an array
  3. Index of the first chemical element starts from 1.
  4. Elements of an array cannot be sorted

Answer: b

Explanation: The answer is b considering the elements in an array are stored in a contiguous block of memory, so information technology is easier to access the elements of an assortment through indexing.


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

  1. Binary Search tree
  2. Caching
  3. Spatial locality
  4. Scheduling of Processes

Answer: c

Explanation: The answer is c, i.due east., Spatial locality. Here, spatial locality means that the instruction accessed recently, so the nearby memory location would exist accessed in the adjacent iteration. As nosotros know that in an assortment, all the elements are stored in a contiguous cake of memory, so spatial locality is accessed rapidly.


half dozen) Which of the following is the disadvantage of the array?

  1. Stack and Queue data structures can be implemented through an array.
  2. Alphabetize of the starting time element in an array can be negative
  3. Wastage of retention if the elements inserted in an array are bottom than the allocated size
  4. Elements can exist accessed sequentially.

Answer: c

Explanation: The reply is c. For instance, if we have an array of size x elements and we accept inserted only 5 elements in an assortment then there is a wastage of 5 memory blocks which cannot be utilized past another variable.


7) What is the output of the below code?

  1. Garbage value
  2. x
  3. l
  4. None of the to a higher place

Respond: a

Explanation: The answer is a because the indexing in an array starts from 0, so it starts from arr[0] to arr[4]. If we endeavor to access arr[five] then the garbage value will be printed.


eight) Which one of the following is the size of int arr[ix] bold that int is of iv bytes?

  1. nine
  2. 36
  3. 35
  4. None of the to a higher place

Answer: b

Caption: The answer is b because the size of int blazon information is iv bytes. The array stores nine elements, so the size of the assortment is nine*iv=36 bytes.


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

  1. Insert
  2. Add
  3. Push
  4. None of the in a higher place

Answer: c

Caption: The respond is c. In stack, the process of inserting an element is known equally a push operation.


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

  1. Underflow
  2. Garbage collection
  3. Overflow
  4. None of the to a higher place

Answer: a

Explanation: The answer is a. Underflow is a condition that occurs when user tries to implement the pop operation in the empty stack.


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

  1. Underflow
  2. Garbage collection
  3. Overflow
  4. None of the above

Answer: c

Explanation: The respond is c because the stack is total with its x elements, and inserting 1 more than element in a stack volition lead to the stack overflow.


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

  1. String reversal
  2. Recursion
  3. Backtracking
  4. Asynchronous data transfer

Reply: d

Caption: The respond is d. The showtime iii options are the stack applications, merely choice d is non a stack application. The queue data structure is used for synchronization between the processes.


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

  1. Queue
  2. Stack
  3. Binary tree
  4. Linked listing

Answer: b

Explanation: The answer is b. Recursion means calling the role itself again. Stack is used to maintain the previous records of the function.


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

  1. Stack
  2. Linked list
  3. Binary tree
  4. Queue

Answer: a

Caption: The reply is a, i.e., stack. Stack is a data structure used to reverse the society of the operators in the expression. Information technology is also used as a storage structure that stores all the operators and print all the operators when all the operands accept appeared.


fifteen) Which of the following is the infix expression?

  1. A+B*C
  2. +A*BC
  3. ABC+*
  4. None of the higher up

Reply: a

Explanation: The answer is a, i.e., A+B*C because, in infix notation, all the operators appear between the operands.


16) Which of the post-obit is the prefix form of A+B*C?

  1. A+(BC*)
  2. +AB*C
  3. ABC+*
  4. +A*BC

Reply: d

Explanation: The answer is d. The prefix notation ways all the operators that appear earlier operand.

To convert the infix expression into a prefix expression, we will motility the operator to the left of the parenthesis as shown in the below effigy.


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

  1. Arrays can be used to implement the stack
  2. Stack follows FIFO
  3. Elements are stored in a sequential way
  4. Top of the stack contains the last inserted element

Answer: b

Caption: The reply is b because Stack does non follow FIFO. It follows LIFO.


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

  1. 1234
  2. 2134
  3. 4321
  4. None of the above

Answer: c

Explanation: The answer is c considering stack follows LIFO, which means that the chemical element inserted at the terminal will be removed outset.


nineteen) What is the outcome of the prefix expression +, -, *, 3, 2, /, eight, four, ane?

  1. 12
  2. 11
  3. v
  4. 4

Answer: c

Explanation: Reverse of the prefix expression: 1, 4, 8, /, 2, 3, *, -, +

Reading of prefix Top of the stack Stack representation
ane 1 Data Structure MCQ
4 4 Data Structure MCQ
8 8 Data Structure MCQ
/ (8/four) Data Structure MCQ
2 ii Data Structure MCQ
3 3 Data Structure MCQ
* (2*iii) Data Structure MCQ
- (2*iii) - (8/4) Data Structure MCQ
+ (two*iii) - (viii/4) +i Data Structure MCQ

The infix expression of the to a higher place prefix expression is:

(2*3) - (eight/4) +1

six -2 +1 = 5


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

  1. i
  2. three
  3. 2
  4. five

Respond: c

Explanation: The answer is 2. In Queue, one stack is required for the enqueue operation, and another stack will be used for the dequeue operation. The first stack is considered as the input stack whereas the second stack is considered as the output stack.


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

  1. First node
  2. Second node
  3. Terminal node
  4. None of the to a higher place

Answer: a

Explanation: The answer is a, i.east., Showtime node. As we know, that final inserted element in the stack is considered every bit the tiptop of the stack. Whenever the chemical element is added to the linked list, it is always added at the offset of the list. Therefore, nosotros can say that the first node in the linked list is considered as the acme of the stack.


22) Consider the post-obit stack implemented using stack.

What would exist the maximum value of the top that does non cause the overflow of the stack?

  1. 8
  2. 9
  3. eleven
  4. 10

Answer: d

Caption: The respond is 10. The maximum size of the array is 11; therefore, we tin insert eleven elements in the stack. The top value is initialized by -one, and on every insertion, the tiptop value gets incremented.


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

  1. Square buffer
  2. Rectangle buffer
  3. Ring buffer
  4. None of the above

Answer: c

Explanation: The circular queue is also known as a ring buffer. In a circular queue, the concluding element is continued back to the first element of the queue that forms a circumvolve. Therefore, the construction of a circular queue is also known as a ring structure.


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

  1. 1234
  2. 4321
  3. 3241
  4. None of the above

Answer: a

Explanation: The answer is a, i.e., 1234. The queue follows the FIFO principle in which the element inserted offset volition be removed first.


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

  1. Binary tree
  2. Stack
  3. Queue
  4. Linked list

Reply: c

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


26) Which of the following principle does Queue use?

  1. LIFO principle
  2. FIFO principle
  3. Linear tree
  4. Ordered assortment

Reply: b

Explanation: The respond is FIFO principle. Here, FIFO stands for Start-In-Beginning-Out. Information technology means that the chemical element which is inserted first volition also exist removed first.


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

  1. Linear Queue
  2. Circular Queue
  3. Double ended Queue
  4. Single ended Queue

Answer: d

Explanation: The answer is d. i.e., single concluded queue. Queue has 2 ends in which ane end is used for the insertion and another end is used for the deletion. Therefore, information technology is not possible for the Queue to take a single ended queue.


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

  1. rear = forepart
  2. rear = front+1
  3. rear=MAX_SIZE -one
  4. rear = MAX_SIZE

Answer: c

Explanation: The respond is c, i.e., rear=MAX_SIZE-i. As the size of the array is MAX_SIZE, so we tin insert the elements till MAX_SIZE-ane. If nosotros attempt to insert the elements of size MAX_SIZE or more than MAX_SIZE in a queue, and then it leads to the overflow status.


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

  1. rear= MAX-ane
  2. rear=MAX
  3. forepart=(rear+one) mod max
  4. None of the above

Reply: c

Caption: The respond is c, i.eastward., front=(rear+1) modernistic max. The overflow status for the linear queue is rear =MAX-1 as in that location is no infinite left in the Queue if rear = MAX-1. On the other manus, in a circular queue, the overflow condition is front=(rear+1) modern max because the concluding element is connected to the showtime element in a circular queue.


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

  1. O(i)
  2. O(north)
  3. O(logn)
  4. O(nlogn)

Reply: a

Explanation: The answer is a, i.due east., O(ane). In Queue, the insertion is performed at the rear end, which is straight accessible; therefore, it takes O(1) time to insert an element in a Queue.


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

  1. Avoid wastage of memory
  2. Admission the Queue using priority
  3. Follows the FIFO principle
  4. None of the above

Reply: a

Caption: The reply is a, i.e., Avoid wastage of retentiveness. In a linear queue, at that place are chances of wastage of memory because if the rear is pointing to the concluding element whereas the forepart is pointing to the element other than the offset element; it means that spaces allocated before the front are free, but it cannot be reused every bit rear cannot be incremented. In contrast, the final element is connected to the beginning element in a round queue; if initial spaces are vacant, then rear tin can exist incremented past using the statement (rear+1) mod max where max is the size of the array. Therefore, nosotros conclude that the circular queue avoids wastage of memory.


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

  1. rear =rear+1
  2. (rear+one) % max
  3. (rear % max) + i
  4. None of the above

Answer: b

Explanation: The answer is b. It ensures that the rear will have the value from 0 to max-1; if the rear stop points to the final position, and we increment the rear end using (rear+i) % max, then rear volition signal to the first position in the queue.


33) Consider the following lawmaking.

Which functioning does the above code perform?

  1. Enqueue
  2. Dequeue
  3. Render the front element
  4. Both b and c

Respond: d

Explanation: The answer is d because 2 operations are performed in the higher up lawmaking. The first 1 is returning the value of the front with the help of the statement n=q[front], and the second operation is dequeue (deleting an element) past using the statement front++.


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

  1. At the heart position of the linked list
  2. At the caput position of the linked listing
  3. At the tail position of the linked list
  4. None of the in a higher place

Answer: c

Explanation: The reply is c. If the queue is implemented using linked list, so the new chemical element will be inserted at the tail position of the linked list equally Queue follows FIFO principle in which new chemical element volition ever exist added at the terminate of the Queue.


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

  1. 3
  2. 2
  3. 1
  4. 4

Answer: b

Explanation: The answer is b considering i queue is required to perform the push operation while the other queue is used to perform the popular operation.


36) Which 1 of the following is not the awarding of the Queue data construction?

  1. Resource shared between various systems
  2. Data is transferred asynchronously
  3. Load balancing
  4. Balancing of symbols

Answer: d

Explanation:

The respond is d. The options a, b, and c are the applications of the Queue data structure while selection d, i.due east., balancing of symbols is non the application of the Queue information structure. The option a, i.e., resource shared between diverse system is the application of the Queue data structure every bit it allows to align all the requests for the resource in a queue. The pick b, i.eastward., information is transferred asynchronously is a awarding of the Queue data structure. Here asynchronously ways that the data received at the different rate as sent.

The selection c, i.e., load balancing is likewise an application of the Queue data structure considering all the requests from the client are stored in the Queue, and it distributes the requests to the client i by i.

The pick d, i.e., balancing of symbols is an application of the stack information structure.


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

  1. In enqueue operation, new nodes are inserted from the beginning and in dequeue operation, nodes are removed from the stop.
  2. In enqueue operation, new nodes are inserted from the stop and in dequeue operation, nodes are deleted from the starting time.
  3. In enqueue performance, new nodes are inserted from the end and in dequeue functioning, nodes are deleted from the end.
  4. Both a and b

Answer: d

Caption: The answer is d. Equally we know that Queue has ii ends, i.e., one for the insertion and some other one for the deletion. If Queue is implemented using Linked listing so it can be washed in either of the means.


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

  1. Overflow
  2. Underflow
  3. Rear value
  4. Forepart value

Respond: b

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


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

  1. Stack
  2. Linked list
  3. Array
  4. Heap

Respond: d

Explanation: The answer is d, i.due east., Heap. All the data structures that are given in the higher up options tin be used to implement a priority queue but the most efficient manner of implementing a priority queue is heap data structure.


forty) Which of the following principle is used if two elements in the priority queue accept the aforementioned priority?

  1. LIFO
  2. FIFO
  3. Linear tree
  4. None of the higher up

Answer: b

Caption: The answer is b, i.e., FIFO. In a priority queue, if two or more elements have the same priority and then they are arranged based on the FIFO principle.


41) Which of the following argument is non truthful regarding the priority queue?

  1. Processes with unlike priority can exist easily handled
  2. Easy to implement
  3. Deletion is easier
  4. None of the higher up

Answer: c

Explanation: The respond is c. i.e., deletion is easier. In worst instance, the deletion is not easier as we have to traverse to the n elements until the element to be removed is non constitute.


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

  1. Queue
  2. Deque
  3. Priority queue
  4. Circular queue

Answer: b

Explanation: The respond is b, i.eastward., Deque. The deque is a data construction in which both insertion and deletion can be performed from both the ends whereas, in Queue, insertion tin can be washed from ane finish and deletion can be performed from some other cease.


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

  1. O(1)
  2. O(n2)
  3. O(due north)
  4. O(nlogn)

Answer: O(n)

Explanation: The answer is O(n) considering we need to traverse till the n element to delete the chemical element from the rear end.


44) Which of the following data structure allows yous to insert the elements from both the ends while deletion from only 1 cease?

  1. Input-restricted queue
  2. Output-restricted queue
  3. Priority queue
  4. None of the above

Answer: b

Explanation: The answer is b. The output-restricted queue is one of the types of the Deque information structure in which insertion is immune from both the ends but the deletion is allowed from just ane end.


45) What would be the output afterward performing the post-obit operations in a Deque?

  1. ten, 20, xxx
  2. 50, 10, thirty
  3. 40, xx, xxx
  4. None of the above

Answer: b

Explanation:

The answer is b.

Permit's dry run the to a higher place lawmaking.

When insertfront(10) is chosen, 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 thirty

When insertrear(twoscore) is called, the deque would exist:

20 10 30 40

When deletefront() is called, the deque would be:

10 xxx xl

When insertfront(fifty) is called, the deque would be:

50 10 30 40

When deleterear() is chosen, 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 forepart and rear values are 3 and 4 respectively. Determine the array index at which the insertion of the adjacent chemical element will take place.

  1. 5
  2. 0
  3. 1
  4. ii

Reply: b

Explanation: The answer is b, i.e., 0. As it is mentioned in the question that the size of the array is 5; therefore, the range would exist from 0 to 4. In a circular queue, the terminal element is connected to the first element; the value of rear is four so when we increment the value then it volition indicate to the 0th position of the array.


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

  1. Front=rear= -1
  2. Front=rear=0
  3. Front=rear+1
  4. None of the to a higher place

Answer: a

Explanation: The answer is a, i.e., front=rear= -1. When the round queue is empty ways that no element is available in the queue and then the forepart and rear are initialized with a -1 value.


48) Consider the implementation of the singly linked listing having the head pointer merely in the representation. Which of the following operations can be performed in O(1) fourth dimension?

i) Deletion of the last node in the linked list
ii) Insertion at the front end of the linked listing
three) Deletion of the commencement node in the linked list
4) Insertion at the cease of the linked listing

  1. ii
  2. both 2 and iii
  3. both i and iv
  4. both i and two

Answer: b

Explanation: The answer is b. As it is mentioned in the to a higher place question that at that place is only head pointer pointing to the front node in the list so information technology will take O(i) fourth dimension to insert at the front as well equally to delete the commencement node from the list. If nosotros endeavour to insert the node at the end or delete the last node and so it will accept O(northward) time equally we demand to traverse till the n elements.


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

  1. O(1)
  2. O(northward)
  3. O(logn)
  4. O(nlogn)

Answer: b

Explanation: The reply is b, i.e., O(north). Equally information technology is mentioned in the to a higher place question that head pointer is known, then to insert the node at the end of the linked list; we accept to traverse till the nth node. Therefore, the time complexity would be O(northward).


50) Which of the post-obit is the time complexity to search an element in the linked listing?

  1. O(ane)
  2. O(n)
  3. O(logn)
  4. O(nlogn)

Answer: O(north)

Explanation: The respond is O(n). The worst-instance time complexity to search an element in the linked list is O(n) considering if nosotros have to find the final element then we demand to traverse till the nth node.


51) Consider the following lawmaking

Which i of the following is the right selection to create a new node?

  1. ptr= (node*)malloc(sizeof(node*))
  2. ptr=(node)malloc(sizeof(node))
  3. ptr=(node*)malloc(sizeof(node))
  4. None of the above

Respond: c

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


52) Which of the following argument is not true well-nigh the doubly linked list?

  1. We tin can traverse in both the directions.
  2. It requires extra space
  3. Implementation of doubly linked list is easier than the singly linked list
  4. It stores the addresses of the side by side and the previous node

Answer: c

Explanation: The answer is c. The implementation of doubly linked list is complex as compared to singly linked listing as information technology needs to store the addresses of the two nodes, i.eastward., the previous and the next node. If nosotros insert or delete the node from the doubly linked listing and so information technology needs to adapt two pointers, previous and the next pointer.


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

  1. 3
  2. one
  3. 4
  4. 2

Reply: d

Explanation: The answer is d. The binary tree can contain utmost two children.


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

  1. Randomized traversal
  2. Preorder traversal
  3. Postorder traversal
  4. Inorder traversal

Answer: a

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


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

  1. The value of the left child should be less than the root node
  2. The value of the right child should be greater than the root node.
  3. The left and right sub trees should also be a binary search tree
  4. None of the to a higher place

Answer: d

Caption: The answer is d. All the three options, i.e., a, b and c are true for the binary search tree. In binary search tree, the left kid should be less than the root node and the correct child should exist greater than the value of the root node.


56) How can we define a AVL tree?

  1. A tree which is binary search tree and height counterbalanced tree.
  2. A tree which is a binary search tree only unbalanced tree.
  3. A tree with utmost two children
  4. A tree with utmost 3 children

Answer: a

Explanation: The answer is a. An AVL tree is a binary search tree and tiptop balanced tree.


57) Why do we adopt Blood-red Black tree over AVL tree?

  1. Red Black trees are non strictly balanced
  2. Ruby black tree requires lesser rotations than AVL tree.
  3. AVL tree needs more than space to store the residuum factor.
  4. Both b and c

Answer: d

Explanation: The answer is d. Blood-red Black tree requires fewer rotations for inserting or deleting the node whereas AVL tree requires multiple rotations to balance the tree. AVL tree stores balance factor per node that requires space whereas Red Black tree stores 1-bit information.


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

  1. A tree which is a binary search tree but not strictly counterbalanced tree.
  2. A node must be either Red or Black in color and root node must be black.
  3. A tree with maximum three children
  4. Both a and b

Reply: d

Explanation: The answer is d. Cerise black tree is a binary search tree but it is not a strictly balanced tree like AVL tree. In Red Blackness tree, a node must be either in Black or Carmine in color and root node must be in Blackness color.


59) What would exist the colour of newly created node while inserting a new element in a Cherry-red blackness tree?

  1. Black, if the new node is non a root node
  2. Reddish, if the new node is non a root node
  3. Black, if the new node is a root node
  4. Both b and c

Reply: d

Explanation: The respond is d. The belongings of Red Black tree is that if the newly created node is a root node then the color of the node would be Black otherwise the color of the node would be Ruddy.


lx) Identify the AVL tree among the post-obit options?

Data Structure MCQ
Data Structure MCQ
Data Structure MCQ
  1. A
  2. C
  3. Both A and C
  4. B

Respond: c

Explanation: The answer is c. Both A and C are the AVL trees but B is non a AVL tree. Equally we know that remainder factor of every node in AVL tree should exist either -ane, 0 or 1. But in case of B, the residue factor of node eighty is 2, so it is non a AVL tree.


Adjacent Topic DS Tutorial

← prev side by side →

D All Of The Above,

Source: https://www.javatpoint.com/data-structure-mcq

Posted by: grigsbyseethe.blogspot.com

0 Response to "D All Of The Above"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel