/data-structures-ts

๐Ÿ›ข Codes containing implementation of data structures in Typescript.

Primary LanguageTypeScript

Data Structures

๐Ÿ›ข Codes containing implementation of data structures in Typescript.

GitHub license made-with-typescript

Requirements

This application requires the following resources:

Optional:

Getting started

After having the project cloned on your computer and opening the folder, you must install the dependencies.

With yarn: run the following command in your project clone

yarn 

With npm:

npm install

Usage example

The classes of the algorithms have already been instantiated in the file src/main.ts. You can change this implementation if you want.

import Stack from './algorithms/stack';
import Queue from './algorithms/queue';
import Deck from './algorithms/deck';
import binarySearch from './algorithms/binarySearch';

const InstantiatedStack = new Stack();
const InstantiatedQueue = new Queue();
const InstantiatedDeck = new Deck();


InstantiatedStack.push(5, 6, 7, 8, 9);

console.log(InstantiatedStack.showStack()); // [5, 6, 7, 8, 9]
InstantiatedStack.pop(); // 9 
console.log(InstantiatedStack.showStack()); // [5, 6, 7, 8]

InstantiatedQueue.enqueue(12);
InstantiatedQueue.enqueue(55);
InstantiatedQueue.enqueue(9);

console.log(InstantiatedQueue.showQueue()); // [12, 55, 9]
InstantiatedQueue.dequeue(); // 12
console.log(InstantiatedQueue.showQueue()); // [55, 9]

InstantiatedDeck.addBack(6);
InstantiatedDeck.addFront(3);

console.log(InstantiatedDeck.showDeck());  // [3, 6]

console.log(binarySearch([67, 69, 70, 85, 100, 102, 254, 800], 70)); // 70

With yarn:

yarn start

Wiht npm:

npm run start

Meta

Leonardo Oliveira โ€“ @leozartino โ€“ leozartino@gmail.com

Distributed under the MIT license. See MIT for more information.

Contributing

Feel free to contribute by adding other data structure algorithms using typescript. Add the files in the folder src/algorithms.

  1. Fork it (https://github.com/Leozartino/data-structures-ts/fork)
  2. Create your feature branch (git checkout -b feature/newFeature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin feature/newFeature)
  5. Create a new Pull Request

Auhors

  • Leonardo de Andrade Oliveira (leozartino) - Javascript Developer Made with ๐Ÿ’œ