Hot answers tagged

1

The following two points might clear your confusion. The pseudocode in the book is following $1$ based indexing. Your code is following $0$ based indexing. Your code is technically doing nothing in the first iteration of the while loop. In the first iteration $i = 0$, therefore $j = -1$. Since $j<0$, the inside while loop is not executed. And it keeps $...


Only top voted, non community-wiki answers of a minimum length are eligible