Not the right program sir. I have tried this program several times and it only returns me a singleton list. I guess problem is there in the first if statement in mergesort function
A shorter Program for Merge Sort. Using recursion without much variables and also usible one of the combine as given in the wrongmergesort program. def mergesort(seq): k=len(seq) if k==1: return seq else: return Merge(mergesort(seq[:k//2]),mergesort(seq[k//2:])) def Merge(seq1,seq2): C,m,n,i,j=[],len(seq1),len(seq2),0,0 while i+j
Left Is the first index right is the last index, if left and right are the same then there is only 1 element. If left and right differ by 1 there are 2 elements. So sorting a single element or 2 elements is very is. For eg sort 5 will return 5, and sort 4,5 will return 4,5
Here, he is just merging the two sorted list in a sorted order, but is not using any divide and conquer strategy. For your input write divide and conquer program and then apply merge sort.
Worst explanation ever He's assuming everyone know these programs before hand and explaining things without stop not even thinking whether the people watching will understand or not
Just wondering, where can I find the lecture-handout (PDF) of this lecture, for download?
Not the right program sir. I have tried this program several times and it only returns me a singleton list. I guess problem is there in the first if statement in mergesort function
A shorter Program for Merge Sort. Using recursion without much variables and also usible one of the combine as given in the wrongmergesort program.
def mergesort(seq):
k=len(seq)
if k==1:
return seq
else:
return Merge(mergesort(seq[:k//2]),mergesort(seq[k//2:]))
def Merge(seq1,seq2):
C,m,n,i,j=[],len(seq1),len(seq2),0,0
while i+j
Best explanation ever!
Explain ,if right - left
So right and left are indices right? right - left
Left Is the first index right is the last index, if left and right are the same then there is only 1 element. If left and right differ by 1 there are 2 elements. So sorting a single element or 2 elements is very is. For eg sort 5 will return 5, and sort 4,5 will return 4,5
@@vaishnaves1723 how can i consider no element either ther is 3 is present or 2 element is present(3,4)
If I give input list 38 27 43 3 9 82 10
The output I get is 3 9 38 27 43 82 10
Here, he is just merging the two sorted list in a sorted order,
but is not using any divide and conquer strategy. For your input write divide and conquer program and then apply merge sort.
1st method is cool but second is .......................
Worst explanation ever
He's assuming everyone know these programs before hand and explaining things without stop not even thinking whether the people watching will understand or not