You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think we might need it because when we want to finally print what we have, when we find the maximum count in a node we print it and then we delete the node, then we run the find max function again to find the next max.
We can't not delete the node, because if we do then we have a problem:
Imagine we have 3 words with count 3, when we find the first and print it, we will run the program again, we will find the same node again.. and we might not find the third node with count 3 at all.
I think you are talking about distinct issues. Louis is asking: do we need a function to destroy one node, and the answer to that is: IF the node contains dynamic memory (e.g. if its constructor function allocates more memory than just the Node struct), then you DEFINITELY need a function to destroy the node, and thus free any dynamic memory it is managing. Destroying the tree will free dynamic nodes in the tree, but not memory allocated within the node.
Nima is talking about the algorithm to extract the count data from the tree. This will use the tree's API to remove nodes from the tree (for reasons Nima gives above), but it is not concerned with any of the internal details of how the tree accomplishes this.
So long as there is a Remove Node function, Nima will be happy.
So long as removing a node does not create a memory leak, Joseph will be happy :-)
I don't think that we need to worry about destroy just single node since we can destroy the whole tree at once just like the code I wrote in lab9.
The text was updated successfully, but these errors were encountered: