Application of Linked List (Addition of Two Polynomials)

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

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

  • @MrudulaSonawane
    @MrudulaSonawane 3 วันที่ผ่านมา +1

    your way of teaching is so detailed yet in short time......excellently taught this concept ...just awesome....
    .thankyouuuuu..........

  • @manojs6043
    @manojs6043 ปีที่แล้ว +61

    Source code:
    #include
    #include
    struct node{
    float co;
    int expo;
    struct node* link;
    };
    struct node* insert(struct node* head,float co,int expo)
    {
    struct node* temp=malloc(sizeof(struct node));
    temp->co=co;
    temp->expo=expo;
    temp->link=NULL;
    if(head==NULL || head->expolink=head;
    head=temp;
    }
    else
    {
    struct node* temp1=head;
    while(temp1->link!=NULL && temp1->link->expo>=expo)
    {
    temp1=temp1->link;
    }
    temp->link=temp1->link;
    temp1->link=temp;
    }
    return head;
    }
    struct node* add(struct node* head,struct node* head1)
    {
    struct node* temp=head;
    struct node* temp1=head1;
    struct node* head2=NULL;
    while(temp!=NULL && temp1!=NULL)
    {
    if(temp->expo==temp1->expo)
    {
    head2=insert(head2,temp->co+temp1->co,temp->expo);
    temp=temp->link;
    temp1=temp1->link;
    }
    else if(temp->expo>temp1->expo)
    {
    head2=insert(head2,temp->co,temp->expo);
    temp=temp->link;
    }
    else if(temp1->expo>temp->expo)
    {
    head2=insert(head2,temp1->co,temp1->expo);
    temp1=temp1->link;
    }
    }
    while(temp!=NULL)
    {
    head2=insert(head2,temp->co,temp->expo);
    temp=temp->link;
    }
    while(temp1!=NULL)
    {
    head2=insert(head2,temp1->co,temp1->expo);
    temp1=temp1->link;
    }
    return head2;
    }
    struct node* create(struct node* head)
    {
    int n,expo;
    float co;
    printf("Enter the number of terms: ");
    scanf("%d",&n);
    for(int i=0;ico,ptr->expo);
    ptr=ptr->link;
    if(ptr!=NULL)
    {
    printf("+");
    }
    else
    printf("
    ");

    }
    }

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

      Thank you bro...

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

      Appreciated 💯🙏

    • @abudardamallik1651
      @abudardamallik1651 ปีที่แล้ว +6

      struct node* temp=malloc(sizeof(struct node)); change struct node* temp=(struct node*)malloc(sizeof(struct node));

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

      no need@@abudardamallik1651

    • @Rytham.
      @Rytham. 25 วันที่ผ่านมา

      Send this code on my email

  • @sumitraj6878
    @sumitraj6878 ปีที่แล้ว +38

    the perfect teacher... one with perfect pronunciation, perfect ppt, perfect voice, perfect everything, perfect what not??? huh? everything is awesome!!!!

  • @dipeshjaswani8142
    @dipeshjaswani8142 3 ปีที่แล้ว +89

    sir, I am a first-year engineering student and have been watching these videos for 3 months and I really understanding the concepts in-depth thank you for such wonderful videos. Sir, I only request you to increase the frequency of videos so we can learn all the concepts cause there is no teacher better than you.

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

      Ice chey ayitha

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

      @@manojkrishna5137 🤣🤣🤣🙌🙌🙌

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

      You better not to study engineering bro
      You are not suitable for engineering

  • @rsingh6216
    @rsingh6216 3 ปีที่แล้ว +7

    Today stacks has been started in my class ,i hope you will upload videos before the mid sem.
    Love❤️❤️❤️

  • @DeepakKumar-nk3cv
    @DeepakKumar-nk3cv 3 ปีที่แล้ว +6

    Sir this is huge request plzz complete this course ASAP.......🙏🙏🙏

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

    Neso academy is the best channel to learn dsa in youtube

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

    Took me forever to learn from my textbook. But your explanation was something unimaginably easy and clear.
    Thank you Sir!

  • @vettri5002
    @vettri5002 9 หลายเดือนก่อน

    Very Clear Explanation excellent👌🏾👌🏾

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

    I love Neso Academy :)

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

    Thanks for the best explanation

  • @manjunadhkonapalli4260
    @manjunadhkonapalli4260 3 ปีที่แล้ว +9

    Sir please Complete the Discrete Mathematics playlist as early as you can (Humble request). It is very much usefull to us in terms of concepts and understanding too... So I have also referred this playlist to many of my frnds. Only bcz it's incomplete, they are feeling somewhat inconvenience. (Going to another channel). So please complete it soon sir🙏

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

      What is the use of discrete mathematics for cs student

  • @AllInONE-uc1gj
    @AllInONE-uc1gj 3 ปีที่แล้ว +1

    you are the best lecturer i have seen
    thank u so much

  • @ankitmishra697
    @ankitmishra697 6 หลายเดือนก่อน

    thankyou sir ,best explanation

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

    Thanks for the video

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

    This is best video ♥️ thank you sir

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

    Thanks for the video , I'm looking for recursive way to do this ?

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

    Jai ho maharaj 🙏🙏🙏.
    Just continue the same..upload as many videos of DS and complete this course..
    Thanks a ton. Cz of you i learned c language and DS 🙏

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

    Thanks for your hard work.

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

    Thanks sir from Kanpur 💕💯👌 good explanation of this session in TH-cam

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

    Best video ❤️💯

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

    please upload videos on trees. I am searching everywhere but none of the video quality match yours and i understand your explanation well

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

    Sir make sure to continue the videos please continue sir🙏🙏🙏🙏🙏🙏

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

    very useful, i love you

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

    Excellent explanation 👌 👏 sir

  • @SaiKumar-cs6sf
    @SaiKumar-cs6sf ปีที่แล้ว

    Why we use insert in addition of two polynomials

  • @Kat.kritian
    @Kat.kritian ปีที่แล้ว

    Thank you sir😘

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

    Thanks for this video... 😇😇
    Explanation was greart

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

    excellent sir

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

    Sir I want any of your instructors to teach design and analysis of algorithms this chapter was very important in the aspects of gate as well as in our curriculum currently we have this it is very helpful for us if u teach that subject

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

    THANK YOU SIR

  • @ketanpandey182
    @ketanpandey182 10 หลายเดือนก่อน

    what is the use of the two while loops used in polyadd function after the first while loop ?????

  • @mohamedrazith1323
    @mohamedrazith1323 3 ปีที่แล้ว +26

    #include
    #include
    void print(struct node *head3);
    struct node
    {
    float coeff;
    int expo;
    struct node *next;

    };
    struct node *insert(struct node *head,float co,int ex)
    {

    struct node *temp;
    struct node *newp=(struct node *)malloc(sizeof(struct node));
    newp->coeff=co;
    newp->expo=ex;
    newp->next=NULL;



    if(head==NULL || ex>head->expo)
    {
    newp->next=head;
    head=newp;
    }
    else
    {
    temp=head;
    while(temp->next!=NULL && temp->next->expo>=ex)
    {
    temp=temp->next;
    }
    newp->next=temp->next;
    temp->next=newp;

    }
    return head;

    }
    struct node *create(struct node *head)
    {
    int n,i,ex;
    float co;
    printf("please enter the number of nodes :\t--==> ");
    scanf("%d",&n);
    for(i=0;iexpo==ptr2->expo)
    {
    head3=insert(head3,ptr1->coeff+ptr2->coeff,ptr1->expo);
    ptr1=ptr1->next;
    ptr2=ptr2->next;
    }
    else if(ptr1->expo>ptr2->expo)
    {
    head3=insert(head3,ptr1->coeff,ptr1->expo);
    ptr1=ptr1->next;
    }
    else if(ptr2->expo>ptr1->expo)
    {
    head3=insert(head3,ptr2->coeff,ptr2->expo);
    ptr2=ptr2->next;
    }
    }
    while(ptr1!=NULL)
    {
    head3=insert(head3,ptr1->coeff,ptr1->expo);
    ptr1=ptr1->next;
    }
    while(ptr2!=NULL)
    {
    head3=insert(head3,ptr2->coeff,ptr2->expo);
    ptr2=ptr2->next;
    }
    printf("

    ADDED POLYNOMIALS IS
    ");
    print(head3);

    }
    void print(struct node *head3)
    {
    struct node * temp=head3;
    if(head3=NULL)
    printf("no polynomials");
    while(temp!=NULL)
    {
    printf("(%.1f)^%d",temp->coeff,temp->expo);
    temp=temp->next;
    if(temp!=NULL)
    {
    printf("+");
    }
    else
    printf("
    ");


    }
    }
    int main()
    {
    struct node *head1 = NULL;
    struct node *head2 = NULL;
    ;
    printf("POLYNOMIAL 1

    ");
    head1=create(head1);
    printf("


    POLYNOMIAL 2

    ");
    head2=create(head2);

    polyadd(head1,head2);
    return 0;
    }

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

      thanks bro

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

      thanks bruh....but in 3rrd line no need to declare like that...instead u can give void print().

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

      code is working fine but the output is not crt
      can u check it and resend the code

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

      @@subashkannan949 yes same issue

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

      @@prajapatishyamdineshkumar4456 output haven,t give the sum in this..

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

    How to insert the direct equation as a user input
    Like i type x^2+5x+2 and the program should be understood the variables and operations (characters) ?

  • @adolfocarrillo248
    @adolfocarrillo248 7 หลายเดือนก่อน

    Merge sort adapted for Linked lists.

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

    Thanks for the video sir...

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

    sir its humble request to make videos on tree and graphs pls pls sir

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

    it could be better if I could get the code and copy it.

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

    Good work

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

    Thankyou sir💚💚

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

    Great explanation sir

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

    can u pls provide the same in java, sir?

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

    sir resultant liked list not in sorted form please explain

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

    Where can i get this code

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

    can anyone pls send the link for previous lecture for insert and print function as you said in this video

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

    exponet means what

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

    Bro could you provide the source code ?

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

    sir could you please comment the code in comment section

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

    Plz give code link
    To execute my self

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

    Source code plz sir

  • @Kishan_Gupta2.0
    @Kishan_Gupta2.0 11 หลายเดือนก่อน

    Bhai code bhi de diya kar

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

    Sir Your Video is coming very late Sir please upload ASAP

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

    #include
    #include
    struct polynode
    {
    float coeff;
    int expo;
    struct polynode *link;
    };
    struct polynode *insert(struct polynode* head,float co,int ex)
    {
    struct polynode *temp;
    struct polynode* newp=malloc(sizeof(struct polynode));
    newp->coeff=co;
    newp->expo=ex;
    newp->link=NULL;
    //If there is no node in the list or given exponent is greater than first node exponent
    if((head==NULL)|| ex>head->expo)
    {
    newp->link=head;
    head=newp;
    }
    else
    {
    temp=head;
    while(temp->link != NULL && temp->link->expo>=ex)
    {
    temp=temp->link;
    }
    newp->link=temp->link;
    temp->link=newp;
    }
    return(head);
    }
    struct polynode* create(struct polynode *head)
    {
    int n,i;
    float coeff;
    int expo;
    printf("Enter the number of terms
    ");
    scanf("%d",&n);
    for(i=0;icoeff,temp->expo);
    temp=temp->link;
    if(temp!=NULL)
    {
    printf(" + ");
    }
    else
    {
    printf("
    ");
    }
    }
    }
    }
    void polyAdd(struct polynode* head1,struct polynode* head2)
    {
    struct polynode* ptr1=head1;
    struct polynode* ptr2=head2;
    struct polynode* head3=NULL;
    while(ptr1!=NULL && ptr2!=NULL)
    {
    if(ptr1->expo == ptr2->expo)
    {
    head3=insert(head3,ptr1->coeff+ptr2->coeff,ptr1->expo);
    ptr1=ptr1->link;
    ptr2=ptr2->link;
    }
    else if(ptr1->expo>ptr2->expo)
    {
    head3=insert(head3,ptr1->coeff,ptr1->expo);
    ptr1=ptr1->link;
    }
    else if(ptr1->expoexpo)
    {
    head3=insert(head3,ptr2->coeff,ptr2->expo);
    ptr2=ptr2->link;
    }
    }
    while(ptr1!=NULL)
    {
    head3=insert(head3,ptr1->coeff,ptr1->expo);
    ptr1=ptr1->link;
    }
    while(ptr2!=NULL)
    {
    head3=insert(head3,ptr2->coeff,ptr2->expo);
    ptr2=ptr2->link;
    }
    printf("Added polynomial is:");
    print(head3);
    }
    int main()
    {
    struct polynode* head1=NULL;
    struct polynode* head2=NULL;
    printf("Enter the first polynomial:
    ");
    head1=create(head1);
    printf("Enter the second polynomial:
    ");
    head2=create(head2);
    polyAdd(head1,head2);
    return 0;
    }

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

      I am getting wrong output when I run this code

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

      Can anyone help me with this please

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

      Thanks a lot

  • @ironman-ht4ov
    @ironman-ht4ov 3 ปีที่แล้ว +1

    dude can anyone just give me this code...it's a request @Neso please share the code in the description

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

      #include
      #include
      struct node
      {
      float coeff;
      int expo;
      struct node *next;
      };
      struct node *insert(struct node *head, float co, int ex)
      {
      struct node *temp;
      //Creating a new node
      struct node *newp = malloc(sizeof(struct node));
      newp->coeff = co;
      newp->expo = ex;
      newp->next = NULL;
      if (head == NULL || ex > head->expo)
      {
      newp->next = head;
      head = newp;
      }
      else
      {
      temp = head;
      while (temp->next != NULL && temp->next->expo > ex)
      {
      temp = temp->next;
      }
      newp->next = temp->next;
      temp->next = newp;
      }
      return head;
      }
      struct node *create(struct node *head)
      {
      int n, i, expo;
      float coeff;
      printf("Enter the no of terms");
      scanf("%d", &n);
      for (i = 0; i < n; i++)
      {
      printf("Enter the coeff of the term %d:", i + 1);
      scanf("%f", &coeff);
      printf("Enter the expo of the term %d:", i + 1);
      scanf("%d", &expo);
      head = insert(head, coeff, expo);
      }
      return head;
      }
      void print(struct node *head)
      {
      if (head == NULL)
      {
      printf("No polynomial");
      }
      else
      {
      struct node *temp = head; //Assigning head to temp pointer
      while (temp != NULL)
      {
      printf("(%.2fx^%d)", temp->coeff, temp->expo);
      temp = temp->next;
      if (temp != NULL)
      {
      printf(" + ");
      }
      else
      {
      printf("
      ");
      }
      }
      }
      }
      struct node *poly_add(struct node *head1, struct node *head2)
      {
      struct node *ptr1 = head1;
      struct node *ptr2 = head2;
      struct node *head3 = NULL;
      while (ptr1 != NULL && ptr2 != NULL)
      {
      if (ptr1->expo == ptr2->expo)
      {
      head3 = insert(head3, ptr1->coeff + ptr2->coeff, ptr1->expo);
      ptr1 = ptr1->next;
      ptr2 = ptr2->next;
      }
      else if (ptr1->expo > ptr2->expo)
      {
      head3 = insert(head3, ptr1->coeff, ptr1->expo);
      ptr1 = ptr1->next;
      }
      else if (ptr1->expo < ptr2->expo)
      {
      head3 = insert(head3, ptr2->coeff, ptr2->expo);
      ptr2 = ptr2->next;
      }
      }
      while (ptr1 != NULL)
      {
      head3 = insert(head3, ptr1->coeff, ptr1->expo);
      ptr1 = ptr1->next;
      }
      while (ptr2 != NULL)
      {
      head3 = insert(head3, ptr2->coeff, ptr2->expo);
      ptr2 = ptr2->next;
      }
      printf("The added polynomial is :
      ");
      print(head3);
      }
      int main()
      {
      struct node *head1 = NULL;
      struct node *head2 = NULL;
      printf("Enter the first polynomial :
      ");
      head1 = create(head1);
      printf("
      ");
      printf("Enter the second polynomial :
      ");
      head2 = create(head2);
      printf("
      ");
      poly_add(head1, head2);
      return 0;
      }

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

      @@debrajdey9060 Thanks

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

    SOURCE CODE
    #include
    #include
    struct node
    {
    float coeff;
    int expo;
    struct node *next;
    };
    struct node* insert(struct node* head,float co,int ex)
    {
    struct node *temp;
    struct node* newP = malloc(sizeof(struct node));
    newP->coeff = co;
    newP->expo = ex;
    newP->next = NULL;
    if(head==NULL || ex > head->expo)
    {
    newP->next = head;
    head = newP;
    }
    else
    {
    temp=head;
    while(temp->next != NULL && temp->next->expo >= ex)
    temp=temp->next;
    newP->next = temp->next;
    temp->next = newP;
    }
    return head;
    }
    struct node* create(struct node* head)
    {
    int n,i;
    float coeff;
    int expo;
    printf("please enter the number of nodes :\t--==> ");
    scanf("%d",&n);
    for(i=0; icoeff, temp->expo);
    temp = temp->next;
    if(temp!=NULL)
    printf(" + ");
    else
    printf("
    ");
    }
    }
    }
    void polyadd(struct node* head1,struct node* head2)
    {
    struct node* ptr1 = head1;
    struct node* ptr2 = head2;
    struct node* head3 = NULL;
    while(ptr1 != NULL && ptr2 != NULL)
    {
    if(ptr1->expo == ptr2->expo)
    {
    head3 = insert(head3, ptr1->coeff+ptr2->coeff, ptr1->expo);
    ptr1 = ptr1->next;
    ptr2 = ptr2->next;
    }
    else if(ptr1->expo > ptr2->expo)
    {
    head3 = insert(head3, ptr1->coeff, ptr1->expo);
    ptr1 = ptr1->next;
    }
    else if(ptr1->expo < ptr1->expo)
    {
    head3=insert(head3,ptr2->coeff,ptr2->expo);
    ptr2=ptr2->next;
    }
    }
    while(ptr1!=NULL)
    {
    head3 = insert(head3, ptr1->coeff, ptr1->expo);
    ptr1 = ptr1->next;
    }
    while(ptr2!=NULL)
    {
    head3 = insert(head3, ptr2->coeff, ptr2->expo);
    ptr2 = ptr2->next;
    }
    printf("

    ADDED POLYNOMIALS IS
    ");
    print(head3);
    }
    int main()
    {
    struct node* head1 = NULL;
    struct node* head2 = NULL;
    printf("POLYNOMIAL 1

    ");
    head1 = create(head1);
    printf("


    POLYNOMIAL 2

    ");
    head2 = create(head2);
    polyadd(head1, head2);
    return 0;
    }

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

    Sir Your Video is coming very late Sir please upload ASAP