AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Treesize personal4/21/2023 ![]() ![]() All BST operations take O(depth of node) time, and it takes O(depth of node) extra time to maintain the "number of elements" information for insertion, deletion or rotation of nodes. This takes O(depth of node) time, which is O(log n) in the worst case on a balanced BST, or O(log n) on average for a random BST.Ī BST requires O(n) storage, and it takes another O(n) to store the information about the number of elements. If k So, we reduce the problem to finding the k - num_elements(left subtree of T) smallest element of the right subtree. If k > num_elements(left subtree of T), then obviously we can ignore the left subtree, because those elements will also be smaller than the kth smallest. ![]()
0 Comments
Read More
Leave a Reply. |