Suppose the count variable was not used in the CircularArrayQueue class. Explain how you could use the values of front and rear to compute the number of elements in the list.

What will be an ideal response?


The difference between the front and rear indexes indicates the number of elements in the list, but the circular nature of the array must be taken into account. The following code could be used:
```
public int size()
{
int result = rear – front;
if (front > rear)
result = MAX – front - rear;
else if (front == rear) && (queue[front] != null)
result = MAX
return result;
}

```

Computer Science & Information Technology

You might also like to view...

What is the purpose of VMware Tools? Do you need to install VMware Tools when running vmplayer on a Linux system? Why or why not?

What will be an ideal response?

Computer Science & Information Technology

Some social networking web sites provide mechanisms for users to determine the GPS coor dinates of where their friends are located at any given moment. Describe a generalization scheme that would anonymize this information using disjoint rectangles so that any reported rectangular region as a "location" always has at least k people in it, for some security pa rameter k

What will be an ideal response?

Computer Science & Information Technology

The start timing setting is on the VIDEO TOOLS PLAYBACK ____.

A. slider B. tab C. button D. group

Computer Science & Information Technology

What Windows process is responsible for authenticating users?

A. Lsass.exe B. Winlogon.exe C. Csrss.exe D. Smss.exe

Computer Science & Information Technology