Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3230846
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:58:30+00:00 2026-05-17T16:58:30+00:00

I have created an AVL tree implementation, but as an AVL tree is quite

  • 0

I have created an AVL tree implementation, but as an AVL tree is quite a complex structure, I need to test it. So the question is – how can I test it?

Up to this moment I have the following tests:

  1. basic sanity check – checks that
    for every node height equals max.
    height of child nodes + 1, balance is in [-1, 1], left child’s
    key < this node’s key < right
    child’s key, and there are no
    circular references (like left child
    of a node is a node himself);

  2. check that inorder traversal on an AVL tree
    (and on a binary search tree in the whole)
    will return values from the underlying set in order;

  3. check that an AVL tree’s height is strictly less than
    1.44*log2(N+2)-1 (there N is number of elements) – proved by AVL tree creators;

  4. visual check – doesn’t work that well, I try to draw a tree (rootnode in the first line, his direct children on the next line, childen of rootnode’s direct childen on the third line and so on), but that works only on small trees, for big trees it becomes a complete mess;

  5. Russian wikipedia says that it is proven experimentally, that for two insertions one rebalancing needed and for five removals also one rebalancing needed, but is it really so? English wikipedia says nothing about it, and for my AVL one rebalancing needed for two insertions or for four removals, which is not quite the same.

Maybe these tests are enough, but if there are any more tests, not difficult to implement, why not do it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:58:31+00:00Added an answer on May 17, 2026 at 4:58 pm

    A key property of an AVL tree is that each of its sub-trees is also an AVL tree. That means that covering the basic scenarios should give you a broad coverage of the AVL tree functionality.

    In other words, these tests done on the smallest tree structure that allows them are the most important ones:

    • Creating a new tree.
    • Inserting the first value.
    • Inserting a bigger value.
    • Inserting a smaller value.
    • Inserting a value that causes LL Rotation.
    • Same for the other rotations.
    • Same for Removing.
    • All the variants of Finding values.

    If your implementation passes these tests, it would probably pass them on larger trees.
    Note that performance and memory usage is not tested here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have created a UIButton programmatically, all works as expected but how can I use
I have created form using ModelForm but its not saving data into database. views.py
I have created a custom JTree. That tree could be filtered to show only
I have in my homework some question about data structure: I have elements which
I have created a list. And I need to get the text on the
i have created one jsp file but it doesn't running in any way..!! it
Have created an android test project and currently trying to write android unit tests
I have created a tableview with grouped style. I have added this table to
I have created new environment staging. Locally it works. I run it this way:
I have created an ajax driven website which can load any page when given

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.