41. 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;
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;
}
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;
}42. What does 'stack overflow' refer to?
43. What is the functionality of the following piece of code?
public void fun(int x)
{
q1.offer(x);
}
public void fun(int x)
{
q1.offer(x);
}44. In a stack, if a user tries to remove an element from an empty stack it is called . . . . . . . .
45. A data structure in which elements can be inserted or deleted at/from both ends but not in the middle is?
46. What does the following function check for? (all necessary headers to be included and function is called from main)
#define MAX 10
typedef struct stack
{
int top;
int item[MAX];
}stack;
int function(stack *s)
{
if(s->top == -1)
return 1;
else return 0;
}
#define MAX 10
typedef struct stack
{
int top;
int item[MAX];
}stack;
int function(stack *s)
{
if(s->top == -1)
return 1;
else return 0;
}47. What are the applications of dequeue?
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 . . . . . . . .
49. With what data structure can a priority queue be implemented?
50. When does the ArrayIndexOutOfBoundsException occur?
Read More Section(Introduction to Data Structures)
Each Section contains maximum 100 MCQs question on Introduction to Data Structures. To get more questions visit other sections.
