dsa-utils
v0.0.0
Published
The utility library for dealing with DSA
Readme
Data Structures and Algorithms (DSA) Implementations
This repository serves as a collection of fundamental Data Structure and Algorithm implementations in JavaScript. The goal is to provide clear, well-tested, and efficient examples of common DSA concepts.
Current Implementations
- Queue: A basic FIFO (First-In, First-Out) queue implementation.
- Stack: A basic LIFO (Last-In, First-Out) stack implementation.
Installation
To get started with this project, clone the repository and install the dependencies using pnpm:
git clone <repository-url>
cd dsa
pnpm installUsage
Stack
import { Stack } from './src/stack';
const stack = new Stack();
stack.push(1);
stack.push(2);
console.log(stack.pop()); // 2
console.log(stack.peek()); // 1
console.log(stack.isEmpty()); // falseQueue
import { Queue } from './src/queue';
const queue = new Queue();
queue.enqueue('a');
queue.enqueue('b');
console.log(queue.dequeue()); // 'a'
console.log(queue.peek()); // 'b'
console.log(queue.isEmpty()); // falseRunning Tests
Tests are written using Vitest. To run the tests, use the following command:
pnpm testComing Soon
This project is continuously evolving. Expect more Data Structure and Algorithm implementations to be added in the near future!
