What is the correct code for void add(String x) operation? Such an operation adds x to the queue

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;


```

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;
}

C)
if (rear != null)
{
rear.next = new Node(x, null);
rear = rear.next;
}
else
{
rear = new Node(x, null);
front = rear;
}

Computer Science & Information Technology

You might also like to view...

Selecting a row and clicking the Insert command, inserts a row above the selected row

Indicate whether the statement is true or false.

Computer Science & Information Technology

When the processor, main memory, and I/O share a common bus, two modes of addressing are possible: memory mapped and ________.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology