Skip to content

Commit

Permalink
datatype fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
holabayor committed Oct 5, 2022
1 parent d883be4 commit c2152c1
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions 0x1E-search_algorithms/100-jump.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,28 @@
* jump_search - function that searches for a value in an array
* of integers using the Jump search algorithm
* @array: pointer to the first element of the array to search in
* @size: number of elements in array
* @size: sizeumber of elements in array
* @value: the value to search for
* Return: first index of the value, else -1
*/

int jump_search(int *array, size_t size, int value)
{
int n = size;
int step = sqrt(size);
int i, j;
size_t step = sqrt(size);
size_t i, j;


if (array == NULL)
return (-1);
for (i = 0; i < n; i += sqrt(size))
for (i = 0; i < size; i += sqrt(size))
{
printf("Value checked array[%d] = [%d]\n", i, array[i]);
if (array[i + step] >= value || i + step > n)
printf("Value checked array[%lu] = [%d]\n", i, array[i]);
if (array[i + step] >= value || i + step > size)
{
printf("Value found between indexes [%d] and [%d]\n", i, i + step);
for (j = i; j < n; j++)
printf("Value found between indexes [%lu] and [%lu]\n", i, i + step);
for (j = i; j < size; j++)
{
printf("Value checked array[%d] = [%d]\n", j, array[j]);
printf("Value checked array[%lu] = [%d]\n", j, array[j]);
if (array[j] == value)
return (j);
}
Expand Down

0 comments on commit c2152c1

Please sign in to comment.