Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Given only a single array of size 10 and no other memory is available. Which of the following operation is not feasible to implement (Given only push and pop operation)?(a) Push(b) Pop(c) Enqueue(d) ReturntopQuery is from Queue using Stacks topic in portion Abstract Data Types of Data Structures & Algorithms II have been asked this question in an interview for internship.

Answer» RIGHT choice is (c) Enqueue

The best explanation: To perform Enqueue using just push and pop OPERATIONS, there is a NEED of another ARRAY of same size. But as there is no extra available memeory, the given operation is not feasible.
2.

Why is implementation of stack operations on queues not feasible for a large dataset (Asssume the number of elements in the stack to be n)?(a) Because of its time complexity O(n)(b) Because of its time complexity O(log(n))(c) Extra memory is not required(d) There are no problemsThis key question is from Queue using Stacks topic in portion Abstract Data Types of Data Structures & Algorithms II have been asked this question in homework.

Answer»

The CORRECT answer is (a) Because of its time complexity O(N)

The explanation is: To perform Queue operations such as enQueue and deQueue there is a need of EMPTYING all the elements of a current stack and pushing elements into the NEXT stack and vice versa. Therfore it has a time complexity of O(n) and the need of extra stack as well, may not be FEASIBLE for a large dataset.

3.

What is the time complexity to insert a node based on position in a priority queue?(a) O(nlogn)(b) O(logn)(c) O(n)(d) O(n^2)My query is from Priority Queue in portion Abstract Data Types of Data Structures & Algorithms II have been asked this question in quiz.

Answer»

Right option is (c) O(n)

The explanation is: In the WORST CASE, you MIGHT have to TRAVERSE the ENTIRE list.

4.

Which of the following is not an advantage of a priority queue?(a) Easy to implement(b) Processes with different priority can be efficiently handled(c) Applications with differing requirements(d) Easy to delete elements in any caseThis is a very interesting question from Priority Queue topic in chapter Abstract Data Types of Data Structures & Algorithms II got this question in examination.

Answer»

The correct answer is (d) EASY to DELETE elements in any case

For explanation: In worst case, the entire QUEUE has to be searched for the element having the HIGHEST priority. This will take more time than usual. So deletion of elements is not an ADVANTAGE.

5.

Which of the following is true about linked list implementation of queue?(a) In push operation, if new nodes are inserted at the beginning of linked list, then in pop operation, nodes must be removed from end(b) In push operation, if new nodes are inserted at the beginning, then in pop operation, nodes must be removed from the beginning(c) In push operation, if new nodes are inserted at the end, then in pop operation, nodes must be removed from end(d) In push operation, if new nodes are inserted at the end, then in pop operation, nodes must be removed from beginningMy question is taken from Queue using Linked List in portion Abstract Data Types of Data Structures & Algorithms II got this question in class test.

Answer»

The CORRECT ANSWER is (a) In push operation, if NEW nodes are inserted at the beginning of LINKED list, then in pop operation, nodes must be removed from end

The best explanation: It can be done by both the METHODS.

6.

The essential condition which is checked before deletion in a linked queue is?(a) Underflow(b) Overflow(c) Front value(d) Rear valueThe question is from Queue using Linked List in division Abstract Data Types of Data Structures & Algorithms IThis question was posed to me in an online interview.

Answer»

Correct OPTION is (a) Underflow

Explanation: To CHECK WHETHER there is element in the LIST or not.

7.

The essential condition which is checked before insertion in a linked queue is?(a) Underflow(b) Overflow(c) Front value(d) Rear valueI'm obligated to ask this question of Queue using Linked List in division Abstract Data Types of Data Structures & Algorithms IThis question was posed to me by my college professor while I was bunking the class.

Answer»

The CORRECT answer is (b) Overflow

Explanation: To CHECK WHETHER there is space in the queue or not.

8.

In linked list implementation of a queue, the important condition for a queue to be empty is?(a) FRONT is null(b) REAR is null(c) LINK is empty(d) FRONT==REAR-1This interesting question is from Queue using Linked List in portion Abstract Data Types of Data Structures & Algorithms II got this question during an interview.

Answer» CORRECT CHOICE is (a) FRONT is null

Explanation: Because front REPRESENTS the deleted NODES.
9.

In linked list implementation of a queue, from where is the item deleted?(a) At the head of link list(b) At the centre position in the link list(c) At the tail of the link list(d) Node before the tailOrigin of the question is Queue using Linked List topic in section Abstract Data Types of Data Structures & Algorithms II had been asked this question during an internship interview.

Answer»

Correct ANSWER is (a) At the head of link list

Easy explanation - SINCE QUEUE follows FIFO so NEW element deleted from first.

10.

In case of insertion into a linked queue, a node borrowed from the __________ list is inserted in the queue.(a) AVAIL(b) FRONT(c) REAR(d) NULLMy question is from Queue using Linked List in section Abstract Data Types of Data Structures & Algorithms IThe question was posed to me in an international level competition.

Answer»

The CORRECT choice is (a) AVAIL

The BEST I can explain: All the NODES are collected in AVAIL list.

11.

In linked list implementation of a queue, front and rear pointers are tracked. Which of these pointers will change during an insertion into EMPTY queue?(a) Only front pointer(b) Only rear pointer(c) Both front and rear pointer(d) No pointer will be changedThis intriguing question originated from Queue using Linked List topic in portion Abstract Data Types of Data Structures & Algorithms IThis question was posed to me in quiz.

Answer»

Correct choice is (c) Both FRONT and rear pointer

To EXPLAIN: SINCE its the STARTING of queue, so both values are changed.

12.

In linked list implementation of a queue, front and rear pointers are tracked. Which of these pointers will change during an insertion into a NONEMPTY queue?(a) Only front pointer(b) Only rear pointer(c) Both front and rear pointer(d) No pointer will be changedThis interesting question is from Queue using Linked List topic in portion Abstract Data Types of Data Structures & Algorithms II have been asked this question in semester exam.

Answer» CORRECT answer is (b) Only rear pointer

Easiest explanation - Since QUEUE follows FIFO so NEW element inserted at last.
13.

In linked list implementation of a queue, where does a new element be inserted?(a) At the head of link list(b) At the centre position in the link list(c) At the tail of the link list(d) At any position in the linked listI want to ask this question from Queue using Linked List topic in portion Abstract Data Types of Data Structures & Algorithms IThis question was posed to me in homework.

Answer»

Right option is (C) At the tail of the LINK list

The explanation is: SINCE QUEUE FOLLOWS FIFO so new element inserted at last.

14.

In linked list implementation of queue, if only front pointer is maintained, which of the following operation take worst case linear time?(a) Insertion(b) Deletion(c) To empty a queue(d) Both Insertion and To empty a queueMy question is taken from Queue using Linked List topic in portion Abstract Data Types of Data Structures & Algorithms II got this question during an interview for a job.

Answer» RIGHT OPTION is (d) Both Insertion and To empty a queue

The best I can explain: Since front pointer is used for DELETION, so worst TIME for the other two cases.
15.

Minimum number of queues to implement stack is ___________(a) 3(b) 4(c) 1(d) 2My query is from Stack using Linked List in chapter Abstract Data Types of Data Structures & Algorithms IThe question was asked in homework.

Answer»

Correct choice is (c) 1

Easy EXPLANATION - Use ONE queue and one counter to COUNT the number of ELEMENTS in the queue.

16.

Which of the following array element will return the top-of-the-stack-element for a stack of size N elements(capacity of stack > N)?(a) S[N-1](b) S[N](c) S[N-2](d) S[N+1]The question is from Stack using Array in portion Abstract Data Types of Data Structures & Algorithms IThe question was posed to me in an online interview.

Answer» CORRECT option is (a) S[N-1]

Best explanation: Array INDEXING start from 0, hence N-1 is the LAST INDEX.
17.

Array implementation of Stack is not dynamic, which of the following statements supports this argument?(a) space allocation for array is fixed and cannot be changed during run-time(b) user unable to give the input for stack operations(c) a runtime exception halts execution(d) improper program compilationMy question comes from Stack using Array topic in division Abstract Data Types of Data Structures & Algorithms IThe question was posed to me in my homework.

Answer» RIGHT option is (a) space allocation for array is FIXED and cannot be changed during run-time

For explanation: You cannot modify the SIZE of an array once the MEMORY has been allocated, ADDING fewer elements than the array size would cause wastage of space, and adding more elements than the array size at run time would cause Stack Overflow.
18.

What happens when you pop from an empty stack while implementing using the Stack ADT in Java?(a) Undefined error(b) Compiler displays a warning(c) EmptyStackException is thrown(d) NoStackException is thrownMy query is from Stack using Array topic in portion Abstract Data Types of Data Structures & Algorithms IThis question was addressed to me during an internship interview.

Answer»

Right CHOICE is (c) EMPTYSTACKEXCEPTION is thrown

For EXPLANATION: The Stack ADT THROWS an EmptyStackException if the stack is empty and a pop() operation is tried on it.

19.

Which of the following array position will be occupied by a new element being pushed for a stack of size N elements(capacity of stack > N)?(a) S[N-1](b) S[N](c) S[1](d) S[0]This intriguing question originated from Stack using Array in chapter Abstract Data Types of Data Structures & Algorithms II had been asked this question during a job interview.

Answer»

Right ANSWER is (B) S[N]

Explanation: ELEMENTS are pushed at the end, HENCE N.

20.

What is the time complexity of pop() operation when the stack is implemented using an array?(a) O(1)(b) O(n)(c) O(logn)(d) O(nlogn)My enquiry is from Stack using Array in division Abstract Data Types of Data Structures & Algorithms II have been asked this question in an interview for job.

Answer»

The correct answer is (a) O(1)

The BEST I can explain: pop() accesses only one END of the structure, and HENCE CONSTANT time.

21.

Which of the following real world scenarios would you associate with a stack data structure?(a) piling up of chairs one above the other(b) people standing in a line to be serviced at a counter(c) offer services based on the priority of the customer(d) tatkal Ticket Booking in IRCTCEnquiry is from Stack using Array in division Abstract Data Types of Data Structures & Algorithms II have been asked this question in examination.

Answer»

Correct option is (a) piling up of chairs one above the other

Best explanation: Stack follows Last In First Out (LIFO) POLICY. Piling up of chairs one above the other is based on LIFO, people standing in a line is a queue and if the service is based on priority, then it can be associated with a priority queue. Tatkal Ticket Booking Follows First in First Out Policy. People who CLICK the book now first will enter the booking page first.

22.

Consider a small circular linked list. How to detect the presence of cycles in this list effectively?(a) Keep one node as head and traverse another temp node till the end to check if its ‘next points to head(b) Have fast and slow pointers with the fast pointer advancing two nodes at a time and slow pointer advancing by one node at a time(c) Cannot determine, you have to pre-define if the list contains cycles(d) Circular linked list itself represents a cycle. So no new cycles cannot be generatedThis question is from Circular Linked List in section Abstract Data Types of Data Structures & Algorithms II had been asked this question during an online exam.

Answer»

Correct choice is (b) Have fast and slow pointers with the fast pointer advancing two nodes at a time and slow pointer advancing by one NODE at a time

Best EXPLANATION: Advance the pointers in such a WAY that the fast pointer advances two nodes at a time and slow pointer advances one node at a time and check to see if at any given instant of time if the fast pointer points to slow pointer or if the fast pointer’s ‘next’ points to the slow pointer. This is applicable for smaller LISTS.

23.

In the worst case, the number of comparisons needed to search a singly linked list of length n for a given element is?(a) log2 n(b) ^n⁄2(c) log2 n – 1(d) nThe above asked question is from Singly Linked List Operations topic in portion Abstract Data Types of Data Structures & Algorithms IThe question was asked in quiz.

Answer» CORRECT answer is (d) n

The BEST I can explain: The worst-case happens if the REQUIRED ELEMENT is at last or the element is absent in the list. For this, we need to compare every element in the linked list. If n elements are there, n COMPARISONS will happen in the worst case.
24.

You are given pointers to first and last nodes of a singly linked list, which of the following operations are dependent on the length of the linked list?(a) Delete the first element(b) Insert a new element as a first element(c) Delete the last element of the list(d) Add a new element at the end of the listThis intriguing question originated from Singly Linked List Operations topic in section Abstract Data Types of Data Structures & Algorithms IThe question was posed to me during an online exam.

Answer»

Right choice is (c) Delete the last element of the list

Explanation: Deletion of the first element of the list is done in O (1) time by deleting memory and changing the first pointer.

Insertion of an element as a first element can be done in O (1) time. We will create a node that holds data and points to the head of the GIVEN linked list. The head pointer was changed to a newly created node.

Deletion of the last element requires a pointer to the previous node of last, which can only be OBTAINED by traversing the list. This requires the length of the linked list.

Adding a NEW element at the END of the list can be done in O (1) by changing the pointer of the last node to the newly created node and last is changed to a newly created node.

25.

Given pointer to a node X in a singly linked list. Only one pointer is given, pointer to head node is not given, can we delete the node X from given linked list?(a) Possible if X is not last node(b) Possible if size of linked list is even(c) Possible if size of linked list is odd(d) Possible if X is not first nodeMy question is from Singly Linked List Operations topic in division Abstract Data Types of Data Structures & Algorithms II had been asked this question by my college director while I was bunking the class.

Answer»

Correct OPTION is (a) POSSIBLE if X is not last node

The best EXPLANATION: FOLLOWING are simple steps.

26.

Which of the following sorting algorithms can be used to sort a random linked list with minimum time complexity?(a) Insertion Sort(b) Quick Sort(c) Heap Sort(d) Merge SortI want to ask this question from Singly Linked List Operations in division Abstract Data Types of Data Structures & Algorithms IThis question was posed to me in my homework.

Answer»

The correct option is (d) Merge Sort

Best EXPLANATION: Both Merge sort and Insertion sort can be used for linked lists. The SLOW random-access PERFORMANCE of a linked list makes other algorithms (such as quicksort) perform poorly, and others (such as HEAPSORT) completely impossible. Since worst CASE time complexity of Merge Sort is O(nLogn) and Insertion sort is O(n^2), merge sort is preferred.

27.

Which of the following points is/are not true about Linked List data structure when it is compared with an array?(a) Arrays have better cache locality that can make them better in terms of performance(b) It is easy to insert and delete elements in Linked List(c) Random access is not allowed in a typical implementation of Linked Lists(d) Access of elements in linked list takes less time than compared to arraysQuery is from Singly Linked List Operations topic in chapter Abstract Data Types of Data Structures & Algorithms II have been asked this question in a job interview.

Answer» RIGHT option is (d) Access of elements in linked list takes less time than compared to ARRAYS

Easy explanation - To access an element in a linked list, we need to TRAVERSE every element until we reach the desired element. This will take more time than arrays as arrays PROVIDE random access to its elements.
28.

Linked list data structure offers considerable saving in _____________(a) Computational Time(b) Space Utilization(c) Space Utilization and Computational Time(d) Speed UtilizationMy query is from Singly Linked List Operations in portion Abstract Data Types of Data Structures & Algorithms II had been asked this question by my school teacher while I was bunking the class.

Answer»

The correct answer is (c) SPACE Utilization and COMPUTATIONAL Time

Easy EXPLANATION - LINKED lists saves both space and time.

29.

In Linked List implementation, a node carries information regarding ___________(a) Data(b) Link(c) Data and Link(d) NodeEnquiry is from Singly Linked List Operations in division Abstract Data Types of Data Structures & Algorithms IThis question was posed to me in class test.

Answer»

Correct answer is (c) DATA and LINK

Best explanation: A LINKED list is a collection of objects linked together by references from an object to ANOTHER object. By convention these objects are names as nodes. Linked list consists of nodes where each node contains one or more data fields and a reference(link) to the next node.

30.

Linked list is considered as an example of ___________ type of memory allocation.(a) Dynamic(b) Static(c) Compile time(d) HeapQuery is from Singly Linked List Operations in section Abstract Data Types of Data Structures & Algorithms IThis question was addressed to me in a job interview.

Answer» RIGHT choice is (a) Dynamic

Best EXPLANATION: As memory is ALLOCATED at the run TIME.
31.

Linked lists are not suitable for the implementation of ___________(a) Insertion sort(b) Radix sort(c) Polynomial manipulation(d) Binary searchI want to ask this question from Singly Linked List Operations topic in section Abstract Data Types of Data Structures & Algorithms II had been asked this question in final exam.

Answer» CORRECT choice is (d) Binary search

Best explanation: It cannot be implemented USING linked LISTS.
32.

What kind of linked list is best to answer questions like “What is the item at position n?”(a) Singly linked list(b) Doubly linked list(c) Circular linked list(d) Array implementation of linked listMy question is from Singly Linked List Operations in section Abstract Data Types of Data Structures & Algorithms II had been asked this question in an online interview.

Answer»

Right option is (d) Array implementation of linked LIST

To explain: Arrays PROVIDE random access to elements by providing the index VALUE within square brackets. In the linked list, we need to traverse through each element until we reach the nth position. Time taken to access an element represented in arrays is less than the singly, doubly and circular linked LISTS. Thus, array implementation is USED to access the item at the position n.

33.

The concatenation of two lists can be performed in O(1) time. Which of the following variation of the linked list can be used?(a) Singly linked list(b) Doubly linked list(c) Circular doubly linked list(d) Array implementation of listOrigin of the question is Singly Linked List Operations in portion Abstract Data Types of Data Structures & Algorithms IThis question was addressed to me in class test.

Answer»

The correct ANSWER is (c) CIRCULAR doubly linked LIST

Best explanation: We can easily concatenate two LISTS in O (1) time using singly or doubly linked list, provided that we have a pointer to the last node at least one of the lists. But in case of circular doubly linked lists, we will break the link in both the lists and hook them together. Thus circular doubly linked list concatenates two lists in O (1) time.

34.

What would be the asymptotic time complexity to insert an element at the second position in the linked list?(a) O(1)(b) O(n)(c) O(n^2)(d) O(n^3)My question is based upon Singly Linked List Operations topic in division Abstract Data Types of Data Structures & Algorithms IThis question was addressed to me in class test.

Answer»

Right OPTION is (a) O(1)

For explanation: A new node is created with the required ELEMENT. The pointer of the new node points the node to which the HEAD node of the linked list is also pointing. The head node pointer is changed and it points to the new node which we created earlier. The ENTIRE process completes in O (1) time. Thus the asymptotic time complexity to insert an element in the second position of the linked list is O (1).

35.

What would be the asymptotic time complexity to find an element in the linked list?(a) O(1)(b) O(n)(c) O(n^2)(d) O(n^4)This is a very interesting question from Singly Linked List Operations topic in chapter Abstract Data Types of Data Structures & Algorithms II got this question by my college director while I was bunking the class.

Answer»

Correct ANSWER is (B) O(n)

For explanation: If the required ELEMENT is in the last POSITION, we need to traverse the ENTIRE linked list. This will take O (n) time to search the element.

36.

What would be the asymptotic time complexity to insert an element at the front of the linked list (head is known)?(a) O(1)(b) O(n)(c) O(n^2)(d) O(n^3)The doubt is from Singly Linked List Operations in chapter Abstract Data Types of Data Structures & Algorithms II have been asked this question during an online interview.

Answer»

The correct OPTION is (a) O(1)

To explain: To add an element at the front of the LINKED list, we will CREATE a new node which holds the data to be added to the linked list and pointer which points to head POSITION in the linked list. The entire thing happens within O (1) time. Thus the asymptotic time complexity is O (1).

37.

What would be the asymptotic time complexity to add a node at the end of singly linked list, if the pointer is initially pointing to the head of the list?(a) O(1)(b) O(n)(c) θ(n)(d) θ(1)Question is from Singly Linked List Operations in portion Abstract Data Types of Data Structures & Algorithms II had been asked this question in an international level competition.

Answer»

Right choice is (C) θ(n)

Best explanation: In CASE of a linked LIST having n elements, we need to travel through every node of the list to add the element at the end of the list. Thus asymptotic time COMPLEXITY is θ(n).

38.

In linked list each node contains a minimum of two fields. One field is data field to store the data second field is?(a) Pointer to character(b) Pointer to integer(c) Pointer to node(d) NodeQuestion is from Singly Linked List Operations in portion Abstract Data Types of Data Structures & Algorithms IThis question was posed to me in class test.

Answer»

Right OPTION is (C) Pointer to NODE

The best I can explain: Each node in a linked list CONTAINS DATA and a pointer (reference) to the next node. Second field contains pointer to node.

39.

A linear collection of data elements where the linear node is given by means of pointer is called?(a) Linked list(b) Node list(c) Primitive list(d) Unordered listMy question is taken from Singly Linked List Operations topic in portion Abstract Data Types of Data Structures & Algorithms IThis question was addressed to me at a job interview.

Answer»

The correct option is (a) Linked list

The BEST explanation: In Linked list each node has its own data and the address of NEXT node. These nodes are linked by USING pointers. Node list is an object that consists of a list of all nodes in a document with in a PARTICULAR SELECTED set of nodes.

40.

Which of the following is not the type of queue?(a) Ordinary queue(b) Single ended queue(c) Circular queue(d) Priority queueMy question is from Queue Operations in chapter Abstract Data Types of Data Structures & Algorithms IThis question was posed to me in exam.

Answer»

The CORRECT choice is (B) Single ended queue

To EXPLAIN: Queue always has TWO ends. So, single ended queue is not the type of queue.

41.

Queues serve major role in ______________(a) Simulation of recursion(b) Simulation of arbitrary linked list(c) Simulation of limited resource allocation(d) Simulation of heap sortThe above asked question is from Queue Operations topic in portion Abstract Data Types of Data Structures & Algorithms II have been asked this question during an interview for a job.

Answer»

Correct choice is (c) Simulation of LIMITED RESOURCE allocation

The explanation is: Simulation of recursion uses stack data structure. Simulation of arbitrary linked lists uses linked lists. Simulation of resource allocation uses queue as first entered data needs to be GIVEN first PRIORITY during resource allocation. Simulation of heap SORT uses heap data structure.

42.

A normal queue, if implemented using an array of size MAX_SIZE, gets full when?(a) Rear = MAX_SIZE – 1(b) Front = (rear + 1)mod MAX_SIZE(c) Front = rear + 1(d) Rear = frontQuestion is taken from Queue Operations topic in division Abstract Data Types of Data Structures & Algorithms IThe question was posed to me in my homework.

Answer»

Correct ANSWER is (a) Rear = MAX_SIZE – 1

Easy explanation - When Rear = MAX_SIZE – 1, there will be no space LEFT for the elements to be added in QUEUE. Thus queue BECOMES full.

43.

A data structure in which elements can be inserted or deleted at/from both ends but not in the middle is?(a) Queue(b) Circular queue(c) Dequeue(d) Priority queueAsked question is from Queue Operations in portion Abstract Data Types of Data Structures & Algorithms IThe question was asked in examination.

Answer»

Correct answer is (C) Dequeue

The best I can EXPLAIN: In dequeuer, we can INSERT or delete elements from both the ends. In queue, we will follow first in first out principle for insertion and deletion of elements. Element with LEAST priority will be DELETED in a priority queue.

44.

If the elements “A”, “B”, “C” and “D” are placed in a queue and are deleted one at a time, in what order will they be removed?(a) ABCD(b) DCBA(c) DCAB(d) ABDCMy question comes from Queue Operations topic in portion Abstract Data Types of Data Structures & Algorithms II got this question in homework.

Answer»

Right answer is (a) ABCD

The BEST I can explain: Queue FOLLOWS FIFO approach. i.e. First in First Out Approach. So, the order of removal elements are ABCD.

45.

Circular Queue is also known as ________(a) Ring Buffer(b) Square Buffer(c) Rectangle Buffer(d) Curve BufferMy enquiry is from Queue Operations topic in portion Abstract Data Types of Data Structures & Algorithms II had been asked this question in examination.

Answer»

The CORRECT choice is (a) Ring BUFFER

Explanation: Circular Queue is also called as Ring Buffer. Circular Queue is a linear data STRUCTURE in which last position is connected BACK to the first position to make a circle. It forms a ring structure.

46.

A queue follows __________(a) FIFO (First In First Out) principle(b) LIFO (Last In First Out) principle(c) Ordered array(d) Linear treeMy doubt is from Queue Operations topic in portion Abstract Data Types of Data Structures & Algorithms IThe question was asked in final exam.

Answer» CORRECT answer is (a) FIFO (First In First Out) PRINCIPLE

For explanation: ELEMENT first added in queue will be DELETED first which is FIFO principle.
47.

The data structure required for Breadth First Traversal on a graph is?(a) Stack(b) Array(c) Queue(d) TreeMy doubt is from Queue Operations topic in section Abstract Data Types of Data Structures & Algorithms IThe question was posed to me in quiz.

Answer»

Right CHOICE is (c) Queue

Best explanation: In Breadth First Search TRAVERSAL, BFS, starting vertex is first TAKEN and adjacent vertices which are UNVISITED are also taken. Again, the first vertex which was added as an unvisited adjacent vertex list will be considered to add further unvisited vertices of the graph. To get the first unvisited vertex we need to follows First In First Out PRINCIPLE. Queue uses FIFO principle.

48.

A linear list of elements in which deletion can be done from one end (front) and insertion can take place only at the other end (rear) is known as _____________(a) Queue(b) Stack(c) Tree(d) Linked listThe question is from Queue Operations topic in section Abstract Data Types of Data Structures & Algorithms IThis question was posed to me at a job interview.

Answer»

The correct option is (a) Queue

For explanation: Linear LIST of ELEMENTS in which deletion is done at front SIDE and INSERTION at rear side is called Queue. In stack we will delete the LAST entered element first.

49.

If the elements “A”, “B”, “C” and “D” are placed in a stack and are deleted one at a time, what is the order of removal?(a) ABCD(b) DCBA(c) DCAB(d) ABDCThis intriguing question comes from Stack Operations in chapter Abstract Data Types of Data Structures & Algorithms IThis question was addressed to me in homework.

Answer» RIGHT CHOICE is (B) DCBA

The explanation is: Stack follows LIFO(Last In First Out). So the removal order of elements are DCBA.
50.

The type of expression in which operator succeeds its operands is?(a) Infix Expression(b) Prefix Expression(c) Postfix Expression(d) Both Prefix and Postfix ExpressionsI would like to ask this question from Stack Operations topic in division Abstract Data Types of Data Structures & Algorithms II got this question during an online interview.

Answer»

The correct choice is (c) Postfix Expression

The EXPLANATION is: The expression in which OPERATOR succeeds its operands is called postfix expression. The expression in which operator precedes the operands is called prefix expression. If an operator is present between two operands, then it is called INFIX EXPRESSIONS.