From the course: Python Data Structures: Trees

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Introduction to rotations

Introduction to rotations - Python Tutorial

From the course: Python Data Structures: Trees

Start my 1-month free trial

Introduction to rotations

- [Instructor] In the last chapter, we looked at the unbalanced tree. So how to detect imbalances and how to mark the nodes at which these imbalances occur. And remember the notation I'm using here is the asterisk. And in this chapter, we're going to look at how to actually fix these imbalances. So how to take a scraggly tree like this and turn it into a bushy and faster search tree. Remember, and imbalance occurs when there's a height difference of two or more between the left and the right side at any given node. So when computer scientists are looking at an imbalance, what they're really looking at is the next two levels below the current node. And because we only need to look at two levels to see if an imbalance exists, these two levels can also be used to classify the imbalance into one of four types. You see, computer scientists really care about whether these imbalances are on the left or the right, and whether they…

Contents