Skip to content

Latest commit

 

History

History
12 lines (7 loc) · 660 Bytes

README.md

File metadata and controls

12 lines (7 loc) · 660 Bytes

algorithms

median.py

Finds the median value of an array of numbers using binary tree insertion sort.

The insertion and flattening the tree into a list are straightforward enough using recursion, but finding the median within the binary tree, especially for an even number of items, proved to be much more difficult.

Obtaining the middle values from a list retrieved from the binary tree seems trivial enough, but I took the challenge to find the middle values within the tree itself.

On hindsight, obtaining the median from the list is much easier and more desirable. Neighbour lookup inside a tree structure is fraught with difficulties.