BEST代写-线上编程学术专家

Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

C++代写 | Implementation of AVL Trees | Assignment

C++代写 | Implementation of AVL Trees | Assignment

这是一个C++数据结构的作业代写,涉及二叉树和平衡二叉搜索树,作业难度中下。

1 Task Description

You are asked to use C++ to implement
Binary Tree Traversal
AVL Tree Insertion and Deletion

2 Submission Guideline

You must follow this guideline! Your submission will be marked automatically. Failure to
follow this guideline will result in 0.

Your submission should contain exactly one le: main.cpp

You do not need to submit a design.

There are be di erent versions of AVL trees. You should implement the one speci ed on the slides (e.g.,
when 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 modi cation moves” separated by spaces (1  n  100). The available
modi cation 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 nishing move (PRE or POST or IN): If the nishing 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.

You don’t 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

3 Marking

Marking will be done automatically. There are 100 test cases.
C++ Implementation of AVL Trees
We will compile your code using g++ -o main.out -std=c++11 -O2 -Wall main.cpp

bestdaixie

评论已关闭。