Rikka's Profile
Reputation: 0
Apprentice
- Group:
- Members
- Active Posts:
- 31 (0.04 per day)
- Joined:
- 21-June 11
- Profile Views:
- 1,105
- 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
- Your Car:
- Who Cares
- Dream Kudos:
- 0
Posts I've Made
-
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
-
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.. -
In Topic: problem with constructors and methods
Posted 28 Jul 2011
Thanks to all who answered.
I'm done with this already.
Lots of Love
-
In Topic: problem with constructors and methods
Posted 26 Jul 2011
macosxnerd101, on 26 July 2011 - 12:02 PM, said:You should be using instance fields, not local variables. Instance fields are declared in the class, but not within any methods. These fields do not have the static modifier, and they are used to represent attributes about the object.
class Person{ private String name; //<-- name is an instance field }
Also, make sure you read my tutorial as well. It covers this in greater detail, and I think it will help clear up a lot of concepts regarding OOP.
so how will "Ann" in main be passed in setName and in s.Name?
-
In Topic: problem with constructors and methods
Posted 26 Jul 2011
Oh sorry for that. It actually has "}" but since I edited the code, it was accidentally removed. Sorry sir.
I'm having troubles in these:
public Student(String nm, int t1, int t2, int t3) { String Name = nm ; int Test1 = s.Test1() ; int Test2 = s.Test2() ; int Test3 = s.Test3();
I dunno how will I use this "s" in each line
and how to manipulate the setName and setScores so that the values will be passed to the ones above.
My Information
- Member Title:
- New D.I.C Head
- Age:
- Age Unknown
- Birthday:
- Birthday Unknown
- Gender:
-
- Years Programming:
- 3
- Programming Languages:
- c++, java, visual basic, cobol
Contact Information
- E-mail:
- Private
- Twitter:
- innocentchill
|
|


Find Topics
Find Posts
View Reputation Given



|
Comments
jeremejazz
12 Apr 2012 - 18:53jeremejazz
11 Sep 2011 - 22:25fromTheSprawl
17 Jul 2011 - 18:05fromTheSprawl
17 Jul 2011 - 17:06fromTheSprawl
15 Jul 2011 - 02:46bevz
13 Jul 2011 - 08:05LieannM
13 Jul 2011 - 00:58LieannM
13 Jul 2011 - 00:58pau:)
13 Jul 2011 - 00:49pau:)
13 Jul 2011 - 00:49bevz
13 Jul 2011 - 00:43