Data Structures Using C++: Inserting a Node into a Linked List (Sorted Linked List)

Concepts:
Logical representation of inserting a node into a linked list to maintain a sorted list
Three Cases are examined:
Inserting a node into an empty linked list
Inserting a node into a list with at least one node and we want to insert the new node at the head.
Inserting a node into a list with at least one node and we want to insert the new node somewhere other than the head.
Usage of a current pointer.
Usage of a trail or previous pointer.
How pointers must be updated to perform an insert.

Пікірлер: 44

  • @laithalajarmah406
    @laithalajarmah4063 жыл бұрын

    9 years later, and you just got me out of this unending runtime errors Thanks a lot!

  • @elwafi2001
    @elwafi20013 ай бұрын

    The best way to learn linked is through drawing demonstrations as you did in this videos, I’m glad I find this video. 👍

  • @andrewnguyen6894
    @andrewnguyen68943 жыл бұрын

    Professors in universities should go through process like this to provide scenario for students. Thank you so much. Your video saved my degree.

  • @pedrowski007
    @pedrowski00711 жыл бұрын

    Exceptional tutorial! I cant wait to watch the rest of your videos!

  • @jaehuhn
    @jaehuhn9 жыл бұрын

    Thank you very very much for this set of videos with kind explanations! May God bless you!

  • @felixkimutai8478
    @felixkimutai84785 жыл бұрын

    Awesome! well explained, that trailing pointer made my day

  • @unknownindian230295
    @unknownindian23029511 жыл бұрын

    Nice tutorial! thanks. cleared out what I was failing to understand since long! :)

  • @mohdadyg
    @mohdadyg12 жыл бұрын

    Thanks a lot for your time. Keep the good tutorials.

  • @MrDubs
    @MrDubs3 жыл бұрын

    Thank you. You are totally right about visualizing it.

  • @tarabolical
    @tarabolical11 жыл бұрын

    thanks for this tutorial, it was exactly what I needed to know.

  • @ronniesaieed1373
    @ronniesaieed13734 жыл бұрын

    Finallyyyy a tutorial in English!! And not Indian.

  • @mosesmccabe8983
    @mosesmccabe89837 жыл бұрын

    This is very helpful. Thx for making this awesome video

  • @abugslife2461
    @abugslife24614 жыл бұрын

    thank you for the video! am slowly understanding it. thank you again

  • @anthonypark9158
    @anthonypark91586 жыл бұрын

    Thank you! Now it's clear to me :D

  • @fzane14
    @fzane143 жыл бұрын

    Thanks for sharing this, really helpful and well explained content.

  • @AliEmreCakmakoglu
    @AliEmreCakmakoglu11 жыл бұрын

    And also, there's no need trail node to add new node after second node. The code below works properly: Contact* tp = head->next; newOne->next = tp->next; tp->next = newOne;

  • @dark.violin
    @dark.violin2 ай бұрын

    you are amazing thank you so much for your work

  • @ReelLearning
    @ReelLearning11 жыл бұрын

    "head" is a pointer that holds the address of the "Bill" node at 4:47, so assigning newNode->next (next is also a pointer) to "head" is assigning it to point to "Bill". We have no other mechanism in this example to set newNode-next to point to the "Bill" node other than the "head" pointer. Let me know if I misunderstood your question.

  • @Boisterous716
    @Boisterous71611 жыл бұрын

    Thank you!

  • @SurajThapar
    @SurajThapar11 жыл бұрын

    Great tutorial

  • @patsjainj
    @patsjainj8 жыл бұрын

    That just helped me a lotttttt!

  • @guardofhonour3089
    @guardofhonour30895 жыл бұрын

    great explanation

  • @ralmarri12
    @ralmarri1210 жыл бұрын

    Thank you very much

  • @leimonis1
    @leimonis111 жыл бұрын

    very helpfull...

  • @ReelLearning
    @ReelLearning11 жыл бұрын

    I messed up a bit there... I wanted C to go between A and B so bad for my example that I reordered the alphabet. Thanks for catching my mistake.

  • @manojsangita9620
    @manojsangita962010 жыл бұрын

    thanks for not making this thing complex

  • @agonforreal
    @agonforreal11 жыл бұрын

    Thanks alot

  • @reuphyazer1600
    @reuphyazer16009 жыл бұрын

    is it the same logic with a double linked list ? nullptr or head or somewhere else ?

  • @ryanflynn386
    @ryanflynn3868 жыл бұрын

    Would you even need a "trailing" pointer if you were inserting into a Doubly Linked list? You would have the pointer back to Bob from Tom's previous pointer, right?

  • @berlinjames184
    @berlinjames1843 жыл бұрын

    how to find out where the node is to be inserted by just using names that are string types??

  • @thedankest1974
    @thedankest19745 жыл бұрын

    What is the time complexity of inserting into this data structure?

  • @AliEmreCakmakoglu
    @AliEmreCakmakoglu11 жыл бұрын

    Is there something wrong at "Add Node After Head" stuff? Because, you have added the new node after second node. - List before addition: April (Head) -> Bob -> Tom - List after addition: April (Head) -> Bob -> Sally -> Tom. Is the list suppose to be (April -> Sally -> Bob -> Tom) ?

  • @abugslife2461
    @abugslife24614 жыл бұрын

    lmao came back to this video cause i got confused again... god this pointer business is rough... will get it tho hopefully soon haha

  • @bdtamuka521
    @bdtamuka52111 жыл бұрын

    ooh my bad guess I ws getting tired .... confusing Bill the string and head the pointer ... thanx again

  • @bdtamuka521
    @bdtamuka52111 жыл бұрын

    gr8 tutorial... @ 04.47 shld it not point to Bill?instead of Head

  • @sln7736
    @sln77365 жыл бұрын

    Where is the code

  • @possibility28able
    @possibility28able10 жыл бұрын

    What about at end of list?

  • @4Y0P

    @4Y0P

    8 жыл бұрын

    +possibility28able It being the end of a list doesn't make it an exception

  • @XxelitebeautyxX
    @XxelitebeautyxX8 жыл бұрын

    newNode-->next=bill; head=newNode; shouldn't it be like this? 4:44

  • @onurbayrktr
    @onurbayrktr7 жыл бұрын

    is it sheldon speaking ? ??

  • @DigitalDivotGolf
    @DigitalDivotGolf4 жыл бұрын

    Length of video is 12:34 hehe

  • @SurajThapar
    @SurajThapar11 жыл бұрын

    9:16 It's ABCDE... not ACBDE...

  • @tarabolical
    @tarabolical11 жыл бұрын

    no thanks jesus