Inserting/Adding Elements At The End Of The Linked List | Python Program

แชร์
ฝัง
  • เผยแพร่เมื่อ 10 ธ.ค. 2024

ความคิดเห็น • 104

  • @bakhitmahamat7359
    @bakhitmahamat7359 4 ปีที่แล้ว +44

    After switching from so many tutorials on TH-cam regarding DSA. I’ve come across the best channel. You’re explaining very well. You’re an excellent teacher & by far the best. Keep it up.

    • @AmulsAcademy
      @AmulsAcademy  4 ปีที่แล้ว +12

      Thank you :)

    • @manichandu2742
      @manichandu2742 11 หลายเดือนก่อน

      @@AmulsAcademy really mam thank you for this wonderful explanation

  • @krishnakiranvajha3175
    @krishnakiranvajha3175 2 ปีที่แล้ว +5

    I have been struggling with DSA's concepts. But your videos are crystal clear that now I could able to handle DSA's. Thank you so much for all your efforts

  • @darkxxslayer2109
    @darkxxslayer2109 3 ปีที่แล้ว +8

    underrated video for understanding the concept of linked list in python.....very nice explanation

  • @tejas.winiii
    @tejas.winiii 6 หลายเดือนก่อน

    After almost an hour of having multiple breakdowns trying to understand this shit by watching multiple vids across yt, I found this video and the programming part totally makes sense FINALLY. Thank you !

  • @praizdev
    @praizdev 2 ปีที่แล้ว +2

    I love this channel. I have searched for several videos on DSA but this was the best. It felt like you opened my head and paste all the knowledge in there. Thanks for sharing your knowledge on DSA. I look forward to more interesting videos. God bless you.

  • @Aly_.3_3
    @Aly_.3_3 3 ปีที่แล้ว +6

    If i count my all words these will not enough for u...... Excellent work really bravo ❣️.... Fully understandable

  • @devangprabhune3591
    @devangprabhune3591 2 ปีที่แล้ว +1

    your voice is really calm whgile explaining this complex topic. Very smooth explanation. Thanks Amulya's Academy

  • @codelike_namikaze4016
    @codelike_namikaze4016 2 ปีที่แล้ว

    The best Explaination of linkedlist program that I have ever seen so far. Thank for this video

  • @bhadrinarayanan9660
    @bhadrinarayanan9660 ปีที่แล้ว +1

    i have my placements next semester so far every topic i saw you have explined crystal clearly

  • @venkatareddykunduru1828
    @venkatareddykunduru1828 3 ปีที่แล้ว +4

    Mam please keep going really awesome explanation and you deserves one of the best teacher i have seen so far👍👍👍

  • @sanc7897
    @sanc7897 ปีที่แล้ว +1

    Most underrated youtuber

  • @akshayp503
    @akshayp503 3 ปีที่แล้ว

    Mam you worth Million Subs.....Thank you for your every little detail.

  • @kananiltorres1968
    @kananiltorres1968 3 ปีที่แล้ว +2

    Thank you very much. You explained it explicitly and I've come to understand it very well. This is an excellent tutorial!

  • @srikarchatla5178
    @srikarchatla5178 3 ปีที่แล้ว

    omg even i tried various sources and couldn't find anything this good you are so beautiful i love you sooo much thank you........

  • @ichigokurosaki2851
    @ichigokurosaki2851 2 ปีที่แล้ว

    Besides you i did watch other videos relating to linked list and python, yours by far was the most helpful due to your expansive explanations. Really appreciate the effort!

  • @anuragtiwari9793
    @anuragtiwari9793 4 ปีที่แล้ว +4

    You explained really well, I understood it very well, thank you so much mam for providing us with this easy to understand explaination.

  • @Sairamgunturu
    @Sairamgunturu 3 ปีที่แล้ว +1

    your way of xplanation was really osm,tnq so much...

  • @daniilkucalov7310
    @daniilkucalov7310 2 ปีที่แล้ว

    Thank you very much! This explanation solved problem in my program!

  • @kundakurade5556
    @kundakurade5556 3 ปีที่แล้ว +1

    Excellent teaching quality...🙏

  • @Aswartha-x7m
    @Aswartha-x7m หลายเดือนก่อน

    Really helpful these classes for us mam..

  • @prikshitbatta
    @prikshitbatta ปีที่แล้ว

    Awesomeness Overload!

  • @Mohan-o5k4c
    @Mohan-o5k4c 7 หลายเดือนก่อน

    nice video I am really amazed and your teaching way is to good thank you

  • @MrCEO-jw1vm
    @MrCEO-jw1vm 6 หลายเดือนก่อน

    Thank you so much for this tutorial. you do a very good job

  • @KANIZMAHBUBAPRIYA-yw9vi
    @KANIZMAHBUBAPRIYA-yw9vi ปีที่แล้ว

    Mam you are the best 🥰

  • @lohir446
    @lohir446 2 ปีที่แล้ว

    Excellent work ⭐⭐⭐⭐

  • @sivakumarupparapalli1320
    @sivakumarupparapalli1320 4 ปีที่แล้ว +1

    Thank you for the video mam.. With Very good explanation..

  • @rahadulislamrahat328
    @rahadulislamrahat328 5 หลายเดือนก่อน

    Thankyou for explaining in details

  • @mageshmagi6167
    @mageshmagi6167 ปีที่แล้ว

    too good and easy to understand

  • @pf98
    @pf98 2 ปีที่แล้ว

    You explained it very well. Thank you, ma'am! :))

  • @amarsinhjadhav8156
    @amarsinhjadhav8156 2 ปีที่แล้ว

    very nice ma'am🙂

  • @supritamurmu2165
    @supritamurmu2165 2 ปีที่แล้ว

    Thanku so much your videos are amazing 💕

  • @siriraghavendra5577
    @siriraghavendra5577 4 ปีที่แล้ว +1

    thanks a lot maam!loved the explanation!!

  • @lohithabandirala803
    @lohithabandirala803 ปีที่แล้ว

    Thank you so much❤❤

  • @deviinairr
    @deviinairr 4 หลายเดือนก่อน

    hi, is it necessary that while running a program i am getting error at LL1.print_LL.
    and also can someone say if i have to do everything in order like first create node then linkedlist then traverse,add and then remove?

  • @BilalKhan-ib3wf
    @BilalKhan-ib3wf 3 ปีที่แล้ว

    very help full thank u very much!

  • @sureshv8773
    @sureshv8773 2 ปีที่แล้ว

    Hi mam Thank you for the video. I have one doubt in the Display link list we write the condition as While n is not None but in inserting the last node we use while n.ref is not None. Y so difference as both accessing same element.. Please clarify why n.ref in inserting..

  • @sanjayms7956
    @sanjayms7956 3 ปีที่แล้ว +2

    Mam i get confused what to code.. Self.head=new node...or... new node=self.head....can u explain this?

    • @AmulsAcademy
      @AmulsAcademy  3 ปีที่แล้ว +1

      You are talking about singly linked list or doubly linked list ?

    • @sanjayms7956
      @sanjayms7956 3 ปีที่แล้ว +1

      @@AmulsAcademy singly linked list mam.. Basically everytime get confused.. When it comes to assigning a variable like.. Self. head=new node or new node=self.head...?

    • @AmulsAcademy
      @AmulsAcademy  3 ปีที่แล้ว +2

      First you need to learn working of linked list watch all the videos, learn what happens when we perform operation on linked list then you will understand how to write programs :)

  • @vesaxcity9104
    @vesaxcity9104 4 ปีที่แล้ว +1

    Mam are there any plans for you to teach machine learning using python , I would really love to study it the way you teach python.

  • @allstarmashups5970
    @allstarmashups5970 4 ปีที่แล้ว +2

    Hi, one doubt. If I used self.head.ref instead of n.ref. The code is not working. Why is that?

    • @AmulsAcademy
      @AmulsAcademy  4 ปีที่แล้ว +3

      when you take self.head.ref we are referring to the link stored in the first node, in the program we want to traverse through every node to reach last node so for that first we need to take first node as n.

  • @rohankumawat2870
    @rohankumawat2870 2 ปีที่แล้ว

    mam, i had fear of DSA, now i feel like very easy.

  • @rakshitjambavalikar7101
    @rakshitjambavalikar7101 3 ปีที่แล้ว +1

    thank you... very much

  • @maheshreddy5786
    @maheshreddy5786 2 ปีที่แล้ว +1

    Please help 🙏🙏🙏
    If we call add_last() .... Self.head will go to last node right?
    If we call add_begin() now... Then new element will add at third position from end right?
    But How is it coming exactly how we want please help?😕😕

    • @aniketdev1157
      @aniketdev1157 8 หลายเดือนก่อน

      Why this self.head is acting like global?

  • @sillytechy
    @sillytechy 3 ปีที่แล้ว +1

    Hey i have tried this code but, I am getting an error *add_beggining(30)* then *add_beggining(40)* then *add_end(11)* . when I print the Linked list it is showing me _from 30 --> 11 not from 40--> 30 --> 11_ . this is happening in the code *add_end()* when you put at the end. *n.ref = new_node* here, *self.head.data* is still *30* and *_self.head.next_**_ is pointing to my new node_* after this code when I use the * print code* it is starting from node *_self.head.data_**_ 30_* . please help.

    • @AmulsAcademy
      @AmulsAcademy  3 ปีที่แล้ว +1

      Hey can you give me the code , I will check what is wrong in that 😊

    • @sillytechy
      @sillytechy 3 ปีที่แล้ว

      @@AmulsAcademy can u sent me your email id

    • @sillytechy
      @sillytechy 3 ปีที่แล้ว +1

      class Node:
      """Class for node creation"""
      def __init__(self, data):
      self.data = data
      self.next = None
      class LL:
      """ Class which links all the nodes together"""
      def __init__(self):
      self.head = None
      def traverse(self):
      """ Traversing through the linked list"""
      if self.head is None:
      print("linkedlist is empty")
      else:
      while self.head is not None:
      print(self.head.data, "-->", end=" ")
      # we are passing the self.head with self.next
      self.head = self.head.next
      def add_begining(self, data):
      """ adding the node to the beginning of the Linked list"""
      # get the data which is to be added to the beginning of the linked list
      my_node = Node(data)
      # Changing the my node reference to the new node
      # self.data = 30 self.next = None
      my_node.next = self.head
      # point the current head to the new node
      self.head = my_node
      def add_end(self, data):
      """ Adding node to the end of the linked list"""
      self.head = self.head
      my_node = Node(data)
      if self.head is None:
      self.head = my_node
      while self.head.next is not None:
      self.head = self.head.next
      self.head.next = my_node
      def add_between(self, data, x):
      my_node = Node(data)
      while self.head is not None:
      if x == self.head.data:
      break
      self.head = self.head.next
      if self.head is None:
      print("The item is not present in the list")
      my_node.next = self.head.next
      self.head.next = my_node
      def add_before(self, data, x):
      if self.head is None:
      print("Linked List is empty!")
      return
      if self.head.data == x:
      new_node = Node(data)
      new_node.ref = self.head
      self.head = new_node
      return
      n = self.head
      while n.ref is not None:
      if n.ref.data == x:
      break
      n = n.ref
      if n.ref is None:
      print("Node is not found!")
      else:
      new_node = Node(data)
      new_node.ref = n.ref
      n.ref = new_node
      # node1 = Node(10)
      linkedlist = LL()
      linkedlist.add_begining(30)
      linkedlist.add_begining(40)
      linkedlist.add_begining(50)
      linkedlist.add_begining(60)
      linkedlist.add_between(45, 50)
      # linkedlist.add_end(11)
      linkedlist.traverse()

    • @AmulsAcademy
      @AmulsAcademy  3 ปีที่แล้ว

      In your program add_between function will add node after mentioned node right ?
      in that function
      take n =self.head
      also you missed else block
      In add_end Also you missed else block :)

  • @siddumathapati4797
    @siddumathapati4797 2 ปีที่แล้ว

    madam,
    after while loop "n" is "None"?

  • @shibujoseukken
    @shibujoseukken 2 ปีที่แล้ว

    LL1 is not a list. I am i correct. if so why the term coming , beging , end and between

  • @tejateju9232
    @tejateju9232 3 ปีที่แล้ว

    What is the time complexity of inserting node at the end

  • @prashantranjan3777
    @prashantranjan3777 3 ปีที่แล้ว

    Hi Thank you for the video. I have one doubt in the Display link list we write the condition as While n is not None but in inserting the last node we use while n.ref is not None. Y so difference as both accessing same element.. Please clarify

    • @naveenreddy5994
      @naveenreddy5994 2 ปีที่แล้ว

      I exactly have the same question, could someone please clarify? Thanks.

    • @jatin2921
      @jatin2921 2 ปีที่แล้ว

      Because last element is tail which donot have refrence so we use..in that way

  • @debojitmandal8670
    @debojitmandal8670 3 ปีที่แล้ว +1

    Am basically your traversing here as well to move to the last element then y can't we call the above class and it's functions

  • @python_knooobb
    @python_knooobb ปีที่แล้ว

    In add_end() function to add element in the end of LL, the line n.ref=newnode, it is throwing me an error
    AttributeError: 'NoneType' object has no attribute 'ref' ,,,,,,,,,,, can you pls help

    • @OscuraGamer
      @OscuraGamer 8 หลายเดือนก่อน

      same error

    • @aniketdev1157
      @aniketdev1157 8 หลายเดือนก่อน

      Why this self.head is acting like global?

  • @madhiranagender6758
    @madhiranagender6758 2 ปีที่แล้ว

    Please provide cheat sheet when your explaining in that notes

  • @tapstothebeat
    @tapstothebeat 4 ปีที่แล้ว +2

    Shouldn't there be a new_node.next = None at the end of add_end() method since a reference isn't being assigned to the last node?

    • @AmulsAcademy
      @AmulsAcademy  4 ปีที่แล้ว +4

      when you created new node by default reference is taken as None, so need to write that again :)

    • @rajeshbanala1366
      @rajeshbanala1366 3 ปีที่แล้ว

      Thank you bro

  • @rohankumawat2870
    @rohankumawat2870 2 ปีที่แล้ว

    mam, why 20 is added first? and why don't 10 is added in first???? i am still confused

  • @omkarjadhav7009
    @omkarjadhav7009 2 ปีที่แล้ว

    for add_end() function after using
    n = self.head
    while n.ref is not None:
    n= n.ref
    n.ref = new_node
    In the above code, self.head is updated nowhere; however, after execution of the last line, s self.head is updated automatically. How? @Amulya's Academy

    • @ugurcan1206
      @ugurcan1206 ปีที่แล้ว +1

      For keeping it short, let's assume we know that the linked list is not empty. So, let's review step by step:
      1. Let's say n will be the head of the linked list. So it will be self.head.
      2. We need to iterate through every node to reach the last node. We know that after the last node, which is n.ref, there should not be any value.
      3. After we reach the last node, the next node will be the new node that we provided and it becomes the last node(tail) of the list.

  • @phasematerialsresearch9319
    @phasematerialsresearch9319 2 ปีที่แล้ว

    The way she says "linked list" is so cute

  • @amanimanai5205
    @amanimanai5205 3 ปีที่แล้ว

    I can't understand why u potted while n is not none to adding new node in the last list

  • @tejapavankorada5780
    @tejapavankorada5780 8 วันที่ผ่านมา

    i think in print_ll while n is not correct it is n.ref

  • @aniketdev1157
    @aniketdev1157 8 หลายเดือนก่อน

    Why this self.head is acting like global? I m confused

  • @sudarsan-b9o
    @sudarsan-b9o 2 หลายเดือนก่อน

    You have made a mistake here we have to change the ref of the prev element from the last element to the ref of the new node that we added in the linked list

  • @pragyasinha9114
    @pragyasinha9114 3 ปีที่แล้ว +1

    Why n = self.head? explain plz

    • @AmulsAcademy
      @AmulsAcademy  3 ปีที่แล้ว

      Just a variable, instead of writing self.head.ref we can write it in short n.ref 😊

  • @muhammedshabeel1351
    @muhammedshabeel1351 3 ปีที่แล้ว

    i think while loop have some correction:
    while n is not None: instead of this , they wrote (while n.ref is not None: )

    • @aniketdev1157
      @aniketdev1157 8 หลายเดือนก่อน

      Why this self.head is acting like global?

  • @selvanm2872
    @selvanm2872 4 ปีที่แล้ว +1

    👍

  • @meerasarna6862
    @meerasarna6862 2 ปีที่แล้ว

    Hi guys I think it is mandatory to take n = self.head
    she said in one of the lesson that she doesn't want to take self.head again and again.
    But this is not true. We have to take a variable 'n' and we have to assign n = self.head

  • @sanstalks
    @sanstalks ปีที่แล้ว

    someone post codes here please

  • @arundarksiderise6816
    @arundarksiderise6816 3 ปีที่แล้ว

    how old are you maybe 20

  • @konaudaykumarreddy3515
    @konaudaykumarreddy3515 2 ปีที่แล้ว

    ....

  • @anubhavsingh9049
    @anubhavsingh9049 3 ปีที่แล้ว +1

    Content is good but this chuk irritates me

  • @ruhaimhakeem6170
    @ruhaimhakeem6170 3 ปีที่แล้ว +1

    Thank You So Much

  • @kavitanagpal8863
    @kavitanagpal8863 5 หลายเดือนก่อน

    Thank you so much