This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) { | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Node { | |
| constructor(val) { | |
| this.val = val; | |
| this.next = null; | |
| } | |
| } | |
| class SinglyLinkedList { | |
| constructor() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Node { | |
| constructor(val) { | |
| this.val = val; | |
| this.next = null; | |
| this.prev = null; | |
| } | |
| } | |
| class DoublyLinkedList { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Node { | |
| constructor(value) { | |
| this.value = value; | |
| this.next = null; | |
| } | |
| } | |
| class Stack { | |
| constructor() { | |
| this.first = null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Node { | |
| constructor(value) { | |
| this.value = value; | |
| this.next = null; | |
| } | |
| } | |
| class Queue { | |
| constructor() { | |
| this.first = null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Node { | |
| constructor(value) { | |
| this.value = value; | |
| this.left = null; | |
| this.right = null; | |
| } | |
| } | |
| class BinarySearchTree { | |
| constructor() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Node { | |
| constructor(value) { | |
| this.value = value; | |
| this.left = null; | |
| this.right = null; | |
| } | |
| } | |
| class BinarySearchTree { | |
| constructor() { |