Skip to content
This repository was archived by the owner on Apr 16, 2024. It is now read-only.

harrisonhoward/data-structures-and-algorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Data Structures and Algorithms

This project was not designed with the intent that non of the models, sorting algorithms and data structures would be used. This project was completed with the sole intent of broading my own knowledge and assisting others who required help with building similar data structures and algorithms.

Testing

1. Change to the root directory of the project
2. Run "npm test" (Will include a coverage folder)

What is included

  • SingleNode

    constructor(data: any)
    .data (property) any type
    .next (property) SingleNode type
    .compareInstance(a: SingleNode, b: SingleNode) (static method) => boolean type

  • DoubleNode

    constructor(data: any)
    .data (property) any type
    .next (property) DoubleNode type
    .previous (property) DoubleNode type
    .compareInstance(a: DoubleNode, b: DoubleNode) (static method) => boolean type

  • TreeNode

    constructor(key: number, data: any)
    .key (property) number type
    .data (property) any type
    .left (property) TreeNode type
    .right (property) TreeNode type
    .parent (property) TreeNode type
    .compareInstance(a: TreeNode, b: TreeNode) (static method) => boolean type

  • HeapNode

    constructor(key: number, data: any)
    .key (property) number type
    .data (property) any type
    .compareInstance(a: HeapNode, b: HeapNode) (static method) => boolean type

  • GraphNode

    constructor(key: number, data: any)
    .key (property) number type
    .data (property) any type
    .getEdge(node: GraphNode) (method) => GraphNode type
    .addEdge(node: GraphNode) (method) => GraphNode type
    .deleteEdge(key: number) (method) => void type
    .compareInstance(a: GraphNode, b: GraphNode) (static method) => boolean type

  • SinglyLinkedList

    .head (property) SingleNode type
    .tail (property SingleNode type
    .prepend(node: SingleNode) (method) => SingleNode type
    .append(node: SingleNode) (method) => SingleNode type
    .insertBefore(node: SingleNode, nodeBefore: SingleNode) (method) => SingleNode type
    .insertAfter(node: SingleNode, nodeAfter: nodeAfter) (method) => SingleNode type
    .delete(node: SingleNode) (method) => void type
    .deleteBefore(node: SingleNode) (method) => void type
    .deleteAfter(node: SingleNode) (method) => void type
    .clear() (method) => void type
    .get(index: number) (method) => SingleNode type
    .find(callbackFn: function) (method) => SingleNode type
    .getNodeBefore(node: SingleNode) (method) => SingleNode type
    .forEach(callbackFn: function, thisArg?: any) (method) => void type
    .filter(callbackFn: function, thisArg?: any) (method) => void type
    .clone() (method) => SinglyLinkedList type
    .size (property) number type
    .toArray() (method) => SingleNode[] type
    .toString() (method) => string type
    .toStringReverse() (method) => string type

  • DoublyLinkedList

    .head (property) DoubleNode type
    .tail (property DoubleNode type
    .prepend(node: DoubleNode) (method) => DoubleNode type
    .append(node: DoubleNode) (method) => DoubleNode type
    .insertBefore(node: DoubleNode, nodeBefore: DoubleNode) (method) => DoubleNode type
    .insertAfter(node: DoubleNode, nodeAfter: nodeAfter) (method) => DoubleNode type
    .delete(node: DoubleNode) (method) => void type
    .deleteBefore(node: DoubleNode) (method) => void type
    .deleteAfter(node: DoubleNode) (method) => void type
    .clear() (method) => void type
    .get(index: number) (method) => DoubleNode type
    .find(callbackFn: function) (method) => DoubleNode type
    .getNodeBefore(node: DoubleNode) (method) => DoubleNode type
    .forEach(callbackFn: function, thisArg?: any) (method) => void type
    .filter(callbackFn: function, thisArg?: any) (method) => void type
    .clone() (method) => SinglyLinkedList type
    .size (property) number type
    .toArray() (method) => DoubleNode[] type
    .toString() (method) => string type
    .toStringReverse() (method) => string type

  • Queue

    .peek (property) any type
    .enqueue(value: any) (method) => void type
    .dequeue() (method) => any type
    .isEmpty() (method) => boolean type
    .clear() (method) => void type
    .clone() (method) => Queue type
    .size (property) number type
    .toArray() (method) => any[] type
    .toString() (method) => string type

  • Stack

    .peek (property) any type
    .push(value: any) (method) => void type
    .pop() (method) => any type
    .isEmpty() (method) => boolean type
    .clear() (method) => void type
    .clone() (method) => Stack type
    .size (property) number type
    .toArray() (method) => any[] type
    .toString() (method) => string type

  • BinaryTree

    .root (property) TreeNode type
    .insert(node: TreeNode) (method) => TreeNode type
    .delete(node: TreeNode) (method) => void type
    .clear() (method) => void type
    .get(key: number) (method) => TreeNode type
    .find(callbackFn: function) (method) => TreeNode type
    .min() (method) => TreeNode type
    .max() (method) => TreeNode type
    .lowerBound(key: number) (method) => TreeNode type
    .upperBound(key: number) (method) => TreeNode type
    .forEach(callbackFn: function, startNode?: TreeNode, thisArg?: any) (method) => void type
    .clone() (method) => BinaryTree type
    .size (property) number type
    .toPreOrder() (method) => TreeNode[] type
    .toInOrder() (method) => TreeNode[] type
    .toPostOrder() (method) => TreeNode[] type

  • HashMap

    .keys (property) string[] type
    .hashes (property) number[] type
    .values (property) any[] type
    .hash(key: string) (method) => number type
    .has(key: string) (method) => boolean type
    .get(key: string) (method) => any type
    .set(key: string, value: any) (method) => any type
    .delete(key: string) (method) => void type

  • Heap

    .root (property) HeapNode type
    .insert(node: HeapNode) (method) => HeapNode type
    .delete(node: HeapNode) (method) => void type
    .clear() (method) => void type
    .get(index: number) (method) => HeapNode type
    .find(callbackFn: function, thisArg?: any) (method) => HeapNode type
    .findIndex(callbackFn: function, thisArg?: any) (method) => number type
    .forEach(callbackFn: function, thisArg?: any) (method) => void type
    .clone(HeapType: MinHeap | MaxHeap) (method) => MinHeap | MaxHeap type

  • MinHeap extends Heap

    .compareKeys(parentKey: number, childKey: number) (method) => boolean type
    .clone() (method) => MinHeap type

  • MaxHeap extends Heap

    .compareKeys(parentKey: number, childKey: number) (method) => boolean type
    .clone() (method) => MinHeap type

  • Graph

    constructor(egdeDirection?: "directed" | "undirected")
    .isDirected (property) boolean type
    .hasVertex(key: number) (method) => boolean type
    .addVertex(node: GraphNode) (method) => GraphNode type
    .deleteVertex(key: number) (method) => void type
    .hasEdge(srcKey: number, destKey: number) (method) => boolean type
    .addEdge(source: GraphNode, dest: GraphNode) (method) => {source: GraphNode, destination: GraphNode} type
    .deleteEdge(srcKey: number, destKey: number) (method) => void type
    .clear() (method) => void type
    .clone() (method) => Graph type
    .verticesSize (property) number type
    .size (property) number type
    .toBFS() (method) => GraphNode[] type
    .toDFS() (method) => GraphNode[] type

  • MergeSort

    (originalArr: any[], classType?: class) => any[] type

  • BubbleSort

    (originalArr: any[], classType?: class) => any[] type

  • QuickSort

    (originalArr: any[], classType?: class) => any[] type

About

My implementation of common data structures and algorithms in JavaScript

Topics

Resources

Stars

Watchers

Forks