Giter Club home page Giter Club logo

bsu-self-organizing-list's Introduction

Self organizing list

Deadline
20.02.2017 09:00

Your task is to implement Self organizing list data structure. Please read about Move to Front Method.

  1. Fork this repo
  2. Install nodejs (>= v6.2.0)
  3. open bash in this folder
  4. npm install
  5. Implement class methods (fille src/self-organized-list.js, tests test/self-organized-list.spec.js)
  6. Commit your changes
  7. Push changes to github
  8. Submit your task to RS School Padawans

Methods

const sol = new SelfOrganizedList()
sol.insert(data)

Inserts data to the list;

sol.size()

Returns list length;

sol.at(index)

Returns data of the n-th element in the list;

sol.findNode(data)

Returns first founded Node that has provided data;

sol.toArray()

Returns array representation of the list;

sol.removeAt(index)

Remove n-th node from the list;

sol.moveToFront(node)

Moves node to the top of the list;

sol.reorganize(data)

Tries to find node with the data and move to front if data exist in the list; returns true if exist and false if not;

Example

const sol = new SelfOrganizedList();

sol.insert('Game of gnomes');
sol.insert('Superficial');
sol.insert('Breaking good');

sol.size(); // 3
sol.at(1); // Superficial
sol.toArray(); // ['Game of gnomes', 'Superficial', 'Breaking good']
sol.reorganize('Breaking good'); // true, and reorganize list to 'Breaking good' -> 'Game of gnomes' -> 'Superficial'
sol.reorganize('Breaking bad'); // false, list the same

FAQ

  1. How to fork github repo
  2. How to commit and push changes

Run tests

npm test

Run in browser

npm start

open http://localhost:8080 and hack in the browser console!


© humanamburu

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.