Skip to content

Instantly share code, notes, and snippets.

View christophewang's full-sized avatar
🎯
Focusing

Christophe Wang christophewang

🎯
Focusing
View GitHub Profile
@christophewang
christophewang / MergeSort.cpp
Last active August 9, 2023 08:27
Merge Sort in C++
#include <iostream>
void printArray(int *array, int n)
{
for (int i = 0; i < n; ++i)
std::cout << array[i] << std::endl;
}
void merge(int *array, int low, int mid, int high)
{
@christophewang
christophewang / QuickSort.cpp
Last active April 10, 2024 22:59
Quick Sort in C++
#include <iostream>
void printArray(int *array, int n)
{
for (int i = 0; i < n; ++i)
std::cout << array[i] << std::endl;
}
void quickSort(int *array, int low, int high)
{
@christophewang
christophewang / InsertionSort.cpp
Last active August 9, 2023 08:28
Insertion Sort in C++
#include <iostream>
void printArray(int *array, int n)
{
for (int i = 0; i < n; ++i)
std::cout << array[i] << std::endl;
}
void insertionSort(int *array, int n)
{
@christophewang
christophewang / SelectionSort.cpp
Last active August 9, 2023 08:29
Selection Sort in C++
#include <iostream>
void printArray(int *array, int n)
{
for (int i = 0; i < n; ++i)
std::cout << array[i] << std::endl;
}
void selectionSort(int *array, int n)
{
@christophewang
christophewang / BubbleSort.cpp
Last active August 9, 2023 08:29
Bubble Sort in C++
#include <iostream>
void printArray(int *array, int n)
{
for (int i = 0; i < n; ++i)
std::cout << array[i] << std::endl;
}
void bubbleSort(int *array, int n)
{
@christophewang
christophewang / BinarySearch.cpp
Last active August 9, 2023 08:29
Binary Search in C++
#include <iostream>
/* Binary Search */
int binarySearch(int *array, int n, int target)
{
int low = 0;
int high = n - 1;
while (low <= high)
{
@christophewang
christophewang / BinarySearchTree.cpp
Last active August 9, 2023 08:27
Binary Search Tree in C++
#include <iostream>
/* Node Structure */
struct BstNode
{
int data;
BstNode *left;
BstNode *right;
};