Skip to content

Instantly share code, notes, and snippets.

View Darkborderman's full-sized avatar

Darkborderman Darkborderman

View GitHub Profile
@Darkborderman
Darkborderman / quickSort.cpp
Created April 22, 2018 08:26
A quickSort algorithm
#include<iostream>
using namespace std;
void quickSort(int* data, int left, int right);
void swap(int* data, int i, int j);
int partition(int* data,int left,int right);
int main()
{
int input[10]={1,6,3,2,5,8,7,0,9,4};
@Darkborderman
Darkborderman / countSort.cpp
Last active April 22, 2018 09:32
A counting sort algorithm
#include<iostream>
using namespace std;
void countingSort(int* data,int size,int value);
int main()
{
int input[10]={1,6,5,0,7,2,9,3,4,8};
int size=10,value=9;
countingSort(input,size,value);
@Darkborderman
Darkborderman / heapSort.cpp
Last active April 23, 2018 02:54
A heap sort algorithm
#include <iostream>
using namespace std;
void heapify(int* data,int size,int i);
void heapSort(int* data,int size);
void swap(int* data, int i,int j);
int main()
{
int input[10]={1,0,2,8,3,6,7,9,4,5};
@Darkborderman
Darkborderman / min_max.cpp
Created May 7, 2018 06:34
A algorithm to find minium and maxium in an array.
#include<iostream>
using namespace std;
class min_max
{
public:
min_max(int min,int max)
{
this->min=min;
this->max=max;
@Darkborderman
Darkborderman / MongoOperation.js
Last active May 20, 2018 04:46
Basic MongoDB 3.X operation using javascript.
let MongoClient=require('mongodb').MongoClient;
let userName="name";
let userPassword="password";
let serverHost="localhost";
let serverPort=27017;
let databaseURL=`mongodb://${userName}:${userPassword}@${serverHost}:${serverPort}`;
let databaseName="test";
let databaseCollection="test";
//about to insert data
@Darkborderman
Darkborderman / draw.js
Last active May 23, 2018 01:25
Retro game color palette
document.addEventListener('DOMContentLoaded',function(){
for(colorData in color) draw(colorData);
});
function draw(data){
let canvas=document.getElementById(data);
canvas.height=Config.tile.height;
canvas.width=Config.tile.width*color[data].length;
let context=canvas.getContext('2d');
for(let i=0;i<=color[data].length-1;i++)
#include<iostream>
#include<cstdio>
using namespace std;
void addEdge(int source,int target,int weight);
void Floyd();
int w(int source,int target);
#include<iostream>
#include<cstdio>
using namespace std;
void addEdge(int source,int target,int weight);
void BellmanFord();
int w(int source,int target);
#include<iostream>
using namespace std;
int main(){
//1 2 3 4
//1 2 5 6
int price[4]={1,2,5,6};
int size;
//input size and initialize DP table
#include <stdio.h>
void addEdge(int source,int target,int weight);
int graph[5][5]={0};
int main()
{
//Init
int parent[5]; //I'th parent