i did not understand yhe condition j>=0 and arr[j]>e
I did not understand yhe condition j>=0 and arr[j]>e
hello @Aditya-Kushwaha-914550392281281
we are comparing element value at j index with the value of new element we want to insert.if arr[j] > e it means arr[j] should come after e . therefore we shift arr[j] . one position to its right.
condition j>=0 is to make sure that our j is not negative (i,e index is not negative)
will u plzz dry run on example 1 2 3 4 5 in which these 5 elements are sorted and we have 0 in last we have to insert . plzz send a snap of it
pls refer this for dry run.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.