This commit is contained in:
2026-03-05 10:35:31 +03:00
parent 11b118b3bf
commit 5a942f935f
10 changed files with 447 additions and 3 deletions
+29
View File
@@ -0,0 +1,29 @@
#pragma once
#include "Sorter.hpp"
class HeapSorter : public Sorter {
public:
HeapSorter();
void step(Array& array) override;
bool isFinished() const override;
std::string getName() const override;
void reset() override;
std::string getTimeComplexity() const override;
std::string getSpaceComplexity() const override;
private:
enum class Phase { BUILDING_HEAP, HEAPIFY_DOWN, EXTRACTING, EXTRACT_SWAP, EXTRACT_HEAPIFY };
int n_;
int heapSize_;
int buildIndex_;
int extractIndex_;
int heapifyIndex_;
int leftChild_;
int rightChild_;
int largest_;
bool finished_;
Phase phase_;
bool needSwap_;
};
+27
View File
@@ -0,0 +1,27 @@
#pragma once
#include "Sorter.hpp"
#include <vector>
class RadixSorter : public Sorter {
public:
RadixSorter();
void step(Array& array) override;
bool isFinished() const override;
std::string getName() const override;
void reset() override;
std::string getTimeComplexity() const override;
std::string getSpaceComplexity() const override;
private:
enum class Phase { INIT, COUNTING, PLACING, COPYING_BACK };
int n_;
int maxValue_;
int exp_;
int i_;
std::vector<int> count_;
std::vector<float> output_;
bool finished_;
Phase phase_;
};
+25
View File
@@ -0,0 +1,25 @@
#pragma once
#include "Sorter.hpp"
class ShellSorter : public Sorter {
public:
ShellSorter();
void step(Array& array) override;
bool isFinished() const override;
std::string getName() const override;
void reset() override;
std::string getTimeComplexity() const override;
std::string getSpaceComplexity() const override;
private:
enum class Phase { COMPARING, SHIFTING, PLACING };
int n_;
int gap_;
int i_;
int j_;
float temp_;
bool finished_;
Phase phase_;
};