Upgrade to Pro — share decks privately, control downloads, hide ads and more …

[DSA-Java] Binary Search Trees - Remove Hibbard

Emory Courses
September 28, 2020

[DSA-Java] Binary Search Trees - Remove Hibbard

Emory Courses

September 28, 2020
Tweet

More Decks by Emory Courses

Other Decks in Technology

Transcript

  1. https://emory.gitbook.io/dsa-java Abstract BST - Remove 1 5 4 6 protected

    N removeHibbard(N node) { N successor = node.getRightChild(); N min = findMinNode(successor); N parent = min.getParent(); min.setLeftChild(node.getLeftChild()); if (min != successor) { parent.setLeftChild(min.getRightChild()); min.setRightChild(successor); } replaceChild(node, min); return parent; } 3 G 0 2
  2. https://emory.gitbook.io/dsa-java Abstract BST - Remove 1 5 4 6 protected

    N removeHibbard(N node) { N successor = node.getRightChild(); N min = findMinNode(successor); N parent = min.getParent(); min.setLeftChild(node.getLeftChild()); if (min != successor) { parent.setLeftChild(min.getRightChild()); min.setRightChild(successor); } replaceChild(node, min); return parent; } 3 G 0 2
  3. https://emory.gitbook.io/dsa-java Abstract BST - Remove 1 5 4 6 protected

    N removeHibbard(N node) { N successor = node.getRightChild(); N min = findMinNode(successor); N parent = min.getParent(); min.setLeftChild(node.getLeftChild()); if (min != successor) { parent.setLeftChild(min.getRightChild()); min.setRightChild(successor); } replaceChild(node, min); return parent; } 3 G 0 2
  4. https://emory.gitbook.io/dsa-java Abstract BST - Remove 1 5 4 6 protected

    N removeHibbard(N node) { N successor = node.getRightChild(); N min = findMinNode(successor); N parent = min.getParent(); min.setLeftChild(node.getLeftChild()); if (min != successor) { parent.setLeftChild(min.getRightChild()); min.setRightChild(successor); } replaceChild(node, min); return parent; } 3 G 0 2
  5. https://emory.gitbook.io/dsa-java Abstract BST - Remove 1 5 4 6 protected

    N removeHibbard(N node) { N successor = node.getRightChild(); N min = findMinNode(successor); N parent = min.getParent(); min.setLeftChild(node.getLeftChild()); if (min != successor) { parent.setLeftChild(min.getRightChild()); min.setRightChild(successor); } replaceChild(node, min); return parent; } 3 G 0 2
  6. https://emory.gitbook.io/dsa-java Abstract BST - Remove 1 5 4 6 protected

    N removeHibbard(N node) { N successor = node.getRightChild(); N min = findMinNode(successor); N parent = min.getParent(); min.setLeftChild(node.getLeftChild()); if (min != successor) { parent.setLeftChild(min.getRightChild()); min.setRightChild(successor); } replaceChild(node, min); return parent; } 3 G 0 2
  7. https://emory.gitbook.io/dsa-java Abstract BST - Remove 1 5 4 6 protected

    N removeHibbard(N node) { N successor = node.getRightChild(); N min = findMinNode(successor); N parent = min.getParent(); min.setLeftChild(node.getLeftChild()); if (min != successor) { parent.setLeftChild(min.getRightChild()); min.setRightChild(successor); } replaceChild(node, min); return parent; } 3 G 0 2
  8. https://emory.gitbook.io/dsa-java Abstract BST - Remove 1 5 4 6 protected

    N removeHibbard(N node) { N successor = node.getRightChild(); N min = findMinNode(successor); N parent = min.getParent(); min.setLeftChild(node.getLeftChild()); if (min != successor) { parent.setLeftChild(min.getRightChild()); min.setRightChild(successor); } replaceChild(node, min); return parent; } 3 G 0 2
  9. https://emory.gitbook.io/dsa-java Abstract BST - Remove 1 5 4 6 protected

    N removeHibbard(N node) { N successor = node.getRightChild(); N min = findMinNode(successor); N parent = min.getParent(); min.setLeftChild(node.getLeftChild()); if (min != successor) { parent.setLeftChild(min.getRightChild()); min.setRightChild(successor); } replaceChild(node, min); return parent; } 3 G 0 2
  10. https://emory.gitbook.io/dsa-java Abstract BST - Remove 1 5 4 6 protected

    N removeHibbard(N node) { N successor = node.getRightChild(); N min = findMinNode(successor); N parent = min.getParent(); min.setLeftChild(node.getLeftChild()); if (min != successor) { parent.setLeftChild(min.getRightChild()); min.setRightChild(successor); } replaceChild(node, min); return parent; } 3 G 0 2
  11. https://emory.gitbook.io/dsa-java Abstract BST - Remove 5 4 6 protected N

    removeHibbard(N node) { N successor = node.getRightChild(); N min = findMinNode(successor); N parent = min.getParent(); min.setLeftChild(node.getLeftChild()); if (min != successor) { parent.setLeftChild(min.getRightChild()); min.setRightChild(successor); } replaceChild(node, min); return parent; } 3 G 0 2