a) Undefined error b) Compiler displays a warning c) EmptyStackException is thrown d) ...
View QuestionWhat 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) Answer: a Explanation: ...
View QuestionWhat does ‘stack underflow’ refer to?
a) accessing item from an undefined stack b) adding items to a full stack c) removing items from an ...
View QuestionWhich 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 ...
View QuestionConsider 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 ...
View Question
What is the functionality of the following code?
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? public int function() { if(head == null) return Integer.MIN_VALUE; int var; Node temp = head; while(temp.getNext() ...
View QuestionWhich of the following application makes use of a circular linked list?
a) Undo operation in a text editor b) Recursive function calls c) Allocating ...
View QuestionWhat is the time complexity of searching for an element in a circular linked list?
a) O(n) b) O(nlogn) c) O(1) d) O(n2) Answer: a Explanation: In ...
View QuestionWhat differentiates a circular linked list from a normal linked list?
a) You cannot have the ‘next’ pointer point to null in a circular linked list b) ...
View Question
What is the functionality of the following piece of code?
public int function()
{
Node temp = tail.getPrev();
tail.setPrev(temp.getPrev());
temp.getPrev().setNext(tail);
size–;
return temp.getItem();
}
What is the functionality of the following piece of code? public int function() { Node temp = tail.getPrev(); tail.setPrev(temp.getPrev()); temp.getPrev().setNext(tail); size--; return temp.getItem(); } a) Return ...
View Question