quick sort – sorting algorithm – library MetaTrader 5

quick sort - sorting algorithm - library for MetaTrader 5
//+——————————————————————+ //|                                                    QuickSort.mq5 | //|                                    2019-2020, dimitri pecheritsa | //|                                                 792112@gmail.com | //+——————————————————————+ // //   quick sort – sorting algorithm // //   quick sort is a highly efficient sorting algorithm and is based //on partitioning of array of data into smaller arrays //   a large array is partitioned into two arrays one of which holds //values smaller … Read more

MultiSort – sorting algorithm – library MetaTrader 5

MultiSort - sorting algorithm - library for MetaTrader 5
A sorter class to sort an array based on other arrays. //+——————————————————————+ //| class MultiSort<TItem,TKey1,TKey2,TKey3>.                        | //| Usage: Sorter class to sort an array based on other arrays.      | //+——————————————————————+ template<typename TItem,typename TKey1,typename TKey2,typename TKey3> class MultiSort   { public:    //— method to sort items by keys    void              SortBy(TItem& items[],                             TKey1& keys1[],                             TKey2& keys2[],                             TKey3& keys3[],                             bool   … Read more

merge sort – a merging method comparison-based sorting algorithm – library MetaTrader 5

merge sort - a merging method comparison-based sorting algorithm - library for MetaTrader 5
//+——————————————————————+ //|                                                    MergeSort.mq5 | //|                                    2019-2020, dimitri pecheritsa | //|                                                 792112@gmail.com | //+——————————————————————+ //   merge sort – a merging method comparison-based sorting algorithm // //   merge sort is an efficient, general-purpose, comparison-based //sorting algorithm. most implementations produce a stable sort, //which means that the order of equal elements is the same in the //input and output. merge … Read more

heap sort – array sorting algorithm – library MetaTrader 5

heap sort - array sorting algorithm - library for MetaTrader 5
//+——————————————————————+ //|                                                     HeapSort.mq5 | //|                                  2019 – 2021, dimitri pecheritsa | //|                             https://www.mql5.com/en/users/dmipec | //+——————————————————————+ //+——————————————————————+ //| heap sort – array sorting algorithm                              | //|  best – n log n, average – n log n, worst – n log n              | //|  memory – 1, stable – no, method – selection                     | //|  heapsort is a much more efficient version of … Read more

shell sort – array sorting algorithm – library MetaTrader 5

shell sort - array sorting algorithm - library for MetaTrader 5
//+——————————————————————+ //|                                                    ShellSort.mq5 | //|                                    2019-2021, dimitri pecheritsa | //|                                         mql5.com/en/users/dmipec | //+——————————————————————+ //+——————————————————————+ //| shell sort – array sorting algorithm                             | //|  cases: best: n log n, average: n^(4/3), worst: n^(3/2)          | //|  memory: 1, stable: no, method: insertion                        | //|  note: small code size                                           | //+——————————————————————+ //+——————————————————————+ //|  shellsort, also known as shell sort or shell’s method, is an    | //|in-place comparison … Read more

selection sort – array sorting algorithm – library MetaTrader 5

selection sort - array sorting algorithm - library for MetaTrader 5
//+——————————————————————+ //|                                                SelectionSort.mq5 | //|                                    2019-2021, dimitri pecheritsa | //|                                         mql5.com/en/users/dmipec | //+——————————————————————+ //| selection sort – array sorting algorithm                         | //+——————————————————————+ //|  best: n^2, average: n^2, worst: n^2                             | //|  memory: 1, stable: no, method: selection                        | //|  note: stable with o(n) extra space or when using linked lists.  | //+——————————————————————+ //|  in computer science, selection sort is an in-place comparison   | … Read more

insertion sort – array sorting algorithm – library MetaTrader 5

insertion sort - array sorting algorithm - library for MetaTrader 5
//+——————————————————————+ //|                                                InsertionSort.mq5 | //|                                    2019-2021, dimitri pecheritsa | //|                                         mql5.com/en/users/dmipec | //|——————————————————————| //| cls | insertion sort                                             | //|——————————————————————| //| use | array sorting algorithm                                    | //|  best: n; average: n^2; worst: n^2                               | //|  memory: 1; stable: yes; method: insertion                       | //|  note: o(n + d), in the worst case over sequences that have d    | //|inversions.                                                       | //|——————————————————————| //|  insertion … Read more

gnome sort – array sorting algorithm – library MetaTrader 5

gnome sort - array sorting algorithm - library for MetaTrader 5
//+——————————————————————+ //|                                                    GnomeSort.mq5 | //|                                    2019-2021, dimitri pecheritsa | //|                                         mql5.com/en/users/dmipec | //|——————————————————————| //|  c  | gnome sort                                                 | //|——————————————————————| //| use | array sorting algorithm                                    | //|  best: n; average: n^2; worst: n^2                               | //|  memory: 1; stable: yes; method: exchanging                      | //|  note: tiny code size                                            | //|  originally proposed by iranian computer scientist hamid         | //|sarbazi-azad (professor of computer science and engineering at    | … Read more

introsort – array sorting algorithm – library MetaTrader 5

introsort - array sorting algorithm - library for MetaTrader 5
//+——————————————————————+ //|                                                    Introsort.mq5 | //|                                    2019-2021, dimitri pecheritsa | //|                                         mql5.com/en/users/dmipec | //|——————————————————————| //|   c| array sorting algorithm                                     | //|  introsort or introspective sort is a hybrid sorting algorithm   | //|that provides both fast average performance and (asymptotically)  | //|optimal worst-case performance. it begins with quicksort, it      | //|switches to heapsort when the recursion depth exceeds a level     | //|based … Read more