Lab 3
Warning
To compile you should use a CMakeLists.txt. It takes sometimes to get use to it, but it makes the compilation much easier.
AVL - Start
AVL - Template
Import the classes
Rectangle
andPosition
like in the previous lab (the comparison on the area).Create different rectangles (position and size), at least 15, and insert them in an AVL Tree.
Print the tree and ensure that the tree:
Contains all the rectangles
Have the rectangle ordered by the area
The tree is balanced
Try to remove some rectangle.
Make sure that the tree is still ordered.
Make sure that the tree is still balanced.
Do try to remove a rectangle that would make the rectangle unbalanced.
Modify the operators
operator<
,operator>
operator==
to compare the rectangle with the position.Redo the steps from 1 to 4. Make sure everything is working.
AVL - Advanced
Write the functions to perform the double rotation without the inefficiency of doing two single rotations. Make sure that it is working by comparing the two methods.
Write a nonrecursive function to insert into an AVL tree.
LeetCode
If you are done, you can start doing the following problems on LeetCode: