0
bool search(int value, int values[], int n)

// TODO: implement a searching algorithm
    if (n >= 0)
    {
        for (int i = 0; i < n; i++) 
        {
            if (values[i] == value)   
                return true;
        }
    }
return false;

Very confused.
1. When I make the program, do I "make helpers" or "make find"? Or does it even matter for this part, because I'll be typing ./generate 1000 50 | ./find 127?
2. Why do a linear search inside a bool search? What is a bool search? What's the difference between it an a linear search?
3. The short on this sucks - their code uses colons, and doesn't include semicolons in the right spots (I think).
4. Does it matter if I type "true" or "TRUE"?
5. Why is this code not working when I type ./generate 1000 50 | ./find 127?

1 Answer 1

0
  1. The way to compile the program is make find It will locate all of the files used in the program based on the rules that reside in the Makefile file. You should review the class material on make and compiling.
  2. bool is not the type of search that you are doing, it is the type of the value returned by the function when it finishes - a boolean, or a true/false variable. A linear seaarch starts at the beginning of a list and moves through it from end to end, or linearly, until it either finds the target or the end. BTW, you'll be doing a binary search next.
  3. QED
  4. I suspect that TRUE or FALSE will give you an error. THe lower case versions are the ones declared in
  5. No idea why it doesn't work. Can't see enough of the code and my crystal ball is in the shop.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

You must log in to answer this question.

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