GithubHelp home page GithubHelp logo

linked-list's Introduction

Linked Lists in Ruby

This project creates a Ruby LinkedList class to mimic the behavior of the linked list data structures found in other programming languages. This project is part of the The Odin Project curriculum.

A linked list is a linear collection of data elements, where each element contains some sort of data or value and a pointer to the next element in the list. In the list, "head" refers to the first element, and "tail" refers to the last element.

[ NODE (head) ] -> [ NODE ] -> [ NODE ] -> [ NODE (tail) ] -> nil

Along with the Node class, the LinkedList class contains the following functionality:

  1. #append adds a new node to the end of the list.
  2. #prepend adds a new node to the start of the list.
  3. #size returns the total number of nodes in the list.
  4. #head returns the first node in the list.
  5. #tail returns the last node in the list.
  6. #at(index) returns the node at the given index.
  7. #pop removes the last element from the list.
  8. #contains?(value) returns true if the passed in value is in the list and returns false otherwise.
  9. #find(value) returns the index of the node containing the given value or nil if the value is not found.
  10. #to_s represents the LinkedList object as a string so that they can be printed out and previewed in the console. The format of this string is, "( data ) -> ( data ) -> ( data ) -> nil".

Development versions

  • Ruby 2.5.3
  • RSpec 3.8

Using this code

  1. Fork this repository on GitHub.
  2. Clone your forked reposity onto your local computer.
  3. To run the tests, cd into the main directory and then run rspec.

linked-list's People

Contributors

leila-alderman avatar

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.