{"id":27093556,"url":"https://github.com/amliyanage/data-structures","last_synced_at":"2025-04-06T08:37:21.915Z","repository":{"id":284979283,"uuid":"955819802","full_name":"amliyanage/Data-Structures","owner":"amliyanage","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-28T17:50:45.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"Main","last_synced_at":"2025-03-28T18:32:59.667Z","etag":null,"topics":["arrays","binary-tree","data","data-structures","graph","hashtable","linked-list","stack"],"latest_commit_sha":null,"homepage":"","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/amliyanage.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-27T08:49:52.000Z","updated_at":"2025-03-28T17:50:49.000Z","dependencies_parsed_at":"2025-03-28T18:45:31.844Z","dependency_job_id":null,"html_url":"https://github.com/amliyanage/Data-Structures","commit_stats":null,"previous_names":["amliyanage/data-structures"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amliyanage%2FData-Structures","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amliyanage%2FData-Structures/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amliyanage%2FData-Structures/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amliyanage%2FData-Structures/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amliyanage","download_url":"https://codeload.github.com/amliyanage/Data-Structures/tar.gz/refs/heads/Main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247457737,"owners_count":20941905,"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":["arrays","binary-tree","data","data-structures","graph","hashtable","linked-list","stack"],"created_at":"2025-04-06T08:37:21.380Z","updated_at":"2025-04-06T08:37:21.889Z","avatar_url":"https://github.com/amliyanage.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Data Structures and Algorithms in JavaScript\n\nThis repository contains implementations of common data structures and algorithms in JavaScript, including arrays, linked lists, stacks, trees, and graphs. Each section demonstrates the usage of these data structures with comments and example code.\n\n## Table of Contents\n\n- [Arrays](#arrays)\n- [Linked List](#linked-list)\n- [Stack (LIFO)](#stack-lifo)\n- [Binary Tree](#binary-tree)\n- [Graph (Adjacency List)](#graph-adjacency-list)\n- [Hash Table](#hash-table)\n\n## Arrays\n\nThe **array** implementation includes several operations such as adding, removing, searching, looping through elements, and sorting. Example operations include:\n\n- Adding and removing elements from the array (using `push()`, `pop()`, `shift()`, `unshift()`).\n- Searching for elements (using `indexOf()`, `includes()`, `find()`, and `findIndex()`).\n- Looping through the array (using `for`, `forEach()`, `map()`, `filter()`, and `reduce()`).\n- Sorting the array in ascending or descending order and reversing it.\n\n### Example:\n```js\nlet num = [10, 20, 30];\nnum.push(40); // Adds 40 to the array\nnum.pop(); // Removes the last element\nconsole.log(num); // [10, 20, 30]\n```\n\n## Linked List\n\nThe **linked list** implementation includes methods for adding, removing, and searching for nodes in the list. It supports basic linked list operations:\n\n- Add a new node to the end of the list.\n- Remove a node from the list.\n- Search for a node by its value.\n\n### Example:\n```js\nlet list = new LinkedList();\nlist.add(10);\nlist.add(20);\nlist.remove(10);\nconsole.log(list.search(20)); // true\n```\n\n## Stack (LIFO)\n\nThe **stack** implementation follows the Last In, First Out (LIFO) principle. You can perform the following operations:\n\n- Push an element onto the stack.\n- Pop an element from the stack.\n- Peek at the top element of the stack.\n- Check if the stack is empty.\n- Search for an element in the stack.\n\n### Example:\n```js\nlet stack = new Stack();\nstack.push(10);\nstack.push(20);\nconsole.log(stack.pop()); // 20\nconsole.log(stack.peek()); // 10\n```\n\n## Binary Tree\n\nThe **binary tree** implementation allows inserting nodes and performing an in-order traversal. It supports the following operations:\n\n- Insert a new node into the tree.\n- Perform an in-order traversal of the tree.\n\n### Example:\n```js\nlet tree = new BinaryTree();\ntree.insert(10);\ntree.insert(20);\ntree.insert(30);\ntree.inOrderTraversal(); // Output: 10 20 30\n```\n\n## Graph (Adjacency List)\n\nThe **graph** implementation uses an adjacency list to represent the graph. It supports the following operations:\n\n- Add a vertex to the graph.\n- Add an edge between two vertices.\n- Print the graph's adjacency list representation.\n\n### Example:\n```js\nlet graph = new Graph();\ngraph.addVertex('A');\ngraph.addVertex('B');\ngraph.addEdge('A', 'B');\ngraph.printGraph(); // Output: A -\u003e B, B -\u003e A\n```\n\n## Hash Table\n\nThe **hash table** implementation uses an array and a hash function to store key-value pairs. It supports basic operations like inserting, retrieving, and deleting key-value pairs.\n\n### Example:\n```js\nlet hashTable = new HashTable();\nhashTable.insert('name', 'John');\nconsole.log(hashTable.get('name')); // John\n```\n\n## Usage\n\nTo run any of the above implementations, simply include the respective code in your JavaScript environment (e.g., browser console, Node.js) and execute the functions to observe the outputs.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famliyanage%2Fdata-structures","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famliyanage%2Fdata-structures","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famliyanage%2Fdata-structures/lists"}