Skip to content

Instantly share code, notes, and snippets.

View scriptonian's full-sized avatar

I-am Konstantin scriptonian

View GitHub Profile
var book = {
title : 'The hidden Universe',
author: 'Konstantin',
printPage : function(){
console.log('printing book page');
},
editions: ['1', '2', '3'],
translators : [
{
publisher: 'Unipub A',
var book = {
title : 'The hidden Universe',
author: 'Konstantin',
publishDate: 'Jan 1 2016',
pageCount: 300
};
@scriptonian
scriptonian / heapsort.js
Created January 2, 2018 03:17
Heap Sort
function HeapSort(arr) {
console.log('Heap Sort Intialized!')
this.items = arr;
}
HeapSort.prototype = {
//swap items in array
swap: function(index_one, index_two) {
//swap
var temp = this.items[index_one];
@scriptonian
scriptonian / minheap.js
Created January 1, 2018 23:57
javascript minimum heap
function MinHeap(heap_size) {
//initialize parent class passing in heap size
Heap.call(this, heap_size);
//sub class of Head
console.log('Minheap Initialized!')
}
//setup the prototypal inheritance change so MinHeap can inherit from Heap
MinHeap.prototype = Object.create(Heap.prototype);
//Setup constructure of MinHeap to be itself instead of something else
MinHeap.prototype.constructor = MinHeap;
@scriptonian
scriptonian / maxheap.js
Created January 1, 2018 23:52
maximum heap subclass
function MaxHeap(heap_size) {
//initialize parent class passing in heap size
Heap.call(this, heap_size);
//sub class of Head
console.log('Maxheap Initialized!')
}
//setup the prototypal inheritance change so Maxheap can inherit from Heap
MaxHeap.prototype = Object.create(Heap.prototype);
//Setup constructure of Maxheap to be itself instead of something else
MaxHeap.prototype.constructor = MaxHeap;
@scriptonian
scriptonian / jsheap.js
Created January 1, 2018 23:22
Heap Base
function Heap(size) {
this.MAX_SIZE = size;
this.items = new Array(size);
this.count = 0;
}
Heap.prototype = {
//swap items in array
swap: function(index_one, index_two) {
//console.log('swapping ' + index_one + ' with ' + index_two);
@scriptonian
scriptonian / quicksort.js
Created December 18, 2017 14:35
Javscript Quick Sort
function ScriptoniteSort() {
this.arr = [];
}
ScriptoniteSort.prototype = {
swap: function(arr, index_one, index_two) {
//swap
var temp = arr[index_one];
arr[index_one] = arr[index_two];
arr[index_two] = temp;
@scriptonian
scriptonian / mergesort.js
Created December 16, 2017 20:05
Javascript merge sort
function ScriptoniteSort() {
this.arr = [];
}
ScriptoniteSort.prototype = {
/*
other code goes here
*/
//split the datalist recursively
mergeSplit: function(datalist) {
@scriptonian
scriptonian / shellsort.js
Created December 14, 2017 15:35
Javascript Shell Sort
function ScriptoniteSort() {
this.arr = [];
}
ScriptoniteSort.prototype = {
swap: function(arr, index_one, index_two) {
//swap
var temp = arr[index_one];
arr[index_one] = arr[index_two];
arr[index_two] = temp;
@scriptonian
scriptonian / insertion-sort.js
Created December 9, 2017 16:54
Javascript Insertion Sort
function ScriptoniteSort() {
this.arr = [];
}
ScriptoniteSort.prototype = {
swap: function(arr, index_one, index_two) {
//swap
var temp = arr[index_one];
arr[index_one] = arr[index_two];
arr[index_two] = temp;