Giter Site home page Giter Site logo

linked-list's Introduction

linked-list

A linked list is a data structure in which the objects are arranged in a linear order. Each element of a doubly linked list L is an object with an attribute key and two other pointer attributes: next and prev. Given an element x in the list, x.next points to its successor in the linked list, and x.prev points to its predecessor. If x.prev is NIL, the element x has no predecessor and is therefore the first element, or head, of the list. If x:next = NIL, the element x has no successor and is therefore the last element, or tail, of the list. An attribute L.head points to the first element of the list. If L.head = NIL, the list is empty.

Searching a linked list:

The function SEARCH finds the first element with key k in list L by a simple linear search, returning a pointer to this element. If no object with key k appears in the list, then the procedure returns NIL. To search a list of n objects, the SEARCH function takes O(n) time in the worst case, since it may have to search the entire list.

Inserting into a linked list:

Given an element x whose key attribute has already been set, the INSERT function “splices” x onto the front of the linked list. The running time for INSERT on a list of n elements is O(1).

Deleting from a linked list:

The function DELETE removes an element x from a linked list L. It must be given a pointer to x, and it then “splices” x out of the list by updating pointers. If we wish to delete an element with a given key, we must first call SEARCH function to retrieve a pointer to the element. If we wish to delete an element with a given key Θ(n) time is required in the worst case because we must first call SEARCH to find the element.

Getting first value (head):

The function getFirst returns value of head from linked list L. The running time of getFirst function is O(1).

Logging linked list:

The function log logs whole linked list L. Starts logging from head while head.Next is not NIL. The running time of log function is Θ(n).

linked-list's People

Contributors

narekhovhannisyan avatar

Stargazers

 avatar

Watchers

 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.