On This Page

This set of Data Structure DS Multiple Choice Questions & Answers (MCQs) focuses on Data Structure Set 4

Q1 | A circular linked list can be used for
  • stack
  • queue
  • both stack & queue
  • neither stack or queue
Q2 | In doubly linked lists
  • a pointer is maintained to store both next and previous nodes.
  • two pointers are maintained to store next and previous nodes.
  • a pointer to self is maintained for each node.
  • none of the above
Q3 | The disadvantage in using a circular linked list is …………………….
  • it is possible to get into infinite loop
  • last node points to first node.
  • time consuming
  • requires more memory space
Q4 | A linear list in which each node has pointers to point to the predecessor and successors nodes is called as
  • singly linked list
  • circular linked list
  • doubly linked list
  • linear linked list
Q5 | The situation when in a linked list START=NULL is
  • underflow
  • overflow
  • housefull
  • saturated
Q6 | In doubly linked lists, traversal can be performed?
  • only in forward direction
  • only in reverse direction
  • in both directions
  • none of the above
Q7 | What differentiates a circular linked list from a normal linked list?
  • you cannot have the ‘next’ pointer point to null in a circular linked list
  • it is faster to traverse the circular linked list
  • you may or may not have the ‘next’ pointer point to null in a circular linked list
  • head node is known in circular linked list
Q8 | How do you count the number of elements in the circular linked list?
  • public int length(node head){int length = 0;if( head == null)return 0;node temp = head.getnext();while(temp != head){temp = temp.getnext();length++;}return length;}
  • public int length(node head){int length = 0;if( head == null)return 0;node temp = head.getnext();while(temp != null){temp = temp.getnext();length++;}return length;}
  • public int length(node head){int length = 0;if( head == null)return 0;node temp = head.getnext();while(temp != head && temp != null){temp = head.getnext();length++;}return length;}
  • public int length(node head){int length = 0;if( head == null)return 0;node temp = head.getnext();while(temp != head && temp == null){temp = head.getnext();length++;}return length;}
Q9 | public int function(){if(head == null)return Integer.MIN_VALUE;int var;Node temp = head;while(temp.getNext() != head)temp = temp.getNext();if(temp == head){var = head.getItem();head = null;return var;}temp.setNext(head.getNext());var = head.getItem();head = head.getNext();return var;} What is the functionality of the following code? Choose the most appropriate answer.
  • return data from the end of the list
  • returns the data and deletes the node at the end of the list
  • returns the data from the beginning of the list
  • returns the data and deletes the node from the beginning of the list
Q10 | What is the functionality of the following code? Choose the most appropriate answer. public int function(){if(head == null)return Integer.MIN_VALUE;int var;Node temp = head;Node cur;while(temp.getNext() != head){cur = temp;temp = temp.getNext();}if(temp == head){var = head.getItem();head = null;return var;}var = temp.getItem();cur.setNext(head);return var;}
  • return data from the end of the list
  • returns the data and deletes the node at the end of the list
  • returns the data from the beginning of the list
  • returns the data and deletes the node from the beginning of the list
Q11 | How do you insert a node at the beginning of the list?
  • public class insertfront(int data){node node = new node(data, head, head.getnext());node.getnext().setprev(node);head.setnext(node);size++;}
  • public class insertfront(int data){node node = new node(data, head, head);node.getnext().setprev(node);head.setnext(node);size++;}
  • public class insertfront(int data){node node = new node(data, head, head.getnext());node.getnext().setprev(head);head.setnext(node);size++;}
  • public class insertfront(int data){node node = new node(data, head, head.getnext());node.getnext().setprev(node);head.setnext(node.getnext());size++;}
Q12 | What is a dequeue?
  • a queue with insert/delete defined for both front and rear ends of the queue
  • a queue implemented with a doubly linked list
  • a queue implemented with both singly and doubly linked lists
  • a queue with insert/delete defined for front side of the queue
Q13 | Suppose a circular queue of capacity (n – 1) elements is implemented with an array of n elements. Assume that the insertion and deletion operation are carried out using REAR and FRONT as array index variables, respectively. Initially, REAR = FRONT = 0. The conditions to detect queue full and queue empty are
  • full: (rear+1) mod n == front, empty: rear == front
  • full: (rear+1) mod n == front, empty: (front+1) mod n == rear
  • full: rear == front, empty: (rear+1) mod n == front
  • full: (front+1) mod n == rear, empty: rear == front
Q14 | Suppose implementation supports an instruction REVERSE, which reverses the order of elements on the stack, in addition to the PUSH and POP instructions. Which one of the following statements is TRUE with respect to this modified stack?
  • a queue cannot be implemented using this stack.
  • a queue can be implemented where enqueue takes a single instruction and dequeue takes a sequence of two instructions.
  • a queue can be implemented where enqueue takes a sequence of three instructions and dequeue takes a single instruction.
  • a queue can be implemented where both enqueue and dequeue take a single instruction each.
Q15 | Suppose you are given an implementation of a queue of integers. The operations that can be performed on the queue are:i. isEmpty (Q) — returns true if the queue is empty, false otherwise.ii. delete (Q) — deletes the element at the front of the queue and returns its value.iii. insert (Q, i) — inserts the integer i at the rear of the queue.Consider the following function:void f (queue Q) {int i ;if (!isEmpty(Q)) {i = delete(Q);f(Q);insert(Q, i);}}What operation is performed by the above function f ?
  • leaves the queue q unchanged
  • reverses the order of the elements in the queue q
  • deletes the element at the front of the queue q and inserts it at the rear keeping the other elements in the same order
  • empties the queue q
Q16 | Consider the following statements:i. First-in-first out types of computations are efficiently supported by STACKS.ii. Implementing LISTS on linked lists is more efficient than implementing LISTS onan array for almost all the basic LIST operations.iii. Implementing QUEUES on a circular array is more efficient than implementing QUEUESon a linear array with two indices.iv. Last-in-first-out type of computations are efficiently supported by QUEUES.Which of the following is correct?
  • (ii) and (iii) are true
  • (i) and (ii) are true
  • (iii) and (iv) are true
  • (ii) and (iv) are true
Q17 | Which of the following option is not correct?
  • if the queue is implemented with a linked list, keeping track of a front pointer, only rear pointer s will change during an insertion into an non-empty queue.
  • queue data structure can be used to implement least recently used (lru) page fault algorithm and quick short algorithm.
  • queue data structure can be used to implement quick short algorithm but not least recently used (lru) page fault algorithm.
  • both (a) and (c)
Q18 | Consider a standard Circular Queue 'q' implementation (which has the same condition for Queue Full and Queue Empty) whose size is 11 and the elements of the queue are q[0], q[1], q[2].....,q[10]. The front and rear pointers are initialized to point at q[2] . In which position will the ninth element be added?
  • q[0]
  • q[1]
  • q[9]
  • q[10]
Q19 | Overflow condition in linked list may occur when attempting to .............
  • create a node when free space pool is empty
  • traverse the nodes when free space pool is empty
  • create a node when linked list is empty
  • none of these
Q20 | Which of the following is not a type of Linked List ?
  • doubly linked list
  • singly linked list
  • circular linked list
  • hybrid linked list
Q21 | Linked list is generally considered as an example of _________ type of memory allocation.
  • static
  • dynamic
  • compile time
  • none of these
Q22 | Each Node contain minimum two fields one field called data field to store data. Another field is of type _________.
  • pointer to class
  • pointer to an integer
  • pointer to character
  • pointer to node
Q23 | If in a linked list address of first node is 1020 then what will be the address of node at 5th position ?
  • 1036
  • 1028
  • 1038
  • none of these
Q24 | In Circular Linked List insertion of a node involves the modification of ____ links.
  • 3
  • 4
  • 1
  • 2
Q25 | If a list contains no elements it is said to be
  • hollow
  • empty
  • finite
  • infinite