In this assignment you will implement AVL trees. You are responsible for implementing insertion and deletion, so you are also responsible for rotating subtrees to maintain the balance property, find the minimum, and a few additional auxiliary methods. In assignment3.zip, we are providing you with the following code: avl.cpp -> your AVL implementation, mostly dummy text avl.hpp -> header file, you do not have to change it

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

how to do this in c++ programming? HELP with explanation of the code!!

In this assignment, you will implement AVL trees. You are responsible for implementing insertion and deletion, so you are also responsible for rotating subtrees to maintain the balance property, find the minimum, and a few additional auxiliary methods.

In `assignment3.zip`, we are providing you with the following code:

- **avl.cpp**: Your AVL implementation, mostly dummy text
- **avl.hpp**: Header file, you do not have to change it

`avl.cpp` already has a couple of methods implemented that you **should not change**:

- A method to print trees
- A main method that reads test cases (sequences of operations) and executes them

A sample README file is also provided. You may find how to compile and test the code.

We will test your implementation with test cases that spell out operations (insert a number, delete a number, and print) to be executed on an (initially) empty AVL tree. For example,

```
insert 100
insert 30
insert 20
insert 50
print
delete 30
print
insert 990
insert 900
print
```

This means that you should insert 100, 30, 20, 50 and print the resulting AVL tree. Then, you should delete 30 and print the resulting AVL tree. Finally, you need to insert 990 and 900 and print the resulting AVL tree. The expected outcome is the following:

```
30
| l 20
| r 100
|  | l 50
```

**Explanation of the AVL Tree Diagram:**

- The root node is **30**.
- Node **20** is the left child of 30.
- Node **100** is the right child of 30.
- Node **50** is the left child of 100. 

This visual structure represents the balanced nature of AVL trees, where each node maintains the AVL property of balanced subtrees.
Transcribed Image Text:In this assignment, you will implement AVL trees. You are responsible for implementing insertion and deletion, so you are also responsible for rotating subtrees to maintain the balance property, find the minimum, and a few additional auxiliary methods. In `assignment3.zip`, we are providing you with the following code: - **avl.cpp**: Your AVL implementation, mostly dummy text - **avl.hpp**: Header file, you do not have to change it `avl.cpp` already has a couple of methods implemented that you **should not change**: - A method to print trees - A main method that reads test cases (sequences of operations) and executes them A sample README file is also provided. You may find how to compile and test the code. We will test your implementation with test cases that spell out operations (insert a number, delete a number, and print) to be executed on an (initially) empty AVL tree. For example, ``` insert 100 insert 30 insert 20 insert 50 print delete 30 print insert 990 insert 900 print ``` This means that you should insert 100, 30, 20, 50 and print the resulting AVL tree. Then, you should delete 30 and print the resulting AVL tree. Finally, you need to insert 990 and 900 and print the resulting AVL tree. The expected outcome is the following: ``` 30 | l 20 | r 100 | | l 50 ``` **Explanation of the AVL Tree Diagram:** - The root node is **30**. - Node **20** is the left child of 30. - Node **100** is the right child of 30. - Node **50** is the left child of 100. This visual structure represents the balanced nature of AVL trees, where each node maintains the AVL property of balanced subtrees.
### Binary Tree Structures

#### Tree 1:
- **Root Node**: 50
  - **Left Child**: 20
  - **Right Child**: 100
  
#### Tree 2:
- **Root Node**: 50
  - **Left Child**: 20
  - **Right Child**: 900
    - **Left Child of 900**: 100
    - **Right Child of 900**: 990

The second tree's structure is such that the root node is 50. It has two children: 20 and 900. The node 900 further has two children: 100 and 990. Additionally, in Tree 1, node 50 is the left child of node 100.
Transcribed Image Text:### Binary Tree Structures #### Tree 1: - **Root Node**: 50 - **Left Child**: 20 - **Right Child**: 100 #### Tree 2: - **Root Node**: 50 - **Left Child**: 20 - **Right Child**: 900 - **Left Child of 900**: 100 - **Right Child of 900**: 990 The second tree's structure is such that the root node is 50. It has two children: 20 and 900. The node 900 further has two children: 100 and 990. Additionally, in Tree 1, node 50 is the left child of node 100.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Binomial Heap
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education