Skip to content

Instantly share code, notes, and snippets.

View mustafadalga's full-sized avatar

Mustafa Dalga mustafadalga

View GitHub Profile
@mustafadalga
mustafadalga / insertion-sort.js
Created October 24, 2021 09:37
Insertion Sort Algorithm
function insertionSort(array) {
let adım = 1;
for (let i = 1; i < array.length; i++) {
var currentValue = array[i]
for (var j = i - 1; j >= 0 && array[j] > currentValue; j--) {
array[j + 1] = array[j];
}
array[j + 1] = currentValue
@mustafadalga
mustafadalga / mergeSort.js
Created November 23, 2021 14:54
Merge Sort Algorithm Example
function merge(firstArray, secondArray) {
let results = [], firstArrayIndex = 0, secondArrayIndex = 0;
while (firstArrayIndex < firstArray.length && secondArrayIndex < secondArray.length) {
if (secondArray[secondArrayIndex] > firstArray[firstArrayIndex]) {
results.push(firstArray[firstArrayIndex])
firstArrayIndex++;
} else {
@mustafadalga
mustafadalga / quickSort.js
Created December 11, 2021 10:38
Quick Sort Algorithm
function swap(array, i, j) {
var temp = array[i];
array[i] = array[j];
array[j] = temp;
}
function pivot(arr, start = 0, end = arr.length + 1) {
@mustafadalga
mustafadalga / radixSort.js
Last active December 11, 2021 13:49
Radix Sort Algorithm
function getDigit(number, digit) {
return Math.floor(Math.abs(number) / Math.pow(10, digit)) % 10
}
function digitCount(number) {
if (number === 0) return 1;
return Math.floor(Math.log10(Math.abs(number))) + 1;
}
@mustafadalga
mustafadalga / singly-linked-lists.js
Created December 21, 2021 21:02
Singly Linked Lists
class Node {
constructor(val) {
this.val = val;
this.next = null;
}
}
class SinglyLinkedList {
constructor() {
class Node {
constructor(val) {
this.val = val;
this.next = null;
this.prev = null;
}
}
class DoublyLinkedList {
@mustafadalga
mustafadalga / stack.js
Created March 20, 2022 11:40
Stack Data Structure Example
class Node {
constructor(value) {
this.value = value;
this.next = null;
}
}
class Stack {
constructor() {
this.first = null;
@mustafadalga
mustafadalga / queue.js
Created March 20, 2022 11:42
Queue Data Structure Example
class Node {
constructor(value) {
this.value = value;
this.next = null;
}
}
class Queue {
constructor() {
this.first = null;
@mustafadalga
mustafadalga / binary-search-tree.js
Created March 25, 2022 21:28
Binary Search Tree Data Structure Example in Javascript
class Node {
constructor(value) {
this.value = value;
this.left = null;
this.right = null;
}
}
class BinarySearchTree {
constructor() {
@mustafadalga
mustafadalga / utility-classes.scss
Created March 28, 2022 19:02
Utility Classes in heybooster project
@import "~@/scss/variables/_variables.scss";
// Color Palette
$colors: (
'primary':$primaryColor,
'accent':$accentColor,
'secondary':$secondaryColor,
'white':$whiteColor,
'black':$blackColor,