Hello. My deleteItem and insertItem functions are not working: when you try to delete an item from the array it says "the item is not in the list"...and when you try to insert an item, it does nothing but spit back 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 back to you when the display function is called. Any help would be appreciated in figuring this out. I believe the linear and binary search functions are OK, for what it's worth. Thank you.
Hey I think my code right now is not executing from line 18 and skipping to the else statement. What should I do so that I don't say "good bye" to the sorted property?
Also I deleted the while loop and the location++ without any problems so I think you were right.
I updated my code, but it's not displaying the right deleted number and not putting things in ascending order. How can I fix that? Thanks for the help...anyone?
int SortedList::linearSearch(int item)
{
int location = 0;
while ((item >= numbers[length]) && (location < length))
location++;
return location;
}
test your functions
you check `item' against the same element several times. Moreover, that element (numbers[lenght]) is invalid, as it is outside the "used" range
if the item is not present, `binarySearch()' returns a value that is indistinguishable of a found case.