Solved

A Queue Based on a Linked List Uses the Following

Question 36

Multiple Choice

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:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions