c - Program crashes as it executes `free()` -


I am working with BST and I have to remove the node without any children. So the following steps are in my plan:

  1. Access the node;
  2. Check that he does not have any child;
  3. Find out that the node is on the left
  4. Delete the node and set the pointer to NULL .

My plan fails badly when the intrude free (father-> left) has arrived, I can not understand why the program crashes Even though I'm sure that father- & gt; In the left the memory address of the node is what I am trying to get rid of. What is happening? {If (root! = Null) {if ((root-> gt; value)> value);

  node * destroyed_a_net (node ​​* root, node * dad, conif int value) {Root-> Left = destroyed_a_net (root-> left, root, value); } And if ((root-> values) & lt; value) {root- & gt; Right = destroyed_a_node (root-> right, root, value); } Other {printf ("I am% d and my dad is% d \ n", root-> gt; value, father-> value); If (has_no_children (root)) {if (father-> gt; left == root) {Free (father-> left); Father- & gt; Left = null; }} // code to come for more ...}} return route; }  


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -