Skip to content

AVL Tree did not remain at 1 after inserting a large amount of data #119

@zrwusa

Description

@zrwusa

Describe the bug
Tests showed that the height difference in the AVL Tree did not remain at 1 after inserting a large amount of data. This indicates a flawed AVL Tree.

To Reproduce

const { AVLTree, RedBlackTree } = require('data-structure-typed');
const { getRandomIntArray } = require('../utils/array');

const MILLION = 1000000;
const randomArray = getRandomIntArray(MILLION, 0, MILLION - 1, false);
const avlTree = new AVLTree();

for (let i = 0; i < randomArray.length; i++)
    avlTree.add(randomArray[i]);

console.log(avlTree.getHeight() - avlTree.getMinHeight());

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions