jakenoble
01-14-2005, 12:02 AM
Hi All
I am having some major problems with a piece of work involving Java.
We have been giving the following:
static int add(int chain, int value)
// here you need to provide the code that adds a new element to the front of the chain
// my solution has four lines ...
{
return NULL; // this line is only here so you can compile and run the code as is.
} // end of method "add"
We are supposed to simulating the "Heap".
Then later we have this:
static public void main(String args[])
{
System.out.println("start of program");
int myChain = NULL; // initialise the chain ...
int values [] = {76, 42, 33, 29, 50};
for (int i = 0; i < HEAP_SIZE; i++)
{
heapArray[i] = new HeapElement();
};
for (int i = 0; i < 5; i++) {
System.out.println(myChain = add(myChain,values[i]));
}
System.out.println("end of program");
}
I need to add the values in the "values" Array into specific random points allocated earlier in the program.
But the bit I am confused about is the "add" method, and the way it is used, specifically, what does this mean?
myChain = add(myChain,values[i]
Thanks in advance, jake
I am having some major problems with a piece of work involving Java.
We have been giving the following:
static int add(int chain, int value)
// here you need to provide the code that adds a new element to the front of the chain
// my solution has four lines ...
{
return NULL; // this line is only here so you can compile and run the code as is.
} // end of method "add"
We are supposed to simulating the "Heap".
Then later we have this:
static public void main(String args[])
{
System.out.println("start of program");
int myChain = NULL; // initialise the chain ...
int values [] = {76, 42, 33, 29, 50};
for (int i = 0; i < HEAP_SIZE; i++)
{
heapArray[i] = new HeapElement();
};
for (int i = 0; i < 5; i++) {
System.out.println(myChain = add(myChain,values[i]));
}
System.out.println("end of program");
}
I need to add the values in the "values" Array into specific random points allocated earlier in the program.
But the bit I am confused about is the "add" method, and the way it is used, specifically, what does this mean?
myChain = add(myChain,values[i]
Thanks in advance, jake