zrwusa / data-structure-typed

Javascript Data Structure & TypeScript Data Structure. Heap, Binary Tree, Red Black Tree, Linked List, Deque, Trie, HashMap, Directed Graph, Undirected Graph, Binary Search Tree, AVL Tree, Priority Queue, Graph, Queue, Tree Multiset, Singly Linked List, Doubly Linked List, Max Heap, Max Priority Queue, Min Heap, Min Priority Queue, Stack.
https://data-structure-typed-docs.vercel.app
MIT License
114 stars 8 forks source link

After deleting all nodes in a certain order in BST, the size is not zero. #71

Closed zrwusa closed 8 months ago

zrwusa commented 8 months ago

Describe the bug After deleting all nodes in a certain order, the size is not zero.

To Reproduce Steps to reproduce the behavior:

    const numBST = new BST<number>();
    numBST.addMany([2, 4, 5, 3, 1]);
    expect(numBST.size).toBe(5);
    numBST.delete(1);
    expect(numBST.size).toBe(4);

    numBST.delete(2);
    numBST.delete(3);
    numBST.delete(4);
    numBST.delete(5);
    expect(numBST.size).toBe(0);
    numBST.delete(5);
    expect(numBST.size).toBe(0);
zrwusa commented 8 months ago

In version 1.50.2, this issue has been resolved.