Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are asked to use C++ to implement Binary Tree Traversal AVL Tree Insertion and Deletion Your submission should contain exactly one file: main.cpp You

You are asked to use C++ to implement

Binary Tree Traversal

AVL Tree Insertion and Deletion

Your submission should contain exactly one file: main.cpp You do not need to submit a design.

There are be different versions of AVL trees. You should implement one where you delete a node with two children, swap the value with the largest value on the left.

You should start your program by initializing an empty AVL tree. Your program takes one line as input. The input line contains n modification moves separated by spaces (1 n 100). The available modification moves are

Aint (Character A followed by an int value between 1 and 100): A3 means insert value 3 into the AVL tree. If 3 is already in the tree, do nothing.

Dint (Character D followed by an int value between 1 and 100): D3 means delete value 3 into the AVL tree. If 3 is not in the tree, do nothing.

Your input is then followed by exactly one finishing move (PRE or POST or IN): If the finishing move is PRE, then you should print out the tree (in its current situation) in pre-order. If the tree is empty, print out EMPTY. Otherwise, print out the values separated by spaces. POST and IN are handled similarly.

compile your code using g++ -o main.out -std=c++11 -O2 -Wall main.cpp

You dont need to worry about invalid inputs.

Sample input 1: A1 A2 A3 IN Sample output 1: 1 2 3

Sample input 2: A1 A2 A3 PRE Sample output 2: 2 1 3

Sample input 3: A1 D1 POST Sample output 3: EMPTY

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

More Books

Students also viewed these Databases questions

Question

dy dx Find the derivative of the function y=(4x+3)5(2x+1)2.

Answered: 1 week ago

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago