APPLICATION OF BINARY SEARCH TREE WITH FIXED HEIGHT TO ACCELERATE PROCESSING OF ONE-DIMENSIONAL ARRAYS
DOI:
https://doi.org/10.15588/1607-3274-2025-1-18Keywords:
array sorting, array medians, method of two binary pyramids, binary search tree with fixed heightAbstract
Topicality. Nowadays, binary search trees are widely used to speed up searching, sorting, and selecting array elements. But the computational complexity of searching using a binary tree is proportional to its height, which depends on the sequence of processing the elements of the array. In order to reduce the height of a tree, its balancing is periodically carried out, which is a long process,, thus, the development of alternative methods of controlling the height of a binary tree is currently an actual scientific task.
Objective. Development of algorithms for the formation and use of a binary tree with a fixed height to accelerate the search for an element in an array and to determine arbitrary i-th order statistics, in particular, the median of the array.
Method. In this study, it is proposed to set the fixed height of the binary search tree by one greater than the minimum possible height of the binary tree to accommodate all the elements of the array because increasing the fixed height leads to excessive RAM consumption, and decreasing it slows down tree modifications. The formation of such trees is similar to the balancing of trees but, unlike it, the recursive movement of nodes in them is performed only when the corresponding subtree is completely filled. For a binary search tree with a fixed height, RAM is allocated once when it is created, immediately under all possible nodes of a binary tree with a given height. This allows to avoid allocating and freeing memory for each node of the tree and store the values of the nodes in a one-dimensional array without using pointers.
The results. Our experiments showed that in order to speed up the search of elements and to determine the i-th order statistics of frequently changing unordered arrays, it is advisable to additionally form a binary search tree with a fixed height. To initialize this tree, it is advisable to use a sorted copy of the keys of the array elements, and not to insert them one by one. For example, the use of a binary tree with a fixed height accelerates the search of medians of such arrays by more than 7 times compared to the method of two binary pyramids and additionally accelerates the redistribution of compressed data between modified DEFLATE-blocks in the process of progressive hierarchical lossless compression of images of the ACT set by an average of 2.92%.
Conclusions. To determine medians or i-th order statistics of individual unrelated arrays and subarrays, instead of known sorting methods, it is advisable to use Hoare partitioning with exchange over long distances as it rearranges only individual elements and does not order the entire array completely. In order to determine the medians of the sequence of nested subarrays, ordered by the growth of their length, it is worth using the method of two binary pyramids because they are oriented to rapid addition of new elements. To find medians or i-th order statistics after changes or removal of elements of an unordered array, it is advisable to use a binary search tree for the keys of array elements with a fixed height as such fixing prevents uncontrolled growth of the number of comparison operations and makes it possible to process the tree without using instructions.
References
Cormen T. H. Leiserson C. E. , Rivest R. L. , Stein C. . Introduction to Algorithms, Fourth Edition. Cambridge, MIT Press, 2022, 1312 p. Access mode:
http://mitpress.mit.edu/9780262046305/introduction-to-algorithms.
Shakhovska N. B., Holoshchuk R. O. Alhorytmy i struktury danykh : Navchalnyi posibnyk. Lviv, Mahnoliia-2006, 2020, 214 p.
Silberschatz A., Korth H. F., Sudarshan S. Database system concepts, Seventh edition. New York, McGraw-Hill Education, 2020. ISBN 978-1-260-08450-4.
Kerttu P-M. B+-trees [Electronic resource] / P-M. Kerttu. – The Department of Computer Science University of Helsinki, 9 p. Access mode: https://www.cs.helsinki.fi/u/mluukkai/tirak2010/Btree.pdf.
Gentle J. E. Computational Statistics. Springer, 2009, 749 p. ISBN 9780387981444.
DOI: 10.1007/978-0-387-98144-4.
Ageel M. I. The Mean-Median-Mode Inequality for Discrete Unimodal Probability Measure, Far East Journal of Mathematical Sciences, 2000, № 2 (2), pp. 187–192.
Abadir K M. The mean-median-mode inequality: counter examples, Econometric Theory, 2005, № 21 (02), pp. 477–482. DOI: 10.1017/S0266466605050267.
C# 8.0 draft specification [Electronic resource]. – Microsoft Corporation, 2024, 3769 p. Access mode: https://learn.microsoft.com/en-us/dotnet/csharp/languagereference/language-specification/introduction.
Knuth D. E. The Art of Computer Programming, Vol. 3. Sorting and Searching, Second edition. Massachusetts, Addison Wesley Longman, 1998, 791 p.
Bomba A. Ya., Shportko A. V. , Postolatii V. A. Redistribution of the Compressed Data Between Modified DEFLATE-Blocks in the Image Compression Process Without Lossless, Computational Linguistics and Intelligent Systems (COLINS 2024) : Proceedings of the 8th International Conference (Lviv, 12–13 april, 2024). Volume II: Modeling, Optimization, and Controlling in Information and Technology Systems Workshop (MOCITSW). CEUR Workshop
Proceedings, 2024, Vol. 2604, pp. 145–156. Access mode: https://ceur-ws.org/Vol-3668/paper11.pdf.
Hoare C. A. R. Quicksort, Computer Journal, 1962, № 5 (1), pp. 10–16.
DOI: 10.1093/comjnl/5.1.10.
Shportko A., Shportko V. The Acceleration of the Determination of the Median of Nested Subarrays Using Two Binary Pyramids, Computational Linguistics and Intelligent Systems (COLINS 2020) : Proceedings of the 4th International Conference (Lviv, Ukraine,
–24 april, 2020), CEUR Workshop Proceedings, 2020, Vol. 2604, pp. 1102–1116. Access mode: http://ceur-ws.org/Vol-2604/paper72.pdf.
Shportko O., Shportko L. The Use of a Fixed Height Binary Tree to Accelerate the Calculation of the Medians of Subarrays, Computer Science and Information Technologies (CSIT 2020) : Proceedings of the XVth International Scientific and Technical Conference
(Zbarazh, Ukraine, 23–26 septembr, 2020). Springer Cham, 2020, Vol. 2, pp. 46–49. Access mode:https://ieeexplore.ieee.org/document/9321921.
Deutsch P. DEFLATE Compressed Data Format Specification version 1.3. RFC 1951. Alladin enterprises, 1996, 15 p. Access mode: https://www.rfc-editor.org/rfc/rfc1951. DOI:
17487/rfc1951.
Kotha H. D., Tummanapally M. , Upadhyay V. K. Review on Lossless Compression Techniques, Journal of Physics, 2019, Vol. 1228.
DOI: 10.1088/1742-6596/1228/1/012007.
Shportko A. V., Bomba A. Ya , Postolatii V. A. Programming the Formation of Difference Color Models for Lossless Image Compression, Computational Linguistics and Intelligent Systems (COLINS 2023) : Proceedings of the 7th International Conference (Kharkiv, Ukraine, 20–21 april, 2023). CEUR Workshop Proceedings, 2023, Vol. 3, pp. 53–68. Access mode: http://ceur-ws.org/Vol-3403/paper5.pdf.
Downloads
Published
How to Cite
Issue
Section
License
Copyright (c) 2025 A. V. Shportko, A. Ya. Bomba

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Creative Commons Licensing Notifications in the Copyright Notices
The journal allows the authors to hold the copyright without restrictions and to retain publishing rights without restrictions.
The journal allows readers to read, download, copy, distribute, print, search, or link to the full texts of its articles.
The journal allows to reuse and remixing of its content, in accordance with a Creative Commons license СС BY -SA.
Authors who publish with this journal agree to the following terms:
-
Authors retain copyright and grant the journal right of first publication with the work simultaneously licensed under a Creative Commons Attribution License CC BY-SA that allows others to share the work with an acknowledgement of the work's authorship and initial publication in this journal.
-
Authors are able to enter into separate, additional contractual arrangements for the non-exclusive distribution of the journal's published version of the work (e.g., post it to an institutional repository or publish it in a book), with an acknowledgement of its initial publication in this journal.
-
Authors are permitted and encouraged to post their work online (e.g., in institutional repositories or on their website) prior to and during the submission process, as it can lead to productive exchanges, as well as earlier and greater citation of published work.