i ve Q which ask me to write method called nodelevel(int k ) which returns how many nodes in level k..

and i write a code but i dont know what is wrong with it ???

public nodelevel(int k){
if(root == null)
        return 0;
    else
        return getnodelevel(root, 1);
}
 
private int getnodelevel(TreeNode root, int k){
    if(root == null)
        return 0;
    else
        return level +getnodelevel(root.left, k) + getnodelevel(root.right,k);
}

could u help me plz

could u help me plz

I couldn't find anyone by the name of 'u' in the memberlist?

First of all, you're passing 1 to the private method instead of K. I have no idea why you have a public method call a private method that does the exact same thing anyway. And how you're figuring the total count of nodes at a certain level makes absolutely no sense to me. I'll even ignore for the moment that your method will most likely cause a buffer overflow error do to the endless recursion.(because K never changes). I'll also overlook the fact that you're not using good old java naming conventions. You should write it as getNodeLevel instead of getnodelevel. I'd suggest reading the API docs on TreeNode.

I couldn't find anyone by the name of 'u' in the memberlist?

nor could I find anyone with the name "plz" :cheesy:

i think this is not suitable place to joke ok ....

and we think this is not a suitable place to use "language" meant for mobile phone text messaging among 10 year old kids.

As we're the ones you're asking your questions, keep that in mind.

you are really have a free time,but i don't have to answer people like you

I don't think you understand what he's saying... If you aren't willing to write in proper English where we can understand, then why should we help?

We can always start replying in other languages and show you how it's like.

you are really have a free time,but i don't have to answer people like you

yet you do expect answers from us to your ramblings in incomprehensible "language".

If you're too lazy to use human language properly and at least try to communicate clearly in it, I see no reason to expect you to even try to communicate clearly with computers at all.
Remember that computers require you to be far more precise still in the way you address them, there is hardly anything like slang in programming languages for example.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.