This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes a question in binary tree and factorisation Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "a question in binary tree and factorisation" Watch "a question in binary tree and factorisation" New topic
Author

a question in binary tree and factorisation

alex lotel
Ranch Hand

Joined: Feb 01, 2008
Posts: 191
we have a class that some has in soeof him the folwing
getfirst()
getsecond()
splip()

i was told that the "split" method splits the number which
it was given into two numbers which by multpilication gives us the original number
for example if 8 the given number
then we get 4 as the first
and 2 as the second one
if we get a number 5
then the first will be 5
and the second one is 1

i was told to build a method which stores all the primal numbers of
a given number
i cant wright it on eclipse because its a theoretical question
which only says that there is such a method called "split"
and we can use it.

can you tell me if my logic ok??

[ February 20, 2008: Message edited by: donaldth smithts ]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32649
    
    4
Your title is confusing; it is neither about binary trees nor about gcd.

The algorithm for gcd is simple; it is called Euclid's algorithm because Euclid discovered it, and is the oldest named algorithm known. What you want appears to be factorisation. There is an example here.
alex lotel
Ranch Hand

Joined: Feb 01, 2008
Posts: 191
can you tell me wether i did it ok??

there is no way for me to know that
exept you correcting me were i got wrong
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32649
    
    4
Have you tried it? Have you run it? Where did it go wrong?

As people have already told you (I think it was Joanne Neal), you will not find out whether a program works without running it.
Show Some Effort Please run it and then try to work out what goes wrong.
alex lotel
Ranch Hand

Joined: Feb 01, 2008
Posts: 191
this is a question from a test
i am theoreticly given a working method

i cant test it in eclipse

i have written a program by my logic
this is the only tool i've got

can you tell me if my method is ok??
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3011
    
    9
Write a dummy version of the class that has the getfirst(), getsecond() and split() methods that you can use to test your code.
You could either hard code the values that the getfirst() and getsecond() methods return or you could pass them to the constructor. The split() method wouldn't actually have to do anything.


Joanne
 
I agree. Here's the link: jrebel
 
subject: a question in binary tree and factorisation
 
Similar Threads
Deleting all leaves from a binary tree
Binary Search Trees
how to split a number into two multipliyers
Inorder traversal of a Binary Search Tree
a binary tree question..