Skip to main content

Section 32.14 Exercises

These exercises use the same BSTNode structure as our basic binary search tree implementation. Here is the BSTNode definition:
Listing 32.14.1. BSTNode Declaration
struct BSTNode {
  // Store a value and two child pointers
  char value;
  BSTNode* left;
  BSTNode* right;
};

Checkpoint 32.14.1.

Implement getHeight to return the height of the subtree rooted at the given node.

Checkpoint 32.14.2.

Implement rotateRight to perform a right rotation on the subtree rooted at the given node. It should return the new root of the rotated subtree.

Checkpoint 32.14.3.

Implement rotateLeft to perform a left rotation on the subtree rooted at the given node. It should return the new root of the rotated subtree.
You have attempted of activities on this page.