A queue based on a linked list uses the following code
Class Node{
String element;
Node next;
Node (String el,Node n) {
Element = el;
Next = n;
}
}
Node front = null,rear = null;
What is the right code for void add(String x) operation? Such an operation adds x to the queue
A) rear = new Node(x,null) ;
B) rear = new Node(x,null.;rear = rear.next;
C) if (rear != null.
{
Rear.next = new Node(x,null.;
Rear = rear.next;
}
Else
{
Rear = new Node(x,null.;
Front = rear;
}
D) if (rear != null.
{
Rear.next = new Node(x,null.;
Rear = rear.next;
}
Else
{
Rear.next = new Node(x,null.;
Front = rear;
}
Correct Answer:
Verified
Q25: A stack based on a linked list
Q26: Consider a class that uses the following
Q27: In an implementation of a stack based
Q28: The operation for removing an item from
Q29: Consider a class that uses the following
Q31: A queue invariant is a condition
A) obeyed
Q32: The operation for adding an item to
Q33: Which of the following operations is not
Q34: A queue based on a linked list
Q35: A queue based on a linked list
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents