Skip to content

Instantly share code, notes, and snippets.

View JohnKeysCloud's full-sized avatar
💻
Probably Coding

JOHN KEYS CLOUD JohnKeysCloud

💻
Probably Coding
View GitHub Profile
const knightMoves = [
[-1, 2],
[1, 2],
[-2, 1],
[2, 1],
[-2, -1],
[2, -1],
[-1, -2],
[1, -2],
];
@JohnKeysCloud
JohnKeysCloud / cyclone-binary-search-tree.js
Last active June 4, 2024 17:27
My implementation of a simple binary search tree class in JavaScript.
class Tree {
constructor(root = null) {
this.root = root;
}
// 💭 --------------------------------------------------------------
// 💭 Static Private
static #_sortedArrayToBSTInternal(sortedArray, start, end) {
if (start > end) return null;
@JohnKeysCloud
JohnKeysCloud / cyclone-string-hash-set.js
Created May 15, 2024 03:17
My implementation of a simple hash set class in JavaScript for string handling.
class CycloneHashSet {
constructor(capacity, loadFactor, name) {
this.buckets = new Array(capacity).fill(null).map(() => []);
this.loadFactor = loadFactor;
this.numberOfKeys = 0;
this.name = name;
this.setSize = capacity;
}
/**
@JohnKeysCloud
JohnKeysCloud / cyclone-singly-linked-list.js
Created May 14, 2024 05:06
My implementation of a simple singly linked list class in JavaScript.
/**
* Class representing a single node in a linked list.
* Each node holds data and a reference to the next node in the list.
*/
class Node {
/**
* Create a node.
* @param {*} data - The data to store in the node. This can be of any type.
*/
constructor(data) {
@JohnKeysCloud
JohnKeysCloud / cyclone-string-hash-map.js
Last active May 15, 2024 03:16
My implementation of a simple hash map class in JavaScript for string handling.
/**
* Class representing a hash map designed to handle strings.
*/
class HashMap {
constructor(name, capacity, loadFactor) {
this.buckets = new Array(capacity).fill(null).map(() => []);
this.loadFactor = loadFactor
this.mapSize = capacity;
this.name = name;
this.numEntries = 0;
@JohnKeysCloud
JohnKeysCloud / cyclone-merge-sort.js
Last active June 17, 2024 05:13
My Merge-Sort Implementation
const testArray1 = [3, 2, 1, 13, 8, 5, 0, 1];
const testArray2 = [105, 79, 100, 110, 3];
function merge(leftHalfOfArray, rightHalfOfArray) {
let mergedArray = [];
let leftHalfPointer = 0;
let rightHalfPointer = 0;
let mergedPointer = 0;