Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
algorithmskit
Advanced tools
An npm package for several complex algorithms and data structures like randomized quick sort, count sort, disjoint set union, etc.
algorithmskit
is a comprehensive library providing implementations of various data structures and algorithms. It includes classes for common data structures such as linked lists, stacks, queues, trees, and more. Additionally, it provides utility functions for sorting.
npm install algorithmskit
addLast(value)
: Adds a value to the end of the linked list. Accepts a number value.addFirst(value)
: Adds a value to the start of the linked list. Accepts a number value.returnFirst()
: Returns the first value of the linked list as a number. Returns -1 if the list is empty.returnLast()
: Returns the last value of the linked list as a number. Returns -1 if the list is empty.deleteFirst()
: Deletes the first node of the linked list.deleteLast()
: Deletes the last node of the linked list.addLast(value)
: Adds a value to the end of the linked list. Accepts a number value.addFirst(value)
: Adds a value to the start of the linked list. Accepts a number value.returnFirst()
: Returns the first value of the linked list as a number. Returns -1 if the list is empty.returnLast()
: Returns the last value of the linked list as a number. Returns -1 if the list is empty.deleteFirst()
: Deletes the first node of the linked list.deleteLast()
: Deletes the last node of the linked list.push(value)
: Pushes a value onto the stack. Accepts a number value.pop()
: Pops the top value from the stack. Returns the popped number value, or -1 if the stack is empty.peek()
: Peeks at the top value of the stack without removing it. Returns the number value at the top, or -1 if the stack is empty.isEmpty()
: Returns true if the stack is empty, otherwise false.getSize()
: Returns the size of the stack.printStack()
: Prints elements in the stack from top to bottom.push(key)
: Pushes a key into the MonotonicStack ensuring it remains monotonic (increasing or decreasing). Accepts a number key. Returns the key at the top of the stack just before the push operation.enqueue(value)
: Adds an element to the end of the queue. Accepts a number value.dequeue()
: Removes and returns the first element from the queue. Returns the value removed from the front of the queue, or null if the queue is empty.peek()
: Returns the first element of the queue without removing it.isEmpty()
: Returns true if the queue is empty, otherwise false.getSize()
: Returns the size of the queue.printQueue()
: Prints elements in the queue from front to end.addFront(value)
: Adds an element to the front of the deque. Accepts a number value.addRear(value)
: Adds an element to the rear of the deque. Accepts a number value.removeFront()
: Removes and returns the first element from the deque. Returns the value removed from the front of the deque, or null if the deque is empty.removeRear()
: Removes and returns the last element from the deque. Returns the value removed from the rear of the deque, or null if the deque is empty.peekFront()
: Returns the first element of the deque without removing it.peekRear()
: Returns the rear element of the deque without removing it.isEmpty()
: Returns true if the deque is empty, otherwise false.getSize()
: Returns the size of the deque.printDeque()
: Prints elements in the deque from front to end.insert(value)
: Inserts a value into the Binary Search Tree. Accepts a number value.search(value)
: Searches for a value in the Binary Search Tree. Accepts a number value. Returns true if the value is found, false otherwise.preorderTraversal(node=this.root)
: Performs a pre-order traversal of the Binary Search Tree. Accepts a BinaryTreeNode (default is the root). Returns an array of numbers in pre-order sequence.inorderTraversal(node=this.root)
: Performs an in-order traversal of the Binary Search Tree. Accepts a BinaryTreeNode (default is the root). Returns an array of numbers in in-order sequence.postorderTraversal(node=this.root)
: Performs a post-order traversal of the Binary Search Tree. Accepts a BinaryTreeNode (default is the root). Returns an array of numbers in post-order sequence.levelorderTraversal()
: Performs a level-order traversal of the Binary Search Tree. Returns an array of numbers in level-order sequence.getHeight(node)
: Gets the height of a node. Accepts an AVLTreeNode. Returns a number.getBalanceFactor(node)
: Gets the balance factor of a node. Accepts an AVLTreeNode. Returns a number.insert(value)
: Inserts a value into the AVL Tree. Accepts a number value.preorderTraversal(node=this.root)
: Performs a pre-order traversal of the AVL Tree. Accepts an AVLTreeNode (default is the root). Returns an array of numbers in pre-order sequence.inorderTraversal(node=this.root)
: Performs an in-order traversal of the AVL Tree. Accepts an AVLTreeNode (default is the root). Returns an array of numbers in in-order sequence.build(array)
: Builds the Fenwick Tree from the given array. Accepts an array of numbers.update(i, x)
: Updates the Fenwick Tree with the given value at the specified index. Accepts a number i (index) and a number x (value).query(i)
: Queries the prefix sum from index 1 to the specified index. Accepts a number i (index). Returns a number (prefix sum).rangeQuery(l, r)
: Queries the range sum from index l to index r. Accepts a number l (left index) and a number r (right index). Returns a number (range sum).insert(word)
: Inserts a word into the Trie. Accepts a string word.search(word)
: Searches for a word in the Trie. Accepts a string word. Returns true if the word is found, false otherwise.delete(word)
: Deletes a word from the Trie. Accepts a string word.startsWith(prefix)
: Checks if any word in the Trie starts with the given prefix. Accepts a string prefix. Returns true if there is any word with the given prefix, otherwise false.push(value)
: Pushes a value onto the heap.pop()
: Pops the top value from the heap.peek()
: Peeks at the top value of the heap without removing it.set(key, value)
: Adds or updates a key-value pair in the map. The key must be a number or a string.get(key)
: Retrieves the value associated with the specified key. Returns undefined if the key does not exist.delete(key)
: Removes the key-value pair associated with the specified key. Returns true if the key was removed, false if the key was not found.has(key)
: Checks if the specified key exists in the map. Returns true if the key exists, false otherwise.size()
: Returns the number of key-value pairs in the map.clear()
: Removes all key-value pairs from the map.printMap()
: Prints the contents of the map to the console, displaying each key-value pair.countSort(array)
: Performs Count Sort on the given array. Accepts an array of numbers. Returns the sorted array.radixSort(array)
: Performs Radix Sort on the given array. Accepts an array of numbers. Returns the sorted array.randomizedSort(array)
: Performs Randomized Quick Sort on the given array. Accepts an array of numbers. Returns the sorted array.FAQs
An npm package for several complex algorithms and data structures like randomized quick sort, count sort, disjoint set union, etc.
The npm package algorithmskit receives a total of 4 weekly downloads. As such, algorithmskit popularity was classified as not popular.
We found that algorithmskit demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.