Write an enqueue method for a queue implemented as a linked structure. You may assume that the class has references to LinearNode objects called front and rear, which represent the front and rear of the queue respectively. You may also assume that the class has a variable called count, which represents the number of elements in the queue.

What will be an ideal response?

```
public void enqueue(T element) {
LinearNode newNode = new LinearNode(element);
if(count == 0)
front = newNode;
else
rear.setNext(newNode);
rear = newNode;
count++;
}
```

Computer Science & Information Technology

You might also like to view...

A(n) ________ is a note or comment that displays at the bottom of the page on which the reference occurs

Fill in the blank(s) with correct word

Computer Science & Information Technology

Which of the matching from the following diagram is correct?

Network Class Definition 1 Local-area network (LAN) A It interconnects locations scattered throughout a metropolitan area. 2 Wide-area network (WAN) B It is a network whose scale is even smaller than a LAN. An example of this type of network is a connection between a PC and a digital camera via a universal serial bus. 3 Metropolitan-area network (MAN) C It interconnects network components within a local region. 4 Personal-area network (PAN) D It interconnects network components that are geographically dispersed between two locations. A) 1C, 2D, 3A, 4B B) 1D, 2C, 3B, 4A C) 1B, 2D, 3A, 4C D) 1A, 2D, 3C, 4B

Computer Science & Information Technology