Consider the following operation performed on a stack of size 5.
Push(1);
Pop();
Push(2);
Push(3);
Pop();
Push(4);
Pop();
Pop();
Push(5);
After the completion of all operation, the number of elements present in stack is?
Select an option to see the answer and solution.
The prefix form of an infix expression (p + q) - (r * t) is?
A. + pq - *rt
B. - +pqr * t
C. - +pq * rt
D. - + * pqrt
Select an option to see the answer and solution.
What is the functionality of the following code?
public void function(Node node)
{
if(size == 0)
head = node;
else
{
Node temp,cur;
for(cur = head; (temp = cur.getNext())!=null; cur = temp);
cur.setNext(node);
}
size++;
}A. Inserting a node at the beginning of the list
B. Deleting a node at the beginning of the list
C. Inserting a node at the end of the list
D. Deleting a node at the end of the list
Select an option to see the answer and solution.
In Linked List implementation, a node carries information regarding . . . . . . . .
A. Data
B. Link
C. Data and Link
D. Node
Select an option to see the answer and solution.
What are the disadvantages of arrays?
A. Data structure like queue or stack cannot be implemented
B. There are chances of wastage of memory space if elements inserted in an array are lesser than the allocated size
C. Index value of an array can be negative
D. Elements are sequentially accessed
Select an option to see the answer and solution.
What is the term for inserting into a full queue known as?
A. overflow
B. underflow
C. null pointer exception
D. program won't be compiled
Select an option to see the answer and solution.
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 changed
Select an option to see the answer and solution.
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 list
Select an option to see the answer and solution.
The following function reverse() is supposed to reverse a singly linked list. There is one line missing at the end of the function.
/* Link list node */
struct node
{
int data;
struct node* next;
};
/* head_ref is a double pointer which points to head (or start) pointer
of linked list */
static void reverse(struct node** head_ref)
{
struct node* prev = NULL;
struct node* current = *head_ref;
struct node* next;
while (current != NULL)
{
next = current->next;
current->next = prev;
prev = current;
current = next;
}
/*ADD A STATEMENT HERE*/
}
What should be added in place of "/*ADD A STATEMENT HERE*/", so that the function correctly reverses a linked list.
A. *head_ref = prev;
B. *head_ref = current;
C. *head_ref = next;
D. *head_ref = NULL;
Select an option to see the answer and solution.
What is the value of the postfix expression 6 3 2 4 + - *?
Select an option to see the answer and solution.
What is the functionality of the following piece of code?
public void function(Object item)
{
Node temp=new Node(item,trail);
if(isEmpty())
{
head.setNext(temp);
temp.setNext(trail);
}
else
{
Node cur=head.getNext();
while(cur.getNext()!=trail)
{
cur=cur.getNext();
}
cur.setNext(temp);
}
size++;
}A. Insert at the front end of the dequeue
B. Insert at the rear end of the dequeue
C. Fetch the element at the rear end of the dequeue
D. Fetch the element at the front end of the dequeue
Select an option to see the answer and solution.
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(n2 )
Select an option to see the answer and solution.
In general, the index of the first element in an array is . . . . . . . .
Select an option to see the answer and solution.
The postfix form of A*B+C/D is?
A. *AB/CD+
B. AB*CD/+
C. A*BC+/D
D. ABCD+/*
Select an option to see the answer and solution.
Consider the following doubly linked list: head-1-2-3-4-5-tail. What will be the list after performing the given sequence of operations?
Node temp = new Node(6,head,head.getNext());
Node temp1 = new Node(0,tail.getPrev(),tail);
head.setNext(temp);
temp.getNext().setPrev(temp);
tail.setPrev(temp1);
temp1.getPrev().setNext(temp1);A. head-0-1-2-3-4-5-6-tail
B. head-1-2-3-4-5-6-tail
C. head-6-1-2-3-4-5-0-tail
D. head-0-1-2-3-4-5-tail
Select an option to see the answer and solution.
Which of the following is not the application of stack?
A. A parentheses balancing program
B. Tracking of local variables at run time
C. Compiler Syntax Analyzer
D. Data Transfer between two asynchronous process
Select an option to see the answer and solution.
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 beginning
Select an option to see the answer and solution.
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)
Select an option to see the answer and solution.
What is the time complexity of deleting from the rear end of the dequeue implemented with a singly linked list?
A. O(nlogn)
B. O(logn)
C. O(n)
D. O(n2 )
Select an option to see the answer and solution.
The data structure required for Breadth First Traversal on a graph is?
A. Stack
B. Array
C. Queue
D. Tree
Select an option to see the answer and solution.