2.8 Reverse a Linked List - Iterative Method | Data Structure Tutorials

Поделиться
HTML-код
  • Опубликовано: 8 сен 2024
  • Jennys Lectures DSA with Java Course Enrollment link: www.jennyslect...
    In this lecture I have written C program to reverse a singly linked list. I have followed iterative approach to solve this problem.
    DSA Full Course: https: • Data Structures and Al...
    ******************************************
    See Complete Playlists:
    C Programming Course: • Programming in C
    C++ Programming: • C++ Complete Course
    Python Full Course: • Python - Basic to Advance
    Printing Pattern in C: • Printing Pattern Progr...
    DAA Course: • Design and Analysis of...
    Placement Series: • Placements Series
    Dynamic Programming: • Dynamic Programming
    Operating Systems: // • Operating Systems
    DBMS: • DBMS (Database Managem...
    *********************************************
    Connect & Contact Me:
    Facebook: / jennys-lectures-csit-n...
    Quora: www.quora.com/...
    Instagram: / jayantikhatrilamba
    #linkedlistindatastructure
    #algorithms
    #dsa
    #operationsonlinkedlist

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

  • @himanshumangal8077
    @himanshumangal8077 5 лет назад +204

    Finally someone who is teaching assuming the viewers are beginners.

  • @somhua5234
    @somhua5234 3 года назад +120

    This has to be the best linkedlist reversal video on the internet. Mam, you’re so good at breaking down such confusing logic into something so simple. You’re really blessed to be a teacher

  • @riadhaidar7025
    @riadhaidar7025 4 года назад +127

    because of you ma'am i've understood everything in singly linked list and here is the full code :
    #include
    #include
    struct node {
    int data;
    struct node *next;
    }*head,*newnode,*temp;
    int pos;
    int n;
    void create(int n);
    void print();
    void addbig();
    void addend();
    void addspecific(int pos);
    void delbeg();
    void delend();
    void delspecpos();
    void getlength();
    void reverse();
    int main()
    {
    int num,choice;
    while(1){
    printf("
    ENTER '1' TO CREATE LINKED LIST:
    ");
    printf("
    ENTER '2' TO ADD NODE AT BEGINNING:
    ");
    printf("
    ENTER '3' TO ADD AT NODE THE END OF THE LIST:
    ");
    printf("
    ENTER '4' TO ADD NODE AT SPECIFIC POSITION:
    ");
    printf("
    ENTER '5' TO DELETE THE FIRST NODE:
    ");
    printf("
    ENTER '6' TO DELETE LAST NODE:
    ");
    printf("
    ENTER '7' TO DELETE A NODE FROM SPECIFIC POSITION:
    ");
    printf("
    ENTER '8' TO GET LENGTH OF THE LIST:
    ");
    printf("
    ENTER '9' TO REVERSE THE LIST:
    ");
    printf("
    ENTER '10' TO EXIT:
    ");
    scanf("%d",&num);
    switch (num)
    {
    case 1:
    create(n);
    print();
    break;
    case 2:
    addbig();
    print();
    break;
    case 3:
    addend();
    print();
    break;
    case 4:
    addspecific(pos);
    print();
    break;
    case 5:
    delbeg();
    print();
    break;
    case 6:
    delend();
    print();
    break;
    case 7:
    delspecpos();
    print();
    break;
    case 8:
    getlength();
    print();
    break;
    case 9:
    reverse();
    print();
    break;
    case 10:
    printf("bye bye :) !!");
    exit(0);
    break;
    default:
    printf("WRONG CHOICE...!");
    }//end of switch statement
    }//end of while
    return 0;
    }//end of main
    void create(int n)
    {
    printf("enter the length of the list: ");
    scanf("%d",&n);
    struct node *newnode;
    head=0;
    int i;
    for(i=0;idata);
    newnode->next=0;
    if (head==0)
    {
    head=temp=newnode;
    }
    else {temp->next=newnode;
    temp=newnode;
    }
    }
    }
    void print()
    {
    temp=head;
    printf("
    the list is:
    ");
    while(temp!=0)
    {
    printf("%d ",temp->data);
    temp=temp->next;
    }
    }
    void addbig()
    {
    struct node *newnode;
    if (head==0)
    {
    printf("invalid position");
    }
    else
    {
    newnode=(struct node *)malloc(sizeof(struct node));
    printf("
    enter the data of new beginning node: ");
    scanf("%d",&newnode->data);
    newnode->next=head;
    head=newnode;
    }
    }
    void addend()
    {
    struct node *newnode;
    temp=head;
    if(head==0)
    {
    printf("invalied position");
    }
    else{
    newnode=(struct node*)malloc(sizeof(struct node));
    printf("
    enter the data of new last node: ");
    scanf("%d",&newnode->data);
    newnode->next=0;
    while(temp->next!=0)
    {
    temp=temp->next;
    }
    temp->next=newnode;
    }
    }
    void addspecific(int pos)
    {
    int j;
    printf("
    enter position of newnode: ");
    scanf("%d",&pos);
    struct node *newnode;
    if (pos>n||posdata);
    for(j=0;jnext;
    }
    newnode->next=temp->next;
    temp->next=newnode;
    }
    }
    void delbeg()
    {
    printf("
    first node will be deleted....
    ");
    if (head==0)
    {
    printf("lsit is empty");
    }
    else
    {
    temp=head;
    head=head->next;
    free(temp);
    }
    }
    void delend()
    {
    struct node *prevnode;
    printf("
    last node will be deleted....
    ");
    temp=head;
    while(temp->next!=0)
    {
    prevnode=temp;
    temp=temp->next;
    }
    if(temp==head)
    {head=0;
    }
    else{
    prevnode->next=0;
    }
    free (temp);
    }
    void delspecpos()
    {
    int x;
    int posi;
    struct node *nextnode;
    temp=head;
    printf("
    enter the position of node you want to delete: ");
    scanf("%d",&posi);
    for(x=0;xnext;
    }
    nextnode=temp->next;
    temp->next=nextnode->next;
    free(nextnode);
    }
    void getlength()
    {
    temp=head;
    int count;
    while(temp!=0)
    {
    count++;
    temp=temp->next;
    }
    printf("
    list length is: %d",count);
    }
    void reverse()
    {
    struct node *prevnode,*current,*nextnode;
    prevnode=0;
    current=nextnode=head;
    while(nextnode!=0)
    {
    nextnode=nextnode->next;
    current->next=prevnode;
    prevnode=current;
    current=nextnode;
    }
    head=prevnode;
    }

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

      Thank you for this

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

      @@vineethnarayan5159 welcome

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

      i'm about to take my exam of data structures and you made my day brother. Stay Blessed forever :)

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

      @@aminaaslam33 all the best in your exams ,
      good luck

    • @shinosukenohara.123
      @shinosukenohara.123 3 года назад +1

      maza aa gaya

  • @anubharathor7955
    @anubharathor7955 4 года назад +21

    Teachers like you are needed seriously....who give not only theories and codes....but knowledge also....

  • @sreeharimysore838
    @sreeharimysore838 4 года назад +35

    Reversing the linked list is always a confusing stuff for me. But finally I got this concept clear with your unique style of explanation. Very grateful to you MadamJi ... !

  • @pratikpatil8938
    @pratikpatil8938 5 лет назад +35

    This is my favorite u tube channel to learn data structure and algoritham... thanks mam💻

  • @somsuryananda
    @somsuryananda 4 года назад +26

    Dear Jenny,
    You seem to enlighten us on a daily basis. Your way of teaching is very simple and yet very impacting. Thank you for all you have done/posted. 😊😊 Wish you all success in life and career.

  • @sachinkainth9508
    @sachinkainth9508 2 года назад +6

    I have 20 years of development experience in industry but still I have found reversing a linked list to be quite difficult, until that is I came across this excellent video.

  • @bhadreesh787
    @bhadreesh787 5 лет назад +8

    Hi Ma'am Happy Teachers Day....Ma'am Your Teaching is so Understandable that any Below Average Students can also easily Grasp the Concepts..Jayanti Ma'am please Cover all the Concepts of "Advanced Data Structures & Algorithms" without leaving even a Single Concept...You are also having so "Beautiful Face along with Beautiful Voice & Genius Brain"💐🎂...You will Definitely become one of the Reputed RUclips Professor in front of the Whole World...I will be waiting for that Day👍

  • @SanjayKIG
    @SanjayKIG 5 лет назад +16

    Finally someone who is teaching assuming the viewers are beginners. Subscribing the channel for more viewership and exposure. Good luck. We really dont mind the long length of the videos.

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

      😂😂😂😂😂

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

    No background music, No fancy introduction of channel or anything. Simple, to the point and perfect explanation. Thank you and God bless you.

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

    YOU'RE TRUELY ONE OF THE FINEST TEACHERS!!

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

    Whenever i watch your video it feels like i was sitting in the classroom. I spent my whole one day but not find out how to reverse. finally after watching this video i solve the problem in minutes.

  • @yuktagaba525
    @yuktagaba525 4 года назад +4

    Thanks a lot for making us understand this easily. I went through a lot of videos but yours is actually the "BEST" one.

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

    feel like tuition class.. thank you madam .. from Nepal

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

    Just one word for u mam "ZABARDAST" .
    GREAT explanation and simple style, and i loved my all teachers but u r one of the best teacher ever on dsa.😍😍😍😍

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

    This is my favorite youtube channel to learn whatever course in computer science......i lv u so much mam

  • @MDSHAHABUDDIN-ep4rc
    @MDSHAHABUDDIN-ep4rc 4 года назад +3

    Blessed, thrilled, excited all at the same time to have a teacher like you!!

  • @gabriellerosa6453
    @gabriellerosa6453 4 года назад +4

    PERFEITA MARAVILHOSA SEM DEFEITOS, toda vez que tenho que reverter uma lista eu colo aqui

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

    Most simple and clear explanation I've come across so far . Keep us providing with more of these wonderful videos. Much appreciated !

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

    omg, I'm a girl and I wanna say I love you! You are such a good teacher who makes this complicated knowledge into something clear and understandable. Thank you! Appreciated all your work!🥰🥰🥰

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

    Madam you have a lot of patience....while learning in my class I faced lot of confusion but now my all doubts are clarified..your doing greatest service for the poor people that who are not able to invest..thank you is very small word but it contains lot of emotional feeling 🙏

  • @prinkaraina2511
    @prinkaraina2511 4 года назад +4

    Best RUclips channel for data structure ☺️

  • @nephophile4461
    @nephophile4461 2 месяца назад

    Your schematic representation are best. Thanks a lot!

  • @mahimsd7645
    @mahimsd7645 5 лет назад +4

    Excellent explanations Jenny ...
    God bless you !!!!

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

    never have i ever been taught like this before.... concepts are so clear to me now that I can bloody teach someone.

  • @AbhishekSingh-tz3uv
    @AbhishekSingh-tz3uv 2 года назад

    Seeing just the first 5 mins of this video got me clear the whole traversal & reversal process. Thanks for such a wonderful content!

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

    Bestest explanation of reverse linked list , for your struggle I have clear knowledge in DSA, thankyou ma'am ❤

  • @user-hd1tn4bp6z
    @user-hd1tn4bp6z 3 месяца назад

    your are the best teacher i have ever seen

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

    Ur teaching skills are really awesome... simple and concise... I understood this concept... Ur doing invaluable service in CS teaching in India. U really deserve President award for teaching..Hats off u ..Maam..

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

    very nicely explained. exceptional style of teaching. god bless you . thanks

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

    Speechless, mind blowing explanation mam....keep going and we are looking forward for more easy understanding, useful concepts like this.... Fan from Andhra Pradesh....

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

    Last year I got A+ in the discrete mathematics course watching your video. Now I am watching DS videos .. (Love from Bangladesh

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

    Being in the Final year and preparing DS and ALGO for placement. What have I learned from college NOTHING. What have I learn from you is the logic behind those from scratch. You have my utmost respect. I will again comment you when I will get a Job.
    Stay happy, stay safe and take care Ma'am .:-)

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

    I love your way of teaching PLEASE do a video of how to delete all negative numbers in a linked list

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

    ALWAYS I SUPRISED BY YOUR TEACHING MAM, IT's BEEN LIKE SPOON FEEDING VERY EASY TO UNDERSTAND MAM, THAN YOU SO MUCH

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

    today I taught my frnd linked list after learning from your video & he was like wow !! bhot acche se explain Kiya phli Baar mein hi sab smjh aagya...Thnq soo much mam, U teach soo well

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

    woaw ma'am ! your teaching skill is absolutley faad👌👌, many more teachers and lectures on you tube but i love the way you teach !
    when im free i will draw your beautiful sketch 🙌🙌

  • @moazzamqureshi7150
    @moazzamqureshi7150 4 года назад +4

    Truly Grateful for these lectures ~

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

    I've subscribed ❤ thank you for explaining it so easily and clearly, finally I understood how to reverse linked list after coming across many complicated videos

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

    Thanks a lot mam....you are working hard for us.....perfectly explained everything .

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

    Thank you, Jayanthi.. explanation is awesome. Straight to the basics... no need to memorize.. all logical

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

    Ever hear these kind of lectures.Thank u mam for providing better lectures for us.❤❤❤

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

    Sabse acha data structure apne padhaya h...mene ummid hi kho di thi....god bless you........or bhi vedio bnado maim....Hindi me record krdo possible ho ske to

  • @DurgaSaathwikKolla
    @DurgaSaathwikKolla 5 месяцев назад

    Thank you very much mam. you made me learn without skipping backwards😊😊😎😎

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

    ma'am your level of explanation is really very helpful... and understandable. their are lot of video on ds on different platform i visited almost source possible for learning ds but i don't find any video content around you .... this is best content i ever seen on d.s ..ma'am small love from younger brother ..from bihar..

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

    Finally found a video that explains the concept so systematically! Thanks a lot!

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

    She's dope man😍😍😍
    DS and ALGO MADE BEAUTIFUL😌

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

    Liked the teaching approach. What we might miss when traversing and the logic to hold them. Nice.
    Thanks.

  • @Khatarnak.Bakchodi
    @Khatarnak.Bakchodi 2 года назад

    Good explanation Jenny! I could understand logic in 5 mins and create my own program

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

    I took cormen. Left it. I downloaded tens of books. I read , I yawned and I stopped. Suddenly one day this video pops up on my youtube screen. Woaaah, my mind said.

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

    Extraordinary Teaching Skills 🙇‍♂🙇‍♂

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

    Hi mam, I am from ece stream and not familiar with how to calculate the timing complexity of an algorithm. I have understood a little about big O notation from ur explanations but if u could make a separate video, that would be very helpful.
    Your way of explaining is very good and clear. These videos are very helpful. Thanks mam☺️

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

    I am grateful to you for this video. It helps me alot thanks!

  • @motivalife1234
    @motivalife1234 9 месяцев назад

    Mam your lec so helpful ... I understand all points very well❤❤ ...great work 👍👍

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

    Mam aap abhut accha samjhate ho keep it up mam you are the only one with great content aman bhaiya ka bhi course accha hai but explaination for beginers is very poor

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

    Very beautifully explained ...the working you have made us visualize it

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

    Sabse pahle tah-e-dil se shukriya.
    Ek sawal hai, zehan me. Kyu na while loop ki shuruati line ye ho
    nextnode = currentnode->next;
    bajaye isake
    nextnode = nextnode->next;
    Ye dono mere mutabik ek hi tarah se kam karengi, lekin dimag ke liye uper wali line jyada asardar hogi

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

    Thanku mam... Finally I can understand this topic...

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

    best explanation for reversing the linked list. Thank you maam!

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

    One of the easiest way to reverse linkedlist
    Great work ma'am
    Keep it up 👍

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

    Nice explanation indeed, and reversal of string can be done using 2 pointers, 3rd extra pointer not required.

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

    greatest work by the most beautiful youtuber.
    thanks mam

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

    The way she smiles at end of every video is love......till then bye bye take care...

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

    Thanks a lot ma'am! Very helpful

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

    Thank You So much by far the best Reversal Video !!!

  • @sasikirankakara3773
    @sasikirankakara3773 5 лет назад +2

    Awesome Teaching Mam!!!

  • @khaledov7305
    @khaledov7305 2 месяца назад

    Thank you so much for your efforts.

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

    greatest instructor of all time 🙏🙏🙏

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

    Very clear explanation thank you from Egypt

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

    Big Fan Ma'am From Pakistan
    Stay Blessed

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

    Thanks mam for sharing your knowledge. It helped me a lot

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

    super mam.
    i request you to post video on interview question and answer also please.
    then post video on mirror program in c.

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

    Mam ji namste 🙏🏼🙏🏼
    Your teaching way is very very admirable

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

    Your explanation is so clear..thanku mam

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

    best teaching method

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

    your amazing!! i love you Teacher🥰🥰🥰

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

    thank you so much for this beautiful explanation mam.

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

    Thank you mam... Very Helpful for umcoming gate and net exam

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

    Thank you so much ma'am God bless you and ur family

  • @vishalchauhan9832
    @vishalchauhan9832 5 лет назад +2

    Nice lecture mam ji 😍

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

    Thank you mam you are always best

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

    thanku mam ,I love only your videos !!!

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

    this is what student is always looking for!!!!!

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

    Code with Harry and Miss Jenny. They are performing much more better than so called PHD stupid scholars in the University. Love from Pakistan!

  • @Arjun-dj2lc
    @Arjun-dj2lc 2 месяца назад

    Thank you for this video

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

    Wow mam 1 time me clear ho gya...... thanks

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

    Great job ma'am!!!....keep it up please:)

  • @Coder-kl6pd
    @Coder-kl6pd 17 дней назад

    Super mam!!!!!!!!!!!!!

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

    struggled for 40mins without any direction, finally understood.

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

    Thanqu soooooo much mamm your explanation is too good ...

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

    gjbb ekbrr mai hi smgh gyiii

  • @Sarkar.editsz
    @Sarkar.editsz 2 года назад +1

    Thanks a lot

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

    Best explanation .....Thank you Mam☺

  • @adarirohith6177
    @adarirohith6177 5 лет назад +1

    excellent explaination madam ji

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

    i have subscription if ravindra babu's lectures, still kush smj ni aaya, thanku mam for this lecture now i clear all doubts after watching this, nd you looking too beautiful mam

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

    finally i got the concept 😍

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

    Your teaching method is awesome sis

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

    Mam your lectures are awesome. Keep it up for us. Best wishes.

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

    Very helpful video,thank you ma'am.