Understanding Applications of Binary Search in ComputingOrder Statistics A fundamental idea in computer science, binary searches are essential to many algorithms and data structures. The uses of binary searches in computingorder statistics and the use of binary search trees in storing assorted lists will bethe main topics of this paper. How do Order Statistics work? An individual ranking inside a collection of numerical or categorical variables is referred to as an order statistic. The order statistics problem, wherek is an integer between 1 and n, asks for the kth lowest or greatest element in aset of elements (the total number of elements in the set). The order statisticproblem, for instance, arises when determining the median, the 25th percentile,or the seventh largest element in a set. Making Order Statistics Using Binary Searches It is fundamentally a search problem to approach computing order statistics using binary searches. The procedure should provide the kth smallestelement kept in the tree given the root of a binary search tree and the number k.To accomplish this, we must first determine which subtree to look in. In order tosolve this issue, a new field called N.Size that returns the number of entries inthe N subtree must be added. We must add an operation called RecomputeSize to verify that the value of thefield N.Size is accurate at all times. The size of a node is recalculated in thisoperation as the sum of the sizes of its left and right children plus one. Thewidths of the subtree will vary when the tree is rotated, thus we must recalculatethe sizes of the two rotated nodes. Once we have all of the nodes' sizes stored, computing order statistics is rathersimple. We first determine the size of the left subtree, R.Left.Size, in order tocalculate the kth lowest element in the tree. The root is the st smallest 𝑠 + 1 element, and we return R if , where s is the size of the left subtree. 𝑘 = 𝑠 + 1 If k s + 1, the left subtree has the kth smallest element, and we recurse on theleft child. But if , the kth lowest element is in the right subtree, 𝑘 > 𝑠 + 1 and we recurse on the right child while decreasing k by . (𝑠 + 1)
Binary Search Trees for Assorted List Storage Assorted lists can also be stored using binary search trees. In a binary search tree, where the members are stored in a particular order depending ontheir values, we can insert a set of ordered elements. This makes it possible forus to quickly search for items in the list and carry out other tasks likedetermining the minimum or maximum element or the kth smallest item in theset (as described above). Binary search trees can also be used to hold dynamic sets, which allow for the addition and deletion of elements. We might need to do rotations andrebalancing operations to keep the tree height balanced in order to maintain thebinary search tree's attributes. Conclusion To sum up, binary searches are essential to many algorithms and data structures, such as those that compute order statistics and store assorted lists. Wecan create more effective algorithms and data structures that can handlechallenging computer science problems by comprehending the uses of binarysearches.