Get Instant Help From 5000+ Experts For
question

Writing: Get your essay and assignment written from scratch by PhD expert

Rewriting: Paraphrase or rewrite your friend's essay with similar meaning at reduced cost

Editing:Proofread your work by experts and improve grade at Lowest cost

And Improve Your Grades
myassignmenthelp.com
loader
Phone no. Missing!

Enter phone no. to receive critical updates and urgent messages !

Attach file

Error goes here

Files Missing!

Please upload all relevant files for quick & complete assistance.

Guaranteed Higher Grade!
Free Quote
wave

What is AVL tree?

Write three functions in C or C++, that determine if a tree is balanced, and are able to balance a tree. Function prototypes are as follows: int isBalanced(BSTHead *mytree) void rotateLeft(Node *pPre)
void rotateRight(Node *pPre)
Function isBalanced will return 0 if it is balanced, -1 if height on left subtree is larger than height on right subtree, and 1 if height on left subtree is smaller than height on right subtree. BSTHead is a defined type for the head of a BST.
For rotateLeft and rotateRight, a reference to the parent node of node to be rotated is passed as parameter. Hint: To be able to rotate you may need the memory address of both, the node to be rotated and its parent You may create additional functions, as needed.

Delivery:
- The submission of your source code is required. Copyright on code will be honoured.
- One document (pdf, md, doc, …) with the name of the project, a description of it,
author name and instructions to use the code (when required).


Assessment Criteria
Your project will be assessed based on the following set of assessment criteria. Assessment category Assessment Criteria Marks isBalanced function Function determines if a BST is balanced or not.Returns -1, 0 and 1 as described.


rotateLeft Function rotates left 3 rotateLeft Function may do a double rotation: right-left 5 rotateRight Function rotates right 3 rotateRight Function may do a double rotation: left-right 5
Late Submission of Assignments
Assignments submitted after the due date and time without having received an extension through

Special Assessment Circumstances (SAC) will be penalised according to the following:
10% of marks deducted if submitted within 24hrs of the deadline 20% of marks deducted if submitted after 24hrs and up to 48hrs of the deadline 30% of marks deducted if submitted after 48hrs and up to 72hrs of the deadline No grade will be awarded for an assignment that is submitted later than 72hrs after the deadline Assignments handed in more than 72 hours late will not be marked unless Special
Assessment Circumstances apply. So, it is better to hand in an incomplete assignment on time.

Special Assessment Circumstances
A student, who due to circumstances beyond his or her control, misses a test, final exam or an assignment deadline or considers his or her performance in a test, final exam or an assignment to have been adversely affected, should complete the Special Assessment Circumstances (SAC) form available from Student Central.

Within any semester, a student may have only one SAC per course. When requesting an SAC for an assignment, the SAC application form must be submitted (along with the work completed to date) within the time frame of the extension requested; i.e. if the Doctor’s certificate is for one (1) day, then the SAC application form and work completed must be submitted within one (1) day. Assistance to other Students Students themselves can be an excellent resource to assist the learning of fellow students, but there are issues that arise in assessments that relate to the type and amount of assistance given by students to other students. It is important to recognise what types of assistance are beneficial to another’s learning and also what types of assistance are unacceptable in an assessment.

Beneficial Assistance
• Study Groups.
• Discussion.
• Sharing reading material.
• Testing another student’s programming work using the executable code and giving them the results of that testing.
Unacceptable Assistance
• Working together on one copy of the assessment and submitting it as own work.
• Giving another student your work.
• Copying someone else’s work. This includes work done by someone not on the course.
• Changing or correcting another student’s work.
• Copying from books, Internet etc. and submitting it as own work.

Anything taken directly from another source must be acknowledged correctly: show the source alongside the uotation. Do you want to do the best that you can do on this assignment and improve your grades? You could:
• Talk it over with your lecturer
• Visit Te Tari Awhina or Maia for learning advice and support
• Visit the Centre for Pacific Development and Support
• Contact the USU Advocate for independent advice 

What is AVL tree?

AVL tree is the height balanced binary search tree. AVL tree is named after its inventors Adelson-Velskii and Landis. AVL tree is the first proposed dynamically balanced tree. In AVL tree the sub trees are balanced in height of at-most 1. The balance factor is computed using the below formula:

Balanced Factor=| Height of Left Sub tree – Height of the Right sub tree |

In AVL tree operation like insertion, deletion and searching time of the AVL tree is O(log n).

Thus, AVL tree is a binary search tree with the following two properties:

  • In AVL tree, every sub tree is an AVL tree.
  • All sub tree of the AVL tree differ in height by at-most 1

On inserting a node to the binary search tree, the tree may end up in unbalanced state with balance factor exceeding 1. In such situation it is check whether the left sub tree height is more, or right sub tree height is more. In right sub tree height is more it is rotated to left. If the left sub tree height is more it is rotated to right. In rotation there are four cases like LL (Left-Left) rotation, LR (Left-Right) rotation, RR (Right-Right) rotation, RL (Right-Left) rotation.

LL (Left Left) Rotation:

A                                                                  B                    

                                                                  /   

      B                                  à                  A      C

        

           C

In the above case the node A is in unbalanced state as new node is inserted as the right child to the right sub tree of A. So, a LL rotation is performed to bring the tree into the balanced state.

LR (Left Right) Rotation or Double Left Rotation:

     A                                                           C

    /                                                            /    

   B                                     à                 B     A

         

      C

In the above case the node A is in unbalanced state as new node is inserted as the right child to the left sub tree of A. So, a LR rotation is performed to bring the tree into the balanced state.

RR (Right Right) Rotation:

             A                                                      B

           /                                                        /   

         B                                à                   C     A

       /

     C      

In the above case the node A is in unbalanced state as new node is inserted as the left child to the left sub tree of A. So, a RR rotation is performed to bring the tree into the balanced state. 

RL (Right Left) Rotation or Double Right Rotation:

     A                                                                C

                                                                      /    

           B                             à                       A    B   

           /

          C

In the above case the node A is in unbalanced state as new node is inserted as the left child to the right sub tree of A. So, a rotation is performed to bring the tree into the balanced state.

Author Name:

Instructions to use the code:

The int isBalanced(BSTHead *mytree) is used to determine whether the tree is balanced, left skewed, or right skewed. This function is used whenever a new node is inserted or deleted from the binary search tree.

The void rotateLeft(Node *pPre) is used to rotate the tree unbalanced at  right to be rotated to left.

The void rotateRight(Node *pPre) is used to rotate the tree unbalanced at  left to be rotated to right.

References:

Drozdek, A. (2013). Data Structures and Algorithms in C++.  Boston,  MA: Cengage Learning.

Storer, J.A. (2002). An Introduction to Data Structures and Algorithms. Springer Science.

Weiss, M. A. (1996). Algorithms, Data Structures, and Problem Solving with C++. Addison-Wesley Publishing Company.

Weiss, M. A. (2014). Data Structures and Algorithm Analysis in C++. Pearson Education Limited.

Cite This Work

To export a reference to this article please select a referencing stye below:

My Assignment Help. (2020). AVL Tree: Height-Balanced Binary Search Tree Implementation With Examples. Retrieved from https://myassignmenthelp.com/free-samples/iscg-6426-data-structures-and-algorithms/deletion-and-searching.html.

"AVL Tree: Height-Balanced Binary Search Tree Implementation With Examples." My Assignment Help, 2020, https://myassignmenthelp.com/free-samples/iscg-6426-data-structures-and-algorithms/deletion-and-searching.html.

My Assignment Help (2020) AVL Tree: Height-Balanced Binary Search Tree Implementation With Examples [Online]. Available from: https://myassignmenthelp.com/free-samples/iscg-6426-data-structures-and-algorithms/deletion-and-searching.html
[Accessed 02 May 2024].

My Assignment Help. 'AVL Tree: Height-Balanced Binary Search Tree Implementation With Examples' (My Assignment Help, 2020) <https://myassignmenthelp.com/free-samples/iscg-6426-data-structures-and-algorithms/deletion-and-searching.html> accessed 02 May 2024.

My Assignment Help. AVL Tree: Height-Balanced Binary Search Tree Implementation With Examples [Internet]. My Assignment Help. 2020 [cited 02 May 2024]. Available from: https://myassignmenthelp.com/free-samples/iscg-6426-data-structures-and-algorithms/deletion-and-searching.html.

Get instant help from 5000+ experts for
question

Writing: Get your essay and assignment written from scratch by PhD expert

Rewriting: Paraphrase or rewrite your friend's essay with similar meaning at reduced cost

Editing: Proofread your work by experts and improve grade at Lowest cost

loader
250 words
Phone no. Missing!

Enter phone no. to receive critical updates and urgent messages !

Attach file

Error goes here

Files Missing!

Please upload all relevant files for quick & complete assistance.

Plagiarism checker
Verify originality of an essay
essay
Generate unique essays in a jiffy
Plagiarism checker
Cite sources with ease
support
Whatsapp
callback
sales
sales chat
Whatsapp
callback
sales chat
close