Giter VIP home page Giter VIP logo

linkedlists's Introduction

Data Structures


06/10/2019

Like your toolkit. They are tools. Use the one for the right problem you are trying to solve.

Arrays and Hash Tables are so common because they handle many things well. Every data structure has it's use case.

They come up often in interviews.

Linked Lists

similar to their cousin arrays. both used for storing lists of data.

lots of languages don't even include linked lists. Not in JS or python. Java and Rust do.

doesn't have to be right next to each other like an array. They just follow the next arrow or link to get to the next one.

If you are short on memory linked list might be better. We only need enough enough memory for a certain node at each location so they can be scattered throughout memory.

you might pick a linked list if

reference: head of list and tail of list.

H = head, T = tail, x = node, - = link

Hx-x-x-x-x-xT

Nothing has to get shifted in a linked list. really no such thing as a hole in a linked list. We can just shift the arrows or the (-, links) around. Nothing in memory has to be shifted around we can just move around the arrows / links.

Removing from front of the list would be O(1)

Adding to the back of list keeps same runtime of array so O(1). We just change the pointer and reassign the tail reference.

Arrays

similar to a bookshelf or a row of lockers. Data goes into these slots or lockers in order.

x = node - = link

x-x-x-x-x-x

usually stored right next to each other in memory / ram

need to store things continuously. sometimes we can't actually do that

most of the time you will just use an array.

pop(o) will remove that thing from array and then we have hole. arrays don't like holes. only holes at the end allowed. So that extra hole would have to be filled and shifts everything to the left. The runtime would be O(n) to do this. So removing from the front or the middle of an array is a linear operation in the worst case. Removing from the end would be a constant time operation.

linkedlists's People

Contributors

bangarangler avatar

Watchers

James Cloos 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.