Тёмный

Reverse Singly Linked List | Data Structures using C 

Naresh i Technologies
Подписаться 1,3 млн
Просмотров 152 тыс.
50% 1

Опубликовано:

 

26 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 123   
@NareshIT
@NareshIT 5 лет назад
Please Comment, Subscribe and Click Bell🔔🔔🔔 Icon for More Updates. To learn software course from our experts please register here for online training: goo.gl/HIB0wL
@gauravgogoinitsilchar4146
@gauravgogoinitsilchar4146 4 года назад
sir how is the arrow link is working , link is not pointing to anything in the program!!!
@sandeepgouda543
@sandeepgouda543 6 лет назад
sir your video are literally worth enough ..!!apart from this your knowledge your gesture your way of explanations set the platform to different level..!! hands up to u sir👏👏
@neethus9848
@neethus9848 5 лет назад
That was excellent .. I went through so many videos to get the concept and honestly this was the best...
@LiveLifeee
@LiveLifeee 5 лет назад
You are an excellent teacher sir , you clear the concepts so well . So glad i found this channel.
@kaustavpaul199
@kaustavpaul199 7 лет назад
u r great sir...make tough pblm very easy
@soumikdutta77
@soumikdutta77 5 лет назад
Sir your video is worth watching .. Never had such clear conception ... a thank you wont be enough !
@nafisnawalnahiyan5032
@nafisnawalnahiyan5032 4 года назад
Love and respect form Bangladesh ! You are an awesome teacher Sir !
@Justdoing185
@Justdoing185 3 года назад
I am not tired of to comment on your every vedio ,👍👍👍
@86kuntalmohan
@86kuntalmohan 7 лет назад
Sir, your explanation is great! I am very thanks full to you.
@Sylie1111
@Sylie1111 5 лет назад
I watched ur complete playlist...that's really helpful for fresher students
@finetechie5550
@finetechie5550 6 лет назад
Sir, Please upload All sorting programs Sir, I am a great fan of yours teaching. I studied C from you in Ameerpet and studying data structure from youtube... Please...Uploading all sorting programs.ASAP as it great time for us in Bangalore to get a job.
@anjalikaranam6134
@anjalikaranam6134 7 лет назад
Sir can u explain merging of two linked lists please sir
@crackcodinginterview4995
@crackcodinginterview4995 4 года назад
Simple and to the point Naresh!
@goyaldeekshant
@goyaldeekshant 4 года назад
HERE IS THE COMPLETE CODE: It includes all functions of linked list tought in this channel. To watch the code of only this video, Please see the void reverse() function only: #include #include struct node { int data; struct node* link; }; struct node* root = NULL; int len; void append(); void addatbegin(); void addatafter(); int length(void); void display(); void delete(); void reverse(); void main() { int ch; while(1) { printf("Single linked list operations are: "); printf("1.Append "); printf("2.AddAtBegin "); printf("3.AddAtAfter "); printf("4.length "); printf("5.delete "); printf("6.display "); printf("7.Reverse "); printf("8.Exit "); printf("enter your choice: "); scanf("%d",&ch); printf("Your choice was: %d ",ch); switch(ch) { case 1: append(); break; case 2: addatbegin(); break; case 3: addatafter(); break; case 4: len = length(); printf("length is %d ",len); break; case 5: delete(); break; case 6: display(root); break; case 7: reverse(); break; case 8: exit(0); default : printf("invalid input "); } } } void append() { struct node* temp; temp=(struct node*)malloc(sizeof(struct node)); printf("Enter node data "); scanf("%d",&temp->data); temp->link=NULL; if(root==NULL) { root= temp; } else { struct node* p; p=root; while(p->link!=NULL) { p=p->link; } p->link=temp; } } void display(struct node* temp) { if(temp==NULL) { printf("list is empty "); } else { printf("elements are: "); while (temp != NULL) { printf(" %d ", temp->data); temp = temp->link; } } printf(" "); } int length() { struct node* temp; int count=0; temp=root; while(temp!=NULL) { count++; temp=temp->link; } return count; } void addatbegin() { printf("to be build "); } void addatafter() { struct node* temp; int loc; printf("Enter location after which, node to be inserted: "); scanf("%d",&loc); if(loc>length()) { printf("invalid input position: "); printf("current list is having %d nodes only",length()); } else { int i=1; struct node* p=root; while(ilink; i++; } temp=(struct node*)malloc(sizeof(struct node)); //new node creation printf("enter new node data: "); scanf("%d",&temp->data); temp->link=NULL; //now just link this new node //first make right connection temp->link=p->link; //right connection p->link=temp; // left connection } } void delete() { struct node* temp; int loc; printf("Enter node number to be delete: "); scanf("%d",&loc); if(loc>length()) printf("invalid position input "); else if (loc==1) { temp=root; root=temp->link; temp->link=NULL; free(temp); } else { int i=1; struct node* p=root; struct node* q=p; while(ilink; i++; } q=p->link; p->link=q->link; q->link=NULL; free(q); } } void reverse() { struct node* p=root; struct node* q=root; int i=0,temp, j=length()-1; while(idata; p->data=q->data; q->data=temp; p-p->link; q=root; i++; j--; } }
@mahadifamgate2686
@mahadifamgate2686 3 года назад
very thank you. can u give me book name (or website) of this code. for learn more.
@sumitrana9999
@sumitrana9999 Год назад
its not optimised.(w.r.t interview)
@villansfftelugugaming5345
@villansfftelugugaming5345 3 года назад
Sir nijamga mi antha clear ga evaru cheypaleru miku Nijam ga johar entha cheypina takuvey sir mi gurunchi
@gamingultimate7489
@gamingultimate7489 3 года назад
very,very,,,,,,,nice sir your videos your explanation morvelessss
@yarramneninikhil1299
@yarramneninikhil1299 4 года назад
Sir, u have given us a wonderful explanation
@chetansahu1505
@chetansahu1505 5 лет назад
This magic happens in the time complexity at the order of N square.
@ansalvi8943
@ansalvi8943 4 года назад
Yes time complexity is expirational time rather than using swapping method he should have been using 3 pointers.....
@riadhallouch
@riadhallouch 2 года назад
thank u so much this is life saviiing man
@nurullahsany2379
@nurullahsany2379 4 года назад
Easy to understand ..Thank you
@PriyankaSingh-dk1zi
@PriyankaSingh-dk1zi 4 года назад
very helpful for me
@prabha20028
@prabha20028 4 года назад
Me 2..😄😉
@dipankar9700
@dipankar9700 3 года назад
Sir you are awesome..😄😄
@shouvikdutta2825
@shouvikdutta2825 5 лет назад
fabulous explanation.
@vineeth8612
@vineeth8612 2 года назад
Instead of reinitialising q we can add j-i in the while loop. I guess it computes to the same
@harshitgoyal2382
@harshitgoyal2382 4 года назад
Pass kra diya bhaishab aapne
@debajyotidey1999
@debajyotidey1999 5 лет назад
Sir , in case of implementing the reverse linked list , why length is used?
@gautam_saxena496
@gautam_saxena496 5 лет назад
to calculate the value of j
@naveenearth2243
@naveenearth2243 6 лет назад
Sir please upload the video about addition of two polynomial
@radartelevision7634
@radartelevision7634 2 года назад
awesome video sir but you didnt define the variable k
@sjamal4403
@sjamal4403 7 лет назад
Sir your lectures are best
@yashwanthl9295
@yashwanthl9295 4 года назад
God of Data Structure
@poojithamadakasira7295
@poojithamadakasira7295 4 года назад
Sir will you please explain reversing singly linked list elements along with there corresponding addresses.
@adarshkv4616
@adarshkv4616 5 лет назад
Thank you sir very great explainanation
@karthikareddy1720
@karthikareddy1720 5 лет назад
sir plzz implement all logics in pc or laptop sir
@sowbarnikab2124
@sowbarnikab2124 2 года назад
sir what about the time complexity of the code given?
@karthikareddy1720
@karthikareddy1720 5 лет назад
tq sir ,clear expalnation
@soubhikdas3997
@soubhikdas3997 5 лет назад
sir,u are initially choosing the elements in increasing order.so in case of reversing swapping helps.what if the elements are not sorted
@soubhikdas3997
@soubhikdas3997 5 лет назад
@Aditya Darade no i was saying that to avoid problem sir intentionally choosed sorted elements and that helped in reversing.
@soubhikdas3997
@soubhikdas3997 5 лет назад
@Aditya Darade what if initially the chosen elements are not sorted.?
@susheelyadav6143
@susheelyadav6143 5 лет назад
reversing or swapping is not done on the basis of node data,its based on there position(address). Here we did not interfere with node data.
@prabhpreetkaur7758
@prabhpreetkaur7758 7 лет назад
Sir ,can you show how will you create struct Node in which you can store the root and pointers and also best and worst cases! Thanks!
@suresha6276
@suresha6276 8 лет назад
very nice explanation could you please post reverse double linked list and tress like BST,AVL tress operations,hashing also iam looking for your posts please post ASAP
@indrapratapyadav1166
@indrapratapyadav1166 5 лет назад
More helpful video, sir.tq
@kissantv7431
@kissantv7431 4 года назад
Respected Sir I have understood very well but having problem in printing the reverse linked list how to print it can you please explain in text or any other way I'll be very thankful to you
@rajanagendra7042
@rajanagendra7042 5 лет назад
sir, i need to learn data structures completely but i did not find data structures in online training
@swathithatikonda6722
@swathithatikonda6722 3 года назад
U r amazing sir!!!! :)
@002_abhinavsingh3
@002_abhinavsingh3 4 года назад
Thank You
@aatifnazar8203
@aatifnazar8203 5 лет назад
Isnt this algorithm O(N2)?
@sulaimanwestbrook2580
@sulaimanwestbrook2580 4 года назад
Guess so
@sjamal4403
@sjamal4403 7 лет назад
Best explanation
@kprakash9665
@kprakash9665 6 лет назад
good xplanation
@keshavburud7584
@keshavburud7584 4 года назад
Sir, can't we take i=1 and j=len??
@sauravhateme
@sauravhateme 4 года назад
One question, I thought root will point to last node in the linked list and address will be reversed.
@codingguru4865
@codingguru4865 4 года назад
Hi Saurav, Check this Full Playlist of Data Structure Explained very easily ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-gh9siMkdLkM.html
@shariqueshaikhh
@shariqueshaikhh 6 лет назад
Thank you so much sir!
@sjamal4403
@sjamal4403 7 лет назад
Please explain other topics of data structures
@amankrsingh
@amankrsingh 4 года назад
Sir please explain how i become 0 and J become 3
@RohitSingh-gg5qw
@RohitSingh-gg5qw 5 лет назад
make the videos on data structure using java, please
@shobitshobit
@shobitshobit 7 лет назад
i wish you were using java :( but i liked your videos :) please make videos in data structure in java.
@shashwatdev2371
@shashwatdev2371 4 года назад
Thanks👌
@romymarry7604
@romymarry7604 4 года назад
Thank u sir
@kavithapriyacj4868
@kavithapriyacj4868 4 года назад
Sir u mistakenly explained as I=0 and j=4 after first iteration actually it's I=1 and j=3
@kurrucharan9376
@kurrucharan9376 5 лет назад
Thank you sir..
@ArunKumar-vg7xi
@ArunKumar-vg7xi 6 лет назад
Good explanation sir
@hometvfirestick
@hometvfirestick 3 года назад
complete this playlist and arrange videos in correct manner
@lovingmyself1196
@lovingmyself1196 3 года назад
Tqqqqq. Sir
@rewasone8826
@rewasone8826 7 лет назад
sir what we do when eleemnt in array is 5 if u swap 0with4 and 1wit3 and then which elemet weselect to swap wit loc 2 element
@ManyuDhyani
@ManyuDhyani 6 лет назад
at time of loc 2, I=j=2 and as in while loop (I
@entrtnmnthub5357
@entrtnmnthub5357 5 лет назад
Awesome
@anusha1676
@anusha1676 5 лет назад
Super
@sampakundu5483
@sampakundu5483 5 лет назад
K variable is not declared. And temp pointer variable also.
@karthikareddy1720
@karthikareddy1720 5 лет назад
plzz implement all operations in laipi sir
@venkateshdammala7
@venkateshdammala7 4 года назад
Sir, I executed the code but reverse order of linked list is not coming perfectly..it is reversing in inorder sir, please help me in this anybody
@faisalalmamun4312
@faisalalmamun4312 7 лет назад
just awesome
@sushmitaroy9776
@sushmitaroy9776 7 лет назад
Sir, don't we need to reverse the link part too?
@harishkumarramsagarvanganu4257
No need. We should not care about the link (Adrees of next node which we can't predict). It's only the matter is the data (elements)
@shubhshree5419
@shubhshree5419 6 лет назад
good Sir
@percussionistbypassion2931
@percussionistbypassion2931 6 лет назад
and we need to create a local variable temp by using "struct node* temp"
@venkateshdammala7
@venkateshdammala7 4 года назад
We need to declare temp as int type ..not struct node* because it is Storing int type data
@AniKet-bw7vv
@AniKet-bw7vv 4 года назад
for this method, it is mandatory that the list should be arranged in ascending order first otherwise it fails
@rayeesdot310
@rayeesdot310 3 года назад
It is all done by loop's . Actually we Traverse lists via loop
@pushparay5554
@pushparay5554 5 лет назад
thank u
@holyshit922
@holyshit922 7 лет назад
Reverse function can be written simpler by changing only links
@jalendhrkumarkushwaha3415
@jalendhrkumarkushwaha3415 6 лет назад
Jacek Soplica I
@adarshkv4616
@adarshkv4616 5 лет назад
Sir why you are writing after i++ and j-- P P.data Q root Pls explain sir😔😔
@shreyashchauhan8567
@shreyashchauhan8567 5 лет назад
learn pointers, Structures and then watch all the videos from this playlist, you will know. In short it is a structure member
@prabha20028
@prabha20028 4 года назад
We r taking the p pointer to pointer to next node..and q pointer to point to the previous node (u can see q node in inner while loop)..i mean in order to swap all elements of linkes list we have to make the p pointer to point to next node and q pointer point to previous node... Hope u got clarify man. Happy coding😉
@ChSureshLeBKIET
@ChSureshLeBKIET 2 года назад
What happens if the array consists 7 elements
@RishabMenonR
@RishabMenonR 6 лет назад
All the program implementations are available here :) houseofgeek.in/single-linked-list-operations/
@behindthescene4406
@behindthescene4406 6 лет назад
Sir why there is nested while , I can't get that can any one please explain me
@anirudhsilverking5761
@anirudhsilverking5761 5 лет назад
The first while loop is used for increasing i and decreasing j until i
@govindprajapati5524
@govindprajapati5524 6 лет назад
sir all things are good but sir you didn't reversed middle element
@nehakumar6831
@nehakumar6831 6 лет назад
Middle elements stay at middle only
@ameyamahadevgonal8130
@ameyamahadevgonal8130 4 года назад
Hats off
@nagarajukolar2121
@nagarajukolar2121 4 года назад
Radix sort
@rocker4037
@rocker4037 3 года назад
//all sll oprations #include #include using namespace std; struct node{ int data; node *next; }; struct node *temp,*temp1,*head,*tem; int len=0; //head=NULL; void insertatend(){ temp=new node; int e; coute; temp->data=e; temp->next=NULL; if(head==NULL){ head=temp; } else{ temp1=head; while(temp1->next!=NULL){ temp1=temp1->next; } temp1->next=temp; } } void display(){ if(head==NULL){ coutnext; temp->next=tem; } } void delet(){ int pos; coutpos; if(head==NULL){ coutnext=tem->next; free(tem);}} int length(){ temp=head; while(temp!=NULL){ len++; temp=temp->next; } return len; } void reverse(){ int i=0; int j=length(); node *p,*q; //p=new node; //q=new node; p=head; q=head; int t,k; while(idata; p->data=q->data; q->data=t; i++; j--; q=head; p=p->next; } cout
@asmdferdousulhaque8425
@asmdferdousulhaque8425 5 лет назад
Not effective in terms of complexity, sorry can't agree
@indianlegendking9071
@indianlegendking9071 4 месяца назад
You are saying arrays
@venkatgambhir9913
@venkatgambhir9913 4 года назад
Why k is used
@ts-ch6zo
@ts-ch6zo 5 лет назад
👏👏
@amitprasad8114
@amitprasad8114 6 лет назад
Explanation is good . But solution is not efficient ,space and time complexity will be more.
@supriyagangadhar2896
@supriyagangadhar2896 6 лет назад
how 'i' value is 0 and 'j' value is 3 at 14:12 min
@supriyagangadhar2896
@supriyagangadhar2896 6 лет назад
'i' will be incremented and 'j' will be decremented right,? then i=1 and j=3 is correct
@manjyotsinghchaudhary6624
@manjyotsinghchaudhary6624 6 лет назад
yes,u are correct
@nareshdosi5754
@nareshdosi5754 6 лет назад
He should have basically said that k =0 instead of i.
@nagarajukolar2121
@nagarajukolar2121 4 года назад
Heap sort
@freddyzhou3130
@freddyzhou3130 5 лет назад
this is a BAD implementation to reverse single linked list! Because there is a great overhead when swapping the data of 2 nodes, and the time complexity is O(n^2) because you have to access linked list each time when going to the position j ! Besides, you can Google for a best solution, maybe it's about O(n) time and just swap the pointer but not the data!
@RahulKumar-pt2su
@RahulKumar-pt2su 5 лет назад
🙏🙏🙏🙏
@shinratenseiratbuvid6938
@shinratenseiratbuvid6938 5 лет назад
it was so hard
@prabha20028
@prabha20028 4 года назад
I dont think so..🙄🙄
@rkprojects6143
@rkprojects6143 2 года назад
Not efficient n optimized algo
@pradyumnanayak8603
@pradyumnanayak8603 5 лет назад
not effective program . time complexity will be n^2 for it .
@lavishgarg8616
@lavishgarg8616 5 лет назад
can you can give an alternative to it if yes then do
@akhilalli5332
@akhilalli5332 6 лет назад
Super
Далее
Circular Queue | Data Structures using C
10:01
Просмотров 286 тыс.
Linked List using C | Data Structures Tutorial
18:29
Просмотров 887 тыс.
Reverse a Single Linked List
11:57
Просмотров 272 тыс.
206. Reverse Linked List | Iterative & Recursive
25:51
How to Perform Operations on Queue | Data Structures
18:57
LINKED LIST (CREATION AND DISPLAY) - DATA STRUCTURES
42:19
Creation of Stack in DS | Data Structures Tutorial
32:22
Operations on Circular Queue |  Data Structures Tutorial
13:30