mardi 5 juillet 2022

How do you right rotate a binary search tree in c++?

I've seen a bunch of stuff about AVL trees and how to rotate them, but it's not exactly what I'm looking for. I'm trying to rotate a binary search tree to the right (a diagram is included below). Like I have a specific node I want to rotate around and I'm confused on how to rotate to the right around it.

If I start with a function like void rotateRight(int key){}, how would I use the value inside each of the nodes to then rotate the tree around it.

enter image description here

Aucun commentaire:

Enregistrer un commentaire