Click here to Skip to main content
15,903,012 members
Home / Discussions / Java
   

Java

 
Question[Solved] Access Problem with different classes and instances [modified] Pin
TheRainer3-Dec-09 16:13
TheRainer3-Dec-09 16:13 
AnswerRe: Access Problem with different classes and instances Pin
Cedric Moonen3-Dec-09 23:40
Cedric Moonen3-Dec-09 23:40 
QuestionRe: Access Problem with different classes and instances [modified] Pin
TheRainer11-Dec-09 4:33
TheRainer11-Dec-09 4:33 
AnswerRe: Access Problem with different classes and instances Pin
Cedric Moonen11-Dec-09 4:43
Cedric Moonen11-Dec-09 4:43 
AnswerRe: Access Problem with different classes and instances Pin
TheRainer11-Dec-09 7:05
TheRainer11-Dec-09 7:05 
QuestionBack Button on popup window doesn't work in IE Pin
sam#2-Dec-09 0:46
sam#2-Dec-09 0:46 
AnswerRe: Back Button on popup window doesn't work in IE Pin
David Skelly2-Dec-09 0:55
David Skelly2-Dec-09 0:55 
QuestionOutput error for Avl tree Pin
vtsmokey881-Dec-09 19:14
vtsmokey881-Dec-09 19:14 
The fact thats it an AVL tree probably doesn't matter. I have a printTree method in my tree class and I'm trying to print the nodes in the form of the tree. I've successfully printed the nodes the correct way but now I'm trying to label the nodes by their relative height (i.e. equalheight, right hi, left hi).

The problem is my root, which is right hi, won't change to that. Everything else is working for every node except the root, but the counter I made that determines the label is the right number. I can't for the life of me figure out why it is staying at equal height.

The first thing is the label, then the node, and the end number is the count.

EDIT: I know you can't tell because the tabs got taken out but alstoto01 is the root, thus the first node to go through the methods.

This is what I'm outputting right now (the Wrong way):
EQUALHT:aaronha01: 0
EQUALHT:agganha01: 0
EQUALHT:alliega01: 0
EQUALHT:alstoto01: -1
EQUALHT:bollifr01: 0
EQUALHT:cronera01: 0
EQUALHT:grammal01: 0
EQUALHT:henlega01: 0
RIGHTHI:herrito01: -1
EQUALHT:jacobsp01: 0

The Correct output should be:
EQUALHT:aaronha01: 0
EQUALHT:agganha01: 0
EQUALHT:alliega01: 0
RIGHTHI:alstoto01: -1
EQUALHT:bollifr01: 0
EQUALHT:cronera01: 0
EQUALHT:grammal01: 0
EQUALHT:henlega01: 0
RIGHTHI:herrito01: -1
EQUALHT:jacobsp01: 0

Here is the code for the printTree method:

private ArrayList<AnyType> printTree( AvlNode<AnyType> t, String buffer )
    {
        if( t != null )
        {
        	int count = counter(t);
            if(count == 0)
            	freq = "EQUALHT:";
            if(count < 0)
            	freq = "RIGHTHI:";
            else if(count > 0)
            	freq = "LEFTHI:";

        	printTree( t.left, buffer + "   ");
            pTree.add((AnyType) (buffer + freq + t.element + ":") );
            System.out.println(buffer + freq + t.element + ":" + count);
            printTree( t.right, buffer + "   ");
            return pTree;
        }
        return null;
    }


Here is the code for my counter method:

private int counter(AvlNode<AnyType> t){
    	int count = 0, left = 0, right = 0;
    	AvlNode<AnyType> temp = t;
    	while(temp != null){
    		temp = temp.right;
    		right++;
    	}
    	while(t != null){
    		t = t.left;
    		left++;
    	}
    	count = left - right;
    	return count;
    }


It's probably a simple fix but I just can't see it. Any help would be appreciated since this is a really stupid problem to have in the grand scheme of things.
AnswerRe: Output error for Avl tree Pin
vtsmokey881-Dec-09 20:04
vtsmokey881-Dec-09 20:04 
GeneralRe: Output error for Avl tree Pin
Nagy Vilmos1-Dec-09 21:40
professionalNagy Vilmos1-Dec-09 21:40 
QuestionBakhshali Approximation for finding the square root of a number..? Pin
silentbob03211-Dec-09 14:27
silentbob03211-Dec-09 14:27 
AnswerRe: Bakhshali Approximation for finding the square root of a number..? Pin
Nagy Vilmos1-Dec-09 21:47
professionalNagy Vilmos1-Dec-09 21:47 
AnswerRe: Bakhshali Approximation for finding the square root of a number..? Pin
Richard MacCutchan1-Dec-09 21:48
mveRichard MacCutchan1-Dec-09 21:48 
QuestionHow to make Swing GUI stable in GridBagLayout Pin
don Moen30-Nov-09 19:20
don Moen30-Nov-09 19:20 
AnswerRe: How to make Swing GUI stable in GridBagLayout [modified] Pin
LunaticFringe2-Dec-09 2:45
LunaticFringe2-Dec-09 2:45 
GeneralRe: How to make Swing GUI stable in GridBagLayout Pin
don Moen2-Dec-09 19:57
don Moen2-Dec-09 19:57 
Questionjava effects Pin
ammu2328-Nov-09 5:23
ammu2328-Nov-09 5:23 
AnswerRe: java effects Pin
Richard MacCutchan28-Nov-09 5:52
mveRichard MacCutchan28-Nov-09 5:52 
AnswerRe: java effects Pin
scottgp28-Nov-09 11:09
professionalscottgp28-Nov-09 11:09 
QuestionEmbedding Pentaho Dashboard into my web application in struts 1 Pin
Vivek Vijayan27-Nov-09 17:43
Vivek Vijayan27-Nov-09 17:43 
AnswerRe: Embedding Pentaho Dashboard into my web application in struts 1 Pin
Richard MacCutchan27-Nov-09 22:03
mveRichard MacCutchan27-Nov-09 22:03 
QuestionWrite XML Attribute Pin
toby3127-Nov-09 13:02
toby3127-Nov-09 13:02 
QuestionA Web Crawler code...help Pin
sangeeta200927-Nov-09 2:23
sangeeta200927-Nov-09 2:23 
AnswerRe: A Web Crawler code...help Pin
Richard MacCutchan27-Nov-09 2:32
mveRichard MacCutchan27-Nov-09 2:32 
GeneralRe: A Web Crawler code...help Pin
sangeeta200927-Nov-09 2:54
sangeeta200927-Nov-09 2:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.