{"id":21521353,"url":"https://github.com/walkerrandolphsmith/js-data-structures","last_synced_at":"2025-03-17T17:17:19.501Z","repository":{"id":57169298,"uuid":"62967954","full_name":"walkerrandolphsmith/js-data-structures","owner":"walkerrandolphsmith","description":"Javascript implementations of common data structures.","archived":false,"fork":false,"pushed_at":"2021-03-04T14:15:07.000Z","size":302,"stargazers_count":2,"open_issues_count":11,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-07T08:34:47.029Z","etag":null,"topics":["adjacency-matrix","binary-tree","data-structures","graph","heap","huffman-tree","linked-list","stack","tree"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/walkerrandolphsmith.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-09T20:31:22.000Z","updated_at":"2023-03-08T04:11:45.000Z","dependencies_parsed_at":"2022-09-04T10:20:13.132Z","dependency_job_id":null,"html_url":"https://github.com/walkerrandolphsmith/js-data-structures","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walkerrandolphsmith%2Fjs-data-structures","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walkerrandolphsmith%2Fjs-data-structures/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walkerrandolphsmith%2Fjs-data-structures/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/walkerrandolphsmith%2Fjs-data-structures/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/walkerrandolphsmith","download_url":"https://codeload.github.com/walkerrandolphsmith/js-data-structures/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244075649,"owners_count":20393980,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adjacency-matrix","binary-tree","data-structures","graph","heap","huffman-tree","linked-list","stack","tree"],"created_at":"2024-11-24T01:06:58.381Z","updated_at":"2025-03-17T17:17:19.477Z","avatar_url":"https://github.com/walkerrandolphsmith.png","language":"JavaScript","readme":"# js-data-structures :dancer: [![Build Status](https://travis-ci.org/Quillio/js-data-structures.svg?branch=master)](https://travis-ci.org/Quillio/js-data-structures)\n\n\n- [Linked List](#linked-list)\n- [Stack](#stack)\n- [Binary Tree](#binary-tree)\n- [Binary Search Tree](#binary-serach-tree)\n- [Huffman Tree](#huffman-tree)\n- [Heap](#heap)\n- [Adjacency Matrix](#adjacency-matrix)\n- [Graph](#graph)\n\n### Linked List\n```\na-\u003eb-\u003ec\n```\n\n`new LinkedList(comparator)` Create a new linked list given a comparator function\n\n`isEmpty()` \nDetermine if there is any elements in list.\n\n`length()`\nDetermine the number of elements in the list.\n\n`contains(element)`\nGiven an element determine if the element is in the list.\n\n`getFirst()`\nRetrieve the first element in the list.\n\n`getLast()`\nRetrieve the last element in the list.\n\n`push(element)`\nAdd an element to the end of the list.\n\n`pop(element)`\nGiven an element remove the first element that matches the comparison.\n\n\n### Stack\n```\n|_|\n|_|\n|_|\n```\n\n`isEmpty()` Determine if there are any elements in the stack.\n\n`peek()` Retrieve the element on top of the stack without removing it from the stack.\n\n`pop()` Retrieve the element on top of the stack and remove it from the stack.\n\n`push(element)` Add an element to the top of the stack.\n\n### Binary Tree\n```\n    9\n  /   \\\n2       3\n  \\   /   \\\n   4 5     6\n```\n\n`isEmpty()` Determine if there are any elements in the tree.\n\n`getData()` Retreive the element at the root of the tree.\n\n`isLeaf()` Determine if the tree is a leaf node.\n\n`getLeftSubtree()` Retrieve the tree that is the left child of the current root node.\n\n`getRightSubtree()` Retrieve the tree that is the right child of the current root node.\n\n### Binary Search Tree : Binary Tree\n```\n    9\n  /   \\\n2       3\n  \\   /   \\\n   4 5     6\n```\n`new BinarySearchTree(comparator)` Create a new Binary Search Tree given a compartor function.\n\n`add(element)` Given an element add an element to the tree.\n\n`find(element)` Given an element retrieve the first element that matchs the comparison.\n\n`findLargestChild(parent)` Given a node in the tree, find the descendant node with greatest value.\n\n`remove(element)` Given an element remove the first element that matches the comparison.\n\n### Huffman Tree : Binary Tree\n```\n    *\n  /   \\\ne       *\n      /   \\\n     n     s\n```\n`new HuffmanTree(comparator)` Create a new Huffman Tree given a comprator.\n\n`add(element, code)` Given an element and a bit string, add a node in the tree for the element such that the tree can be traversed using the bit string as a sequence of edges.\n\n`decode(code)` Given a bit string, retrieve the element in the tree it corresponds to.\n\n### Heap : Binary Tree\n```\n    1\n  /   \\\n2       3\n  \\   /   \\\n   4 5     6\n```\n`new Heap(comparator)` Create a new Heap given a comparator function.\n\n`insert(element)` Given an element insert the element in the heap.\n\n`remove()` Retrieve and remove the root node which is the largest or smallest element in the heap.\n\n### Adjacency Matrix\n```\n[ 1 0 1 ] \n[ 0 1 0 ]\n[ 1 0 1 ]\n```\n`addEdge(v, w)` Given two verticies then create an edge with an initial vertex of v and terminal vertex of w.\n\n`hasEdge(v, w)` Given two vertices determine if there is an edge with a initial vertex of v and terminal vertex of w.\n\n`removeEdge(v, w)` Given two vertices remove the edge with an initial vertex of v and terminal vertex of w.\n\n`outEdges(v)` Given a vertex find all edges where the initial vertex is v.\n\n`inEdges(v)` Given a vertex find all edges where the terminal vertex is v.\n\n### Graph\n```\nA       B - F\n  \\   /\n    C\n  /   \\\nD       E\n```\n`getVertices()` Retrieve all verticies in the graph.\n\n`getEdges(v)` Given a vertex, retrieve all the vertices it is incedent to.\n\n`addVertex(v)` Given data, add the vertex to the graph.\n\n`findVertex(v)` Given data, retrieve the vertex in the graph.\n\n`addEdge(v, w)` Given two verticies relate them to one another to form an edge.\n\n`degree(v)` Given a vertex determine how many vertices it is incedent to.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwalkerrandolphsmith%2Fjs-data-structures","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwalkerrandolphsmith%2Fjs-data-structures","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwalkerrandolphsmith%2Fjs-data-structures/lists"}