Rikka's Profile User Rating:

Reputation: 0 Apprentice
Group:
Members
Active Posts:
31 (0.03 per day)
Joined:
21-June 11
Profile Views:
1,638
Last Active:
Mar 09 2012 11:43 PM
Currently:
Offline

Previous Fields

Country:
Who Cares
OS Preference:
Windows
Favorite Browser:
Chrome
Favorite Processor:
AMD
Favorite Gaming Platform:
PC
Who Cares
Dream Kudos:
0
Rikka Master all the Sorting Algorithms! :)

1. In Topic: Problem on Implementing Heap Tree only not the Sort itself

Posted 8 Mar 2012

This is my new code:

```public static void heapTree(int array[], int len){
boolean heap;

for (int i =((len-1)/2); i>0; i--){
int k=i;
int v= array[k];
heap = false;

while ((!heap)&&(2*k)<len-1){
int j=2*k;
if(j<len-1){
if(array[j]<array[j+1])
j=j+1;
if(v>=array[j])
heap=true;
else{
array[k] = array[j];
k=j;
}

} array[k] = v;

}
System.out.print(" || ");
for(int x = 0; x < array.length; x++) {
System.out.print(" || " + array[x] + " ");
}
System.out.println();
}
}
```

the output is only up to the third pass
2. In Topic: Problem on Implementing Heap Tree only not the Sort itself

Posted 8 Mar 2012

The example output is what it should be..

```public static void heapTree(int array[], int len){
int i, o;
int lChild, rChild, mChild, root, temp;
root = (len-1)/2;

for(o = root; o >= 0; o--){
for(i=root;i>=0;i--){
lChild = (2*i)+1;
rChild = (2*i)+2;
if((lChild <= len) && (rChild <= len)){
if(array[rChild] >= array[lChild])
mChild = rChild;
else
mChild = lChild;
}
else{
if(rChild > len)
mChild = lChild;
else
mChild = rChild;
}

System.out.print(" || Pass " + o + "-->  ");
for(int x = 0; x < array.length; x++) {
System.out.print(array[x] + " ");
}
System.out.println();
}
}
}
```

I just want to view the tree itself and not the sorted one..

My Information

Member Title:
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Years Programming:
3
Programming Languages:
c++, java, visual basic, cobol

E-mail:
Private
innocentchill

Friends

Page 1 of 1
1. jeremejazz

12 Apr 2012 - 18:53
hi how r u? :)
2. jeremejazz

11 Sep 2011 - 22:25
hello :) are you from the Phils? :D
3. fromTheSprawl

17 Jul 2011 - 18:05
4. fromTheSprawl

17 Jul 2011 - 17:06
My workmate is a cum laude from FEU. I did not study there though
5. fromTheSprawl

15 Jul 2011 - 02:46
FEU?
6. bevz

13 Jul 2011 - 08:05
.....?where kna
7. LieannM

13 Jul 2011 - 00:58
haaard :(
8. LieannM

13 Jul 2011 - 00:58
haaard :(
9. pau:)

13 Jul 2011 - 00:49
0.0?? hahah
10. pau:)

13 Jul 2011 - 00:49
0.0?? hahah
11. bevz

13 Jul 2011 - 00:43
hi...
Page 1 of 1