This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void Swap(int& x, int& y) { | |
int swap = x; | |
x = y; | |
y = swap; | |
} | |
static int Partition(int arr[], int minIndex, int maxIndex) { | |
int pivot = arr[maxIndex]; | |
int i = minIndex - 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void Swap(int& x, int& y) { | |
int swap = x; | |
x = y; | |
y = swap; | |
} | |
static void BubbleSort(int arr[], int length) { | |
for (int i = 0; i < length - 1; i++) { | |
for (int l = i + 1; l < length; l++) { | |
if (arr[i] < arr[l]) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
void Merge(int arr[], int minIndex, int middleIndex, int maxIndex) { | |
int left = minIndex; | |
int right = middleIndex + 1; | |
int count = maxIndex - minIndex + 1; | |
int tempArray[100]; | |
int index = 0; | |
while ((left <= middleIndex) && (right <= maxIndex)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void GnomeSort(int arr[], int count) { | |
int index = 1; | |
int nextIndex = index + 1; | |
while (index < count) | |
{ | |
if (arr[index - 1] < arr[index]) | |
{ | |
index = nextIndex; |