void search(int array[] , int length)
{
int min = 0;
while (min <= length-1)
{
int index = min+1;
if array[min] >= array[index]
{
min = index;
min++;
index++;
else if ((index == length-1))
{
min++;
index = min+1;
}
else
{
index++;
}
printf ("%d", array[min]";
return;
}
}
}
I realize this code is not the nices, but wIll this code work? The code is for pset3 selection sort?
-
Haven't you tested your code? Maybe print out the sorted list to see if the target is present? Please review the following link, particularly the sections on naked code drops and code reviews.– Cliff BCommented Aug 27, 2017 at 22:24
Add a comment
|
1 Answer
In short, no, it won't work. It may or may not find the target in the list, but since it returns void, i.e., it doesn't return anything, it will never say if it found something or not.