Inserting/Adding Elements After The Given Node in The Linked List | Python Program

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

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

  • @mehedifahim8773
    @mehedifahim8773 3 года назад +29

    Ohh god this channel is soo underrated... :(

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

      Thank you :)

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

      @@AmulsAcademy please upload full playlist of DsA with python or else bring a full structured course, I'm ready to purchase

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

      I agree 👍

  • @jasbir5722
    @jasbir5722 3 года назад +13

    I personally never comment, but after watching your videos, I really want to say that you are just awesome at explaination.

    • @AmulsAcademy
      @AmulsAcademy  3 года назад +1

      Thank you 😊❤️

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

      @@AmulsAcademy how do i contact u , i still have doubts

  • @priyadarshinivenkatesan9111
    @priyadarshinivenkatesan9111 2 года назад +7

    I have Watched your complete series on LL, was searching for an LL explanation in python. Great explanation,articulate it was. Thank you

  • @shashankgowda8063
    @shashankgowda8063 4 года назад +18

    Amulya, ...Really nice, and well balanced both practically and theoritically.
    thank you.

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

    One of the best channel to learn dsa in python ... understood linked list by watching your videos at first time itself ... nice explanation

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

    Your channel is the reason why I have not dropped Computer Science yet. Thanks a lot...!!!

  • @rajyalakshmigonaboina7708
    @rajyalakshmigonaboina7708 3 месяца назад

    Best channel ever found..... Tq so much with lots of love ❤

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

    best channel i have ever found on DSA course.worth watching ur videos

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

    What a great clarity in teaching data structures!! 😃😃😃

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

    Mam I will never forget your "chuck" . 😚

  • @yuanran2440
    @yuanran2440 3 года назад +2

    I really love you video, it's very clear and detailed. ps: this is my first time to comment

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

    For this difficult topic you made it so easy to understand! what an excellent explaination!

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

      We can all agree that she's one great teacher

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

    Amazing voice with wonderful explanation

  • @jayveersinhchavda412
    @jayveersinhchavda412 6 месяцев назад +1

    Amezing Learning

  • @mdarsad7694
    @mdarsad7694 3 года назад +1

    You have explained very well mam
    Thanks for providing a very nive titerial

  • @jayveersinhchavda412
    @jayveersinhchavda412 6 месяцев назад

    You Are A mind-blowing person

  • @rohankhatua5088
    @rohankhatua5088 3 года назад +5

    Mam, I have a question! For finding the node which node.data =x . That node may be not unique right? Because there may be two node like node1 and node2 such that node1.data= x as well as node2.data=x. Then how can we find that particular node, which I required to found?.

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

      my answer for your question: it all depends on your scenario. if your requirement is to stop at the earliest node match(node1.data =x), then you can 'break' it after adding your new node. else, you can continue your search and repeat it after your second match(node2.data=x) and so on...
      PFB code:
      def add_after(self, data, x):
      n = self.head
      while n:
      if n.data == x:
      new_node = Node(data)
      new_node.ref = n.ref
      n.ref = new_node
      # break
      n = n.ref
      if n is None:
      print('{} is not available'.format(x))

  • @kalpeshmali1476
    @kalpeshmali1476 4 года назад +1

    Nice video mam plz complete this series as soon as possible plz

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

    Ohh God..
    U r Fantastic..
    Thank You soo much 🥺

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

    You Are Amazing !!! your Explanation is Amazing
    you helped me a lot Thank you !!!!

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

    best tuts so far

  • @shinaspk9276
    @shinaspk9276 7 месяцев назад

    Nice Explanation

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

    Mam ,I have just thought of different way of coding to this same topic ..like if we assume x as position where we want to insert node ,assuming that first node starts from zeroth position .if we follow this method we would not be able to write different codes for After node and before node... Below is the code..
    def insert_after_nodes(self,data,x):
    newnode=node(data)
    temp=self.head
    i=1
    while(i

  • @pritam-kunduu
    @pritam-kunduu 3 года назад +1

    Love your explanation

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

    Please where is the videos you have explained class for node and linked list and travasel?

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

    14:10second if statement I got that, but a little confusion , thanks for the vedio🙌🙌

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

      Hi Mahendra,
      13.12 - 13.22 "listen here" - that means, if x is not there in our linked list, the value of n will be None because of the (n = n.ref) statement in while loop, i.e. because of the while loop, after traversing the entire linked list, value of n will be none, as the last node always points to None. That is why the "if statement" is like that. And, if we are getting the x in our linked list, the value of n cannot be None.
      I hope this clears your doubt :)

  • @manojt7012
    @manojt7012 3 года назад +1

    Shit. I have wasted my money on useless DS course on Udemy. I wish I found your course somewhat earlier... Thanks Amulya

  • @graciousguru7383
    @graciousguru7383 4 года назад +1

    Thanks madam
    I learnt a lot
    👍🤝

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

    When will you continue making video's?😥

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

    Thank u so much akka for ur teaching ☺️☺️☺️

  • @BATTULARAHUL
    @BATTULARAHUL Месяц назад

    While we are searching for node x and traversing, what to do if there duplicate data in nodes and we are talking about 2nd duplicate value which our goal x..? Can any one please explain

  • @funnytrollrk
    @funnytrollrk 3 года назад +1

    Mam you are Vera level
    What do you studyed

  • @SnehaLatha-1224
    @SnehaLatha-1224 4 месяца назад

    You haven't incremented the while loop....Is it auto incremented..Can you explain in detail

  • @nagadinesh8364
    @nagadinesh8364 3 года назад +1

    Mam can u please do vedios on solving problems in python data structures

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

    Beautifully explained :)

  • @darkxxslayer2109
    @darkxxslayer2109 3 года назад +2

    what if in a linked list duplicate data are present....can we add the node on the basis of index numbers like we do in a list

  • @TheVideoPerfect
    @TheVideoPerfect 3 года назад +1

    Thanks for this video

  • @kowsiganr1058
    @kowsiganr1058 3 года назад +1

    Mam you're awesome

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

    can we do while "n.ref" is not None while iterating to last node?

  • @bhupendravyas6213
    @bhupendravyas6213 4 года назад +1

    Which language should i choose to learn DS and Algo?

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

      C :)

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

      @@AmulsAcademy Mam but u have made DSA series in python if i learn in C will i be able to understand ur series. Can u recommend any Books

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

      @@bhupendravyas6213 then you need to master pointer😂
      Easy to understand but sometime creats confusion😎

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

    Who will tell u that previous node value by which u would traverse till that nd insert after that. Bcoz u will be given a linked list nd just position will be given to u not previous node data value. Bcoz to access previous node data value u have to traverse uptill that otherwise how can u get that? Here u know it’s 100 beforehand That's why u r using that but in real scenerio if any other will make the list nd tell u to insert a element in a certain position then how can u do that??
    I think we can take a counter here nd increment that till before the mentioned position like if position 3 increment that counter till 2, like
    Count = 0
    n = New_node
    While count

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

    Superb

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

    tysm dear!

  • @surred707
    @surred707 4 года назад +1

    perfect

  • @arunaagt8229
    @arunaagt8229 3 года назад +1

    Please give me the book name where you learned 🙏

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

      I didn’t refer any particular book :)

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

    getting runtime error for the code

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

    Good tutorial 👍
    Question :-
    What happen if link list contain dublicate number ?
    Eg :-
    5,5,5,15
    Now I want to add 1000 number after 2nd 5 of index 1.
    5,5,___HERE___,5,15
    Please help

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

    How does python store the address ?

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

      Object, Python is all about object even if you are defining a function then at the time of calling you are making an object.
      So, in other word object is like an address/reference of that particular node or function or class.
      Example
      def fun():
      print("hello")
      a = fun()
      a()
      So, in above example when fun() is called then it actually creats an object and that object is now assigned to 'a' and with the help of that object you again called the same function fun()
      Anyone is welcome to improve my explanation

  • @Memes_babai12
    @Memes_babai12 4 месяца назад

    @AmulsAcademy it is good to learn data structures in python for top company placements

  • @advaiti
    @advaiti Год назад +2

    insert value by index
    class Node:
    def __init__(self, data):
    self.data = data
    self.next = None
    class LinkedList:
    def __init__(self):
    self.head = None
    self.len = 0
    def view(self)-> str:
    string = "["
    if self.head is None:
    return "[]"
    else:
    while self.head is not None:
    string += f"{self.head.data}, "
    self.head = self.head.next
    return string[:-2] + "]"
    def insert(self, data: any):
    if self.head is None:
    self.head = Node(data)
    self.len += 1
    else:
    new_node = Node(data)
    new_node.next = self.head
    self.head = new_node
    self.len += 1
    def append(self,data: any):
    if self.head is None:
    self.head = Node(data)
    self.len += 1
    else:
    n = self.head
    while n.next is not None:
    n = n.next
    n.next = Node(data)
    self.len += 1
    def insert_at(self, data: any, index: int)-> None:
    n = self.head
    count = 0
    if index > self.len:
    print(f"Error: Can not add data into position {index}")
    elif index == self.len:
    self.append(data)
    elif index == 0:
    self.insert(data)
    else:
    while n is not None:
    if count == (index-1):
    new_node = Node(data)
    new_node.next = n.next
    n.next = new_node
    self.len += 1
    n = n.next
    count += 1

    LL = LinkedList()
    LL.insert(5)
    LL.insert(10)
    LL.append(15)
    LL.insert_at(29,2)
    print(LL.view())

  • @Pardhu-g5g
    @Pardhu-g5g 4 месяца назад

    osm osm osm osm osm

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

    nice video, thank you

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

    mam please create class 12 th playlist for boards

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

    Nice voice

  • @vishalchoudhary9037
    @vishalchoudhary9037 3 года назад +1

    The code that you are showing here is not working as it is, suppose your LinkedList is 10 -> 20 -> 30 ->40, and you have to add node after 20, then the print_ll() will not print the first node(10). Code is note working properly, My code is.
    class Node():
    def __init__(self,data):

    self.data=data
    self.ref=None
    class linkedlist():
    def __init__(self):
    self.head=None
    def print_ll(self):

    if self.head is None:
    print("Linkedlist is empty")
    else:
    while self.head is not None:
    print(self.head.data, "--->",end=' ')
    self.head=self.head.ref
    def add_begin(self,data):
    new_node=Node(data)
    if self.head is None:
    self.head=new_node
    else:
    new_node.ref=self.head.ref
    self.head=new_node
    def add_at_end(self,data):
    new_node=Node(data)
    if self.head is None:
    self.head=new_node
    else:
    while self.head.ref is not None:
    self.head=self.head.ref
    self.head.ref=new_node
    def add_in_between(self,data,afternode):
    while self.head is not None:
    if afternode==self.head.data:
    break

    self.head=self.head.ref
    if self.head is None:
    print("Item is Not present in list")
    else:
    new_node=Node(data)
    new_node.ref=self.head.ref
    self.head.ref=new_node
    l=linkedlist()
    l.add_begin(25)
    l.add_at_end(30)
    l.add_begin(20)
    l.add_at_end(90)
    l.add_begin(1)
    l.add_at_end(1800)
    l.add_in_between(1000,20)
    l.print_ll()

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

      But program is working correctly when I add another node after 20 😊

  • @selvanm2872
    @selvanm2872 4 года назад +1

    👍

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

    So many nodes makes this confusing 😅

    • @sola2943
      @sola2943 8 месяцев назад

      Using a website like pythontutor and adding the code (which you can find in the description of the previous linked list videos up to now) might make it clear. It goes through every step of the code and shows exactly what it does with diagrams. That's what I'm using. Best of luck in your studies and work.

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

    confusing