mojo666's Profile User Rating: -----

Reputation: 389 Architect
Group:
Expert
Active Posts:
843 (0.35 per day)
Joined:
27-June 09
Profile Views:
13,736
Last Active:
User is offline Jan 29 2016 12:22 PM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Windows
Favorite Browser:
Mozilla
Favorite Processor:
Who Cares
Favorite Gaming Platform:
PC
Your Car:
Who Cares
Dream Kudos:
0
Expert In:
Computer Science

Latest Visitors

Icon   mojo666 has not set their status

Posts I've Made

  1. In Topic: Binary tree algorithm

    Posted 29 Jan 2016

    Quote

    The "most shortest node" does not make sense. Precisely, what do you mean?

    Also, if you are encountering errors, please post your specific errors as they appear.

    Here is my hint. Note that for every two nodes i, j in a tree, there is a unique ij path. Hence, the shortest path is unique. So your desired node lies along this path.


    Leite can correct me if I'm wrong, but I don't think he is looking for shortest paths. He is looking for the least common ancestor of 2 nodes. Algorithmically, the code is correct with the caveats that both integers actually exist in the tree, the tree is ordered, and neither node is the ancestor of the other. There are just syntax issues.

    That being said, Leite, it would help if you understood what the code is doing. Basically, starting at the root, your current node is an ancestor to both nodes. If any child of your current node is an ancestor to both nodes, then the current node is not the least common ancestor. Thus if both nodes are in the left subtree, then the left child is a less common ancestor to both nodes than the current, so you make the left child your current node and repeat the test.
  2. In Topic: Calculating subtraction from shift of two objects

    Posted 28 Jan 2016

    Based on your input, you never set d so its final value depends on the compiler. Also this is backwards c = b;
  3. In Topic: Binary tree algorithm

    Posted 28 Jan 2016

    typedef struct node node;
    
    struct data
    {
        int data;
    };
    
    struct node
    {
        node *data; //this should not be a node
        node *parent;
        node *leftchild;
        node *rightchild;
    };
    



    It makes no sense for the data pointer in the node to be a "node" type. Either make it type "data" or just an int. Your code in lca attempts to refer to it as if it is just an int. Also, if you have a pointer to a structure and you want to access the members of the structure, the syntax is root->leftchild instead of root.leftchild
  4. In Topic: Algorithm troubles: possilbe n x n matrices with t 1's in each ro

    Posted 19 Jan 2016

    There are (5 choose 2) possibilities for the first round, however you can't just use that result and multiply by subsequent rounds. As you already noticed, certain decisions will leave you with more or less options in the subsequent rounds. What you will have to do is essentially loop through the possible choices in the first round and for each one loop through the possible choices in the second round and so on.
  5. In Topic: Algorithm troubles: possilbe n x n matrices with t 1's in each ro

    Posted 18 Jan 2016

    Quote

    What I think I understand:

    I will need to use an array length n as a "state vector" representing how many 1's still needed to be assigned to each column, as the algorithm progresses all elements are eventually reduced to 0.

    A "puck" variable is used to keep track of the index position of the diagonal and the current row.


    You will also need the storage object mentioned in the last paragraph.

    Quote

    When the algorithm finishes the "count" for each row is multiplied by one another to get the end result in the example 1*1*1*1*3*1 = 3. I've been looking at this for days and I just don't understand where these numbers came from, if some one could shed some light on this I would really appreciated it.


    As the algorithm executes, the number of possibilities for each round decreases. The last round will always have 1 possibility. For the purposes of demonstrating an iteration, the author decided to just investigate one possibility for each round except the last couple where it becomes easy to calculate. You will be iterating over all possibilities.

    Quote

    In the example, the choice of which elements in the state vector to decrement seems arbitrary, when I implement this how would I go about deciding which elements to reduce and in what order?



    Think of the positions as a couple of digits of a number except each digit must be less than the next digit. Then it's just a matter of counting with extra constraints. The possibilities of the first round would be something like
    211222 //23 
    212122 //24
    212212 //25
    212221 //26
    221122 //34
    221212 //35
    221221 //36
    222112 //45
    222121 //46
    222211 //56
    

My Information

Member Title:
D.I.C Addict
Age:
31 years old
Birthday:
July 23, 1984
Gender:
Interests:
Chess, math, computers, AI
Years Programming:
6
Programming Languages:
C++, C#, VB.net, SQL, OCAML, LISP, MIPS

Contact Information

E-mail:
Private
Website URL:
Website URL  http://

Friends

Showing 50 random friends of 3

Comments

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