Do you want BuboFlash to help you learning these things? Or do you want to add or correct something? Click here to log in or create user.

Question
In algorithms, for BinarySearchTree delete method (def delete(self, data): ), first thing you need to do is [...multi word description...] , then there is three cases to handle (node to delete has 0 children, node to delete has 1 child, node to delete has 2 children).
Answer

get the pointer to node to delete and its parent (using helper method: get_node_with_parent(self, data), which returns (parent, node) ):

Here is the helper function implementation (as a bonus):

   def __get_node_with_parent(self, data):
parent = None
current = self.root_node
while current:
if data == current.data:
return (parent, current)
parent = current
if data < current.data:
current = current.left_child
else:
current = current.right_child
return (None, None)

Question
In algorithms, for BinarySearchTree delete method (def delete(self, data): ), first thing you need to do is [...multi word description...] , then there is three cases to handle (node to delete has 0 children, node to delete has 1 child, node to delete has 2 children).
Answer
?

Question
In algorithms, for BinarySearchTree delete method (def delete(self, data): ), first thing you need to do is [...multi word description...] , then there is three cases to handle (node to delete has 0 children, node to delete has 1 child, node to delete has 2 children).
Answer

get the pointer to node to delete and its parent (using helper method: get_node_with_parent(self, data), which returns (parent, node) ):

Here is the helper function implementation (as a bonus):

   def __get_node_with_parent(self, data):
parent = None
current = self.root_node
while current:
if data == current.data:
return (parent, current)
parent = current
if data < current.data:
current = current.left_child
else:
current = current.right_child
return (None, None)
If you want to change selection, open document below and click on "Move attachment"

pdf

owner: kkhosravi - (no access) - PYTHON_DATA_STRUCTURES_AND_ALGORITHMS.pdf, p157

Summary

status measured difficulty not learned 37% [default] 0

No repetitions

Discussion

Do you want to join discussion? Click here to log in or create user.