Skip to content

Instantly share code, notes, and snippets.

View irchimi's full-sized avatar
🐙

May irchimi

🐙
View GitHub Profile
@irchimi
irchimi / QuickSort
Created June 24, 2020 20:15
Quick Sort in C++
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;
@irchimi
irchimi / BubbleSort
Created June 24, 2020 20:17
BubbleSort in C++
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]) {
@irchimi
irchimi / ExampleMergeSort
Created June 25, 2020 06:06
Example Merge sort in C++
#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))
@irchimi
irchimi / GnomeSort
Created June 25, 2020 07:39
GnomeSort in C++
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;