# Questions tagged [linear-search]

The tag has no usage guidance.

24 questions
Filter by
Sorted by
Tagged with
957 views

### PSET3 LINEAR SEARCH

Please help me with this: My code for linear search: // To check n is a positive int. if (n<0) { return false; } // To check if value can be found in values array. if values is found return ...
50 views

### How to create an input for the search function?

I am trying to test my search function by creating a separate function that takes an input [some integer] and then checks whether that integer fits within the given array [numbers 10-19]. I made the ...
161 views

### Pset3 Linear Search (control may reach end of non-void function)

This seems pretty simple, but I'm not sure what I'm doing wrong. Thanks in advance for helping! bool search(int value, int values[], int n) { if (n >= 0) { for (int i = 0; i <= n; i++...
292 views

I'm doing pset3 and I seem to have a functioning linear search. But I can't find my "needle" if it's in a higher array position than 331, which is where 127 is (I've copied the output of "generate" to ...
52 views

### Caesar: Validating the key - stuck

I am stuck with Caesar, validating the key. Before i use the atoi function, I want to check if argv consists of digits. I watched the linear search movie but is is to cryptic for me. I have to ...
49 views

### Linear find function always finding needle in hay stack and generating multiple numbers

I wanted to start simple with a linear search in the helper.c function: bool search(int value, int values[], int n) { // TODO: implement a searching algorithm for (int i = 0; value < n; i++) { ...
64 views

### Pset 3 Helper: Linear search function implem/ header file won't compile

I just tried to compile this file(helpers.c), as a function implementation that is already included as a header for the main programme(find.c). I am not sure what else to do anymore, I have tried ...
16 views

### Why am I generating the following errors with this code if it says it's compiled correctly?

The code compiles, and based off what I've seen in the linear search video, this should work. Tad bit confused why with this code below this error, I'm getting this error. In function `_start': (....
59 views

### pset3 linear search not working

So I've started working on pset3 after a long break, I couldnt even start making a binary search function. Tried to do a linear search function but it doesnt seem to work when i run "./generate 1000 ...
366 views

### Cannot find the needle 127 in the haystack of 1000 random numbers using linear search . Any ideas on what I may have done wrong?

I'm having a bit of difficulty in compiling the helpers.c program. Specifically when I try to check the correctness of the program, it seems it cannot find the needle 127 in the haystack of 1000 ...
512 views

### Linear Search not working

Alright, so, I'm not quite sure what's going wrong here, but maybe you people could help. My implementation of linear search in pset3 will return false no matter what (well, specifically I've only ...
42 views

### I have written a linear searh algorithm. How do I test it to see that it works?

This is my linear search code. How do I test it to see if it works? /** * helpers.c * * Computer Science 50 * Problem Set 3 * * Helper functions for Problem Set 3. */ #include <cs50.h> ...
115 views

### PSet 3 Helpers/Find Compile Error

I started changing "helpers.h" to implement a linear search. I have not changed generate.c or find.c. #include <cs50.h> bool search(int value, int values[], int n); { for(int i = 0; i < n;...
54 views

### PSET 3 Linear Search Error

Keep getting the error of "control may reach end of non-void function" This is for the linear search, can someone please give me some help/tips into getting this error to go away? This is my code: ...
34 views

### search not compiling -

I want to just see if the search part of helpers.c works, but upon compiling, I get a really long error: this goes on for about 20 lines. Not sure what to do. I read through other posts, tried make ...
795 views

### pset3 helpers.c linear search confusion

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) ...
91 views

### Why isn't my linear search working correctly?

I cannot get my linear search programm to work and it seems to be a problem with the return of false if the needle is not found. My coding for the search is bool search(int value, int values[], int n)...
86 views

### My linear search can't find any values. Why?

Here's the code for my pset 3, which fails to find the '127' in the stack. Any hints will be massively appreciated: bool search(int value, int values[], int n) { for(int i = 0; i < n; i++) ...
126 views

### Pset3 - working on linear search

I'm currently working on adding the linear search and receive the following error when I try to compile... Also, when changing the code for helpers.c, is it necessary to compile that file or just ...
74 views

### Control may reach end of non-void function [duplicate]

I have read the following and am still unable to answer my question: How to Fix ācontrol may reach end of non-void functionā and āNo such file or directoryā Errors? Error: control may reach end of ...
249 views

### pset3 - Linear search wont work at all

So, I'm currently stuck on pset3. I'm doing the linear search coding on helpers.c but it doesn't seem to search for the needle in the hay stack. It is behaving quite weird. If i run ./generate 1000 ...
806 views

### linear search compilation error

I've updated search function in helpers.c with code below. I had to remove reference to helpers.h since that was causing even more errors. #include <cs50.h> // #include "helpers.h" bool search ...