Тёмный

Merge two sorted Linked Lists to form a new Sorted Linked List 

Vivekanand Khyade - Algorithm Every Day
Подписаться 114 тыс.
Просмотров 171 тыс.
50% 1

Given two sorted Linked Lists. Merge the two linked lists to form a new sorted Linked List.

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

 

16 сен 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 210   
@kundankarma5707
@kundankarma5707 6 лет назад
You explain every problem in a very simple way. I appreciate your teaching
@lindawisebear
@lindawisebear 7 лет назад
Absolutely brilliant tutorial; one of the best I've seen on youtube for linkedlists!
@vivekanandkhyade
@vivekanandkhyade 7 лет назад
Thanks Linda..!
@panagiotiskoligas9631
@panagiotiskoligas9631 4 года назад
if you like watch my tutorial about linked lists in c:linked lists c by panagiotis koligas.
@Multistanchinguu
@Multistanchinguu 4 месяца назад
Do I have to put header file and main function before the program in exam
@adarsh.singh.777
@adarsh.singh.777 4 года назад
I tried my ass out to solve this problem until I found this video, I was just missing a trick. thanks a lot man..you're amazing.
@osamamughal2707
@osamamughal2707 Год назад
This is the best and the simplest explaination and approach of this problem. Really find this wonderful video after searching and didn't regreted a setting, Very nice Explaination Thankyou very much.
@sushantshirsekar1443
@sushantshirsekar1443 Год назад
Simplicity level to infinite, great respect sir.
@vishesharora3984
@vishesharora3984 5 месяцев назад
Brilliant explanation. Thanks a lot sir. You made such a hard problem so easy.
@F_and_L
@F_and_L 11 месяцев назад
thank you sir.u have explained in a very easy way that even a non tech person also can understand.thank you again sir
@adityabhosale8461
@adityabhosale8461 2 года назад
This is the best tutorial you'll get on RU-vid..
@jayeshvyas6390
@jayeshvyas6390 7 лет назад
Thank you so much i was stuck by this problem but after seeing your explanation now i can easily understand .
@percyygaming
@percyygaming 6 лет назад
Sir i like your explanatory skill as you teach in very easy language!
@adithiyagurupatham3255
@adithiyagurupatham3255 6 лет назад
It's really a nice video and I really understood the concept thanks sir!!!
@gauravsinha5830
@gauravsinha5830 5 лет назад
Great help. However, I don't think you would need the first if(p && q) check. It will only reach there if that case prevailed.
@explorewithshobhit9157
@explorewithshobhit9157 3 года назад
Extremely Satisfying video. Made easy by ( narshima karumanchi ). Has all the problems that you discussed on your videos. Thank you 🙏keep going 🦅
@asim-gandu-phenchod
@asim-gandu-phenchod 2 года назад
Brilliant. Much respect from Pakistan
@muhammadtahakhan1833
@muhammadtahakhan1833 6 лет назад
Best Explanation indeed. Love From Pakistan
@collinsmuriuki2566
@collinsmuriuki2566 Год назад
Thanks, very well explained.
@dishipratap5871
@dishipratap5871 7 лет назад
thank u sir, your explanation helped me lots.
@vivekanandkhyade
@vivekanandkhyade 7 лет назад
thanks Dishi.
@namrataswain7999
@namrataswain7999 5 лет назад
Amazing tutorial Sir. So simple and easy to understand.
@sumitchakraborty9451
@sumitchakraborty9451 2 года назад
best teacher award goes to Vivekanand sir
@ayushshukla1597
@ayushshukla1597 3 года назад
Thanks a lot Sir. You're a gem.
@vivekanandkhyade
@vivekanandkhyade 3 года назад
Glad it helped
@pinkeshpatel1940
@pinkeshpatel1940 3 года назад
Great way to explain the linked list.
@varunsakunia8945
@varunsakunia8945 5 лет назад
Very Nice explanation. i got better understanding of this concept.Thanks sir.
@sivaramchintalapudi5216
@sivaramchintalapudi5216 2 года назад
After searching lot of videos, finally landed at right place.
@h3is3nb3rg
@h3is3nb3rg 5 лет назад
An Awesome Tutorial explained in lucid language. Thanks a lot !!!
@AnilKumar-qy5tf
@AnilKumar-qy5tf 4 года назад
watch this for better understanding ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-kvSW4fAMdzQ.html
@vaibhavgupta1519
@vaibhavgupta1519 6 лет назад
Thank you so much for this elaborated point wise explanation
@TechnicalBaniya
@TechnicalBaniya 7 лет назад
write a code to partition a linked list around a value x such that all nodes less than x come before all nodes greater than or equal to x. if x is contained within the list , the values of x only need to be after the elements less than x. the partition element x can appear anywhere in the right partition it does not need to appear between the left and right partitions. input:. 3->5->8->5->10->2->1(partition 5) output: 3->1->2->10->5->5->8
@TechnicalBaniya
@TechnicalBaniya 7 лет назад
sir please make the video on it actually even I didn't understand the problem
@holyshit922
@holyshit922 5 лет назад
This can be written quite easily if we know how to write a queue but here we dont care about allocating memory Dequeue element from the original linked list Compare key values of dequeued node and pivot node Enqueue dequeued node to the correct sublist Repeat these steps until original list is not empty Lastly sublists can be concatenated If order of nodes with keys equal to pivot key does matter use three sublists First contains nodes less than pivot Second contains nodes equal to pivot Third contains nodes greater than pivot otherwise two sublists will be enough For queue operations and concatenation each list should have pointers to the head node and tail node
@deekshithpranav1619
@deekshithpranav1619 3 года назад
bro we need merge sort with linked list c++!! its a very improtant algo and useful in placement interviews.
@satyamsharma5181
@satyamsharma5181 4 года назад
Awesome concepts And awesome teacher .
@harshitmaurya9140
@harshitmaurya9140 6 месяцев назад
Great explanation sir
@rishabhsahu5257
@rishabhsahu5257 4 года назад
Love your work and efforts bro.!!.Cheers to open source community
@priyashrivastava5943
@priyashrivastava5943 2 года назад
Amazing explanation
@alone_man3198
@alone_man3198 2 года назад
Brilliantly explained
@vivekanandkhyade
@vivekanandkhyade 2 года назад
Thanks a lot Aman
@-_-sweetvibes-_-
@-_-sweetvibes-_- Месяц назад
*Return newhead should be written outside the while loop..else it will be returned in first iteration only...*
@yamotuki
@yamotuki 5 лет назад
great! I refer this video for solving leetCode problem.
@abinashbarik5128
@abinashbarik5128 6 лет назад
Hi Sir, I used to see your videos .Your videos are very very useful for me . I want a video on Flatten a Sorted multilevel linked list and Sort a linked list of 0s, 1s and 2s .Sir Kindly upload upload these videos.
@francobarbosaflores7773
@francobarbosaflores7773 Год назад
congratulations, very good!
@harshraj57
@harshraj57 4 года назад
Amazing sir...i have cleared my concept easily thank u sir
@nayanpandule9779
@nayanpandule9779 3 года назад
Thank you very much Sir for the amazing explanation..!! I really appreciate it
@r3fl3xplays36
@r3fl3xplays36 6 лет назад
these topics are not available on youtube.
@nikhilchopra5512
@nikhilchopra5512 2 года назад
very well explained thx a lot
@rohitdixit1617
@rohitdixit1617 5 лет назад
You my friend are a RockStar!
@SatyendraJaiswalsattu
@SatyendraJaiswalsattu 7 лет назад
very good explanation sir..
@karun4663
@karun4663 5 лет назад
no words simple and clean explanation u deserve more views and subs
@holyshit922
@holyshit922 3 года назад
Both linked lists and files have sequential access so we can adapt file sorting algorithms for sorting linked lists
@randeepsiddhu
@randeepsiddhu 4 года назад
float playbackSpeed = 1.0f; if (you know the logic) playbackSpeed = 1.50; else playbackSpeed = 1.25;
@siddhartharaja9413
@siddhartharaja9413 4 года назад
👍 good one
@gameplanner4110
@gameplanner4110 4 года назад
even 2x will work
@akshaygodase8067
@akshaygodase8067 3 года назад
bro. You explained it really well. Awesome keep it up!
@sriramkukkadapu1049
@sriramkukkadapu1049 7 лет назад
Thanks Vivekanand. Good video :) i tried this and it worked perfectly.
@varunnarayanan8720
@varunnarayanan8720 4 года назад
Very well explained sir Thanks
@sayedathar2507
@sayedathar2507 6 лет назад
Thanks Alot Nice Explanation.
@AdityaKumar-ws5pv
@AdityaKumar-ws5pv 7 лет назад
sir u are doing gr8 job.Please keep uploading videos.Thank u
@vivekanandkhyade
@vivekanandkhyade 7 лет назад
Thanks Aditya..!
@harikhakolipaka9197
@harikhakolipaka9197 3 года назад
Wow finally I understood.Thank you sir.
@talibkhan9193
@talibkhan9193 3 года назад
Mindblowing explanation . Can we write this program for WAP merge of two sorted list ?
@dhavalparikh333
@dhavalparikh333 6 лет назад
Good explanation. But the algorithm doesn't handle the edge case when one of the lists or both the lists has only one node in it.
@dighechinmayt
@dighechinmayt 6 лет назад
clear and concise explanation, thank you!
@sandeshrana7225
@sandeshrana7225 3 года назад
Brilliant. Thanks
@vivekanandkhyade
@vivekanandkhyade 3 года назад
You're welcome!
@tdsfriends1577
@tdsfriends1577 Год назад
Very helpfull, Thx
@GANESHKUMAR-dm5if
@GANESHKUMAR-dm5if 5 лет назад
Great explanation sir really great ...
@piterbajk
@piterbajk 7 лет назад
superb clear explanation, thanks! ;)
@tevaganthanveluppillai720
@tevaganthanveluppillai720 4 года назад
Very well explained. thanks.
@danillomelodafonseca
@danillomelodafonseca Год назад
Thanks, you saved me 😢❤
@prachichandrakar2367
@prachichandrakar2367 7 лет назад
thank you so much for this video it helps me a lot
@vivekanandkhyade
@vivekanandkhyade 7 лет назад
Thanks Prachi..!
@Ozneroc
@Ozneroc 7 лет назад
Great video. I have a question: what if the list was doubly linked, where would the prev point?
@meghamou456
@meghamou456 5 лет назад
Very nicely explained, thank you!
@mahanteshnayakar2227
@mahanteshnayakar2227 6 лет назад
Really good explanation, keep it up.....
@samyakjain3397
@samyakjain3397 6 лет назад
sir ur videos really helped us alot tysm
@CSFGIRIBAABUKG
@CSFGIRIBAABUKG Год назад
extraordinary
@sreelakshmig4004
@sreelakshmig4004 3 года назад
So using if-else condition we're sorting and merging the two already sorted linked lists and using while loop were printing the newly merged single sorted linked list?Amazing explanation sir.
@dannfrank6613
@dannfrank6613 2 года назад
no using the if statement at the beginning we can set the head of the list then using the while loop we can set the rest of the list starting at the head.
@raisanjeeb42
@raisanjeeb42 2 года назад
Thank You sir
@panagiotiskoligas9631
@panagiotiskoligas9631 4 года назад
another way of merging 2 linked lists: if p->datadata:insert(list,p->data); else insert(list,q->data); am i correct?please advise..!thanks.i built this program in my way and worked...
@aaryanbudhirajamusic6874
@aaryanbudhirajamusic6874 4 года назад
it is right but here you are creating a new list, in this tutorial it shows how to merge in the same list
@reyou7
@reyou7 5 лет назад
Amazing->next = amazing!
@ishan_kumar
@ishan_kumar 5 лет назад
Factorial hatao bey
@ravishankarkumar106
@ravishankarkumar106 4 года назад
what a wonderfull explanation
@bharathSPS1995
@bharathSPS1995 4 года назад
Thanks a lot! Really helpful
@Kchima85
@Kchima85 7 лет назад
I apologize if I am incorrect about this, but I was confused about one particular part of this code. When you save newHead = sorting; is that backwards? Should it not be sorting = newHead?
@vivekanandkhyade
@vivekanandkhyade 7 лет назад
we are assigning the 'sorting' node address to the newHead variable...so newHead = sorting . See if we do " sorting = newHead" , then at this time newHead is Null so sorting will also become Null. So that is not correct. The current address of "sorting" node is the starting address of our answer linked list , so newHead = sorting. Once we save the address in newHead , now "sorting" variable is free to move further.
@Kchima85
@Kchima85 7 лет назад
Vivekanand Khyade - Algorithm Every Day I see where our code differs. I assigned the lesser of the two nodes in the initial comparison to newHead. Then when I assigned the sorting to the newHead it set newHead back to null. That is why I am incorrect.
@sankaranarayananh7957
@sankaranarayananh7957 5 лет назад
Nice explanation sir!
@pawandeepchor89
@pawandeepchor89 6 лет назад
Very good ... excellent 👍
@22P938MuhammadSubhanRauf
@22P938MuhammadSubhanRauf 6 месяцев назад
well explained
@khoavouc3706
@khoavouc3706 4 года назад
Hi techer it helpfull
@richagupta1865
@richagupta1865 4 года назад
What ll be the best and worst case complexity for this??
@punitpawar4231
@punitpawar4231 4 года назад
Will it be possible for you to show the recursive approach of doing this operation ?
@poojasakhare8760
@poojasakhare8760 4 года назад
Thank you 🙇
@najimali32
@najimali32 4 года назад
Your explanation is really good , But code is lengthy you can use the same concept using recursion. Node sortedMerge(Node a, Node b) { Node temp=null; if(a==null) return b; else if(b==null) return a; if(a.data
@alokkumarsingh579
@alokkumarsingh579 2 года назад
after this i m fan of recursion....a better solution
@sachinbhalla14
@sachinbhalla14 5 лет назад
Sir your videos are Great But why you do'not provide code ??
@jpakash1999
@jpakash1999 4 года назад
ide.geeksforgeeks.org/LfgR5Cn2wp
@Menikungmu
@Menikungmu 3 года назад
i love the you wrote "r"
@Wh0NeedsFr1ends
@Wh0NeedsFr1ends 2 года назад
Im having trouble with Duplicate values existing in both lists. Also having trouble with null inputs.
@Gandhiboy
@Gandhiboy 3 года назад
Thank you so much ❤️
@mahipalsingh-yo4jt
@mahipalsingh-yo4jt 3 года назад
return very very clear;
@bharathi80205
@bharathi80205 3 года назад
Hi, this is really Awesome!! Could you pls provide the code in java
@holyshit922
@holyshit922 7 лет назад
I would write sorting pointer as local inside function There is missing function which divides list into two sublists and recursive or iterative sorting function How to make this algorithm to work for doubly linked lists To find a midpoint we can use two pointers slow goes once per iteration , fast goes twice per iteration in doubly linked lists we can iterate pointers from both head and tail When we find the midpoid we break the linked list into two sublists Sorting function is similar to this which works for arrays
@vivekanandkhyade
@vivekanandkhyade 7 лет назад
Thanks Jacek...will upload a video in Jacek..!
@holyshit922
@holyshit922 7 лет назад
Natural version of merge sort do not need recursion You can show it If you complete merge sort algorithm we will be able to use linked list for convex hull
@holyshit922
@holyshit922 7 лет назад
Merge sort can be used for sorting files I found in spanish textbook for Pascal natural merge sort for files but i would like to watch version of merge sort with optimized I/O operation Suppose we have limited memory f.e 64kB
@pravesh8187
@pravesh8187 5 лет назад
Grt video sir
@sahelidey3682
@sahelidey3682 3 года назад
Thanks
@BensonMpapa
@BensonMpapa 7 лет назад
What will the code be like when reversing? can we say if (p
@t__--__t
@t__--__t 4 года назад
some advice. You should include your source file
@SurinderKaur-vq6ti
@SurinderKaur-vq6ti 5 лет назад
well explained , thanks sir
@bidsouravbest
@bidsouravbest 5 лет назад
you are awesome sir!
@amritpandher4955
@amritpandher4955 5 лет назад
Sir why does this method ignore multiplicity. If two lists have the same number it only prints it once.
@holyshit922
@holyshit922 7 лет назад
How to modify this function that first occurrence of sorted key value has maximum value of next key value Suppose we have points in polar coordinates , we sort them by angle value and after sorting point with first occurrence of angle value has maximum distance from origin We can apply your next algorithm (removing duplicates from sorted linked list) and we will get most time consuming step of Graham's convex hull
@rwnsaad9738
@rwnsaad9738 5 лет назад
Thank sooo much really helpful
@utkarshdandagavhal2878
@utkarshdandagavhal2878 3 года назад
Thank you sir❤️
@yasim9435
@yasim9435 6 лет назад
Is there a way of merging 3 sorted lists which is better than merging 2 lists at a time?
@raunaqsingh6628
@raunaqsingh6628 3 года назад
Cool!!
Далее
Reverse a Linked List Code/Algorithm/Program
9:03
Просмотров 107 тыс.
World’s Tallest Man VS Shortest Woman!
15:07
Просмотров 17 млн
How To Think Like A Programmer
1:00:07
Просмотров 2 млн
Sorting Algorithms Explained Visually
9:01
Просмотров 535 тыс.
L26. Sort a Linked List | Merge Sort and Brute Force
22:11
Hash Tables and Hash Functions
13:56
Просмотров 1,6 млн