Speeding Up All The Things With Binary Trees


Exercises for Chapter #12 of A Common-Sense Guide To Data Structures and Algorithms

Get The Book!

Chapter Exercises


Exercise #1

Write a function that counts the number of items in a binary tree.

Exercise #2

Write a function that returns the sum of all the keys in a binary tree.

Exercise #3

Write a function that returns the maximum value of all the keys in a binary tree. Assume all values are nonnegative; return nil if the tree is empty.

Exercise #4

The height of a tree is the maximum number of nodes on a path from the root to a leaf node. Write a function that returns the height of a binary tree.

Let's Get In Touch!


Join the forum on The Pragmatic Programmers website to join in on the conversation about this book, or email Jay Wengrow, author of the book and this website directly.