12:04 Bhaiya, (s+e)/2 can overflow when both s and e have maximum possible value of integer i.e. 2^31-1. This will result in wrong answer. So to optimise this, we write- int mid= start + (end - start)/2 to handle such edge cases. Thank you Bhaiya ki aap itni achi series bana rahe hai!!!
@@utkarshgautam1940 yes we can also create it statically but it is mentioned by bhaiyya in earlier videos that whenever we dont know incoming size of the array....... creating array statically might give error if it exceed stack memory, so this is a bad practice....but in dynamic memory allocation it has plenty of memory...so no need to worry about size. this could would work fine when we know incoming size of arrays. But in online judge test cases if array size exceed stack memory then it will lead to prob.so better declare dynamically in some cases.
Apart from the content of course, I really like your way of teaching, like har baat ko ek kahani bata rahe aise karke explain karte, "Maine aapko bola ki aaj hum merge sort padhne wale hain, to aapne bola, kya hota hai merge sort ka matlab", aise type, bahut badhiya tareeka.
Thanks A Lot Bhaiya!!Suffering since 3months,Recursion ke problems ko solve karne ka bahut aacha trick Bataya Aapne.Thank you bhaiya for such a Awsome Content..Stay safe stay Healthy
Bht badi help kr rhe ho bhaiya jiska ehsaan kabhi chuka nhi paege.. aap itna mehnat krte ho isse hume motivation milta hai ki humko bhi aur mehnat krni hai....love you bhaiya.... God bless you❤️
It's difficult to understand for me as an ECE student. But I have come a long way and took significant days to reach this point. I can't just leave now. You teach very precisely but for me, it takes longer time to understand each concept than those of CSE. I will try my best to move forward.
bruh!. programming is nothing to do with your degree. If you are struggling then you need practice. Recursion is a hard topic compared to others. So it will take time.
Thank You So Much BHRAATA SHREE !!!!!! Ram Ram bhai saareya ne aaj hai humare recursion 10 day challenge ka paachva din h or hum padhne beth chuke hain full josh ke saath.
Bhaiya ki chalaki waali trick: (s + e) / 2 //it can lead integer overflow, means that after adding s and e we may get this much bigger value that cannot be stored in int. So let's do Chalaki s + (e - s)/2 //another way of writing the above formula.
11:57 If both start and end are very large then adding them can result in an interger overflow. So, to solve this we can do `start + (end - start) >> 1`
😓Sir i know recursion and i understood ur algorithm but mergeSort(arr,s,mid) and mergeSort(arr,mid+1,e) how are these sorting left and right parts i dont get it somebody plz explain friends
Thank you so much sir complete semester smjh ni aya aj kr liya hai subha exam hai mera thank so much for saving me ab bht achy sy smjh agya. I'm consistently following your DSA playlist
Bhaiya mujhe Recursion ka topic aaj tk samajh hi nhi aaya tha....but....2 video Sraddha Didi ki or baki video aapki dekhne ke baad Recursion ka topic mere liye chhutkiyo ka khel reh gya hai...❤ Thanks bhaiya ❤
Bhaiya, (s+e)/2 can overflow when both s and e have maximum possible value of integer i.e. 2^31-1. This will result in wrong answer. So to optimise this, we write- int mid= start + (end - start)/2 to handle such edge cases. Thank you Bhaiya ki aap itni achi series bana rahe hai!!!
If we use (start + end )/2 then it may happen that the sum will exceed the limit of integer hence we should use start + (end-start)/2 means in your language (code phat jayega)
bhaiya aap great ho the amount of dedication you are putting in the videos mai agar thoda dedication aur laga doon to shayad kuch badhiya ho jaye>>>>>>thankyou so much bhaiya>>>>
the gadbad in mid=(s+e)/2 is because if s and e are big integers then it will create problem in time complexity............USE mid=s+(e-s)/2; and there it will go easy.☺☺☺☺☺☺☺☺☺☺
def merge(arr,s,e): inv_count = 0 mid = s+(e-s)//2 len1 = mid-s+1 len2 = e-mid l1 =[] l2 =[] k = s for i in range(len1): l1.append(arr[k]) k+=1 k = mid+1 for i in range(len2): l2.append(arr[k]) k+=1 i=j=0 k=s while(i
if i take,mid=(s+e)/2 i that case the value of the mid will be out of range of the number that is 2^-31 to 2^31 So to solve this problem using this formula--------> e+(s-e)/2
jab ham mid=(s+e)/2 use karte hai to jab int 2 ki power 31 hoga to int ki range se bahar ho jayega isiliye ham mid=s+(e-s)/2 use use krte hai thank you bhaiya
Mid=start+(end-start)/2 use kro because we know integer ka range -2raise to powe 31 to 2 raise to power 31 minus 1 if we use mid=start+end/2 then integer ka range sa bahar chla jyggg
Ye lecture thora upar upar se chala gaya😢 koi nahi pehle khud try karunga or agar phir bhe nahi howa to wapas se dekhunga complete to kerna hai kisi bhe haal m
Bhaiya we couldn't take mid equal s+e because it may happen sum is greater then integer limit cause overflow problem therefore we take s + (e-s)/2 in place of (s+e)/2
more than learning DSA I am learning to be consistent even during hardships through your videos. Praying for your recovery, Get well soon bhaiya💫
i also bro consitents mean love bhaiya
iam in 1st year i want dsa complete in 1st year with love bhaiya!
This vedio is not a lecture...its just sir coding for himself...no explanation like other lectures.
if you watch it with focus you will get it
🍌
bro your video spelling is wrong
@@Aryan_33345 problem solver
12:04 Bhaiya, (s+e)/2 can overflow when both s and e have maximum possible value of integer i.e. 2^31-1.
This will result in wrong answer.
So to optimise this, we write-
int mid= start + (end - start)/2 to handle such edge cases.
Thank you Bhaiya ki aap itni achi series bana rahe hai!!!
yess!!
lol kimds , everyone knows that
baap ko mat shikha ....wo sab padha chuke h babu
@@SatyamSingh-rq2iy isme itna toxic hone ki zarurat thodi h , vo in general bs bol rha for public awareness
If we use (start + end )/2 then it may happen that the sum will exceed the limit of integer hence we should use start + (end-start)/2
great
bro why we have created aaraay dynamicaaly ,we can also create it statically
@@utkarshgautam1940 yes we can also create it statically but it is mentioned by bhaiyya in earlier videos that whenever we dont know incoming size of the array....... creating array statically might give error if it exceed stack memory, so this is a bad practice....but in dynamic memory allocation it has plenty of memory...so no need to worry about size.
this could would work fine when we know incoming size of arrays. But in online judge test cases if array size exceed stack memory then it will lead to prob.so better declare dynamically in some cases.
@@rohitshrirame2378 thnks bro ,now I got it
th-cam.com/video/tAQIKe0UGH4/w-d-xo.html
12:03 : Problem: (s+e)/2 can result into interger overflow for edge test cases. To avoid this we use s + ((e-s)/2).
This channel is becoming the best on TH-cam
Yess!!
can you please explain merge sort with dry run. Im not getting mergesort function part.
I know recursion before but this Video series help me to understand the basics of recursion. Wow !!!!!! Amazing explanation.
kha se ho bhi job kr te ho ya coding seekh rhe ho
Apart from the content of course, I really like your way of teaching, like har baat ko ek kahani bata rahe aise karke explain karte, "Maine aapko bola ki aaj hum merge sort padhne wale hain, to aapne bola, kya hota hai merge sort ka matlab", aise type, bahut badhiya tareeka.
Thanks A Lot Bhaiya!!Suffering since 3months,Recursion ke problems ko solve karne ka bahut aacha trick Bataya
Aapne.Thank you bhaiya for such a Awsome Content..Stay safe stay Healthy
Attendance marked👍👍
No dropped a single video till now🤗🤗
Placement leke hi manege❤️❤️🙏
umang bhaii 10 mahine ho gaye kaha hoo app thoda batiaye 😊
Ho gaya Placement
Company?
😂
@@fakegmail3051Bhai aap kis year mein ho??
Bht badi help kr rhe ho bhaiya jiska ehsaan kabhi chuka nhi paege.. aap itna mehnat krte ho isse hume motivation milta hai ki humko bhi aur mehnat krni hai....love you bhaiya.... God bless you❤️
instead of(s+e)/2 we have to use s+(e-s)/2..
done with the video today.Thank you so much bhaiya❤✌
use (s+e)>>1;
@@feagy yup, this looks more efficient, it uses bitwise right shift operator to get the mid since right shifting by 1 divides the number by 2👍
Binary search (lec 12-15) , lecture 20(merge two arrays) and lecture 29(DMA) are prerequisites for this particular lecture.
It's difficult to understand for me as an ECE student. But I have come a long way and took significant days to reach this point. I can't just leave now. You teach very precisely but for me, it takes longer time to understand each concept than those of CSE. I will try my best to move forward.
Bro CSE students don't have extra brain , so don't think like that , I am also an Electronics student , so belief in yourself and let's give our best.
bruh!.
programming is nothing to do with your degree. If you are struggling then you need practice. Recursion is a hard topic compared to others. So it will take time.
th-cam.com/video/tAQIKe0UGH4/w-d-xo.html
So now did you complete all the playlist??? it's been 6 months since you left the comment here. I am just curious
@@Aryan-wl7mchave you completed? It's been 6months
Present bhaiya
Best series on u tube
Consistency level is 👍👍
Get well soon bhaiya
Present bhaiya😊
Thank you so much bhaiya ❤️
Hope your health will be better super soon 🥰
Thank You So Much BHRAATA SHREE !!!!!!
Ram Ram bhai saareya ne aaj hai humare recursion 10 day challenge ka paachva din h or hum padhne beth chuke hain full josh ke saath.
Bhaiya ki chalaki waali trick:
(s + e) / 2 //it can lead integer overflow, means that after adding s and e we may get this much bigger value that cannot be stored in int.
So let's do Chalaki
s + (e - s)/2 //another way of writing the above formula.
The effort that ur putting to create the videos is really commendable, Thank u for All the hardwork, stay safe and get better soon!
ek case m handle kr lunga or baki ka recursion smbhal lega ye step aa gaya smjh bhaiya 💫💫💫💥💥💥
Thanks for providing such quality content and consistent. Ye concept thoda fast ho gya.
11:57 If both start and end are very large then adding them can result in an interger overflow. So, to solve this we can do `start + (end - start) >> 1`
Aap bhai jordaar pdhane wale k bhi baap ho 👍 🤩🙏🏼
A lots of love 🙏🏼
ur video is teaching dsa as well as how to be consistent . get well soon bhaiya
Bhaiya far better than paid course OP
😓Sir i know recursion and i understood ur algorithm but mergeSort(arr,s,mid) and mergeSort(arr,mid+1,e) how are these sorting left and right parts i dont get it somebody plz explain friends
In first call we are sorting the left part and in second call we are sorting the right part, dry run the code you will understand
Smoothly skipped the paid promotion quickly 😊
Thank you so much sir complete semester smjh ni aya aj kr liya hai subha exam hai mera thank so much for saving me ab bht achy sy smjh agya. I'm consistently following your DSA playlist
Bhaiya mujhe Recursion ka topic aaj tk samajh hi nhi aaya tha....but....2 video Sraddha Didi ki or baki video aapki dekhne ke baad Recursion ka topic mere liye chhutkiyo ka khel reh gya hai...❤ Thanks bhaiya ❤
Great content taught by great teacher!! You are justifying the channel name as helping many students .😊
Lecture 35 attendance thank you for this amazing course
Hello ji kaise ho saare
This is love babbar ❤️
Welcome to channel codehelp
Bhaiya ye line hi Mera motivation h ek energy level humesa peak pr
Bhaiya, (s+e)/2 can overflow when both s and e have maximum possible value of integer i.e. 2^31-1.
This will result in wrong answer.
So to optimise this, we write-
int mid= start + (end - start)/2 to handle such edge cases.
Thank you Bhaiya ki aap itni achi series bana rahe hai!!!
Get well soon bhaiya
Jaldi thik ho jao aap ♥️♥️
sir, your videos are great and i reached at 35th lecture with consistency....thankyou very much babbar sir ji for creating such content
Thanks bhaiya for consistency 🥳🥳
Attendance marked 💯💯💯
Only because of your teaching style I have interest in coding.
Thank you bhaiya ❤
12:04 (s+e) more than range of interest then it throw error
To avoid use mid=s+(e-s)/2
If we use (start + end )/2 then it may happen that the sum will exceed the limit of integer hence we should use start + (end-start)/2 means in your language (code phat jayega)
What a consistency
❤🧡💛💚💙💜🖤🤍🤎
#include
using namespace std;
void selection(int arr[],int n){
//base case
if(n ==0 || n==1){
return;
}
int minindex=0;
for(int i=1;i
Present Bhaiya!
Take care of your health too!
bhaiya mn first..mmn first
consistent with day 5😎
praying for your good health
Inversion Count :
#include
using namespace std;
int merge(int *arr, int s, int e){
int mid = s+(e-s)/2;
int inv = 0;
int len1 = mid-s+1;
int len2 = e-mid;
int *first = new int[len1];
int *second = new int[len2];
int mainIndex = s;
for(int i=0; i
bhai change kaha par h??? if we see code of merge sort
Great work Brother !!!
bhaiya aap great ho the amount of dedication you are putting in the videos mai agar thoda dedication aur laga doon to shayad kuch badhiya ho jaye>>>>>>thankyou so much bhaiya>>>>
class Solution {
public:
void merge(vector& nums1, int m, vector& nums2, int n) {
for (int j = 0, i = m; j
Lecture 07: 14-09-2024
Lecture 08: 15-09-2024
Lecture 10: 18-09-2024
Lecture 12: 18-09-2024
Lecture 13: 18-09-2024
Lecture 14: 21-09-2024
Lecture 15: 23-09-2024
Lecture 16: 24-09-2024
Lecture 17: 24-09-2024
Lecture 18: 24-09-2024
Lecture 19: 26-09-2024
Lecture 20: 26-09-2024
Lecture 21: 27-09-2024
Lecture 22: 01-10-2024
Lecture 23: 03-10-2024
Lecture 24: 04-10-2024
Lecture 25: 05-10-2024
Lecture 26: 07-10-2024
Lecture 27: 08-10-2024
Lecture 28: 09-10-2024
Lecture 29: 10-10-2024
Lecture 30: 11-10-2024
Lecture 31: 11-10-2024
Lecture 32: 11-10-2024
Lecture 33: 13-10-2024
Lecture 34: 14-10-2024
Lecture 35: 16-10-2024
Start + (end-start/2) should be replaced by ((start+end) /2) bcz the sum of these can also exceed it's limit..
MergeSort with pointers.
void merge(vector &arr, int low, int mid, int high){
vector temp;
int left = low;
int right = mid +1;
while(left
the gadbad in mid=(s+e)/2 is because if s and e are big integers then it will create problem in time complexity............USE mid=s+(e-s)/2; and there it will go easy.☺☺☺☺☺☺☺☺☺☺
def merge(arr,s,e):
inv_count = 0
mid = s+(e-s)//2
len1 = mid-s+1
len2 = e-mid
l1 =[]
l2 =[]
k = s
for i in range(len1):
l1.append(arr[k])
k+=1
k = mid+1
for i in range(len2):
l2.append(arr[k])
k+=1
i=j=0
k=s
while(i
solved inversion count
int merge(int *arr, int start, int end, int& cumulative_count) {
int count = 0;
int mid = start + (end - start) / 2;
int len1 = mid - start + 1;
int len2 = end - mid;
int *first = new int[len1];
int *second = new int[len2];
int mainarrayindex = start;
for (int i = 0; i < len1; i++) {
first[i] = arr[start + i];
}
for (int i = 0; i < len2; i++) {
second[i] = arr[mid + 1 + i];
}
int index1 = 0;
int index2 = 0;
while (index1 < len1 && index2 < len2) {
if (first[index1] = end)
return;
int mid = start + (end - start) / 2;
linears(arr, start, mid, cumulative_count);
linears(arr, mid + 1, end, cumulative_count);
int answer = merge(arr, start, end, cumulative_count);
cout
if i take,mid=(s+e)/2 i that case the value of the mid will be out of range of the number that is 2^-31 to 2^31
So to solve this problem using this formula--------> e+(s-e)/2
For those who didn't get how to merge two sorted arrays, kindly watch lecture no. 20
but i didnt get how these two arrays sorted before merging
thanks bhai
@@MayankSharma08 we send the address of the first element in the array
we can use s + (e-s)/2 instead of (s+e)/2 because s+e may go out of integer range
Homework is done bhaiya-Inversion count. Thanks for your consistency.
can u plz share the code
Josh++🔥✅
Mazaa aa gaya merge sort padhke using recursion🙌🏻🤩
without using recursion kha se padha
@@whitewalker3365 Merge sort is done using recursion in the video.. lol have you watched the video?
@@sanchiagarwal4909 yeah are your working in any company or just learning programming ✌️
I sticked until last minute. I am liking it. Let's keep the josh high🔥
mili job ?
Thank You Bhaiya!
Mine Search and Sort lec about to complete....... Finally Such a relief ❤❤
Bhaiya one of the very nice recursion series
Bhot Mazedaar explanation !!! ❤️
Bahiya coding mujhe ati nhi hai utni.per apna aise padhay hai ki lagta hai kuch toh kar skata hu thanks
Present bhaiya. Hum bus apka hi wait kr rhe the
the main difficulty for me was to finding base case ; end you cleared it ; THANKS BHAIYAA
bhaiya aapke content k aapas shayd hi koii hoga 💯
Bhaiya ye wale topic pe ek aur video bnao bhot zyada ache se smjh nhi aaya ye merge sort
Now... It's look like coding is interesting ❤
why we have created the array dynamically?? we can create it statically like this arr1[len1],arr2[len2]
I liked your all videos bro . This is the one of the best platform on you tube for coding ❤❤.
jab ham mid=(s+e)/2 use karte hai to jab int 2 ki power 31 hoga to int ki range se bahar ho jayega isiliye ham mid=s+(e-s)/2 use use krte hai thank you bhaiya
Hoping for your fast recovery 🥰
Attendance Done Jai Ho🔥
I don't understand merge sort. I understand all your other videos but I didn't get this one.
Watch 3 more time
Dry run and watch animation explaination of merge sort
Bhai mna ek bar ma he samj lia kya meri placement ho sakti ha
@@Deepanshutyagi-q2m lnd smjh aya hai terko kuch
See recursion , how it works and solve merge two sorted arrays problem then you should be fine
bhaiya you are doing good and doing soo much for us thankyou for such a quality content.
jo important hai ussi ko hagg diyaa...wahaa sir ji
lecture 35 to be rewatched again 😅
#PYTHON CODE
def merge_sort(array):
#Agar array sirf 1 element ka hai tab
if (len(array)
Mid=start+(end-start)/2 use kro because we know integer ka range -2raise to powe 31 to 2 raise to power 31 minus 1 if we use mid=start+end/2 then integer ka range sa bahar chla jyggg
thank you bhaiya samajh aa raha hai bas ye wali video repeat karunga
if we implement (s+e)/2 then, there sum can go out of integer value so better to use: s+(e-s)/2;
Happy Teachers Day Sir🙏
Thank bhaiya for all of your efforts
(S+e)/2 me badi value ke liye problem create krega isliye ham s + (e-s)/2 use krte he
marking attendance tbh i havent understand the code part of vdo that much
Ye lecture thora upar upar se chala gaya😢 koi nahi pehle khud try karunga or agar phir bhe nahi howa to wapas se dekhunga complete to kerna hai kisi bhe haal m
Present Bhaiya🙋♂️🙋♂️
Commenting for better reach #dsa #lovebabbar
To the point explanation 👏
How are the two parts of array being sorted by using mergesort recursive call
Ajay Raj bhiya video editing 👌👌👌
Watch striver's video for merge sort for pseduocode
can you show the link ?? what is the name of the channel ?
Bhaiya we couldn't take mid equal s+e because it may happen sum is greater then integer limit cause overflow problem therefore we take s + (e-s)/2 in place of (s+e)/2
As usual marking Present Bhaiya.
S+(E-S)/2,AS s+e/2 will exceed the limit of integer.
It's very intresting to learn from your videos !!
Thankyou bhaiya for this amazing lecture🔥❤️
s+(e-s)/2 ....or else int limit overflow hone k chances or code fhat jaaega ♥️♥️
Great lecture sir, thankyou so much.
It was little difficult.. But bro did his best