# 17.7 Exercises

## Factual

1. Which of the following are valid 2-3 trees?

&#x20;

<figure><img src="/files/VYqU3npB4MbNnkzuQfC0" alt=""><figcaption></figcaption></figure>

<details>

<summary>Problem 1</summary>

Only (a).

A 2-3 tree only allows up to 3 children, which means a node can only have at most 2 values. (b) has an extra value in the rightmost node.

A 2-3 tree must also be perfectly balanced. (c) is imbalanced.

A B-Tree node always has one more child than the number of values. So in a 2-3 tree, a node with 1 value has 2 children, and a node with 2 values has 3 children. (d) violates this with the node `21`, which has one value but 3 children.

</details>

## Procedural

1. Draw the 2-3 tree that results from inserting `1, 2, 3, 4, 5, 6, 7` in order.
2. [Problem 1](https://drive.google.com/file/d/1Vo8p4vbOGt7eY5TtalvAEnk4ignpTVvm/view?usp=sharing) of the Spring 2018 Midterm 2

<details>

<summary>Problem 1</summary>

Check your answers using this [interactive visualizer.](https://www.cs.usfca.edu/~galles/visualization/BTree.html)

</details>

<details>

<summary>Problem 2</summary>

[Solutions](https://drive.google.com/file/d/1LIyFXwHYCWXNqIgKTsTyKiOYnB79_ykk/view?usp=sharing) and [walkthrough](https://www.youtube.com/watch?v=nMZn4EV0gGw) are linked here and on the course website.

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cs61b-2.gitbook.io/cs61b-textbook/17.-b-trees/17.7-exercises.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
