### Installing data-structure-typed via npm Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Command to install the entire data-structure-typed library and save it as a project dependency using npm. ```bash npm i data-structure-typed --save ``` -------------------------------- ### Install Project Dependencies npm Shell Source: https://github.com/zrwusa/data-structure-typed/blob/main/COMMANDS.md Installs all project dependencies listed in package.json and creates the node_modules folder, which is required for all other commands. ```Shell npm install ``` -------------------------------- ### Installing data-structure-typed via yarn Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Command to install the entire data-structure-typed library and save it as a project dependency using yarn. ```bash yarn add data-structure-typed ``` -------------------------------- ### Install Typedoc Dev Dependency npm Shell Source: https://github.com/zrwusa/data-structure-typed/blob/main/COMMANDS.md Installs Typedoc as a development dependency and saves it to package.json, used for generating TypeScript documentation. ```Shell npm install typedoc --save-dev ``` -------------------------------- ### Install ESLint Dev Dependency npm Shell Source: https://github.com/zrwusa/data-structure-typed/blob/main/COMMANDS.md Installs ESLint as a development dependency and saves it to package.json, used for static code analysis (linting). ```Shell npm install eslint --save-dev ``` -------------------------------- ### Using Binary Search Tree (BST) - data-structure-typed Source: https://github.com/zrwusa/data-structure-typed/blob/main/README_zh-CN.md Illustrates common operations on a Binary Search Tree (BST), including adding elements (single and multiple), querying size, checking for element existence, retrieving nodes and their properties (height, depth), finding the minimum element, deleting elements, checking AVL balance, performing Breadth-First Search (BFS), and printing the tree. Includes an example using object values. ```ts import { BST, BSTNode } from 'data-structure-typed'; const bst = new BST(); bst.add(11); bst.add(3); bst.addMany([15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5]); bst.size === 16; // true bst.has(6); // true const node6 = bst.getNode(6); // BSTNode bst.getHeight(6) === 2; // true bst.getHeight() === 5; // true bst.getDepth(6) === 3; // true bst.getLeftMost()?.key === 1; // true bst.delete(6); bst.get(6); // undefined bst.isAVLBalanced(); // true bst.bfs()[0] === 11; // true bst.print() // ______________11_____ // / \ // ___3_______ _13_____ // / \ / \ // 1_ _____8____ 12 _15__ // \ / \ / \ // 2 4_ _10 14 16 // \ / // 5_ 9 // \ // 7 const objBST = new BST(); objBST.add(11, { "name": "Pablo", "age": 15 }); objBST.add(3, { "name": "Kirk", "age": 1 }); objBST.addMany([15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5], [ { "name": "Alice", "age": 15 }, { "name": "Bob", "age": 1 }, { "name": "Charlie", "age": 8 }, { "name": "David", "age": 13 }, { "name": "Emma", "age": 16 }, { "name": "Frank", "age": 2 }, { "name": "Grace", "age": 6 }, { "name": "Hannah", "age": 9 }, { "name": "Isaac", "age": 12 }, { "name": "Jack", "age": 14 }, { "name": "Katie", "age": 4 }, { "name": "Liam", "age": 7 }, { "name": "Mia", "age": 10 }, { "name": "Noah", "age": 5 } ] ); objBST.delete(11); ``` -------------------------------- ### Installing a specific data structure via npm Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Command to install a single data structure package (e.g., heap-typed) independently using npm, useful if you only need one specific structure. ```bash npm i heap-typed --save ``` -------------------------------- ### Using AVL Tree - data-structure-typed Source: https://github.com/zrwusa/data-structure-typed/blob/main/README_zh-CN.md Shows how to use the `AVLTree` class, including adding multiple elements, checking if the tree maintains AVL balance after additions and deletions, and performing a deletion operation. ```ts import { AVLTree } from 'data-structure-typed'; const avlTree = new AVLTree(); avlTree.addMany([11, 3, 15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5]) avlTree.isAVLBalanced(); // true avlTree.delete(10); avlTree.isAVLBalanced(); // true ``` -------------------------------- ### Importing data-structure-typed via CommonJS Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Example demonstrating how to import modules from the data-structure-typed library using the CommonJS module system, typically used in Node.js environments. ```JavaScript require export.modules = ``` -------------------------------- ### Using Directed Graph - data-structure-typed Source: https://github.com/zrwusa/data-structure-typed/blob/main/README_zh-CN.md Provides examples of fundamental operations on a directed graph, such as adding and checking for vertices, adding and checking for edges, deleting edges, and performing a topological sort to get a linear ordering of vertices. ```ts import { DirectedGraph } from 'data-structure-typed'; const graph = new DirectedGraph(); graph.addVertex('A'); graph.addVertex('B'); graph.hasVertex('A'); // true graph.hasVertex('B'); // true graph.hasVertex('C'); // false graph.addEdge('A', 'B'); graph.hasEdge('A', 'B'); // true graph.hasEdge('B', 'A'); // false graph.deleteEdgeSrcToDest('A', 'B'); graph.hasEdge('A', 'B'); // false graph.addVertex('C'); graph.addEdge('A', 'B'); graph.addEdge('B', 'C'); const topologicalOrderKeys = graph.topologicalSort(); // ['A', 'B', 'C'] ``` -------------------------------- ### Importing data-structure-typed via ES Modules/Typescript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Example demonstrating the standard ES Module import syntax, which is also used in Typescript, for importing components from the data-structure-typed library. ```JavaScript import export ``` -------------------------------- ### Using Undirected Graph - data-structure-typed Source: https://github.com/zrwusa/data-structure-typed/blob/main/README_zh-CN.md Illustrates operations on an undirected graph, including adding and deleting vertices, adding edges, and running Dijkstra's algorithm to find the shortest paths from a source vertex. ```ts import { UndirectedGraph } from 'data-structure-typed'; const graph = new UndirectedGraph(); graph.addVertex('A'); graph.addVertex('B'); graph.addVertex('C'); graph.addVertex('D'); graph.deleteVertex('C'); graph.addEdge('A', 'B'); graph.addEdge('B', 'D'); const dijkstraResult = graph.dijkstra('A'); Array.from(dijkstraResult?.seen ?? []).map(vertex => vertex.key) // ['A', 'B', 'D'] ``` -------------------------------- ### Using Red-Black Tree - data-structure-typed Source: https://github.com/zrwusa/data-structure-typed/blob/main/README_zh-CN.md Demonstrates basic operations like adding multiple elements, checking AVL balance, deleting an element, and printing the tree structure using the `RedBlackTree` class from the `data-structure-typed` library. ```ts import { RedBlackTree } from 'data-structure-typed'; const rbTree = new RedBlackTree(); rbTree.addMany([11, 3, 15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5]) rbTree.isAVLBalanced(); // true rbTree.delete(10); rbTree.isAVLBalanced(); // true rbTree.print() // ___6________ // / \ // ___4_ ___11________ // / \ / \ // _2_ 5 _8_ ____14__ // / \ / \ / \ // 1 3 7 9 12__ 15__ // \ \ // 13 16 ``` ```js import { RedBlackTree } from 'data-structure-typed'; const rbTree = new RedBlackTree(); rbTree.addMany([11, 3, 15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5]) rbTree.isAVLBalanced(); // true rbTree.delete(10); rbTree.isAVLBalanced(); // true rbTree.print() // ___6________ // / \ // ___4_ ___11________ // / \ / \ // _2_ 5 _8_ ____14__ // / \ / \ / \ // 1 3 7 9 12__ 15__ // \ \ // 13 16 ``` -------------------------------- ### Importing data structures from data-structure-typed Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Demonstrates how to import various data structure classes (Heap, Graph, Queue, etc.) from the installed data-structure-typed library into a JavaScript or TypeScript project. ```js import { Heap, Graph, Queue, Deque, PriorityQueue, BST, Trie, DoublyLinkedList, AVLTree, SinglyLinkedList, DirectedGraph, RedBlackTree, TreeMultiMap, DirectedVertex, Stack, AVLTreeNode } from 'data-structure-typed'; ``` -------------------------------- ### Accessing data-structure-typed via UMD Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Example showing how to access a specific component (Deque) from the data-structure-typed library when using the UMD build, typically available as a global variable in browser environments. ```JavaScript var Deque = dataStructureTyped.Deque ``` -------------------------------- ### Package Project for Publishing npm Shell Source: https://github.com/zrwusa/data-structure-typed/blob/main/COMMANDS.md Prepares the project for publishing, typically by building and bundling the necessary files. This should be run before 'npm publish'. ```Shell npm run package ``` -------------------------------- ### Initialize ESLint Configuration Shell Source: https://github.com/zrwusa/data-structure-typed/blob/main/COMMANDS.md Runs the ESLint initialization wizard to create or configure the ESLint configuration file (.eslintrc) interactively. ```Shell npx eslint --init ``` -------------------------------- ### Build Documentation npm Shell Source: https://github.com/zrwusa/data-structure-typed/blob/main/COMMANDS.md Generates API documentation from JSDoc comments in the source code and places the output in the 'docs' folder. ```Shell npm run build:docs ``` -------------------------------- ### Publish Package npm Shell Source: https://github.com/zrwusa/data-structure-typed/blob/main/COMMANDS.md Publishes the current package to the npm registry. Ensure you run 'npm run package' first to prepare the package. ```Shell npm publish ``` -------------------------------- ### Authenticate npm Shell Source: https://github.com/zrwusa/data-structure-typed/blob/main/COMMANDS.md Logs in to the npm registry using your credentials, which is necessary before publishing packages. ```Shell npm login ``` -------------------------------- ### Build Project for Production npm Shell Source: https://github.com/zrwusa/data-structure-typed/blob/main/COMMANDS.md Builds the project for production, generating output in multiple formats (ESModule, CommonJS) and including minification (UMD). ```Shell npm run build ``` -------------------------------- ### Run Performance Tests npm Shell Source: https://github.com/zrwusa/data-structure-typed/blob/main/COMMANDS.md Executes all performance tests using Benchmark.js and reports the results. ```Shell npm test:perf ``` -------------------------------- ### Format Codebase npm Shell Source: https://github.com/zrwusa/data-structure-typed/blob/main/COMMANDS.md Uses Prettier to automatically format the code in the src/ and test/ directories according to predefined style rules. ```Shell npm run format ``` -------------------------------- ### Initialize and Print BST from MinPriorityQueue - JavaScript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Demonstrates initializing a Binary Search Tree (BST) using a Min Priority Queue as input and printing its structure. The BST is built from the elements extracted from the priority queue. ```javascript const orgArr = [6, 1, 2, 7, 5, 3, 4, 9, 8]; const pq = new MinPriorityQueue(orgArr); const bst1 = new BST(pq); bst1.print(); // _____5___ // / \ // _2_ _7_ // / \ / \ // 1 3_ 6 8_ // \ \ // 4 9 ``` -------------------------------- ### Initialize and Print BinaryTree from Entries - JavaScript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Shows how to initialize a general Binary Tree from an array of key-value pairs (entries) and print its structure. The tree is built based on the order of entries. ```javascript const entries = [[6, "6"], [1, "1"], [2, "2"], [7, "7"], [5, "5"], [3, "3"], [4, "4"], [9, "9"], [8, "8"]]; const biTree = new BinaryTree(entries); biTree.print(); // ___6___ // / \ // ___1_ _2_ // / \ / \ // _7_ 5 3 4 // / \ // 9 8 ``` -------------------------------- ### Lint Codebase npm Shell Source: https://github.com/zrwusa/data-structure-typed/blob/main/COMMANDS.md Runs ESLint to check the source (src/) and test (test/) directories for code quality and style issues. ```Shell npm run lint ``` -------------------------------- ### Run Specific Performance Test npm Shell Source: https://github.com/zrwusa/data-structure-typed/blob/main/COMMANDS.md Executes a specific performance test file (e.g., priority-queue.test) using Benchmark.js. ```Shell npm run test:perf -- priority-queue.test ``` -------------------------------- ### Run Project Checks Before Pull Request - Shell Source: https://github.com/zrwusa/data-structure-typed/blob/main/CONTRIBUTING.md Execute these commands to ensure code quality, style consistency, and test coverage before submitting a pull request. ```Shell npm run check ``` ```Shell npm run lint ``` ```Shell npm test ``` -------------------------------- ### Initialize and Print RedBlackTree from Deque - JavaScript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Shows how to initialize a Red-Black Tree using a Deque as input and print its structure. This demonstrates converting a sequence-based structure into a balanced tree. ```javascript const orgArr = [6, 1, 2, 7, 5, 3, 4, 9, 8]; const dq1 = new Deque(orgArr); const rbTree1 = new RedBlackTree(dq1); rbTree1.print(); // _____5___ // / \ // _2___ _7___ // / \ / \ // 1 _4 6 _9 // / / // 3 8 ``` -------------------------------- ### Commit and Push New Features - Shell Source: https://github.com/zrwusa/data-structure-typed/blob/main/CONTRIBUTING.md Follow these steps to stage your changes, commit them using the conventional commit format, and push your branch to the remote repository. ```Shell git add . ``` ```Shell git commit -m "feat(rbtree): features" ``` ```Shell git push ``` -------------------------------- ### Run Unit Tests npm Shell Source: https://github.com/zrwusa/data-structure-typed/blob/main/COMMANDS.md Executes all unit tests using Jest and includes code coverage reporting. ```Shell npm test ``` -------------------------------- ### Sync and Rebase Main Branch Before Development - Shell Source: https://github.com/zrwusa/data-structure-typed/blob/main/CONTRIBUTING.md Use these Git commands to update your local branch with the latest changes from the main branch and rebase your work to avoid merge conflicts. ```Shell git pull ``` ```Shell git rebase main ``` -------------------------------- ### Initialize and Print Deque from Heap - JavaScript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Shows how to initialize a Deque using a Heap as input and print its contents. This converts the heap structure back into a sequence. ```javascript const orgStrArr = ["trie", "trial", "trick", "trip", "tree", "trend", "triangle", "track", "trace", "transmit"]; const trie2 = new Trie(orgStrArr); const heap2 = new Heap(trie2, { comparator: (a, b) => Number(a) - Number(b) }); const dq2 = new Deque(heap2); dq2.print(); // ['transmit', 'trace', 'tree', 'trend', 'track', 'trial', 'trip', 'trie', 'trick', 'triangle'] ``` -------------------------------- ### Initialize and Print RedBlackTree from Entries - JavaScript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Demonstrates initializing a Red-Black Tree from an array of key-value pairs (entries) and printing its structure. The tree self-balances according to Red-Black Tree rules. ```javascript const entries = [[6, "6"], [1, "1"], [2, "2"], [7, "7"], [5, "5"], [3, "3"], [4, "4"], [9, "9"], [8, "8"]]; const rbTree = new RedBlackTree(entries); rbTree.print(); // ___4___ // / \ // _2_ _6___ // / \ / \ // 1 3 5 _8_ // / \ // 7 9 ``` -------------------------------- ### Initialize and Print Queue from Array - JavaScript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Demonstrates initializing a Queue data structure using a standard JavaScript array and then printing its contents. The Queue maintains the original order of elements. ```javascript const orgArr = [6, 1, 2, 7, 5, 3, 4, 9, 8]; const queue = new Queue(orgArr); queue.print(); // [6, 1, 2, 7, 5, 3, 4, 9, 8] ``` -------------------------------- ### Initialize and Print Heap from Trie with Comparator - JavaScript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Demonstrates initializing a general Heap data structure using a Trie as input and a custom comparator function, then printing the heap. The comparator defines the ordering within the heap. ```javascript const orgStrArr = ["trie", "trial", "trick", "trip", "tree", "trend", "triangle", "track", "trace", "transmit"]; const trie2 = new Trie(orgStrArr); const heap2 = new Heap(trie2, { comparator: (a, b) => Number(a) - Number(b) }); heap2.print(); // ['transmit', 'trace', 'tree', 'trend', 'track', 'trial', 'trip', 'trie', 'trick', 'triangle'] ``` -------------------------------- ### Initialize and Print HashMap from Entries - JavaScript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Demonstrates initializing a HashMap from an array of key-value pairs (entries) and printing its contents. The map stores key-value pairs with efficient lookup. ```javascript const entries = [[6, "6"], [1, "1"], [2, "2"], [7, "7"], [5, "5"], [3, "3"], [4, "4"], [9, "9"], [8, "8"]]; const hm = new HashMap(entries); hm.print() // [[6, "6"], [1, "1"], [2, "2"], [7, "7"], [5, "5"], [3, "3"], [4, "4"], [9, "9"], [8, "8"]] ``` -------------------------------- ### Run Unit Tests with Coverage npm Shell Source: https://github.com/zrwusa/data-structure-typed/blob/main/COMMANDS.md Explicitly runs all unit tests using Jest and includes code coverage reporting. This command is equivalent to 'npm test'. ```Shell npm run test:unit ``` -------------------------------- ### Initialize and Print RedBlackTree from HashMap - JavaScript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Shows how to initialize a Red-Black Tree directly from a HashMap and print its structure. This demonstrates converting a hash-based map into a balanced tree structure. ```javascript const entries = [[6, "6"], [1, "1"], [2, "2"], [7, "7"], [5, "5"], [3, "3"], [4, "4"], [9, "9"], [8, "8"]]; const hm = new HashMap(entries); const rbTreeH = new RedBlackTree(hm); rbTreeH.print(); // ___4___ // / \ // _2_ _6___ // / \ / \ // 1 3 5 _8_ // / \ // 7 9 ``` -------------------------------- ### Inspect Codebase npm Shell Source: https://github.com/zrwusa/data-structure-typed/blob/main/COMMANDS.md Performs static analysis on the src/ and test/ directories using both TSC (TypeScript compiler) for type checking and ESLint for linting. ```Shell npm run inspect ``` -------------------------------- ### Initialize and Print Stack from Array - JavaScript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Shows how to initialize a Stack data structure using a JavaScript array and print its contents. Elements are pushed onto the stack in the order they appear in the array. ```javascript const orgArr = [6, 1, 2, 7, 5, 3, 4, 9, 8]; const stack = new Stack(orgArr); stack.print(); // [6, 1, 2, 7, 5, 3, 4, 9, 8] ``` -------------------------------- ### Basic BST Operations in TypeScript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Demonstrates how to initialize a Binary Search Tree (BST) using `data-structure-typed`, add single and multiple elements, check size and existence, retrieve nodes, calculate height and depth, find the leftmost node, delete elements, check AVL balance, perform BFS traversal, and print the tree structure. Also shows usage with key-value pairs. ```typescript import { BST, BSTNode } from 'data-structure-typed'; const bst = new BST(); bst.add(11); bst.add(3); bst.addMany([15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5]); bst.size === 16; // true bst.has(6); // true const node6 = bst.getNode(6); // BSTNode bst.getHeight(6) === 2; // true bst.getHeight() === 5; // true bst.getDepth(6) === 3; // true bst.getLeftMost()?.key === 1; // true bst.delete(6); bst.get(6); // undefined bst.isAVLBalanced(); // true bst.bfs()[0] === 11; // true bst.print() // ______________11_____ // / \ // ___3_______ _13_____ // / \ / \ // 1_ _____8____ 12 _15__ // \ / \ / \ // 2 4_ _10 14 16 // \ / // 5_ 9 // \ // 7 const objBST = new BST(); objBST.add(11, { "name": "Pablo", "size": 15 }); objBST.add(3, { "name": "Kirk", "size": 1 }); objBST.addMany([15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5], [ { "name": "Alice", "size": 15 }, { "name": "Bob", "size": 1 }, { "name": "Charlie", "size": 8 }, { "name": "David", "size": 13 }, { "name": "Emma", "size": 16 }, { "name": "Frank", "size": 2 }, { "name": "Grace", "size": 6 }, { "name": "Hannah", "size": 9 }, { "name": "Isaac", "size": 12 }, { "name": "Jack", "size": 14 }, { "name": "Katie", "size": 4 }, { "name": "Liam", "size": 7 }, { "name": "Mia", "size": 10 }, { "name": "Noah", "size": 5 } ] ); objBST.delete(11); ``` -------------------------------- ### AVL Tree Operations in TypeScript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Illustrates the initialization of an AVL Tree using `data-structure-typed`, adding multiple elements, verifying its AVL balance property before and after deletion. ```typescript import { AVLTree } from 'data-structure-typed'; const avlTree = new AVLTree(); avlTree.addMany([11, 3, 15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5]) avlTree.isAVLBalanced(); // true avlTree.delete(10); avlTree.isAVLBalanced(); // true ``` -------------------------------- ### Initialize and Print AVLTree from Entries - JavaScript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Shows how to initialize an AVL Tree from an array of key-value pairs (entries) and print its structure. The tree self-balances to maintain a height difference of at most 1 between left and right subtrees. ```javascript const entries = [[6, "6"], [1, "1"], [2, "2"], [7, "7"], [5, "5"], [3, "3"], [4, "4"], [9, "9"], [8, "8"]]; const avl = new AVLTree(entries); avl.print(); // ___4___ // / \ // _2_ _6___ // / \ / \ // 1 3 5 _8_ // / \ // 7 9 ``` -------------------------------- ### Initialize and Print BST from Entries - JavaScript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Illustrates initializing a Binary Search Tree (BST) from an array of key-value pairs (entries) and printing its structure. The tree adheres to BST properties where left children are less than the parent and right children are greater. ```javascript const entries = [[6, "6"], [1, "1"], [2, "2"], [7, "7"], [5, "5"], [3, "3"], [4, "4"], [9, "9"], [8, "8"]]; const bst = new BST(entries); bst.print(); // _____5___ // / \ // _2_ _7_ // / \ / \ // 1 3_ 6 8_ // \ \ // 4 9 ``` -------------------------------- ### Initialize and Print MinHeap from Array - JavaScript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Illustrates initializing a Min-Heap data structure from a JavaScript array and printing its contents. The heap property is applied during initialization, resulting in the smallest element at the root. ```javascript const orgArr = [6, 1, 2, 7, 5, 3, 4, 9, 8]; const minHeap = new MinHeap(orgArr); minHeap.print(); // [1, 5, 2, 7, 6, 3, 4, 9, 8] ``` -------------------------------- ### Using Red Black Tree in JavaScript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Demonstrates how to import, instantiate, add multiple elements to, check AVL balance, delete an element from, and print a Red Black Tree using the 'data-structure-typed' library in JavaScript. ```javascript import { RedBlackTree } from 'data-structure-typed'; const rbTree = new RedBlackTree(); rbTree.addMany([11, 3, 15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5]) rbTree.isAVLBalanced(); // true rbTree.delete(10); rbTree.isAVLBalanced(); // true rbTree.print() // ___6________ // / \ // ___4_ ___11________ // / \ / \ // _2_ 5 _8_ ____14__ // / \ / \ / \ // 1 3 7 9 12__ 15__ // \ \ // 13 16 ``` -------------------------------- ### Map Deque to Entries, Initialize and Print AVLTree - JavaScript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Demonstrates converting a Deque into an array of key-value pairs (entries) using the map function, then initializing an AVL Tree from these entries and printing its structure. ```javascript const orgStrArr = ["trie", "trial", "trick", "trip", "tree", "trend", "triangle", "track", "trace", "transmit"]; const trie2 = new Trie(orgStrArr); const heap2 = new Heap(trie2, { comparator: (a, b) => Number(a) - Number(b) }); const dq2 = new Deque(heap2); const entries2 = dq2.map((el, i) => [i, el]); const avl2 = new AVLTree(entries2); avl2.print(); // ___3_______ // / \ // _1_ ___7_ // / \ / \ // 0 2 _5_ 8_ // / \ \ // 4 6 9 ``` -------------------------------- ### Run RB-Tree Performance Benchmark Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Executes the performance benchmark specifically for the Red-Black Tree data structure using the pnpm package manager. This command triggers the test suite for the RB-Tree implementation. ```shell pnpm perf:rbtree ``` -------------------------------- ### Include data-structure-typed UMD (Production) via CDN Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md HTML script tag to include the minified production version of the data-structure-typed library's UMD build directly from a CDN into an HTML document. ```HTML ``` -------------------------------- ### Initialize and Print MinPriorityQueue from Array (Repeat) - JavaScript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Re-initializes a Min Priority Queue from the original array. This snippet serves as input for the subsequent BST initialization. ```javascript const orgArr = [6, 1, 2, 7, 5, 3, 4, 9, 8]; const pq = new MinPriorityQueue(orgArr); pq.print(); // [1, 5, 2, 7, 6, 3, 4, 9, 8] ``` -------------------------------- ### Using Red Black Tree in TypeScript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Demonstrates how to import, instantiate, add multiple elements to, check AVL balance, delete an element from, and print a Red Black Tree using the 'data-structure-typed' library in TypeScript. ```typescript import { RedBlackTree } from 'data-structure-typed'; const rbTree = new RedBlackTree(); rbTree.addMany([11, 3, 15, 1, 8, 13, 16, 2, 6, 9, 12, 14, 4, 7, 10, 5]) rbTree.isAVLBalanced(); // true rbTree.delete(10); rbTree.isAVLBalanced(); // true rbTree.print() // ___6________ // / \ // ___4_ ___11________ // / \ / \ // _2_ 5 _8_ ____14__ // / \ / \ / \ // 1 3 7 9 12__ 15__ // \ \ // 13 16 ``` -------------------------------- ### Include data-structure-typed UMD (Development) via CDN Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md HTML script tag to include the development version of the data-structure-typed library's UMD build directly from a CDN into an HTML document. ```HTML ``` -------------------------------- ### Initialize and Print Trie from String Array - JavaScript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Illustrates initializing a Trie (Prefix Tree) from an array of strings and printing its contents. The Trie organizes strings based on common prefixes. ```javascript const orgStrArr = ["trie", "trial", "trick", "trip", "tree", "trend", "triangle", "track", "trace", "transmit"]; const trie2 = new Trie(orgStrArr); trie2.print(); // ['trie', 'trial', 'triangle', 'trick', 'trip', 'tree', 'trend', 'track', 'trace', 'transmit'] ``` -------------------------------- ### Update Changelog npm Shell Source: https://github.com/zrwusa/data-structure-typed/blob/main/COMMANDS.md Runs a script to update the CHANGELOG.md file, typically based on commit messages or release notes. ```Shell npm run changelog ``` -------------------------------- ### Initialize and Print TreeMultiMap from Entries - JavaScript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Illustrates initializing a Tree Multi-Map from an array of key-value pairs (entries) and printing its structure. This map allows multiple values per key, stored in a tree structure. ```javascript const entries = [[6, "6"], [1, "1"], [2, "2"], [7, "7"], [5, "5"], [3, "3"], [4, "4"], [9, "9"], [8, "8"]]; const treeMulti = new TreeMultiMap(entries); treeMulti.print(); // ___4___ // / \ // _2_ _6___ // / \ / \ // 1 3 5 _8_ // / \ // 7 9 ``` -------------------------------- ### Initialize and Print SinglyLinkedList from Array - JavaScript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Illustrates the initialization of a Singly Linked List using a JavaScript array and printing the list. The list nodes are created in the order of the array elements. ```javascript const orgArr = [6, 1, 2, 7, 5, 3, 4, 9, 8]; const sList = new SinglyLinkedList(orgArr); sList.print(); // [6, 1, 2, 7, 5, 3, 4, 9, 8] ``` -------------------------------- ### Fix Vulnerabilities npm Shell Source: https://github.com/zrwusa/data-structure-typed/blob/main/COMMANDS.md Automatically attempts to fix security vulnerabilities found in project dependencies by updating package versions. ```Shell npm audit fix ``` -------------------------------- ### Initialize and Print Deque from Array - JavaScript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Shows how to initialize a Deque (Double-Ended Queue) data structure from a JavaScript array and print its elements. The Deque preserves the order of elements from the input array. ```javascript const orgArr = [6, 1, 2, 7, 5, 3, 4, 9, 8]; const deque = new Deque(orgArr); deque.print(); // [6, 1, 2, 7, 5, 3, 4, 9, 8] ``` -------------------------------- ### Initialize and Print MaxPriorityQueue from Array - JavaScript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Demonstrates initializing a Max Priority Queue from a JavaScript array and printing its contents. The priority queue property ensures the largest element is at the root. ```javascript const orgArr = [6, 1, 2, 7, 5, 3, 4, 9, 8]; const maxPQ = new MaxPriorityQueue(orgArr); maxPQ.print(); // [9, 8, 4, 7, 5, 2, 3, 1, 6] ``` -------------------------------- ### Initialize and Print DoublyLinkedList from Array - JavaScript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Demonstrates initializing a Doubly Linked List from a JavaScript array and printing the list. Nodes are created maintaining the original array order with links in both directions. ```javascript const orgArr = [6, 1, 2, 7, 5, 3, 4, 9, 8]; const dList = new DoublyLinkedList(orgArr); dList.print(); // [6, 1, 2, 7, 5, 3, 4, 9, 8] ``` -------------------------------- ### Initialize and Print Deque from Array (Repeat) - JavaScript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Re-initializes a Deque from the original array. This snippet serves as input for the subsequent Red-Black Tree initialization. ```javascript const orgArr = [6, 1, 2, 7, 5, 3, 4, 9, 8]; const dq1 = new Deque(orgArr); dq1.print(); // [6, 1, 2, 7, 5, 3, 4, 9, 8] ``` -------------------------------- ### Directed Graph Operations in TypeScript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Shows how to create a Directed Graph using `data-structure-typed`, add vertices and edges, check for their existence, delete edges, and perform a topological sort. ```typescript import { DirectedGraph } from 'data-structure-typed'; const graph = new DirectedGraph(); graph.addVertex('A'); graph.addVertex('B'); graph.hasVertex('A'); // true graph.hasVertex('B'); // true graph.hasVertex('C'); // false graph.addEdge('A', 'B'); graph.hasEdge('A', 'B'); // true graph.hasEdge('B', 'A'); // false graph.deleteEdgeSrcToDest('A', 'B'); graph.hasEdge('A', 'B'); // false graph.addVertex('C'); graph.addEdge('A', 'B'); graph.addEdge('B', 'C'); const topologicalOrderKeys = graph.topologicalSort(); // ['A', 'B', 'C'] ``` -------------------------------- ### Undirected Graph Operations in TypeScript Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md Illustrates the creation of an Undirected Graph using `data-structure-typed`, adding and deleting vertices, adding edges, and performing Dijkstra's algorithm to find shortest paths from a source vertex. ```typescript import { UndirectedGraph } from 'data-structure-typed'; const graph = new UndirectedGraph(); graph.addVertex('A'); graph.addVertex('B'); graph.addVertex('C'); graph.addVertex('D'); graph.deleteVertex('C'); graph.addEdge('A', 'B'); graph.addEdge('B', 'D'); const dijkstraResult = graph.dijkstra('A'); Array.from(dijkstraResult?.seen ?? []).map(vertex => vertex.key) // ['A', 'B', 'D'] ``` -------------------------------- ### Destructuring data-structure-typed Components (UMD) Source: https://github.com/zrwusa/data-structure-typed/blob/main/README.md JavaScript code demonstrating how to destructure various data structure components from the global 'dataStructureTyped' object after it has been loaded via the UMD build (e.g., from a CDN). ```JavaScript const { Heap } = dataStructureTyped; const { BinaryTree, Graph, Queue, Stack, PriorityQueue, BST, Trie, DoublyLinkedList, AVLTree, MinHeap, SinglyLinkedList, DirectedGraph, TreeMultiMap, DirectedVertex, AVLTreeNode } = dataStructureTyped; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.