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]
Select an option to see the answer and solution.
Consider you have a stack whose elements in it are as follows.
5 4 3 2 << top
Where the top element is 2.
You need to get the following stack
6 5 4 3 2 << top
The operations that needed to be performed are (You can perform only push and pop):
A. Push(pop()), push(6), push(pop())
B. Push(pop()), push(6)
C. Push(pop()), push(pop()), push(6)
D. Push(6)
Select an option to see the answer and solution.
Which data structure is used for implementing recursion?
A. Queue
B. Stack
C. Array
D. List
Select an option to see the answer and solution.
Which of the following data structures can be used for parentheses matching?
A. n-ary tree
B. queue
C. priority queue
D. stack
Select an option to see the answer and solution.
Here is an infix expression: 4 + 3*(6*3-12). Suppose that we are using the usual stack algorithm to convert the expression from infix to postfix notation. The maximum number of symbols that will appear on the stack AT ONE TIME during the conversion of this expression?
Select an option to see the answer and solution.
A Double-ended queue supports operations such as adding and removing items from both the sides of the queue. They support four operations like addFront(adding item to top of the queue), addRear(adding item to the bottom of the queue), removeFront(removing item from the top of the queue) and removeRear(removing item from the bottom of the queue). You are given only stacks to implement this data structure. You can implement only push and pop operations. What are the total number of stacks required for this operation?(you can reuse the stack)
Select an option to see the answer and solution.
What is the functionality of the following piece of code?
public void display()
{
if(size == 0)
System.out.println("underflow");
else
{
Node current = first;
while(current != null)
{
System.out.println(current.getEle());
current = current.getNext();
}
}
}A. reverse the list
B. display the list
C. display the list excluding top-of-the-stack-element
D. reverse the list excluding top-of-the-stack-element
Select an option to see the answer and solution.
What is the output of the following Java code?
public class array
{
public static void main(String args[])
{
int []arr = {1,2,3,4,5};
System.out.println(arr[5]);
}
}
A. 4
B. 5
C. ArrayIndexOutOfBoundsException
D. InavlidInputException
Select an option to see the answer and solution.
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 list
Select an option to see the answer and solution.
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 arrays
Select an option to see the answer and solution.
Which of the following application makes use of a circular linked list?
A. Undo operation in a text editor
B. Recursive function calls
C. Allocating CPU to resources
D. Implement Hash Tables
Select an option to see the answer and solution.
To implement a stack using queue(with only enqueue and dequeue operations), how many queues will you need?
Select an option to see the answer and solution.
Which data structure is needed to convert infix notation to postfix notation?
A. Branch
B. Tree
C. Queue
D. Stack
Select an option to see the answer and solution.
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;
}A. Return data from the end of the list
B. Returns the data and deletes the node at the end of the list
C. Returns the data from the beginning of the list
D. Returns the data and deletes the node from the beginning of the list
Select an option to see the answer and solution.
What does the following function do for a given Linked List with first node as head?
void fun1(struct node* head)
{
if(head == NULL)
return;
fun1(head->next);
printf("%d ", head->data);
}A. Prints all nodes of linked lists
B. Prints all nodes of linked list in reverse order
C. Prints alternate nodes of Linked List
D. Prints alternate nodes in reverse order
Select an option to see the answer and solution.
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 = front
Select an option to see the answer and solution.
Process of inserting an element in stack is called . . . . . . . .
A. Create
B. Push
C. Evaluation
D. Pop
Select an option to see the answer and solution.
Convert the following Infix expression to Postfix form using a stack.
x + y * z + (p * q + r) * s, Follow usual precedence rule and assume that the expression is legal.
A. xyz*+pq*r+s*+
B. xyz*+pq*r+s+*
C. xyz+*pq*r+s*+
D. xyzp+**qr+s*+
Select an option to see the answer and solution.
After performing these set of operations, what does the final list look contain?
InsertFront(10);
InsertFront(20);
InsertRear(30);
DeleteFront();
InsertRear(40);
InsertRear(10);
DeleteRear();
InsertRear(15);
display(); A. 10 30 10 15
B. 20 30 40 15
C. 20 30 40 10
D. 10 30 40 15
Select an option to see the answer and solution.
Circular Queue is also known as . . . . . . . .
A. Ring Buffer
B. Square Buffer
C. Rectangle Buffer
D. Curve Buffer
Select an option to see the answer and solution.