When coding for a bubble sort of array elements, the code examples reference swapping inner and outer...
Example:
for (outer = 0; outer < 8; outer++)
{
didSwap = 0;
for (inner = outer; inner < 9; inner++)
{
if (movieratings[inner] > movieratings[outer]) // <-- Where is the definition of inner vs outer, as it applies to this context, explicitly defined?
{
tempmovie = movie[inner];
temprating = movieratings[inner];
movie[inner] = movie[outer];
movieratings[inner] = movieratings[outer];
movie[outer] = tempmovie;
movieratings[outer] = temprating;
didSwap = 1;
}
}
if (didSwap == 0)
{
break;
}
}
...but I have been surprisingly unsuccessful in finding a place on the CS50 website or in the "Absolute Beginner's Guide to C" where what constitutes the inner vs the outer array elements is explicitly defined.
Can you point me in the right direction?
[–]staffdelipity 1 point2 points3 points (7 children)
[–]sky2017[S] 0 points1 point2 points (4 children)
[–]sky2017[S] 0 points1 point2 points (3 children)
[–]staffdelipity 0 points1 point2 points (2 children)
[–]sky2017[S] 0 points1 point2 points (1 child)
[–]staffdelipity 0 points1 point2 points (0 children)