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

Поділитися
Вставка
  • Опубліковано 7 лют 2025
  • 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

КОМЕНТАРІ • 304

  • @himanshumangal8077
    @himanshumangal8077 5 років тому +233

    Finally someone who is teaching assuming the viewers are beginners.

  • @somhua5234
    @somhua5234 3 роки тому +142

    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

  • @anubharathor7955
    @anubharathor7955 4 роки тому +25

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

  • @pragmaticcoder6910
    @pragmaticcoder6910 Рік тому +1

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

  • @riadhaidar7025
    @riadhaidar7025 4 роки тому +147

    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 4 роки тому +4

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

    • @riadhaidar7025
      @riadhaidar7025 4 роки тому +1

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

    • @shinosukenohara.123
      @shinosukenohara.123 4 роки тому +1

      maza aa gaya

  • @sreeharimysore838
    @sreeharimysore838 5 років тому +38

    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 ... !

  • @somsuryananda
    @somsuryananda 5 років тому +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 3 роки тому +7

    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.

  • @pratikpatil8938
    @pratikpatil8938 5 років тому +35

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

  • @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.

  • @mridupawan2670
    @mridupawan2670 5 років тому +8

    YOU'RE TRUELY ONE OF THE FINEST TEACHERS!!

  • @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 UA-cam Professor in front of the Whole World...I will be waiting for that Day👍

  • @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 !

  • @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.

  • @AYAMDASH
    @AYAMDASH 5 місяців тому

    Finally a video for all
    levels of students.Its deeply intriguing and really helps boulangerie of epic proportions

  • @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.

  • @MDSHAHABUDDIN-ep4rc
    @MDSHAHABUDDIN-ep4rc 4 роки тому +3

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

  • @dhruvmehra2730
    @dhruvmehra2730 4 місяці тому +1

    I can't believe the way she taught...mindblowing hatts off to ur efforts mam!!🎉🎉🔥

  • @tesfayewako5304
    @tesfayewako5304 5 років тому +2

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

  • @aashishshrestha8180
    @aashishshrestha8180 5 років тому +8

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

  • @saqibjaved1623
    @saqibjaved1623 5 років тому +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.😍😍😍😍

  • @prinkaraina2511
    @prinkaraina2511 5 років тому +4

    Best UA-cam channel for data structure ☺️

  • @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 🙏

  • @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.

  • @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!🥰🥰🥰

  • @AbhishekSingh-tz3uv
    @AbhishekSingh-tz3uv 3 роки тому

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

  • @gabriellerosa6453
    @gabriellerosa6453 4 роки тому +4

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

  • @mahimsd7645
    @mahimsd7645 5 років тому +4

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

  • @gls863
    @gls863 2 місяці тому

    Thank you so much Ma'am, your explanations are so easy to understand !!

  • @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..

  • @lipsmackin3826
    @lipsmackin3826 Рік тому

    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

  • @asmitswarnakar7551
    @asmitswarnakar7551 Рік тому

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

  • @funshorts1248
    @funshorts1248 5 років тому +4

    Truly Grateful for these lectures ~

  • @nephophile4461
    @nephophile4461 7 місяців тому

    Your schematic representation are best. Thanks a lot!

  • @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

  • @Turjackb
    @Turjackb 9 місяців тому

    your are the best teacher i have ever seen

  • @afairywithdemonwings
    @afairywithdemonwings 4 роки тому

    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 .:-)

  • @zakirazakira6951
    @zakirazakira6951 4 роки тому +1

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

  • @syedmansoor4069
    @syedmansoor4069 2 роки тому

    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

  • @harnishsavadia7619
    @harnishsavadia7619 4 роки тому

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

  • @pcpardon
    @pcpardon 4 роки тому

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

  • @majdalin1265
    @majdalin1265 2 роки тому +1

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

  • @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

  • @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..

  • @ramswrooppatidar7599
    @ramswrooppatidar7599 3 роки тому +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 🙌🙌

  • @KanhaiyaKumarbcs
    @KanhaiyaKumarbcs 4 роки тому +1

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

  • @anil9324
    @anil9324 2 роки тому

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

  • @raviease
    @raviease Рік тому

    Extraordinary Teaching Skills 🙇‍♂🙇‍♂

  • @johnp836
    @johnp836 3 роки тому +1

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

  • @rajeevsai91
    @rajeevsai91 3 роки тому

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

  • @uk1523
    @uk1523 4 роки тому

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

  • @Khatarnak.Bakchodi
    @Khatarnak.Bakchodi 3 роки тому

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

  • @murtazamehdi9992
    @murtazamehdi9992 3 роки тому

    greatest instructor of all time 🙏🙏🙏

  • @vanguardianfps4545
    @vanguardianfps4545 3 роки тому

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

  • @aakashmudigonda3375
    @aakashmudigonda3375 4 роки тому +1

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

  • @arshadbagwan3039
    @arshadbagwan3039 4 роки тому +1

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

  • @vaibhavgupta777
    @vaibhavgupta777 3 місяці тому +1

    Thank You Mam So So Much🙏🙏🙏🙏

  • @debupatra2333
    @debupatra2333 4 роки тому

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

  • @iscxii6415
    @iscxii6415 3 роки тому

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

  • @ehabreda365
    @ehabreda365 4 роки тому

    Very clear explanation thank you from Egypt

  • @motivalife1234
    @motivalife1234 Рік тому

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

  • @ronitchaurasia5604
    @ronitchaurasia5604 4 роки тому

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

  • @saijaswanth5085
    @saijaswanth5085 4 роки тому +1

    greatest work by the most beautiful youtuber.
    thanks mam

  • @dharmendrasharma9317
    @dharmendrasharma9317 3 роки тому

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

  • @shreejashukla331
    @shreejashukla331 5 років тому +1

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

  • @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.

  • @aachalmozare8675
    @aachalmozare8675 4 роки тому

    Your explanation is so clear..thanku mam

  • @savangolakiya1926
    @savangolakiya1926 Рік тому

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

  • @Adix_66
    @Adix_66 9 днів тому +1

    FINE 👍

  • @sasikirankakara3773
    @sasikirankakara3773 5 років тому +2

    Awesome Teaching Mam!!!

  • @muhammadnaseeraslam7552
    @muhammadnaseeraslam7552 3 роки тому

    Big Fan Ma'am From Pakistan
    Stay Blessed

  • @ashishpant5548
    @ashishpant5548 Рік тому

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

  • @DurgaSaathwikKolla
    @DurgaSaathwikKolla 10 місяців тому

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

  • @NavaneethBiyyapu
    @NavaneethBiyyapu 11 днів тому

    mam instead of taking extra variables we can just assume head as a previous node since at last it will be pointing to last node. I think in this way we can save memory

  • @mainulhasanrifat
    @mainulhasanrifat 4 роки тому

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

  • @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

  • @snehamareddy1867
    @snehamareddy1867 4 роки тому

    Your teaching method is awesome sis

  • @mohdkashanchaudhary2387
    @mohdkashanchaudhary2387 3 роки тому

    she has awesome teaching skills

  • @ashashainianumolu3792
    @ashashainianumolu3792 3 роки тому +2

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

  • @narendrarana5552
    @narendrarana5552 4 роки тому

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

  • @srishtimishra5101
    @srishtimishra5101 4 роки тому

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

  • @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☺️

  • @biswajitadhikary_0807
    @biswajitadhikary_0807 2 роки тому

    best teaching method

  • @sandipsarkar1516
    @sandipsarkar1516 4 роки тому

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

  • @rahul.rr.p
    @rahul.rr.p Рік тому +2

    DAY 12 COMPLETED

  • @sugaashi
    @sugaashi 6 місяців тому

    Thanks a lot ma'am! Very helpful

  • @kickbuttowsk2i
    @kickbuttowsk2i 5 років тому

    struggled for 40mins without any direction, finally understood.

  • @khaledov7305
    @khaledov7305 7 місяців тому

    Thank you so much for your efforts.

  • @JohnWickea
    @JohnWickea Рік тому

    thank you so much for this beautiful explanation mam.

  • @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

  • @dilshad_ahmed
    @dilshad_ahmed 5 років тому

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

  • @nuraynasirzade
    @nuraynasirzade Рік тому

    your amazing!! i love you Teacher🥰🥰🥰

  • @vishalchauhan9832
    @vishalchauhan9832 5 років тому +2

    Nice lecture mam ji 😍

  • @richashree3345
    @richashree3345 2 роки тому

    Best explanation .....Thank you Mam☺

  • @TheStarboyVlog
    @TheStarboyVlog 4 роки тому

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

  • @karthickm7045
    @karthickm7045 5 років тому +3

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

  • @rajeshdas6438
    @rajeshdas6438 5 років тому

    You have to agree that you taught me and i simply learnt

  • @hmjawad087
    @hmjawad087 4 роки тому

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

  • @adarirohith6177
    @adarirohith6177 5 років тому +1

    excellent explaination madam ji

  • @tusharsaini767
    @tusharsaini767 3 роки тому

    thanku mam ,I love only your videos !!!