Library having data structures and algorithms as utility functions for node.js.
Click here for the link.
Note: This module is still under development and more util functions will be added.
Algo-util philosophy is to provide complex data structures and algorithms as utility to developers.
This will save their precious time, and let them focus on core development.
This will also help new developers who just entered the industry.
cheers... ;)
This is a Node.js module available through the npm registry.
Before installing, download and install Node.js. Node.js 8.x or higher is required.
Installation can be done using the
npm install
command:
$ npm install algo-util --save
const algoUtil = require('algo-util');
let arr = [8, 4, 9, 5, 2];
let sortedList = algoUtil.bubbleSort(arr);
console.log(sortedList);
const algoUtil = require('algo-util');
let arr = [8, 4, 9, 5, 2];
Performing Linear Searching.
let index = algoUtil.linearSearch(arr, 9);
console.log(index); // 2 (-1 if not found)
Performing Binary Searching.
let index = algoUtil.binarySearch(arr, 5);
console.log(index); // 3 (-1 if not found)
Performing Bubble Sorting.
let sortedList = algoUtil.bubbleSort(arr);
console.log(sortedList); // [2, 4, 5, 8, 9]
Performing Selection Sorting.
let sortedList = algoUtil.selectionSort(arr);
console.log(sortedList); // [2, 4, 5, 8, 9]
Singly LinkedList Example:
const { LinkedList } = require('./LinkedList');
// Basic usage of Singly LinkedList
const list = new LinkedList();
// Adding elements
list.insertFirst(3); // List: 3
list.insertLast(7); // List: 3 -> 7
list.insertAt(5, 1); // List: 3 -> 5 -> 7
// Accessing elements
console.log(list.get(1)); // Output: 5
console.log(list.indexOf(7)); // Output: 2
console.log(list.toArray()); // Output: [3, 5, 7]
// Removing elements
list.removeFirst(); // List: 5 -> 7
list.removeLast(); // List: 5
console.log(list.getSize()); // Output: 1
Doubly LinkedList Example:
const { DoublyLinkedList } = require('./DoublyLinkedList');
// Basic usage of Doubly LinkedList
const dList = new DoublyLinkedList();
// Adding elements
dList.insertFirst(10); // List: 10
dList.insertLast(30); // List: 10 <-> 30
dList.insertAt(20, 1); // List: 10 <-> 20 <-> 30
// Accessing elements from both directions
console.log(dList.toArray()); // Output: [10, 20, 30]
console.log(dList.toArrayReverse()); // Output: [30, 20, 10]
// Removing elements
dList.removeFirst(); // List: 20 <-> 30
dList.removeLast(); // List: 20
console.log(dList.getSize()); // Output: 1
- Implemented in native javascript.
- No dependencies or third-party library used.
- Major data structures included.
- Searching algorithms.
- Sorting algorithms.
- Singly and Doubly Linked List.
- More yet to come...
The original author and current maintainer of Algo-util is Rishabh Singh Sengar.