Skip to main content
RISC
  • Home
  • More
English ‎(en)‎
Deutsch ‎(de)‎ English ‎(en)‎
You are currently using guest access
Log in
RISC
Home
Expand all Collapse all
  1. PractSoftTech15
  2. Exercises
  3. Exercise 8 (Binary Search Trees)

Exercise 8 (Binary Search Trees)

Completion requirements
Opened: Thursday, 21 May 2015, 12:00 AM
Due: Saturday, 30 May 2015, 8:00 AM

Delete a Node from a Binary Search Tree

  • Implement an algorithm to delete a node from the binary search tree which we discussed during the lecture.
    • Download the source code from the Moodle page and implement the method delete.
    • Use the method getSuccessor to find the successor if the node to be deleted has two child nodes (like discussed during the lecture).
      public class Tree<E extends Comparable<E>> {
      ...
      /**
      * Returns true in case of success and false if the given node was not found.
      */
      public boolean delete(E node) {
      // TODO: Implement this algorithm.
      }
      private Node<E> getSuccessor(Node<E> delNode) {
      ...
      }
  • Write a short documentation how the delete node algorithm works (format txt or pdf). Explain why the algorithm works (also the sub-algorithm to find a successor).

Hints

Take care of the case where the node to be deleted is the root. There are three cases for the node to be deleted:

  1. The node is a leaf.
  2. The node has one child node.
  3. The node has two child nodes.


You are currently using guest access (Log in)
Data retention summary
Get the mobile app
Powered by Moodle