The binary tree sort algorithm requires placing values into a tree root system in such a way that the retrieved values are sorted.
For a detailed explanation check out the following wikipedia page.
https://en.wikipedia.org/wiki/Binary_tree_sort
The attached spreadsheet has an example of how this works on the DM32.
The program in the attached d32 file will sort up to 290 values. This routine requires more registers than QuickSort because the program must have separate blocks of registers for:
1. Unsorted Values
2. Root system.
3. Sorted values.
4. Recursion stack.
The limit can be extended by using global registers -100 to -999 but that can wait for another day.
Wayne
Binary Tree Sort
Binary Tree Sort
- Attachments
-
DM32 Binary Tree Sort.xlsx
- (26.76 KiB) Downloaded 14 times
-
- BinSort.d32
- (1.81 KiB) Downloaded 8 times