Height Balanced Tree Build From An Arr

im getting segmentation fault plz check my code

add one more condition
if(s==e) return root;
Modified Code

i hope this helps
if yes hit a like and don’t forgot to mark doubt as resolved
if you have more doubts regarding this feel free to ask

see if s==e then mid is also s (mid= (s+s)/2=s)
now look at left call
you call form s to mid but now mid=s
so it stuck in infinite loop from s to s every time

also your condition is also not correct
correct left call is
root->left = hbtBuildFromArr(arr, s, mid-1);
now you need not to use that condition
if(s==e)return root no need for this

Modified Code

hope this is clear now
if yes hit a like and don’t forgot to mark doubt as resolved
if you have more doubts regarding this feel free to ask

i think your doubt is resolved

so please Mark doubt as resolved for your side it’s important


plz check it
que
https://hack.codingblocks.com/app/practice/2/1069/problem