-
Notifications
You must be signed in to change notification settings - Fork 1
/
MergeSort.h
45 lines (42 loc) · 1013 Bytes
/
MergeSort.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef SORT_VISUALIZER_MERGESORT_H_
#define SORT_VISUALIZER_MERGESORT_H_
#include <vector>
/**
* @class MergeSort
* @brief MergeSort class is used to sort an array using merge sort algorithm.
* @param none
* @return none
*/
class MergeSort
{
public:
MergeSort();
/**
* @name tick
* @details Sorts an array using merge sort algorithm.
* @param arr array to sort
* @param i current iteration
* @param operation_counter number of swap operation done
* @return true if sorting is done
* @return false if sorting is not done
*/
bool tick(std::vector<int> &arr, int &i, int &operation_counter);
/**
* @name rebuild
* @details Rebuilds an array using merge sort algorithm.
* @param arr array to sort
* @return none
*/
void rebuild();
private:
int BlockSizeIterator;
int BlockIterator;
int LeftBlockIterator;
int RightBlockIterator;
int MergeIterator;
int LeftBorder;
int MidBorder;
int RightBorder;
std::vector<int> SortedBlock;
};
#endif // SORT_VISUALIZER_MERGESORT_H_