FallenG's Profile User Rating: -----

Reputation: 22 Tradesman
Active Posts:
44 (0.06 per day)
12-January 13
Profile Views:
Last Active:
User is offline May 15 2013 06:14 AM

Previous Fields

OS Preference:
Who Cares
Favorite Browser:
Who Cares
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:

Latest Visitors

Icon   FallenG has not set their status

Posts I've Made

  1. In Topic: Methods, Arrays, and Loops - Oh My! Lottery question in Java.

    Posted 3 Apr 2013

    If you generate the letters independently of each other, there is no guarantee they won't be repeats. What would happen if the five winners were all A, and the five losers were also all A?

    Since you used the word 'set' in your description, and if it isn't too much a change of direction, I would suggest using a Java Set to hold your winners and losers.

    // Create set of A-Z
    // Remove 5 random elements and place into Set `winners`
    // Remove 5 random elements and place into Set `losers`
  2. In Topic: Roll 2 Dice with 36 possibilities

    Posted 28 Mar 2013

    View Postbaavgai, on 28 March 2013 - 03:28 PM, said:

    Now, this is important and no one really hit on it. The frequency is NOT roll()+row(). That should give you a result between 2..12. The frequency is 0..35! That is, there are 36 possible die combinations: 6 * 6. You've been asked to show that.

    Are you saying he is supposed to be recording the combinations, not the sums?

    Because if so, the assignment clearly states otherwise:


    Use a one-dimensional array to tally the number of times each possible sum appears

    View PostFlukeshot, on 28 March 2013 - 03:36 PM, said:

    View Postjon.kiparsky, on 28 March 2013 - 03:20 PM, said:

    A true random number generator is a little more difficult - how would you go about generating actual randomness programmatically? (I'll let you stew over that one for a bit... :)/>)

    I have stewed over this many a time but I'm pretty sure that's beyond me.

    Even if you randomly generated a random generator that randomly generated random number generators of which one was randomly selected to generate a random number.. It would still be possible to duplicate the result wouldn't it?

    You can't produce randomness programmatically, so a true RNG will have a piece of actual hardware to measure a random object in the real world. You can use things like precise CPU temperature, although this is still somewhat predictable, so ideally you would use radioactive decay, background radiation measurements, etc.

    If you need randomness from a user, ask them to wiggle the mouse. (Public/Private key generators usually ask for this).
  3. In Topic: Recursively searching for an existing string in a Binary Tree

    Posted 26 Mar 2013

    Well I don't really know what to say any more. Here is the code if you want it.

  4. In Topic: Recursively searching for an existing string in a Binary Tree

    Posted 26 Mar 2013

    View Postccb77, on 26 March 2013 - 07:44 PM, said:

    I ended up with this, and it appears to work....still working out some other things in the program itselfl
    public static TreeNode search(TreeNode root, String st)
    		if(root == null) 
    			return null;
    			return root;
    		if (root.getLeft() != null){
    			return root.left;	
    			return search(root.getRight(), st);	


    Just read the last if statement in your code...

    "If the root has a left subtree, then return that subtree". How does that solve the problem?
  5. In Topic: Recursively searching for an existing string in a Binary Tree

    Posted 26 Mar 2013

    View Postccb77, on 26 March 2013 - 06:20 PM, said:

    It is an assignment, We were asked to use a Binary Tree, and specifically not to use a BST.

    public static TreeNode search(TreeNode root, String st)
    		if(root != null && st.equals(root.getString()))		
    			return root;
    		if (root.getLeft() != null && st.equals(root.getLeft()))
    			return search(root.getLeft(), st);
    		if(root.getRight() != null && st.equals(root.getRight()))			
    		return search(root.getRight(), st);

    This is what I changed my code to: but I get this error:"This method must return a result of type TreeNode"

    All your functions return statements are conditional, so you are getting a compile time error (your method might never return anything, which doesn't even make sense, so it can't compile).

    Additionally, your code breaks if root is null, even if it were to compile.

    In my eyes you were closer with your previous code. Have a look at that and the line I pointed out you should change (with changes only to that line, you can make it work).

My Information

Member Title:
New D.I.C Head
Age Unknown
Birthday Unknown
Programming Languages:
C, C++, Java, Scala, Haskell, Web dev

Contact Information



FallenG hasn't added any friends yet.


FallenG has no profile comments yet. Why not say hello?