SlideShare a Scribd company logo
1 of 19
Assignment Two
Objectives
• Understand how the AVL tree works
• Give you further practice with C and data structures
Admin
Marks 10 marks, excluding bonus marks. Marking is based on
the correctness and
efficiency of your code. Your code must be well commented.
Group? This assignment is completed individually.
Due Time 23:59:59 pm on Sunday 31 March 2019. 23:59:59
pm on Wed 3 April 2019
Late Submissions Late submissions will not be accepted!
In this assignment, you will implement AVL tree and a set of
functions associated with AVL
tree. For simplicity, we make the following assumptions:
1. Each item of an AVL tree contains an integer key and an
integer value.
2. No AVL tree contains duplicate items. Two items (k1, v1)
and (k2, v2) are duplicates
iff k1=k2 and v1=v2 hold.
3. An AVL tree may contains multiple items with the same key
and the number of
duplicate keys is a constant.
A template file named MyAVLTree.c is provided.
MyAVLTree.c contains the type definitions of
AVL tree and AVL tree node as well as some basic functions.
You can add your own helper
functions and auxiliary data structures for better performance in
terms of time complexity.
You need to implement the following functions:
1. AVLTree *CreateAVLTree(const char *filename). This
function creates an AVL tree by
reading all the items from a text file or from the standard input
(keyboard)
depending on the argument filename. If filename is “stdin”, this
function will read all
the items from the standard input. Otherwise, it will read all the
items from a text
file with filename as its full path name. (2 marks)
An input text file contains zero or more items where each item
is of the form (key,
value). Any characters such as white space between two
adjacent items are ignored.
For example, the following sample file contains 10 items:
(2, 50) (4, 30) (9, 30) (10, 400) (-5, -40)
(7, 20) (19, 200) (20, 50) (-18, -200) (-2, 29)
Similarly, when reading from the standard input, each input line
may have zero or
more items, separated by one or more white space characters.
An empty line
indicates the end of input.
In case of an error in the input, this function will print the error
and your program
terminates.
You may assume that the input does not contain duplicate items
and thus this
function does not need to check for duplicate items.
The time complexity of this function cannot be higher than O(n
logn), where n is the
size of the resulting AVL tree. If your time complexity is
higher, you will get 0 mark
for this function. You may assume that each call to a C built-in
function takes O(1)
time.
2. AVLTree *CloneAVLTree(AVLTree *T). This function
creates an identical copy (clone)
of the input AVL tree T, and returns a pointer to the clone tree.
(1 mark)
The time complexity of this function cannot be higher than
O(n), where n is the size
of T. If your time complexity is higher, you will get 0 mark for
this function.
3. AVLTree *AVLTreesUnion(AVLTree *T1, AVLTree *T2).
This function computes the
union tree of two AVL trees T1 and T2 and returns a pointer to
the union tree. The
union tree of two AVL trees T1 and T2 is an AVL tree that
contains all the items of
both T1 and T2 without duplicate items. Assume that neither T1
nor T2 contains
duplicate items. Note that this function does not make any
change to T1 and T2. (2
marks)
The time complexity of this function cannot be higher than
O((m+n)log(m+n)),
where m and n are the sizes of T1 and T2, respectively. If your
time complexity is
higher, you will get 0 mark for this function.
Bonus marks: A correct tree union function with the time
complexity O(m+n) will be
awarded 1 bonus mark, where m and n are the sizes of T1 and
T2, respectively.
An example: consider the following two AVL trees T1 and T2:
The union tree of T1 and T2 is shown as follows:
Note that in general the union tree may not be unique with
respect to shape
(structure) depending on how it is constructed.
4. AVLTree *AVLTreesIntersection(AVLTree *T1, AVLTree
*T2). This function computes
the intersection tree of two AVL trees T1 and T2 and returns a
pointer to the
intersection tree. The intersection tree of two AVL trees T1 and
T2 is an AVL tree
that contains all the items that appear in both T1 and T2.
Assume that neither T1 nor
T2 contains duplicate items. Note that this function does not
make any change to T1
and T2. (2 marks)
The time complexity of this function cannot be higher than
O(m+n+k log k), where m
and n are the sizes of T1 and T2, respectively, and k the size of
the intersection tree.
If your time complexity is higher, you will get 0 mark for this
function.
Bonus marks: A correct tree intersection function with the time
complexity O(m+n)
will be awarded 1 bonus mark, where m and n are the sizes of
T1 and T2,
respectively.
An example: consider the previous two AVL trees T1 and T2.
The intersection tree is
shown as follows:
Note that in general the intersection tree may not be unique with
respect to shape
(structure) depending on how it is constructed.
5. int InsertNode(AVLTree *T, int k, int v). If the item (k, v)
exists in the tree, this
function simply returns 0 without adding the new item (k, v) to
the tree. Otherwise,
it inserts the new item (k, v) into the AVL tree T, increases the
tree size by one and
returns 1. (0.5 mark)
The time complexity of this function cannot be higher than
O(log n), where n is the
size of T. If your time complexity is higher, you will get 0 mark
for this function.
6. int DeleteNode(AVLTree *T, int k, int v). If the item (k, v)
exists in the AVL tree T, this
function deletes the node containing this item, decreases the
tree size by one and
returns 1. Otherwise, it returns 0 only. (1 mark)
The time complexity of this function cannot be higher than
O(log n), where n is the
size of T. If your time complexity is higher, you will get 0 mark
for this function.
7. AVLTreeNode *Search(AVLTree *T, int k, int v). This
function search for the item (k,
v) in the AVL tree T. If the item is found, it returns a pointer to
the node containing
the item. Otherwise, it returns NULL. (0.5 mark)
The time complexity of this function cannot be higher than
O(log n), where n is the
size of T. If your time complexity is higher, you will get 0 mark
for this function.
8. void FreeAVLTree(AVLTree *T). This function frees up the
heap space occupied by
the AVL tree T. (0.5 mark)
The time complexity of this function cannot be higher than
O(n), where n is the size
of T. If your time complexity is higher, you will get 0 mark for
this function. You may
assume that each call to free() takes O(1) time.
9. void PrintAVLTree(AVLTree *T). This function prints all the
items and their heights
stored in the AVL tree T sorted in non-decreasing order of keys
on the standard
output (screen). Each item is denoted by (key, value) with one
item per line. For
example, consider the following AVL tree:
The output of PrintAVLTree is:
(6, 12), 1
(6, 20), 0
(6, 25), 2
(10, 25), 0
Your output can be different as long as it makes sense.
The time complexity of this function cannot be higher than
O(n), where n is the size
of T. If your time complexity is higher, you will get 0 mark for
this function. You may
assume that each call to a built-in C function takes O(1) time.
(0.5 mark)
For each function, analyze its time complexity, and put the time
complexity analysis as
comments before the function. For the time complexity of each
function, you just need to give
the time complexity of major components (loops) and the total
time complexity. You may
assume that each call to a built-in C function takes constant
(O(1)) time.
How to submit your code?
a. Go to the assignment page
b. Click on Assignment Specifications for Assignment 2
c. Click on Make Submission
d. Submit your MyAVLTree.c file that contains all the code.
Plagiarism
This is an individual assignment. Each student will have to
develop their own solution without
help from other people. In particular, it is not permitted to
exchange code or pseudocode.
You are not allowed to use code developed by persons other
than yourself. All work
submitted for assessment must be entirely your own work. We
regard unacknowledged
copying of material, in whole or part, as an extremely serious
offence. For further information,
see the Course Information.
(2, 50) (4, 30) (9, 30) (10, 400) (-5, -40)
(7, 20) (19, 200) (20, 50) (-18, -200) (-2, 29)
(2, 67) (4, 35) (9, 45) (-18, 100)
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
// all the basic data structures and functions are included in this
template
// you can add your own auxiliary functions as you like
// data type for avl tree nodes
typedef struct AVLTreeNode {
int key; //key of this item
int value; //value (int) of this item
int height; //height of the subtree rooted at this node
struct AVLTreeNode *parent; //pointer to parent
struct AVLTreeNode *left; //pointer to left child
struct AVLTreeNode *right; //pointer to right child
} AVLTreeNode;
//data type for AVL trees
typedef struct AVLTree{
int size; // count of items in avl tree
AVLTreeNode *root; // root
} AVLTree;
// create a new AVLTreeNode
AVLTreeNode *newAVLTreeNode(int k, int v )
{
AVLTreeNode *new;
new = malloc(sizeof(AVLTreeNode));
assert(new != NULL);
new->key = k;
new->value = v;
new->height = 0; // height of this new node is set to 0
new->left = NULL; // this node has no child
new->right = NULL;
new->parent = NULL; // no parent
return new;
}
// create a new empty avl tree
AVLTree *newAVLTree()
{
AVLTree *T;
T = malloc(sizeof (AVLTree));
assert (T != NULL);
T->size = 0;
T->root = NULL;
return T;
}
// put your time complexity analysis of CreateAVLTree() here
AVLTree *CreateAVLTree(const char *filename)
{
// put your code here
}
// put your time complexity analysis for CloneAVLTree() here
AVLTree *CloneAVLTree(AVLTree *T)
{
// put your code here
}
// put your time complexity for ALVTreesUNion() here
AVLTree *AVLTreesUnion(AVLTree *T1, AVLTree *T2)
{
//put your code here
}
// put your time complexity for ALVTreesIntersection() here
AVLTree *AVLTreesIntersection(AVLTree *T1, AVLTree *T2)
{
//put your code here
}
// put the time complexity analysis for InsertNode() here
int InsertNode(AVLTree *T, int k, int v)
{
//put your code here
}
// put your time complexity for DeleteNode() here
int DeleteNode(AVLTree *T, int k, int v)
{
// put your code here
}
// put your time complexity analysis for Search() here
AVLTreeNode *Search(AVLTree *T, int k, int v)
{
// put your code here
}
// put your time complexity analysis for freeAVLTree() here
void FreeAVLTree(AVLTree *T)
{
// put your code here
}
// put your time complexity analysis for PrintAVLTree() here
void PrintAVLTree(AVLTree *T)
{
// put your code here
}
int main() //sample main for testing
{ int i,j;
AVLTree *tree1, *tree2, *tree3, *tree4, *tree5, *tree6, *tree7,
*tree8;
AVLTreeNode *node1;
tree1=CreateAVLTree("stdin");
PrintAVLTree(tree1);
FreeAVLTree(tree1);
//you need to create the text file file1.txt
// to store a set of items without duplicate items
tree2=CreateAVLTree("file1.txt");
PrintAVLTree(tree2);
tree3=CloneAVLTree(tree2);
PrintAVLTree(tree3);
FreeAVLTree(tree2);
FreeAVLTree(tree3);
//Create tree4
tree4=newAVLTree();
j=InsertNode(tree4, 10, 10);
for (i=0; i<15; i++)
{
j=InsertNode(tree4, i, i);
if (j==0) printf("(%d, %d) already existsn", i, i);
}
PrintAVLTree(tree4);
node1=Search(tree4,20,20);
if (node1!=NULL)
printf("key= %d value= %dn",node1->key,node1->value);
else
printf("Key 20 does not existn");
for (i=17; i>0; i--)
{
j=DeleteNode(tree4, i, i);
if (j==0)
printf("Key %d does not existn",i);
PrintAVLTree(tree4);
}
FreeAVLTree(tree4);
//Create tree5
tree5=newAVLTree();
j=InsertNode(tree5, 6, 25);
j=InsertNode(tree5, 6, 10);
j=InsertNode(tree5, 6, 12);
j=InsertNode(tree5, 6, 20);
j=InsertNode(tree5, 9, 25);
j=InsertNode(tree5, 10, 25);
PrintAVLTree(tree5);
//Create tree6
tree6=newAVLTree();
j=InsertNode(tree6, 6, 25);
j=InsertNode(tree6, 5, 10);
j=InsertNode(tree6, 6, 12);
j=InsertNode(tree6, 6, 20);
j=InsertNode(tree6, 8, 35);
j=InsertNode(tree6, 10, 25);
PrintAVLTree(tree6);
tree7=AVLTreesIntersection(tree5, tree6);
tree8=AVLTreesUnion(tree5,tree6);
PrintAVLTree(tree7);
PrintAVLTree(tree8);
return 0;
}

More Related Content

Similar to Assignment Two Objectives • Understand how the.docx

Objectives Assignment 09 Applications of Stacks COS.docx
Objectives Assignment 09 Applications of Stacks COS.docxObjectives Assignment 09 Applications of Stacks COS.docx
Objectives Assignment 09 Applications of Stacks COS.docxdunhamadell
 
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdfAbstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdfkarymadelaneyrenne19
 
Using-Python-Libraries.9485146.powerpoint.pptx
Using-Python-Libraries.9485146.powerpoint.pptxUsing-Python-Libraries.9485146.powerpoint.pptx
Using-Python-Libraries.9485146.powerpoint.pptxUadAccount
 
Computer science ms
Computer science msComputer science ms
Computer science msB Bhuvanesh
 
Digital Signal Processing Lab Manual
Digital Signal Processing Lab Manual Digital Signal Processing Lab Manual
Digital Signal Processing Lab Manual Amairullah Khan Lodhi
 
sonam Kumari python.ppt
sonam Kumari python.pptsonam Kumari python.ppt
sonam Kumari python.pptssuserd64918
 
Maxbox starter19
Maxbox starter19Maxbox starter19
Maxbox starter19Max Kleiner
 
Talk on Standard Template Library
Talk on Standard Template LibraryTalk on Standard Template Library
Talk on Standard Template LibraryAnirudh Raja
 
Kotlin- Basic to Advance
Kotlin- Basic to Advance Kotlin- Basic to Advance
Kotlin- Basic to Advance Coder Tech
 
Intro To C++ - Class #18: Vectors & Arrays
Intro To C++ - Class #18: Vectors & ArraysIntro To C++ - Class #18: Vectors & Arrays
Intro To C++ - Class #18: Vectors & ArraysBlue Elephant Consulting
 
Mat lab workshop
Mat lab workshopMat lab workshop
Mat lab workshopVinay Kumar
 
Assg 14 C++ Standard Template Library (STL)(Extra Credit .docx
Assg 14 C++ Standard Template Library (STL)(Extra Credit .docxAssg 14 C++ Standard Template Library (STL)(Extra Credit .docx
Assg 14 C++ Standard Template Library (STL)(Extra Credit .docxfestockton
 
Array 31.8.2020 updated
Array 31.8.2020 updatedArray 31.8.2020 updated
Array 31.8.2020 updatedvrgokila
 

Similar to Assignment Two Objectives • Understand how the.docx (20)

Objectives Assignment 09 Applications of Stacks COS.docx
Objectives Assignment 09 Applications of Stacks COS.docxObjectives Assignment 09 Applications of Stacks COS.docx
Objectives Assignment 09 Applications of Stacks COS.docx
 
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdfAbstract Data Types (a) Explain briefly what is meant by the ter.pdf
Abstract Data Types (a) Explain briefly what is meant by the ter.pdf
 
Using-Python-Libraries.9485146.powerpoint.pptx
Using-Python-Libraries.9485146.powerpoint.pptxUsing-Python-Libraries.9485146.powerpoint.pptx
Using-Python-Libraries.9485146.powerpoint.pptx
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
 
Bcsl 033 solve assignment
Bcsl 033 solve assignmentBcsl 033 solve assignment
Bcsl 033 solve assignment
 
Computer science ms
Computer science msComputer science ms
Computer science ms
 
Digital Signal Processing Lab Manual
Digital Signal Processing Lab Manual Digital Signal Processing Lab Manual
Digital Signal Processing Lab Manual
 
Mechanical Engineering Homework Help
Mechanical Engineering Homework HelpMechanical Engineering Homework Help
Mechanical Engineering Homework Help
 
Linked list
Linked listLinked list
Linked list
 
sonam Kumari python.ppt
sonam Kumari python.pptsonam Kumari python.ppt
sonam Kumari python.ppt
 
Maxbox starter19
Maxbox starter19Maxbox starter19
Maxbox starter19
 
Talk on Standard Template Library
Talk on Standard Template LibraryTalk on Standard Template Library
Talk on Standard Template Library
 
Matlab-3.pptx
Matlab-3.pptxMatlab-3.pptx
Matlab-3.pptx
 
Kotlin- Basic to Advance
Kotlin- Basic to Advance Kotlin- Basic to Advance
Kotlin- Basic to Advance
 
sol43.pdf
sol43.pdfsol43.pdf
sol43.pdf
 
Intro To C++ - Class #18: Vectors & Arrays
Intro To C++ - Class #18: Vectors & ArraysIntro To C++ - Class #18: Vectors & Arrays
Intro To C++ - Class #18: Vectors & Arrays
 
Python Modules and Libraries
Python Modules and LibrariesPython Modules and Libraries
Python Modules and Libraries
 
Mat lab workshop
Mat lab workshopMat lab workshop
Mat lab workshop
 
Assg 14 C++ Standard Template Library (STL)(Extra Credit .docx
Assg 14 C++ Standard Template Library (STL)(Extra Credit .docxAssg 14 C++ Standard Template Library (STL)(Extra Credit .docx
Assg 14 C++ Standard Template Library (STL)(Extra Credit .docx
 
Array 31.8.2020 updated
Array 31.8.2020 updatedArray 31.8.2020 updated
Array 31.8.2020 updated
 

More from lynettearnold46882

Assignment User FrustrationThe quality of the user experience i.docx
Assignment User FrustrationThe quality of the user experience i.docxAssignment User FrustrationThe quality of the user experience i.docx
Assignment User FrustrationThe quality of the user experience i.docxlynettearnold46882
 
Assignment Upstream Approaches to Canadian Population HealthAlt.docx
Assignment Upstream Approaches to Canadian Population HealthAlt.docxAssignment Upstream Approaches to Canadian Population HealthAlt.docx
Assignment Upstream Approaches to Canadian Population HealthAlt.docxlynettearnold46882
 
Assignment Type up an essay on one of two prompts and submit the .docx
Assignment Type up an essay on one of two prompts and submit the .docxAssignment Type up an essay on one of two prompts and submit the .docx
Assignment Type up an essay on one of two prompts and submit the .docxlynettearnold46882
 
Assignment TypeIndividual ProjectDeliverable Length8–10 slid.docx
Assignment TypeIndividual ProjectDeliverable Length8–10 slid.docxAssignment TypeIndividual ProjectDeliverable Length8–10 slid.docx
Assignment TypeIndividual ProjectDeliverable Length8–10 slid.docxlynettearnold46882
 
Assignment Type Individual discussion Board;   450 – 550 word.docx
Assignment Type Individual discussion Board;   450 – 550 word.docxAssignment Type Individual discussion Board;   450 – 550 word.docx
Assignment Type Individual discussion Board;   450 – 550 word.docxlynettearnold46882
 
Assignment Two UNIT 2Student Name _______________________.docx
Assignment Two UNIT 2Student Name _______________________.docxAssignment Two UNIT 2Student Name _______________________.docx
Assignment Two UNIT 2Student Name _______________________.docxlynettearnold46882
 
Assignment Two Select a college or university and provide th.docx
Assignment Two Select a college or university and provide th.docxAssignment Two Select a college or university and provide th.docx
Assignment Two Select a college or university and provide th.docxlynettearnold46882
 
Assignment Topic Exploration and Analysis (Proposal)In Week 6 o.docx
Assignment Topic Exploration and Analysis (Proposal)In Week 6 o.docxAssignment Topic Exploration and Analysis (Proposal)In Week 6 o.docx
Assignment Topic Exploration and Analysis (Proposal)In Week 6 o.docxlynettearnold46882
 
Assignment To consider three sources about the Fall of Rome and w.docx
Assignment To consider three sources about the Fall of Rome and w.docxAssignment To consider three sources about the Fall of Rome and w.docx
Assignment To consider three sources about the Fall of Rome and w.docxlynettearnold46882
 
Assignment topic Rapid Influenza Testing in Children and Adult.docx
Assignment topic  Rapid Influenza Testing in Children and Adult.docxAssignment topic  Rapid Influenza Testing in Children and Adult.docx
Assignment topic Rapid Influenza Testing in Children and Adult.docxlynettearnold46882
 
Assignment Topic 1Choose a contemporary painting, sculpture, o.docx
Assignment Topic 1Choose a contemporary painting, sculpture, o.docxAssignment Topic 1Choose a contemporary painting, sculpture, o.docx
Assignment Topic 1Choose a contemporary painting, sculpture, o.docxlynettearnold46882
 
Assignment TitleAssessment Item 03 Case Study Analysis – Engagi.docx
Assignment TitleAssessment Item 03 Case Study Analysis – Engagi.docxAssignment TitleAssessment Item 03 Case Study Analysis – Engagi.docx
Assignment TitleAssessment Item 03 Case Study Analysis – Engagi.docxlynettearnold46882
 
Assignment Title Knowledge management cycle process in or.docx
Assignment Title Knowledge management cycle process in or.docxAssignment Title Knowledge management cycle process in or.docx
Assignment Title Knowledge management cycle process in or.docxlynettearnold46882
 
Assignment Three Technical Descriptions Due March 2 (1155 PM .docx
Assignment Three Technical Descriptions Due March 2 (1155 PM .docxAssignment Three Technical Descriptions Due March 2 (1155 PM .docx
Assignment Three Technical Descriptions Due March 2 (1155 PM .docxlynettearnold46882
 
Assignment ThreeUNIT 3 – ON LINE CLASSStudent Name __________.docx
Assignment ThreeUNIT 3 – ON LINE CLASSStudent Name __________.docxAssignment ThreeUNIT 3 – ON LINE CLASSStudent Name __________.docx
Assignment ThreeUNIT 3 – ON LINE CLASSStudent Name __________.docxlynettearnold46882
 
Assignment title An Evaluation of the Business Strategy at Mc D.docx
Assignment title An Evaluation of the Business Strategy at Mc D.docxAssignment title An Evaluation of the Business Strategy at Mc D.docx
Assignment title An Evaluation of the Business Strategy at Mc D.docxlynettearnold46882
 
ASSIGNMENT The student will submit a research project that compares.docx
ASSIGNMENT The student will submit a research project that compares.docxASSIGNMENT The student will submit a research project that compares.docx
ASSIGNMENT The student will submit a research project that compares.docxlynettearnold46882
 
Assignment Three Case study report – mixed mediaValue 40 .docx
Assignment Three Case study report – mixed mediaValue 40 .docxAssignment Three Case study report – mixed mediaValue 40 .docx
Assignment Three Case study report – mixed mediaValue 40 .docxlynettearnold46882
 
Assignment The Nurse Leader as Knowledge WorkerThe term kn.docx
Assignment The Nurse Leader as Knowledge WorkerThe term kn.docxAssignment The Nurse Leader as Knowledge WorkerThe term kn.docx
Assignment The Nurse Leader as Knowledge WorkerThe term kn.docxlynettearnold46882
 
Assignment The Self-Knowledge ProcessPeople come to know themse.docx
Assignment The Self-Knowledge ProcessPeople come to know themse.docxAssignment The Self-Knowledge ProcessPeople come to know themse.docx
Assignment The Self-Knowledge ProcessPeople come to know themse.docxlynettearnold46882
 

More from lynettearnold46882 (20)

Assignment User FrustrationThe quality of the user experience i.docx
Assignment User FrustrationThe quality of the user experience i.docxAssignment User FrustrationThe quality of the user experience i.docx
Assignment User FrustrationThe quality of the user experience i.docx
 
Assignment Upstream Approaches to Canadian Population HealthAlt.docx
Assignment Upstream Approaches to Canadian Population HealthAlt.docxAssignment Upstream Approaches to Canadian Population HealthAlt.docx
Assignment Upstream Approaches to Canadian Population HealthAlt.docx
 
Assignment Type up an essay on one of two prompts and submit the .docx
Assignment Type up an essay on one of two prompts and submit the .docxAssignment Type up an essay on one of two prompts and submit the .docx
Assignment Type up an essay on one of two prompts and submit the .docx
 
Assignment TypeIndividual ProjectDeliverable Length8–10 slid.docx
Assignment TypeIndividual ProjectDeliverable Length8–10 slid.docxAssignment TypeIndividual ProjectDeliverable Length8–10 slid.docx
Assignment TypeIndividual ProjectDeliverable Length8–10 slid.docx
 
Assignment Type Individual discussion Board;   450 – 550 word.docx
Assignment Type Individual discussion Board;   450 – 550 word.docxAssignment Type Individual discussion Board;   450 – 550 word.docx
Assignment Type Individual discussion Board;   450 – 550 word.docx
 
Assignment Two UNIT 2Student Name _______________________.docx
Assignment Two UNIT 2Student Name _______________________.docxAssignment Two UNIT 2Student Name _______________________.docx
Assignment Two UNIT 2Student Name _______________________.docx
 
Assignment Two Select a college or university and provide th.docx
Assignment Two Select a college or university and provide th.docxAssignment Two Select a college or university and provide th.docx
Assignment Two Select a college or university and provide th.docx
 
Assignment Topic Exploration and Analysis (Proposal)In Week 6 o.docx
Assignment Topic Exploration and Analysis (Proposal)In Week 6 o.docxAssignment Topic Exploration and Analysis (Proposal)In Week 6 o.docx
Assignment Topic Exploration and Analysis (Proposal)In Week 6 o.docx
 
Assignment To consider three sources about the Fall of Rome and w.docx
Assignment To consider three sources about the Fall of Rome and w.docxAssignment To consider three sources about the Fall of Rome and w.docx
Assignment To consider three sources about the Fall of Rome and w.docx
 
Assignment topic Rapid Influenza Testing in Children and Adult.docx
Assignment topic  Rapid Influenza Testing in Children and Adult.docxAssignment topic  Rapid Influenza Testing in Children and Adult.docx
Assignment topic Rapid Influenza Testing in Children and Adult.docx
 
Assignment Topic 1Choose a contemporary painting, sculpture, o.docx
Assignment Topic 1Choose a contemporary painting, sculpture, o.docxAssignment Topic 1Choose a contemporary painting, sculpture, o.docx
Assignment Topic 1Choose a contemporary painting, sculpture, o.docx
 
Assignment TitleAssessment Item 03 Case Study Analysis – Engagi.docx
Assignment TitleAssessment Item 03 Case Study Analysis – Engagi.docxAssignment TitleAssessment Item 03 Case Study Analysis – Engagi.docx
Assignment TitleAssessment Item 03 Case Study Analysis – Engagi.docx
 
Assignment Title Knowledge management cycle process in or.docx
Assignment Title Knowledge management cycle process in or.docxAssignment Title Knowledge management cycle process in or.docx
Assignment Title Knowledge management cycle process in or.docx
 
Assignment Three Technical Descriptions Due March 2 (1155 PM .docx
Assignment Three Technical Descriptions Due March 2 (1155 PM .docxAssignment Three Technical Descriptions Due March 2 (1155 PM .docx
Assignment Three Technical Descriptions Due March 2 (1155 PM .docx
 
Assignment ThreeUNIT 3 – ON LINE CLASSStudent Name __________.docx
Assignment ThreeUNIT 3 – ON LINE CLASSStudent Name __________.docxAssignment ThreeUNIT 3 – ON LINE CLASSStudent Name __________.docx
Assignment ThreeUNIT 3 – ON LINE CLASSStudent Name __________.docx
 
Assignment title An Evaluation of the Business Strategy at Mc D.docx
Assignment title An Evaluation of the Business Strategy at Mc D.docxAssignment title An Evaluation of the Business Strategy at Mc D.docx
Assignment title An Evaluation of the Business Strategy at Mc D.docx
 
ASSIGNMENT The student will submit a research project that compares.docx
ASSIGNMENT The student will submit a research project that compares.docxASSIGNMENT The student will submit a research project that compares.docx
ASSIGNMENT The student will submit a research project that compares.docx
 
Assignment Three Case study report – mixed mediaValue 40 .docx
Assignment Three Case study report – mixed mediaValue 40 .docxAssignment Three Case study report – mixed mediaValue 40 .docx
Assignment Three Case study report – mixed mediaValue 40 .docx
 
Assignment The Nurse Leader as Knowledge WorkerThe term kn.docx
Assignment The Nurse Leader as Knowledge WorkerThe term kn.docxAssignment The Nurse Leader as Knowledge WorkerThe term kn.docx
Assignment The Nurse Leader as Knowledge WorkerThe term kn.docx
 
Assignment The Self-Knowledge ProcessPeople come to know themse.docx
Assignment The Self-Knowledge ProcessPeople come to know themse.docxAssignment The Self-Knowledge ProcessPeople come to know themse.docx
Assignment The Self-Knowledge ProcessPeople come to know themse.docx
 

Recently uploaded

Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 

Recently uploaded (20)

Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 

Assignment Two Objectives • Understand how the.docx

  • 1. Assignment Two Objectives • Understand how the AVL tree works • Give you further practice with C and data structures Admin Marks 10 marks, excluding bonus marks. Marking is based on the correctness and efficiency of your code. Your code must be well commented. Group? This assignment is completed individually. Due Time 23:59:59 pm on Sunday 31 March 2019. 23:59:59 pm on Wed 3 April 2019 Late Submissions Late submissions will not be accepted! In this assignment, you will implement AVL tree and a set of functions associated with AVL tree. For simplicity, we make the following assumptions: 1. Each item of an AVL tree contains an integer key and an integer value. 2. No AVL tree contains duplicate items. Two items (k1, v1) and (k2, v2) are duplicates iff k1=k2 and v1=v2 hold. 3. An AVL tree may contains multiple items with the same key
  • 2. and the number of duplicate keys is a constant. A template file named MyAVLTree.c is provided. MyAVLTree.c contains the type definitions of AVL tree and AVL tree node as well as some basic functions. You can add your own helper functions and auxiliary data structures for better performance in terms of time complexity. You need to implement the following functions: 1. AVLTree *CreateAVLTree(const char *filename). This function creates an AVL tree by reading all the items from a text file or from the standard input (keyboard) depending on the argument filename. If filename is “stdin”, this function will read all the items from the standard input. Otherwise, it will read all the items from a text file with filename as its full path name. (2 marks) An input text file contains zero or more items where each item is of the form (key, value). Any characters such as white space between two adjacent items are ignored. For example, the following sample file contains 10 items: (2, 50) (4, 30) (9, 30) (10, 400) (-5, -40) (7, 20) (19, 200) (20, 50) (-18, -200) (-2, 29) Similarly, when reading from the standard input, each input line
  • 3. may have zero or more items, separated by one or more white space characters. An empty line indicates the end of input. In case of an error in the input, this function will print the error and your program terminates. You may assume that the input does not contain duplicate items and thus this function does not need to check for duplicate items. The time complexity of this function cannot be higher than O(n logn), where n is the size of the resulting AVL tree. If your time complexity is higher, you will get 0 mark for this function. You may assume that each call to a C built-in function takes O(1) time. 2. AVLTree *CloneAVLTree(AVLTree *T). This function creates an identical copy (clone) of the input AVL tree T, and returns a pointer to the clone tree. (1 mark) The time complexity of this function cannot be higher than O(n), where n is the size of T. If your time complexity is higher, you will get 0 mark for this function.
  • 4. 3. AVLTree *AVLTreesUnion(AVLTree *T1, AVLTree *T2). This function computes the union tree of two AVL trees T1 and T2 and returns a pointer to the union tree. The union tree of two AVL trees T1 and T2 is an AVL tree that contains all the items of both T1 and T2 without duplicate items. Assume that neither T1 nor T2 contains duplicate items. Note that this function does not make any change to T1 and T2. (2 marks) The time complexity of this function cannot be higher than O((m+n)log(m+n)), where m and n are the sizes of T1 and T2, respectively. If your time complexity is higher, you will get 0 mark for this function. Bonus marks: A correct tree union function with the time complexity O(m+n) will be awarded 1 bonus mark, where m and n are the sizes of T1 and T2, respectively. An example: consider the following two AVL trees T1 and T2: The union tree of T1 and T2 is shown as follows:
  • 5. Note that in general the union tree may not be unique with respect to shape (structure) depending on how it is constructed. 4. AVLTree *AVLTreesIntersection(AVLTree *T1, AVLTree *T2). This function computes the intersection tree of two AVL trees T1 and T2 and returns a pointer to the intersection tree. The intersection tree of two AVL trees T1 and T2 is an AVL tree that contains all the items that appear in both T1 and T2. Assume that neither T1 nor T2 contains duplicate items. Note that this function does not make any change to T1 and T2. (2 marks) The time complexity of this function cannot be higher than O(m+n+k log k), where m and n are the sizes of T1 and T2, respectively, and k the size of the intersection tree. If your time complexity is higher, you will get 0 mark for this function. Bonus marks: A correct tree intersection function with the time complexity O(m+n) will be awarded 1 bonus mark, where m and n are the sizes of T1 and T2, respectively. An example: consider the previous two AVL trees T1 and T2. The intersection tree is shown as follows:
  • 6. Note that in general the intersection tree may not be unique with respect to shape (structure) depending on how it is constructed. 5. int InsertNode(AVLTree *T, int k, int v). If the item (k, v) exists in the tree, this function simply returns 0 without adding the new item (k, v) to the tree. Otherwise, it inserts the new item (k, v) into the AVL tree T, increases the tree size by one and returns 1. (0.5 mark) The time complexity of this function cannot be higher than O(log n), where n is the size of T. If your time complexity is higher, you will get 0 mark for this function. 6. int DeleteNode(AVLTree *T, int k, int v). If the item (k, v) exists in the AVL tree T, this function deletes the node containing this item, decreases the tree size by one and returns 1. Otherwise, it returns 0 only. (1 mark) The time complexity of this function cannot be higher than O(log n), where n is the size of T. If your time complexity is higher, you will get 0 mark
  • 7. for this function. 7. AVLTreeNode *Search(AVLTree *T, int k, int v). This function search for the item (k, v) in the AVL tree T. If the item is found, it returns a pointer to the node containing the item. Otherwise, it returns NULL. (0.5 mark) The time complexity of this function cannot be higher than O(log n), where n is the size of T. If your time complexity is higher, you will get 0 mark for this function. 8. void FreeAVLTree(AVLTree *T). This function frees up the heap space occupied by the AVL tree T. (0.5 mark) The time complexity of this function cannot be higher than O(n), where n is the size of T. If your time complexity is higher, you will get 0 mark for this function. You may assume that each call to free() takes O(1) time. 9. void PrintAVLTree(AVLTree *T). This function prints all the items and their heights stored in the AVL tree T sorted in non-decreasing order of keys on the standard output (screen). Each item is denoted by (key, value) with one item per line. For example, consider the following AVL tree:
  • 8. The output of PrintAVLTree is: (6, 12), 1 (6, 20), 0 (6, 25), 2 (10, 25), 0 Your output can be different as long as it makes sense. The time complexity of this function cannot be higher than O(n), where n is the size of T. If your time complexity is higher, you will get 0 mark for this function. You may assume that each call to a built-in C function takes O(1) time. (0.5 mark) For each function, analyze its time complexity, and put the time complexity analysis as comments before the function. For the time complexity of each function, you just need to give the time complexity of major components (loops) and the total time complexity. You may assume that each call to a built-in C function takes constant (O(1)) time. How to submit your code?
  • 9. a. Go to the assignment page b. Click on Assignment Specifications for Assignment 2 c. Click on Make Submission d. Submit your MyAVLTree.c file that contains all the code. Plagiarism This is an individual assignment. Each student will have to develop their own solution without help from other people. In particular, it is not permitted to exchange code or pseudocode. You are not allowed to use code developed by persons other than yourself. All work submitted for assessment must be entirely your own work. We regard unacknowledged copying of material, in whole or part, as an extremely serious offence. For further information, see the Course Information. (2, 50) (4, 30) (9, 30) (10, 400) (-5, -40) (7, 20) (19, 200) (20, 50) (-18, -200) (-2, 29) (2, 67) (4, 35) (9, 45) (-18, 100) #include <stdlib.h> #include <stdio.h>
  • 10. #include <assert.h> // all the basic data structures and functions are included in this template // you can add your own auxiliary functions as you like // data type for avl tree nodes typedef struct AVLTreeNode { int key; //key of this item int value; //value (int) of this item int height; //height of the subtree rooted at this node struct AVLTreeNode *parent; //pointer to parent struct AVLTreeNode *left; //pointer to left child struct AVLTreeNode *right; //pointer to right child } AVLTreeNode; //data type for AVL trees typedef struct AVLTree{
  • 11. int size; // count of items in avl tree AVLTreeNode *root; // root } AVLTree; // create a new AVLTreeNode AVLTreeNode *newAVLTreeNode(int k, int v ) { AVLTreeNode *new; new = malloc(sizeof(AVLTreeNode)); assert(new != NULL); new->key = k; new->value = v; new->height = 0; // height of this new node is set to 0 new->left = NULL; // this node has no child new->right = NULL; new->parent = NULL; // no parent return new; }
  • 12. // create a new empty avl tree AVLTree *newAVLTree() { AVLTree *T; T = malloc(sizeof (AVLTree)); assert (T != NULL); T->size = 0; T->root = NULL; return T; } // put your time complexity analysis of CreateAVLTree() here AVLTree *CreateAVLTree(const char *filename) { // put your code here }
  • 13. // put your time complexity analysis for CloneAVLTree() here AVLTree *CloneAVLTree(AVLTree *T) { // put your code here } // put your time complexity for ALVTreesUNion() here AVLTree *AVLTreesUnion(AVLTree *T1, AVLTree *T2) { //put your code here } // put your time complexity for ALVTreesIntersection() here AVLTree *AVLTreesIntersection(AVLTree *T1, AVLTree *T2) { //put your code here
  • 14. } // put the time complexity analysis for InsertNode() here int InsertNode(AVLTree *T, int k, int v) { //put your code here } // put your time complexity for DeleteNode() here int DeleteNode(AVLTree *T, int k, int v) { // put your code here } // put your time complexity analysis for Search() here AVLTreeNode *Search(AVLTree *T, int k, int v) { // put your code here
  • 15. } // put your time complexity analysis for freeAVLTree() here void FreeAVLTree(AVLTree *T) { // put your code here } // put your time complexity analysis for PrintAVLTree() here void PrintAVLTree(AVLTree *T) { // put your code here } int main() //sample main for testing { int i,j; AVLTree *tree1, *tree2, *tree3, *tree4, *tree5, *tree6, *tree7, *tree8; AVLTreeNode *node1;
  • 16. tree1=CreateAVLTree("stdin"); PrintAVLTree(tree1); FreeAVLTree(tree1); //you need to create the text file file1.txt // to store a set of items without duplicate items tree2=CreateAVLTree("file1.txt"); PrintAVLTree(tree2); tree3=CloneAVLTree(tree2); PrintAVLTree(tree3); FreeAVLTree(tree2); FreeAVLTree(tree3); //Create tree4 tree4=newAVLTree(); j=InsertNode(tree4, 10, 10); for (i=0; i<15; i++) { j=InsertNode(tree4, i, i);
  • 17. if (j==0) printf("(%d, %d) already existsn", i, i); } PrintAVLTree(tree4); node1=Search(tree4,20,20); if (node1!=NULL) printf("key= %d value= %dn",node1->key,node1->value); else printf("Key 20 does not existn"); for (i=17; i>0; i--) { j=DeleteNode(tree4, i, i); if (j==0) printf("Key %d does not existn",i); PrintAVLTree(tree4); } FreeAVLTree(tree4); //Create tree5
  • 18. tree5=newAVLTree(); j=InsertNode(tree5, 6, 25); j=InsertNode(tree5, 6, 10); j=InsertNode(tree5, 6, 12); j=InsertNode(tree5, 6, 20); j=InsertNode(tree5, 9, 25); j=InsertNode(tree5, 10, 25); PrintAVLTree(tree5); //Create tree6 tree6=newAVLTree(); j=InsertNode(tree6, 6, 25); j=InsertNode(tree6, 5, 10); j=InsertNode(tree6, 6, 12); j=InsertNode(tree6, 6, 20); j=InsertNode(tree6, 8, 35); j=InsertNode(tree6, 10, 25); PrintAVLTree(tree6); tree7=AVLTreesIntersection(tree5, tree6);