Switch to full style
Java2 codes,problems ,discussions and solutions are here
Post a reply

queue of objects keep track of the front and rear

Tue Jun 09, 2009 10:24 pm

Assume that a queue of objects is implemented by an array of size N in a circular fashion
Two variables keep track of the front and rear: front and rear, as described in the following class definition.

java code
public class ArrayQueue {
private Object Q[];
private int front,rear;
private int size;
public ArrayQueue(int capacity) {
Q = new Object[capacity];
// variables front and rear are to be initialized here, based // on the requirements below
}
// methods are to be added here based on the requirements below
}

Complete the constructor for ArrayQueue and write the methods enqueue, dequeue, size, front, isEmpty. (Provide a separate solution for each of the following cases.)

1. front is the index of the first element, rear is the index of the last element and the location following the last element is always kept empty.


2. front is the index of the first element, rear is the index of the last element and the location preceding the first element is always kept empty.

3. front is the index of the location preceding the first element, which is always kept empty, rear is the index of the location following the last element, which is always kept empty.

4. . front is the index of the location preceding the first element, which is always kept empty, rear is the index of the last element. (Draw your own picture.)



Re: Need HelP In JaVa H.W

Wed Jun 10, 2009 8:46 am

ou could implement a Binary Search Tree and put your data into a linked list.

I think this can be used for sorting too but you can use it to count if a particular number is appearing in the list and how many times it is appearing

Re: Need HelP In JaVa H.W

Wed Jun 10, 2009 11:09 pm

thanks for the response..

but can you explain more :d

Post a reply
  Related Posts  to : queue of objects keep track of the front and rear
 Using Web Objects in XML (WOX) to serialize Java objects XML     -  
 vector front     -  
 Can i track calls from mobile phones     -  
 priority queue     -  
 generic queue     -  
 Queue Header     -  
 Circular Queue     -  
 How to track clicks on hash links from Google analytic     -  
 track session from login page-J2EE project     -  
 Get all objects for an entity     -