Linked Lists - Computerphile

Поделиться
HTML-код
  • Опубликовано: 27 ноя 2024

Комментарии • 407

  • @mmanuel6874
    @mmanuel6874 5 лет назад +142

    I love how you pointed out some used cases of the linked lists in real life! It helps me appreciate the data structure and makes me want to learn more!

    • @MrTransits
      @MrTransits 3 года назад +3

      I was mind blown when he gave real examples that we can all try/observe at our own homes. 😌

  • @aksela6912
    @aksela6912 7 лет назад +653

    The traffic noise wasn't that bad. I heard everything that was being said and it added an interesting background.

    • @Computerphile
      @Computerphile  7 лет назад +63

      +Aksel Anker Henriksen thanks, I did my best to filter it but at the time we had to keep stopping and starting because of trucks stopping next to us etc... >Sean

    • @crystallastname9675
      @crystallastname9675 7 лет назад +6

      I agree with aksel, but in my inexperienced opinion indoors'd be better

    • @Shadow4707
      @Shadow4707 7 лет назад +21

      I didn't notice it at all actually.

    • @remmoze
      @remmoze 7 лет назад +3

      I went to the comments section to tell the exact same thing

    • @DrRChandra
      @DrRChandra 7 лет назад +5

      It worked well.

  • @陈瀚龙
    @陈瀚龙 6 лет назад +60

    The best explanation of anything in 10 minutes I've seen, and the best jumping into linked lists explanation I've seen. Thanks, Doc! Love the on the street tutorial. Reminds me of many on the fly, brilliant napkin tutorials I've had with professors and genius artists over the years, with ale, coffee, or tea.

  • @hamzashakeel5684
    @hamzashakeel5684 7 лет назад +147

    Really nice video. You should do more videos on data structures like binary trees, stacks, and queues.

  • @diogofolques3075
    @diogofolques3075 7 лет назад +59

    Lot's of people saying linked lists are sh*t in terms of performance, and that might be true, however they are very useful to start learning data structures, so you can more easily learn other kinds of structures like binary trees

    • @boptillyouflop
      @boptillyouflop 7 лет назад +12

      Yes. That's why they teach linked lists in those computer science classes. It does have real world applications - namely that after that, you know how to use std::map without blowing things up. :3

  • @AnthonyHartwig
    @AnthonyHartwig 7 лет назад +6

    Nerds make me happy. Makes me miss the CS culture from college. Keep up the awesomeness on this channel!

  • @AssailantLF
    @AssailantLF 7 лет назад +7

    I'm loving these recent programming concept explanation videos! I hope the channel progresses to the more complex data structures over time, as those would benefit from the explanations more than the simple stuff.

  • @Brandon_66
    @Brandon_66 4 года назад +11

    This is better than an entire college lecture

  • @craigrotay3732
    @craigrotay3732 7 лет назад +1

    I'm very impressed with Dr A here bcs he is so simplifying a concept that is extremely complicated.

  • @greenolvi
    @greenolvi 7 лет назад +33

    9:20 my thought 'unless you're using vim'. Few seconds after in the video 'unless you're using something like vim'. Great video :-)

  • @Cold_Ham_on_Rye
    @Cold_Ham_on_Rye 7 лет назад +72

    Jesus christ. I said this on another video but the computerphile community is toxic. Like they criticize the shit out of every video.

    • @gophop
      @gophop 7 лет назад +11

      I think it's more of a personality trait of the nerds.

    • @Cold_Ham_on_Rye
      @Cold_Ham_on_Rye 7 лет назад +4

      but the numberphile and sixty symbols communities are nothing like this. It's specifically computer nerds.

    • @ABalazs31
      @ABalazs31 7 лет назад +3

      I found the comments generally well mannered and useful, but leaving out the fact that you should never use linked lists in the real life is a big, glaring omission.

    • @0xCAFEF00D
      @0xCAFEF00D 7 лет назад +7

      No this place is extra terrible for sure. Compare to sixty symbols, numberphile or even better deepskyvideos.
      I think it's because computer people aren't humbled enough as there's so many different correct answers. And we're taught to power through mistakes to a large degree.

  • @raunak51299
    @raunak51299 3 года назад

    You have no idea how helpful is this for new learners like me

  • @jayyyzeee6409
    @jayyyzeee6409 7 лет назад +7

    Brings back fond memories of undergrad Comp Sci classes. Not one mention though of memory deallocation, the worst developer sin in languages without memory management.

  • @patrickmayer9218
    @patrickmayer9218 2 года назад +2

    The comparison to tab history was genius! Thanks for the explanation!

  • @saindst
    @saindst Год назад +1

    Oh my goooooood, an actual damn example wtf. Its mad how a real world example just makes everything click

  • @Woozeesh
    @Woozeesh 7 лет назад +7

    Wow. Where did he get all of that antique fan-fold printer paper? I haven't seen that much ffp since my freshman engineering days back in the 80's.

  • @WarriorAjk
    @WarriorAjk 4 года назад +2

    The wikipedia example he gave was a pretty good application of linked list. Nicely explained!

  • @rsmease
    @rsmease 6 лет назад +1

    The live example with the animation running as he explains it is great.

  • @DrRChandra
    @DrRChandra 7 лет назад +4

    "Pointing at null" seems semantically slightly different than saying "null pointer", which is what my CS courses taught me to put at the end of a linked list. "Pointing at null" means it's pointing at something (that happens to be null), whereas the concept of null pointer is that it isn't pointing at anything at all.

    • @DrRChandra
      @DrRChandra 7 лет назад +2

      Most architectures have the null pointer as 0, but I've seen a few rare ones which it was all 1's for the width of its word. And it has nothing to do with hardware. Just saying, pointing at (for example) a zero is not the same thing as a pointer whose machine value is zero.

  • @grzesiek1x
    @grzesiek1x 4 года назад +8

    I really like how he explains things! I am working now on linked lists and it really helps to understand ! Thanks :)

  • @gregoryfenn1462
    @gregoryfenn1462 3 года назад

    Double linked lists all the way!
    You can also generalise if you want: add a reference to the “middle” node which can fairly easily be maintained. Then inserting or editing the Nth item in your list can be done either from front to end, front end to front, from middle to end, or from middle to front. If you have a very long list then this added overhead is worth it and can half your insertion/modify time cost. (You could gene realise further with a reference to the item at each quartile or decile or percentile too, if you had incredibly big lists.)

  • @PeoniesRoses
    @PeoniesRoses 4 года назад +2

    The noise wasn't too bad, I was just confused as to why you were casually explaining data structures in the streets of London, but oh well. Quite refreshing, I guess :D

  • @N....
    @N.... 7 лет назад +149

    It's a bit troubling though that linked lists are rarely more efficient and yet they are frequently taught as if they are extremely useful. They are a great learning tool, but they are generally very inefficient compared to contiguous arrays unless each element is very large, and it is rare to have very large elements. Always profile your code before settling on a linked list.

    • @probE466
      @probE466 7 лет назад +52

      Uh no, you choose your list implementation based on the operations you plan on doing. if you want to keep adding at the end or front and wont be searching by index a linked list is perfect

    • @N....
      @N.... 7 лет назад +32

      probE466 You choose your list implementation by profiling your code. Even in the scenario you describe, a contiguous list may be more efficient. There's also the issue of memory fragmentation.

    • @Hopsonn
      @Hopsonn 7 лет назад +51

      I think they are mainly taught because it is simple to implement.
      Making my first linked list about a year ago now helped me understand pointers like I had never before.

    • @78wowguy
      @78wowguy 7 лет назад +8

      The problem however is that a linear search is necessary to find the item to remove or add and that takes way more time in an linked list than in an array. This makes the array in most cases faster than a linked list.

    • @ВасилийИванов-п4е
      @ВасилийИванов-п4е 7 лет назад +33

      Linked lists by itself are not very useful. That's true. But the idea of linking "something" by references in memory _is_ useful. And can be used for, for example, implementing graphs. So, I think learning linked lists is very important.

  • @PEGuyMadison
    @PEGuyMadison 5 лет назад +5

    My first class on C was in 1989, the professor started out by saying "I assume you all know how programming languages work, so we are going to focus on pointers and system programming in this class"
    I am a heavy user of linked lists but they also have their limits, I have found they are great for joining data into a pseudo array but when it comes to searching an array is much faster and an array is just a basic list.
    When it comes to multicore use a list with locks can be troublesome but far outweighs the impact of cache invalidations and excess memory bandwidth. For multiprocessors you can break down lists into per-core tasks and join them at the end of each task which will far out perform a array copy.
    Both have their advantages but profiling and ease of use also need to be considered.

  • @brandonjanes6464
    @brandonjanes6464 4 года назад +2

    I like the traffic noise. It reminds me of the before times.

  • @404namemissing6
    @404namemissing6 7 лет назад +25

    Oh i need to know this for my exam in 4 days.

    • @Hopsonn
      @Hopsonn 7 лет назад +2

      If you are interested, I have a video on creating a linked list using C++ on my channel, it might help out with your exam.

    • @PlatonicGuy
      @PlatonicGuy 7 лет назад

      Had an exam on this last week. I guess I just got unlucky with the timing that they decided to post this. Good luck on yours btw :)

    • @404namemissing6
      @404namemissing6 7 лет назад +1

      Matt Hopson I need to do it in scheme.

  • @khaled-dev
    @khaled-dev 4 года назад +2

    thanks for showing the streets, having seen that in awhile :D

  • @coldensapir3901
    @coldensapir3901 2 года назад +1

    Awesome video, thanks for laying things out clearly without going boringly slow. I also liked the use of music paper lol

  • @ikemuoma8495
    @ikemuoma8495 5 лет назад

    Very good video. I particularly liked him using the web page examples as a means of explaining applications of double linked lists.

  • @ashtonscalise6949
    @ashtonscalise6949 6 лет назад

    really liked this video. Every other piece of information i could find just explained what they are instead of the practicality. Understanding the use case makes it much easier to understand for me.

  • @swehunter2000
    @swehunter2000 7 лет назад +4

    at 8:56
    You wouldn't brak the pointer from Neil Armstrong to NASA when linking to ISS from NASA. it doesn't matter if two objects point to NASA, and it takes cycles to break the link for no reason.

  • @andredejager3637
    @andredejager3637 2 года назад

    The back/forward web browser example was delicious

  • @Theraot
    @Theraot 7 лет назад +2

    I would have prefered if they teach to put the link of the new node before you move the link of the previous one. Because if moving the link is an atomic operation (as it should be) then the list was never on an invalid state.
    But if you start by moving the link of the previous node and then set the link of the new one, there is a chance that the state where the new link points to null (or trash depending on your language and compiler) is visible to other threads.

  • @AgentM124
    @AgentM124 7 лет назад +9

    undoing the future and creating a new future destroys the ability to visit the other future unless you have a tree structure...

    • @IceMetalPunk
      @IceMetalPunk 7 лет назад +6

      Right, but in regards to browser history, there are only forward and back buttons, or past and future histories. There's no option to switch to different branches of the history. It's not Git :P

    • @smurfyday
      @smurfyday 7 лет назад +2

      You just repeated something said in the video, genius.

    • @0LoneTech
      @0LoneTech 7 лет назад +1

      Agent M Another option is to treat the undos themselves as new edits, like Emacs does. That way they can in turn be undone, and you keep the history.

    • @Bunny99s
      @Bunny99s 7 лет назад

      +LoneTech Right, that's "partly" what the explorer in windows does. A "back" event is not considered as a change but if you manually click on any parent folder it's a seperate navigation step. Say you navigate a folder down to the third level. If you now click on the root folder, the back action will bring you back to the third level then to the second and so on.
      However If every undo counts as new undo step you run into trouble because you have to keep a seperate list of the current undo step. Because if "going back" is added as new undo step at the end, going two steps back would bring you back where you were at the beginning.

  • @fablungo
    @fablungo 7 лет назад +28

    I know he is just demonstrating on paper and showing the concepts but breaking the link before creating the new link for an insert operation is likely to cause concurrency problems. If you do it the other way around, you can do an atomic replacement of the pointer from "1" and "26" would already be pointing "2" (and not appear like the end of the list if a concurrent iteration of the list is taking place).

    • @fablungo
      @fablungo 7 лет назад +2

      If I am not mistaken doing the same for a doubly-linked list would still be advantageous. Setup the links in the new node (next and prev) then change the next and prev of the prev and next respectively.
      The only problem that might occur between setting the new pointers is of consistency but an inconsistent state is better than an incorrect one. Although, since you can't do it atomically (at least I don't think you can set two addresses atomically) then this could cause a problem depending on what your application is doing.

    • @Bunny99s
      @Bunny99s 7 лет назад +1

      That doesn't really solve concurrency. It might depend on the language / framework and the actual usecase though. If you have another thread currently iterates the list and you "cut off" a part two things could happen: Either the other thread is still before your cutting point in which case there's no problem. However if the other thread is already beyond the cutting point, how do you remove / destroy the cut-away nodes? You as the one who's changing the list can not know if someone is still using those nodes or not.
      If you want a datastructure thread-safe there are many ways to achieve this but it highly depends on the usecase and the language / framework. I mention that since frameworks like .NET / Mono or the Java VM have managed memory so you don't have to worry about invalidating memory (unless you use a node-pool) whereas in languages like C or C++ you have to free the memory yourself. Doing lock-free implementations is a dangerous field where you have to consider all possible cases. If you want to be safe, implement proper synchonisation in which case it doesn't matter in which order you update the pointers ^^.
      ps: How is inconsistant state better than incorrect state? If it's inconsistant it IS incorrect ^^. Inconsistancy is the worst you can do to your program, ever. You should never accept even the slightest bit of inconsistancy as it will, sooner or later, cause a race-condition in a multi-threaded environment.

    • @GenGariczek
      @GenGariczek 7 лет назад

      He was talking about linked list, not concurrent linked list. Off-topic.

    • @prim16
      @prim16 7 лет назад

      That bothered me too. If you break the link to Node 2....it will be forever lost in memory....as well as every Node that it and its latter Nodes were referenced by.

    • @mariohernandez6590
      @mariohernandez6590 7 лет назад

      This is just a high level example... Not actually implementing the functions to add a node... lol relax

  • @sot_dev
    @sot_dev Год назад +1

    thank you for the use cases!!

  • @qwaqwa1960
    @qwaqwa1960 7 лет назад

    The OS/2 Web browser DIDN'T break the forward links when you chose a new path. It kept a tree view of all visited pages. Man, I miss that.

  • @QuomoZ
    @QuomoZ 7 лет назад +1

    I hope at this channel makes a video about algebraic data types and how to define a linked list using them.

  • @jy_chen
    @jy_chen 2 года назад

    The example of webpage history is very interesting and intuitive

  • @TrevorPike
    @TrevorPike 7 лет назад

    In the Amiga OS, the doubly linked lists combined the head and tail pointers in a which eliminated the special cases for insertion or removal at the beginning or end.

  • @AgentM124
    @AgentM124 7 лет назад +3

    If you paste your secrets somewhere, don't delete them, but undo them and overwrite the redo history. that way if somebody sneaks up on your word document, they won't find out... unless they are really geeky and for some reason it's still stored in memory... but realistically... meh.

  • @wildgoosespeeder
    @wildgoosespeeder 7 лет назад

    That's probably why a recursive function is better to search for entries in a linked list instead of an array because you don't need to specify an index because there is no index for each entry of a linked list. If no result is found, null (tail or head of the linked list) will terminate the recursive function. Else it will loop forever.

  • @vivekpal1004
    @vivekpal1004 7 лет назад

    When you are surfing on the internet you are not really traversing a linked list data structure; Internet is more like a big (really big and keeps getting bigger every second) directed graph. Where you can get the feel of linked list is any image viewer on your system -- in its UI, '->' button is node->next; the '

  • @Kanephan
    @Kanephan 6 лет назад

    well shot and edited

  • @Fransamsterdam
    @Fransamsterdam 7 лет назад

    Don't worry too much about the noise. I have seen many videos from Royal British Famous Institutions which were worse.

  • @Croxmata
    @Croxmata 7 лет назад +19

    I like the term "non-blow-away-able".

  • @timh.6872
    @timh.6872 7 лет назад

    minor nitpick: in the drawing, the arrows point to the following pair. in the generated graphic, the arrows point to the *element* of the next pair. The latter is technically incorrect.
    Also, the last element doesn't point to null, its pointer *is* null.

  • @Yupppi
    @Yupppi 11 месяцев назад

    The linked list surely creates an exciting pointer handling job, but is cool if your only option is to always access heap.

  • @IceMetalPunk
    @IceMetalPunk 7 лет назад +2

    On the other hand, you can model undo/redo as a pair of stacks. I don't know if that would be more efficient, but it whittles the functionality down to only the bare necessities for that behavior.

    • @IceMetalPunk
      @IceMetalPunk 7 лет назад

      To elaborate: when a change is made, push the current state onto the undo stack. When UNDO is pressed, pop the top of the stack, set the current state to that popped state, and then push the state onto the redo stack. When REDO is pressed, just do the same thing in reverse. (And of course, clear the redo stack when any other changes are made.)

    • @rlamacraft
      @rlamacraft 7 лет назад +1

      IceMetalPunk That was my thought, but then I thought about how to best implement the stacks and a linked list is probably better than an array because you add frequently and don't require random access. Though I would probably create a memory pool so that allocating memory can be batched up. Maybe each node would contain a small set of operations to reduce the memory overhead of the pointers, but still better than implementing the stacks as arrays.

    • @AdamLeuer
      @AdamLeuer 7 лет назад

      I had a similar thought. I can say for sure a stack is perfect if you just need to implement undo, but maybe a linked list would be better for both undo and redo(?). I can say I've used a stack for implementing time reversal in a video game, and it was well suited to it.

    • @anousenic
      @anousenic 7 лет назад +1

      Yes a stack is an solution - until you consider that you may want to limit how many undo steps are being preserved. Since at some point you probably want to start discarding the oldest undo steps, in order to not consume more and more memory with every action taken.

    • @Bunny99s
      @Bunny99s 7 лет назад +1

      +AnotherUselessNick
      Well an undo stack can be implemented as a circular buffer. So you have a fix sized buffer a start and an end pointer. The start doesn't have to be fix. When you reach the end of the buffer you simply wrap around and start again from the beginning, overwriting the oldest entry. At the same time the start pointer would be moved forward so the second element is now the "first" and the first in the buffer is actually the last.

  • @Redok09
    @Redok09 7 лет назад

    Just an fyi for Computerphile and everyone I guess, the diagrams you did are a little bit wrong. The arrows should not be pointing inside the nodes, because this would mean the association is made with the value inside the node and not the actual node. As you can see, when Dr Alex Pinkney made his drawing on paper, he respected this law. He made the arrows pointing at the node, not inside of it.

  • @nackyding
    @nackyding 6 лет назад +1

    Nice! Especially the case examples you used.

  • @OhNoRh1no
    @OhNoRh1no 7 лет назад +2

    I was just going over this in CS50! now do tries! Those hurt my brain :P

  • @mrinalkd
    @mrinalkd 7 лет назад

    Great video. I want to see more videos like this.

  • @izcool100
    @izcool100 6 лет назад

    When adding a node in the middle of the list, you cannot break the link first as the reference to the node that the link was referencing would be lost. Create a temp variable that points to this node, break the link the you can point to the new node ad the new node point to the next node and remove the temp variable.

  • @Darigitin
    @Darigitin 7 лет назад

    One comment I felt is needed on this video to any students possibly watching this, when adding or deleting a node, you always make the new links before you remove the old ones. It was really bugging me when he was removing the old links before making the one ones. If you delete the link between 2 and 3 before you create the link from 26 to 3, you will lose access to 3 and all subsequent nodes.

  • @juicyclaws
    @juicyclaws 7 лет назад

    undo/redo operation i've always implemented using two "stacks" (arrays).
    do something new, push to the undo stack and clear the redo stack.
    press undo, pop the undo stack and push it to the redo stack.
    press redo, pop the redo stack and push it to the undo stack.

  • @portblock
    @portblock 7 лет назад

    I didnt see it, but you also have to account for the amount of data in the list. Example: first block, has number of bytes in the list, then tail says if its linked or not. Example, is the classic file system. you dont want to have a link list of single bytes, as the link pointers take up more data. just fyi info

  • @disk0__
    @disk0__ 7 лет назад

    I love the comments telling the Doctorate how he should have done something

  • @mrfashionguy1
    @mrfashionguy1 5 лет назад

    So a linked list is like back to the future basically.. you can go back and forth as much as you want until you change something, which them alters your "future" in the list.

  • @VeerleGroot
    @VeerleGroot 7 лет назад +3

    what happens to the linked list elements that are cut away when you click another link in memory terms?

    • @robmckennie4203
      @robmckennie4203 7 лет назад +17

      They become orphaned and are no longer accessible. Poorly designed programs might just leave it there, and over time more and more memory is consumed but isn't actually being used, that's called a memory leak. The proper way to deal with it is to deallocate the memory, which is just telling the operating system that you don't need it anymore and it can be used for something else. Some languages do this automatically in a process called garbage collection, but some lower level languages like C require the programmer to do this manually

  • @786Peacelover
    @786Peacelover 5 лет назад

    Terrific video... Example was great plus the location is an icing on the cake.. makes it learning pretty pleasant and real .. unlike sitting on computer and talking like robot :D

  • @MyAce8
    @MyAce8 7 лет назад

    I used a linked list for a gamestate manager, the current gamestate was the head of the list and every time you started a new state (like if you opened you inventory) I would push the new state on to the the stack, and since I never had more than 3 items in the list, even if I had to access a state at the bottom of the list (which was never actually necessary) it wouldn't be to costly, that being said in retrospect it was dumb considering it would have virtually no performance benefit, and all I accomplished was wasting my time implementing a linked list in lua for one stupid purpose

  • @realraven2000
    @realraven2000 7 лет назад

    Bad example. you should have inserted the number "1.4" :)
    If you look at dictionaries, internally these are often realized as linked lists. This could theoretically also be done with Arrays - once you add a layer of abstraction there is no need to use contiguous memory for them.

  • @digitaldina
    @digitaldina 6 лет назад

    I don't mind the traffic audio. It makes the video interesting.

  • @tobortine
    @tobortine 7 лет назад

    Usually link lists contain two addresses, the forward link address and the address of the data element. Also, I've always pointed the last link to the first such that you can detect the end when the head address is the same as the final link address.

    • @fablungo
      @fablungo 7 лет назад +1

      Unless your list is a list of primitives.
      I think it's better to point to null at the tail: checking if an address is zero is less computationally expensive than a comparison which may require loading the head value into a register to see if they are equal.
      It also blurs the responsibility in code as to who is going to determine that its the end of the list: at what point is the comparison made, and after the comparison is made what is the function going to do? If it's going to return null, you might as well have had null as the next pointer and not have to do any checks when reading the next pointer (leaving them to when the function caller checks if null).

    • @HiddenWindshield
      @HiddenWindshield 7 лет назад +3

      Doubly-linked lists are different than singly-linked lists. Doubly-linked should only be used when you need to move backwards in the list, otherwise, it's a waste of both memory and processor cycles.
      Same with circular linked lists (where the tail points back to the head), but in this case, you're not losing anything, so that's more of a style choice than anything.

    • @tobortine
      @tobortine 7 лет назад

      Yes very true, I hadn't consider the list of primitives. I don't disagree about the null end pointer, it's really a style choice. There's not a lot in it computationally.

    • @jpratt8676
      @jpratt8676 7 лет назад +1

      tobortine It's a little more than a style choice. If you use null you don't have to pass the head around with each computation. It's a small cost but still worth remembering

    • @tobortine
      @tobortine 7 лет назад

      Why do you have to pass the head around? With each new link address you compare it to the head address as opposed to comparing it to null. No extra overhead.

  • @stocktonjoans
    @stocktonjoans 7 лет назад +7

    Could you have a repeating list where you pointed the last node back towards the first?

    • @Hopsonn
      @Hopsonn 7 лет назад +34

      It is called a circular linked list.

    • @stocktonjoans
      @stocktonjoans 7 лет назад

      Matt Hopson
      cheers

    • @Hopsonn
      @Hopsonn 7 лет назад +7

      skunkFU25
      a graph is a very general term, circular linked list is specifically what this guy asked for.

    • @hellterminator
      @hellterminator 7 лет назад +1

      +skunkFU25 No. A linked list is a data structure, a graph is, well, a graph. However, you can represent a linked list with a graph. In this case it would be a directed cycle graph for a singly linked circular list or an undirected cycle graph for a doubly linked circular list.

    • @Quickstep1716
      @Quickstep1716 7 лет назад

      +hellterminator Graphs are data structures too, much like arrays and hash tables.

  • @johngeverett
    @johngeverett 10 месяцев назад

    I prefer a balanced binary tree, which allows sequential traverse of the entire list as well as binary search of the ordered list.

  • @topphemelig
    @topphemelig 7 лет назад

    Sounds like a queue list, with only one link it will just jump forward as you dequeue.

  • @irrigger1
    @irrigger1 7 лет назад +8

    Vim represent!

  • @TheScoobysteve
    @TheScoobysteve 3 года назад

    'So a linked list is the first serious data structure you learn about because it's _very simple_' Damn you guys are smort.

  • @shikharupadhyay7435
    @shikharupadhyay7435 8 месяцев назад +1

    Awesome ❤

  • @josephang9927
    @josephang9927 7 лет назад

    In real life very few programmers use Linked Lists directly, and when they do they use a Library, or they use a "growable aeeay" that is really implemented as a highly advanced data structure that probably is a hybrid between an array and a linked list.

    • @hil449
      @hil449 3 года назад

      yes, just how nowadays engineers use programs instead of calculating stuff on paper but still every engineer must know math and physics

  • @MasterGeekMX
    @MasterGeekMX 7 лет назад

    I'm studying computer sicences in a mexican university and we have two data structure courses wich covers this topic in depth (alongside with other things like trees and graphs). Even we need to program from scratch the lists.
    That courses name (translated from spanish) are: Object-Oriented Algorythms and Linear Storing Patterns and Object-Oriented Algorythms and Non-Linear Storing Patterns

  • @yash1152
    @yash1152 2 года назад

    0:47 I was wondering that what's the significance of showing the arrow curved, rather than straight just how he drew
    but 1:18, yeah, curved arrow are more suitable for conveying the non-contingency. nice detail.

  • @taruntosh7970
    @taruntosh7970 4 года назад +3

    Please add subtitles so that people with poor English skills can understand completely.

  • @amrsaber5457
    @amrsaber5457 7 лет назад +8

    why is he nervous ? he explains very well 😃

  • @firenutz698
    @firenutz698 7 лет назад

    Your animation is incorrect, the arrow does not go inside of the node it points at it. See how Dr Pinkney draws his arrows in his list.

  • @kipbush5887
    @kipbush5887 7 лет назад

    Brought to you by Frank Harris & CO

  • @nienke7713
    @nienke7713 7 лет назад

    Would going to the ISS page not only break the NASA Armstrong link but also the ArmstrongApollo11 link, because if from ISS you'd go back to NASA and click the Armstrong link again, your forward button doesn't suddenly allow you to go forward to Apollo11 again

    • @nienke7713
      @nienke7713 7 лет назад

      Peterolen mmm... yeah, didn't think about that, thanks for the explanation :)

  • @giancarloandrebravoabanto7091
    @giancarloandrebravoabanto7091 3 года назад

    why in the singly linked list you show an example of numbers?
    and for the doubly linked list you show an example of objects?

  • @joaofnds
    @joaofnds 7 лет назад +1

    Remember folks, double pointer FTW

  • @shadowp2066
    @shadowp2066 Год назад

    Very Informative, Thank You

  • @robmckennie4203
    @robmckennie4203 7 лет назад

    couldn't think of something more natural to come between 1 and 2? like 1.5?

  • @LeducDuSapin
    @LeducDuSapin 7 лет назад

    Kudos for mentioning vim and its history tree

  • @FREEZarts
    @FREEZarts 3 года назад

    really cool video

  • @mikael642
    @mikael642 4 года назад

    The last list shouldn't be called tail. That's incorrect. The tail of a linked list is the list without the first element

  • @JohnJones1987
    @JohnJones1987 7 лет назад

    Linked lists for browser history is a good example of a graph-based data structure that was implemented as a linked list and ruined my life. There are others.

  • @AlbertoGuitarrista
    @AlbertoGuitarrista 5 лет назад

    Great explanation indeed! Thank you very much, it was all clear. I'm subscribing.

  • @Barreloffish
    @Barreloffish 6 лет назад

    So when we deleted a node, we essentially unlink it from the list and not really delete it from memory. For array, we use delete [ ] array; but how do we actually delete this unlinked node?

  • @rikwisselink-bijker
    @rikwisselink-bijker 7 лет назад

    There's a back to the future joke waiting to happen at the end.

  • @austinbaldwin7836
    @austinbaldwin7836 7 лет назад

    What happens when item 1 points to item 2 and item 2 points to item 1?

  • @memo6032
    @memo6032 2 года назад

    I can't believe that I've never noticed that when I create a new nod or action in things like do and undo or backward and forward buttons in a browser, I delete the previous forward history! I can't also believe I finally get this thing 😌 I couldn't get it in class and it's really been bothering me.

  • @Lightn0x
    @Lightn0x 7 лет назад

    I think the example with the page navigation is better modeled by an array, since you're only pushing at the back of the structure and only popping from the back. It doesn't highlight any of the strengths of a linked list.

    • @lorenzorossi2000
      @lorenzorossi2000 7 лет назад

      But clearing the next history (when you go back and then change link) with an array takes O(n) iterations

    • @CryZe92
      @CryZe92 7 лет назад +1

      +SnowyCoder Not really. In fact, it's actually the opposite. With a linked list you explicitly have to free all the nodes you drop at the end, while with an array, there's no need to deallocate anything. You may need to deinitialize the values, but that's about it.

    • @lorenzorossi2000
      @lorenzorossi2000 7 лет назад

      Yeah sorry, I was thinking with java xD

    • @Lightn0x
      @Lightn0x 7 лет назад

      Not true. In fact, with a linked list it has O(n) (because you need to free the memory you used for the O(n) nodes which you are clearing) but with an array you can do it in O(1); with an array you don't have to do that; you just set the size of the array to a new number. See, an array is represented as a contiguous block of memory of size let's say MAX_N. Now... since you're not using this entire array, you store a variable array_size which holds the amount of memory you are currently using (for the purpose of this comment, let's assume the elements each have 1 byte in size and as such the physical size in memory of the array is equal to the number of elements). Now.. if want to push an element to the back of the array, you just have to overwrite the memory at address array_size with the new information, and then increase array_size by 1 to signify that you are using 1 more byte of memory. If you want to pop an element from the back of the array, all you have to do is decrease the variable array_size by 1. You do not need to free the memory (in fact you cannot) since the array is one contiguous block. You cannot free memory in the middle of it. It doesn't matter if the data is still physically present at that location in memory since the next time we add an element to the array, it will be overwritten anyway. Similarly, if you want to pop n elements from the back of the array, all you have to do is set the variable array_size to array_size - n. You don't need to delete each individual element, you are just marking them as "unused" and they will be overwritten once new elements get added. Note that if you don't know a-priori an upper bound for your array (that MAX_N I was talking about), you will have to sometimes extend your array, which means reallocating the memory to a different location, which does indeed take O(n). That's why we say that operations on an arbitrarily-sized array take amortized O(1) time, meaning they usually take O(1) but sometimes (very rarely since you won't need to resize your array often) they will take more. If you want to investigate further, you can read upon the std:vector structure from C++; it is implemented on this very notion. Note that in this example I assumed the elements stored in the array don't need to be forcefully closed when no longer needed (such as database connections or whatever) since in this case you cannot escape from the destruction of each individual element and therefore O(n). But that will happen with both arrays and linked lists.

    • @Lightn0x
      @Lightn0x 7 лет назад

      You can achieve O(1) in Java as well, you just have to be a little tricky with the way you write your code. That is, don't use the already implemented ArrayList class; instead, write your own as described in my previous comment :). Or you can use ArrayList but don't use the add and remove methods provided. Not the "proper" way of doing things but hey.

  • @CreachterZ
    @CreachterZ 7 лет назад

    I think you just described time travel.

  • @Junk_bucket
    @Junk_bucket 7 лет назад

    What's the difference between linked lists compared to Queues and deque's?

  • @isaacjacobharris
    @isaacjacobharris 5 лет назад

    Thank you for the lesson

  • @HardwareAddiction
    @HardwareAddiction Год назад

    Why array wouldn't work for browsing history?

  • @evangelosspyromilios5994
    @evangelosspyromilios5994 3 года назад

    its like saying, hey mate can you please explain linked lists to me? I will buy you the coffee, and he says yeah sure lets go

  • @stevelindsey5560
    @stevelindsey5560 7 лет назад

    True nerd, writes on green bar paper. Respect!

  • @CODcanbefornoobs
    @CODcanbefornoobs 7 лет назад

    please do more videos on data structures