-1

I am trying to run check50 for my code using check50 2015.fall.pset3.find helpers.c command. But it keeps giving me the following message in spite of implementing the sort and search functions correctly :

~/workspace/pset3/find $ check50 2015.fall.pset3.find helpers.c
Checking.......................................................................................................................... Unexpected end of input

Here is my Code of helpers.c :

/**
 * helpers.c
 *
 * Computer Science 50
 * Problem Set 3
 *
 * Helper functions for Problem Set 3.
 */

#include <cs50.h>

#include "helpers.h"

/**
 * Returns true if value is in array of n values, else false.
 */
bool search(int value, int values[], int n)
{
// TODO: implement a searching algorithm
int beg,last,mid;
sort(values,n);
beg=0;
last=n-1;
if(!(n>0))
return false;
while(beg<=last)
{
    mid=(beg+last)/2;
    if(value==values[mid])
    return true;
    else if(value>values[mid])
    beg=mid+1;
    else
    last=mid-1;
}
return false;
}

/**
 * Sorts array of n values.
 */
void sort(int values[], int n)
{
// TODO: implement an O(n^2) sorting algorithm
int temp;
for(int i=0;i<n;i++)
{
    for(int j=0;j<(n-1)-i;j++)
    {
        if(values[j]>values[j+1])
        {
            temp=values[j];
            values[j]=values[j+1];
            values[j+1]=temp;
        }
    }
}
}

I am not understanding whether it is a fault in my code or there is some problem on the server's side. Please help...

1

Just ran both your code and mine against the servers. It's timing out. Best advice is to wait a day or two and try again. Give the powers that be a chance to reset the servers.

1
  • That's fine. Is there anything wrong in the code or everything is alright (I mean in normal usage but not check50) ?? Jun 29 '16 at 12:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .