File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Need ideas ......or hints... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Need ideas ......or hints... " Watch "Need ideas ......or hints... " New topic
Author

Need ideas ......or hints...

Peter vanscoy
Greenhorn

Joined: Feb 25, 2007
Posts: 4
guys I got a problem to solve... its on tree vertex splitting problem

1. Write a program to solve the tree vertex splitting problem?

I like to do everything myself. but on this problem I cannot see any ideas on internet.. Can anyone give the data structure on how to code this program..

I will try to write a program myself, I will code.. I'm not asking code.but any hints or ideas. that how should I start and finish this assignment.

Guys please help me out. Its due tomorrow..

thank you
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Hi,

Welcome to JavaRanch!

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!


[Jess in Action][AskingGoodQuestions]
Peter vanscoy
Greenhorn

Joined: Feb 25, 2007
Posts: 4
Thank you for your suggestion.

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...

Help me if you can..
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

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.
Peter vanscoy
Greenhorn

Joined: Feb 25, 2007
Posts: 4
sounds good
Peter vanscoy
Greenhorn

Joined: Feb 25, 2007
Posts: 4
I couldn't figure out the algorithm for tree vertex splitting. Can any one give me some ideas or hints how to this...
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need ideas ......or hints...