darek9576's Profile User Rating: ***--

Reputation: 198 Stalwart
Group:
Active Members
Active Posts:
1,668 (1.11 per day)
Joined:
13-March 10
Profile Views:
40,159
Last Active:
User is offline Today, 03:04 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   darek9576 has not set their status

Posts I've Made

  1. In Topic: Introduce Yourself

    Posted 1 Apr 2014

    So that means i need to be member of dreamincode, stackoverflow, bytes etc etc just to see someone have a similar problem to mine and use solution provided?
  2. In Topic: Pointer value not getting updated

    Posted 27 Mar 2014

    Ignore my previous reply. I have stepped through the code with pen and paper and i see that the leftChild is the local pointer. So how do i change the code so that the left child pointer is the actual pointer of roots left child.
  3. In Topic: Pointer value not getting updated

    Posted 27 Mar 2014

    Why is it a local variable?
    I will break it down and show you my thinking behind it and you can tell me where i am wrong.

    Spoiler


    Let's imagine the code in main we are executing is:
    tree.insert(3);
    


    1) newNode created at memory address: 0xB (inside insert() method)
    2) root has been initialized at memory address: 0xA. (inside insert() method)
    3)calling insertNode(0xA, 0xB);
    5)inside insertNode():
    6)root is not NULL so we skip this
    7)the else if statement executes and we go inside
    8) Node* leftChild is pointing to meomry address 0xC (which is NULL for now).
    9!) We call insertNode(0xC, 0xB)

    10)0xC is NULL so the first if statement executes and we set pointer to point to newNode.

    Where am i missing it?
  4. In Topic: Pointer value not getting updated

    Posted 26 Mar 2014

    OK. I have tried again from scratch and now when i am inserting the first node it is working. When i try to insert the second node - with value 3 - the Node comes out as NULL.
    When calling recursively it is not getting updated. I have tried your suggestion and now i am passing pointer by reference but it still gives errors.

    Updated code:

    Spoiler
  5. In Topic: LinkedList - infinite loop

    Posted 16 Mar 2014

    Thanks. I have fixed the code accordingly but now the program exits with an error code.
    It seems as if i go 1 Node too far in printing since it prints:

    5
    4
    3
    2
    1
    -94064

    Is my while loop in the printList() method correct?
    Updated code:
    Spoiler

My Information

Member Title:
D.I.C Lover
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Click here to e-mail me

Friends

darek9576 hasn't added any friends yet.

Comments

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