It helps to break things down into smaller steps. For example, you might start with:
//1) Collect inputs //2) Solve tree vertex splitting problem //3) Print output
Now, you might not think this has helped much, but now you can start asking useful questions, like "what should the inputs to step #2 be?" In other words, think about what "the tree vertex splitting problem" means; think about however you learned about it in class. What are the data structures that you'd be operating on in solving the problem? Hmmm... that suggests another step belongs in there:
//1a) Collect inputs //1b) Build data structure //2) Solve tree vertex splitting problem //3) Print output
Now think about #2, again. Did the teacher tell you an algorithm to use, or do you have to work one out on your own? If he told you one, then write down all the steps, one at a time, under #2. If you have to figure out how to solve it yourself, well, then do so. When you figure it out, write down the steps.
Notice how I put Java comment marks at the beginning of each line? Now start writing code below the comment lines, leaving the comments there.
So go ahead: give it a try. When you've got at least a decent outline of the program, post it below and we can give you some hints if you need them.
One more thing: as soon as you start writing code, compile it. Get an empty class definition to compile. Then get a class with "main" declared in it to compile, with an empty method body. Then declare a few variables, and get that to compile.
Whatever you do, don't write 200 lines of code -- or even 50 lines of code --and then try to compile it. Take little steps, making sure that your code is OK at each point. You'll save a lot of time!
And each time you compile the program, run it. Make sure it does what it's supposed to. Don't wait until the whole thing is written to start testing!
Basically my teacher didn't give any algorithm.. All he said to do the program.. and should not be a binary tree...It should be n-arrays. So I don't know how to start. So thought of getting ideas from Javaranch. So when you said, 1. getting inputs.. Do i read from the file .
would you happen to know what would be algorithm...
Remember that the number one rule of success in school is
If you don't understand the assignment, ask the instructor for clarification.
In any case, for step 1, it's entirely up to you. If it's convenient to store test data in a file, do so. If it's convenient to type it in, do so. And if it's convenient to simply hard-code the data, that would be OK too -- although it won't be as easy to test your program with different inputs.
And then as far as whether I know the algorithm -- that doesn't much matter, does it? Presumably this is what you're supposed to be learning in class. Let's instead help you to remember what you learned. So first, let's hear you state, clearly, what the problem is.
As I suggested, let's start at the beginning. Tell us, in your words, what the tree vertex splitting problem is. You can't write a program without knowing what it needs to do -- whether or not you know how to do it comes later.