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

  Рет қаралды 174,206

Vivekanand Khyade - Algorithm Every Day

Vivekanand Khyade - Algorithm Every Day

Күн бұрын

Пікірлер: 213
@kundankarma5707
@kundankarma5707 7 жыл бұрын
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 5 жыл бұрын
if you like watch my tutorial about linked lists in c:linked lists c by panagiotis koligas.
@lavender_artistic_05
@lavender_artistic_05 8 ай бұрын
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.
@sushantshirsekar1443
@sushantshirsekar1443 2 жыл бұрын
Simplicity level to infinite, great respect sir.
@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.
@F_and_L
@F_and_L Жыл бұрын
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 3 жыл бұрын
This is the best tutorial you'll get on KZbin..
@sivaramchintalapudi5216
@sivaramchintalapudi5216 3 жыл бұрын
After searching lot of videos, finally landed at right place.
@vishesharora3984
@vishesharora3984 10 ай бұрын
Brilliant explanation. Thanks a lot sir. You made such a hard problem so easy.
@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!
@asim-gandu-phenchod
@asim-gandu-phenchod 3 жыл бұрын
Brilliant. Much respect from Pakistan
@namrataswain7999
@namrataswain7999 5 жыл бұрын
Amazing tutorial Sir. So simple and easy to understand.
@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 🦅
@ayushshukla1597
@ayushshukla1597 4 жыл бұрын
Thanks a lot Sir. You're a gem.
@vivekanandkhyade
@vivekanandkhyade 4 жыл бұрын
Glad it helped
@muhammadtahakhan1833
@muhammadtahakhan1833 7 жыл бұрын
Best Explanation indeed. Love From Pakistan
@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.
@sumitchakraborty9451
@sumitchakraborty9451 2 жыл бұрын
best teacher award goes to Vivekanand sir
@satyamsharma5181
@satyamsharma5181 4 жыл бұрын
Awesome concepts And awesome teacher .
@adithiyagurupatham3255
@adithiyagurupatham3255 7 жыл бұрын
It's really a nice video and I really understood the concept thanks sir!!!
@pinkeshpatel1940
@pinkeshpatel1940 3 жыл бұрын
Great way to explain the linked list.
@rishabhsahu5257
@rishabhsahu5257 4 жыл бұрын
Love your work and efforts bro.!!.Cheers to open source community
@dishipratap5871
@dishipratap5871 7 жыл бұрын
thank u sir, your explanation helped me lots.
@vivekanandkhyade
@vivekanandkhyade 7 жыл бұрын
thanks Dishi.
@varunsakunia8945
@varunsakunia8945 5 жыл бұрын
Very Nice explanation. i got better understanding of this concept.Thanks sir.
@karun4663
@karun4663 6 жыл бұрын
no words simple and clean explanation u deserve more views and subs
@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 6 жыл бұрын
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
@-_-sweetvibes-_-
@-_-sweetvibes-_- 5 ай бұрын
*Return newhead should be written outside the while loop..else it will be returned in first iteration only...*
@h3is3nb3rg
@h3is3nb3rg 5 жыл бұрын
An Awesome Tutorial explained in lucid language. Thanks a lot !!!
@AnilKumar-qy5tf
@AnilKumar-qy5tf 4 жыл бұрын
watch this for better understanding kzbin.info/www/bejne/oae2iGecdrKXsLM
@alone_man3198
@alone_man3198 3 жыл бұрын
Brilliantly explained
@vivekanandkhyade
@vivekanandkhyade 3 жыл бұрын
Thanks a lot Aman
@yamotuki
@yamotuki 5 жыл бұрын
great! I refer this video for solving leetCode problem.
@sriramkukkadapu1049
@sriramkukkadapu1049 7 жыл бұрын
Thanks Vivekanand. Good video :) i tried this and it worked perfectly.
@akshaygodase8067
@akshaygodase8067 4 жыл бұрын
bro. You explained it really well. Awesome keep it up!
@harshraj57
@harshraj57 4 жыл бұрын
Amazing sir...i have cleared my concept easily thank u sir
@vaibhavgupta1519
@vaibhavgupta1519 6 жыл бұрын
Thank you so much for this elaborated point wise explanation
@deekshithpranav1619
@deekshithpranav1619 4 жыл бұрын
bro we need merge sort with linked list c++!! its a very improtant algo and useful in placement interviews.
@collinsmuriuki2566
@collinsmuriuki2566 2 жыл бұрын
Thanks, very well explained.
@tegharomeo
@tegharomeo 22 күн бұрын
love your explaination sir
@nayanpandule9779
@nayanpandule9779 3 жыл бұрын
Thank you very much Sir for the amazing explanation..!! I really appreciate it
@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.
@pulkitsupple6148
@pulkitsupple6148 16 күн бұрын
Well explained 👍👍
@rohitdixit1617
@rohitdixit1617 5 жыл бұрын
You my friend are a RockStar!
@AdityaKumar-ws5pv
@AdityaKumar-ws5pv 7 жыл бұрын
sir u are doing gr8 job.Please keep uploading videos.Thank u
@vivekanandkhyade
@vivekanandkhyade 7 жыл бұрын
Thanks Aditya..!
@harshitmaurya9140
@harshitmaurya9140 10 ай бұрын
Great explanation sir
@varunnarayanan8720
@varunnarayanan8720 4 жыл бұрын
Very well explained sir Thanks
@samyakjain3397
@samyakjain3397 6 жыл бұрын
sir ur videos really helped us alot tysm
@priyashrivastava5943
@priyashrivastava5943 3 жыл бұрын
Amazing explanation
@GANESHKUMAR-dm5if
@GANESHKUMAR-dm5if 6 жыл бұрын
Great explanation sir really great ...
@danillomelodafonseca
@danillomelodafonseca Жыл бұрын
Thanks, you saved me 😢❤
@SatyendraJaiswalsattu
@SatyendraJaiswalsattu 7 жыл бұрын
very good explanation sir..
@holyshit922
@holyshit922 3 жыл бұрын
Both linked lists and files have sequential access so we can adapt file sorting algorithms for sorting linked lists
@CSFGIRIBAABUKG
@CSFGIRIBAABUKG Жыл бұрын
extraordinary
@r3fl3xplays36
@r3fl3xplays36 6 жыл бұрын
these topics are not available on youtube.
@nikhilchopra5512
@nikhilchopra5512 2 жыл бұрын
very well explained thx a lot
@harikhakolipaka9197
@harikhakolipaka9197 4 жыл бұрын
Wow finally I understood.Thank you sir.
@reyou7
@reyou7 5 жыл бұрын
Amazing->next = amazing!
@ishan_kumar
@ishan_kumar 5 жыл бұрын
Factorial hatao bey
@francobarbosaflores7773
@francobarbosaflores7773 2 жыл бұрын
congratulations, very good!
@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.
@dighechinmayt
@dighechinmayt 7 жыл бұрын
clear and concise explanation, thank you!
@meghamou456
@meghamou456 6 жыл бұрын
Very nicely explained, thank you!
@prachichandrakar2367
@prachichandrakar2367 7 жыл бұрын
thank you so much for this video it helps me a lot
@vivekanandkhyade
@vivekanandkhyade 7 жыл бұрын
Thanks Prachi..!
@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 3 жыл бұрын
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.
@tevaganthanveluppillai720
@tevaganthanveluppillai720 5 жыл бұрын
Very well explained. thanks.
@mahanteshnayakar2227
@mahanteshnayakar2227 6 жыл бұрын
Really good explanation, keep it up.....
@sankaranarayananh7957
@sankaranarayananh7957 5 жыл бұрын
Nice explanation sir!
@talibkhan9193
@talibkhan9193 3 жыл бұрын
Mindblowing explanation . Can we write this program for WAP merge of two sorted list ?
@sayedathar2507
@sayedathar2507 6 жыл бұрын
Thanks Alot Nice Explanation.
@piterbajk
@piterbajk 7 жыл бұрын
superb clear explanation, thanks! ;)
@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.
@ravishankarkumar106
@ravishankarkumar106 4 жыл бұрын
what a wonderfull explanation
@Ozneroc
@Ozneroc 7 жыл бұрын
Great video. I have a question: what if the list was doubly linked, where would the prev point?
@richagupta1865
@richagupta1865 5 жыл бұрын
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 ?
@bharathSPS1995
@bharathSPS1995 4 жыл бұрын
Thanks a lot! Really helpful
@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
@Gandhiboy
@Gandhiboy 4 жыл бұрын
Thank you so much ❤️
@poojasakhare8760
@poojasakhare8760 4 жыл бұрын
Thank you 🙇
@sandeshrana7225
@sandeshrana7225 4 жыл бұрын
Brilliant. Thanks
@vivekanandkhyade
@vivekanandkhyade 4 жыл бұрын
You're welcome!
@utkarshdandagavhal2878
@utkarshdandagavhal2878 4 жыл бұрын
Thank you sir❤️
@panagiotiskoligas9631
@panagiotiskoligas9631 5 жыл бұрын
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
@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
@pawandeepchor89
@pawandeepchor89 6 жыл бұрын
Very good ... excellent 👍
@yasim9435
@yasim9435 6 жыл бұрын
Is there a way of merging 3 sorted lists which is better than merging 2 lists at a time?
@BensonMpapa
@BensonMpapa 7 жыл бұрын
What will the code be like when reversing? can we say if (p
@Wh0NeedsFr1ends
@Wh0NeedsFr1ends 2 жыл бұрын
Im having trouble with Duplicate values existing in both lists. Also having trouble with null inputs.
@SurinderKaur-vq6ti
@SurinderKaur-vq6ti 5 жыл бұрын
well explained , thanks sir
@Menikungmu
@Menikungmu 3 жыл бұрын
i love the you wrote "r"
@AbhishekSharma-uh8pb
@AbhishekSharma-uh8pb 5 жыл бұрын
what if our list is not sorted ?
@t__--__t
@t__--__t 4 жыл бұрын
some advice. You should include your source file
@najimali32
@najimali32 5 жыл бұрын
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 3 жыл бұрын
after this i m fan of recursion....a better solution
@tdsfriends1577
@tdsfriends1577 2 жыл бұрын
Very helpfull, Thx
@sachinbhalla14
@sachinbhalla14 5 жыл бұрын
Sir your videos are Great But why you do'not provide code ??
@jpakash1999
@jpakash1999 4 жыл бұрын
ide.geeksforgeeks.org/LfgR5Cn2wp
@pravesh8187
@pravesh8187 5 жыл бұрын
Grt video sir
@bidsouravbest
@bidsouravbest 5 жыл бұрын
you are awesome sir!
@bharathi80205
@bharathi80205 4 жыл бұрын
Hi, this is really Awesome!! Could you pls provide the code in java
@khoavouc3706
@khoavouc3706 5 жыл бұрын
Hi techer it helpfull
@sambhumahato8320
@sambhumahato8320 4 жыл бұрын
very nice..❤❤❤
@rwnsaad9738
@rwnsaad9738 6 жыл бұрын
Thank sooo much really helpful
@amritpandher4955
@amritpandher4955 6 жыл бұрын
Sir why does this method ignore multiplicity. If two lists have the same number it only prints it once.
@lalayadav866
@lalayadav866 7 жыл бұрын
very nice sir,......
@vivekanandkhyade
@vivekanandkhyade 7 жыл бұрын
Thanks LALA..!
@vidyakamath8298
@vidyakamath8298 7 жыл бұрын
i am new to algorithms ,just wanted to know can we solve this using queue where we compare the data from both the linkedlist and which is less we add that to queue ?Please let me know.
Reverse a Linked List Code/Algorithm/Program
9:03
Vivekanand Khyade - Algorithm Every Day
Рет қаралды 109 М.
L23. Merge two sorted Linked Lists
18:55
take U forward
Рет қаралды 84 М.
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН
Что-что Мурсдей говорит? 💭 #симбочка #симба #мурсдей
00:19
Swap nodes in a linked list without swapping data (Very Easy Explanantion)
20:54
Vivekanand Khyade - Algorithm Every Day
Рет қаралды 56 М.
Check if the singly Linked List is a Palindrome
11:10
Vivekanand Khyade - Algorithm Every Day
Рет қаралды 79 М.
Linked List - Data Structures & Algorithms Tutorials in Python #4
28:16
Remove Duplicates From Sorted Linked List
20:05
Vivekanand Khyade - Algorithm Every Day
Рет қаралды 31 М.
L26. Sort a Linked List | Merge Sort and Brute Force
22:11
take U forward
Рет қаралды 129 М.
Add two numbers represented by linked lists
16:26
Vivekanand Khyade - Algorithm Every Day
Рет қаралды 65 М.
Introduction to Linked Lists (Data Structures & Algorithms #5)
18:47
L25. Merge K Sorted Lists | Multiple Approaches
30:02
take U forward
Рет қаралды 61 М.
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН