Questions tagged [find]
The find tag has no usage guidance.
189 questions
4
votes
1
answer
532
views
pset3 find INT_MAX
In find.c, there's a conditional that references a constant called "INT_MAX". I looked through all the pset files and couldn't find any reference to this constant. What is it, what does it represent,...
3
votes
2
answers
691
views
My pset3 find code completes all tasks using check50, but gradebook says it's wrong
I can't seem to figure out why the CS50x gradebook says that my find code is wrong but when I check the exact same code using check50, I get all smileys.
I did everything as per instructed. I ...
2
votes
3
answers
357
views
pset3 FIND: Strange clang error whenever I compile code
I'm coding binary search in helpers.c currently, but I receive a strange clang error every time I try to compile code. I'm absolutely sure my code is logically and syntaxily correct. Where am I going ...
2
votes
2
answers
516
views
Find.c does not find the value that I put in haystack
For pset3, I have to download pset3.zi and unzip it.
I followed all the steps in the instruction. However, when I get to the program find.c, there's a problem.
The program seems like not working ...
2
votes
1
answer
170
views
Pset3 search: can't seem to find the last number
Everything else in check50 works, but my program can't find 42 in {40, 41, 42} and {39, 40, 41, 42}.
I don't think it's sort's fault, and I've implemented search in the correct way (I think, at ...
2
votes
1
answer
1k
views
How does find.c know to use functions from helpers.c?
I've been beating my head trying to understand the second assignment for pset 3. It states in part:
Notice that find.c calls search, a function declared in helpers.h.
Unfortunately, we forgot to ...
1
vote
1
answer
4k
views
How to Fix "control may reach end of non-void function" and "No such file or directory" Errors?
When I compile find, I get this error message
error: control may reach end of non-void function
When I then try to run the program
./find 14
I get this error message
bash: ./find: No such file ...
1
vote
1
answer
76
views
pset3 find: seg fault (int array won't initialize to 0s)
Ok so I made what I believe is a counting sort. I first wrote it in Java just to test it, and it works there, but when I transferred it to CS50 IDE (of course, I modified it slightly to C syntax) it ...
1
vote
2
answers
18k
views
pset 3 GDB: "no executable file specified"
I've been working my way through CS50 and I'm having a problem I hope someone can help me with. I can't get GDB to function at all, and I think it might be a problem with startup - when I type "gdb" ...
1
vote
1
answer
22
views
Find's sort: instructions vs code: O(n) or O
The docs for find's sort say,
The running time of your implementation must be in O(n), where n is the array’s size. Yes, linear! Keep in mind that 65,536 is a constant.
However, the code that we'...
1
vote
1
answer
11
views
Minor typo in cs50ap find docs?
From the docs on find
If you do plan on using additional functions in helpers.c, be sure to include the function prototypes in helpers.c.
I think that last helpers.c, should be helpers.h?
1
vote
1
answer
62
views
Update for the IDE stopped programs from getting compiled [duplicate]
I updated the CS50 IDE and was not able to make 'find' in pset 3. It was working before I updated the IDE.
The error it gives is:
$ make all
clang -ggdb3 -O0 -std=c11 -Wall -Werror -o find find.c ...
1
vote
2
answers
104
views
Binary Search Pset 3 help
As my question is titled, I would appreciate help with my binary search, shown below. Currently, the search will always return false. I am almost certain that my sorting algorithm is correct, as it ...
1
vote
1
answer
423
views
pset3 find/helpers check50 error
When I run find, it reports that it finds the value when it's in the haystack, and reports that it didn't find it when it isn't. (i.e. it works according to the specification).
make find
works with ...
1
vote
1
answer
215
views
Segmentation fault core dump with find and helpers.c
I have been working on find.c for the last three days, without success. When I run check50, 50% of the time it compiles helpers.c but then does not find 42 as it is supposed to. The other 50% of the ...
1
vote
1
answer
7k
views
What does "error in backend: IO failure on output stream" signify?
I altered the code in helpers.c in such a way that when the difference between the find value and the "haystack" value equals zero the program returns true.
However find will no longer compile and ...
1
vote
1
answer
527
views
segmentation fault on binary search
Can anyone tell me how to stop segmentation fault from happening in my binary search? I am trying to implement a recursive binary search and it works when it finds the needle in the haystack but if ...
1
vote
0
answers
126
views
Pset3 find grade 0
My Pset3 has been graded and I received a 0.6 score. I got a full 1.0 for fifteen, but 0 for find. I think I have submitted the files correctly - I can see all the files in the files folder, and ...
1
vote
1
answer
236
views
expected output not standard error
In pset3's find. I have implemented Binary search. Everything works fine when I test it. But when I test it with check50, the last test fails saying: \ expected output, not standard error of "/opt/...
1
vote
1
answer
1k
views
How to use swap?
I am currently in pset3, implementing sort. I chose to do selection sort and at the end of it I need to swap the numbers, but when I try to compile, I get this message:
implicit declaration of ...
1
vote
1
answer
380
views
How do I check pset3 find?
I think I've finished find.c, but I'm not quite sure how to check it. For example, one of the things it must do is find 42 in {42, 43, 44}, so how do I enter this into the terminal window? Do I use ...
0
votes
1
answer
367
views
pset3/find check50 frown helpers.c compiles. expected exit code 0, not 1
When checking my find program with check50 I get a :( frown at the second check, which is:
helpers.c compiles. expected exit code 0, not 1
The log file gives me additional info:
running clang -...
0
votes
1
answer
37
views
Pset3 The file compiled but can't find the needle
The file compiled but can't find the needle. I have read other relevant posts inside which the logic of their code is quite similar to mine, but still haven't figured out where my code is wrong.
bool ...
0
votes
2
answers
3k
views
Pset 3 - Find and Helper.C
Question about find and helpers.c. When I run check50 on my code, I get the following error below:
:( doesn't find 42 in {39,40,41}
\ expected an exit code of 1, not 0
:( doesn't find 42 in {39,...
0
votes
1
answer
145
views
pset3 bubble sort
pls could anyone tell me where have i made the mistake?...as i have tried to find it myself but couldn't find it.
void sort(int values[], int n)
{
int min=0,max=0;
do{
//to compare ...
0
votes
2
answers
163
views
Binary Search for helpers.c
so as the title suggests I am having some trouble with my implementation of binary search. So based on the logic shown in the lecture, I think my implementation is fine, indeed it works for the cases ...
0
votes
2
answers
161
views
Segmentation Fault pset3 for Find
I'm getting a segmentation fault error and I can't figure out why.
void sort(int values[], int n)
{
// TODO: implement a sorting algorithm
for (int i = 0; i<n; i++)
{
if ((n!=i+...
0
votes
1
answer
29
views
PSET3:Find: Code works without the function, doesn't work with the function
So I am working on Selection Sort for Find, Problem Set 3.
When I use a function I made called swap to exchange the values, the array is not sorted. Function snippet:
if (min != i)
{
swap(values[...
0
votes
1
answer
206
views
pset3 "Find" Seg fault issue?
So im running into a strange problem. This is on the "Find:More" PSET3 problem. When I run the program such as:
./generate 1000 50 | ./find 127
or
./generate 1000 50 | ./find 128
the ...
0
votes
1
answer
78
views
WHAT is wrong with this small bool snippet? PSET3. It always returns true. Even if the needle is not in the haystack
bool search(int value, int values[], int n)
{
int p;
if(n<=0)
{
return 1;
}
for(p=0;p==n;p++)
{
if(values[p]==value)
{
return 0;
break;
}
...
0
votes
1
answer
120
views
pset3 - Binary search not finding the element in middle
Binary search doesn't seem to find the element in middle.
int binary_search(int value, int values[], int n) {
int low = 0;
int high = n-1;
while( high >= low )
{
int mid = (...
0
votes
2
answers
57
views
There is something wrong with my keyformula in vigenere cipher, and error message: expected expression
I red all the questions with the code about the same issue but I can't figure out what is wrong with my code. When I use the command ./generate 1000 50 | ./find 127 I get: Didn't find needle in ...
0
votes
1
answer
106
views
Pset3 Sorting Help a bit of out of the scope
I was doing the sorting part and was having trouble in figuring out what file to compile as to check if my code is correct for bubble sort or not. So started searching here and someone posted here ...
0
votes
2
answers
302
views
find.c Compiling in my machine but not while doing check50
My code for find.c is working fine. I checked with other examples other than on the problem set. I implemented binary search using recursion and changed the search function to include beginning and ...
0
votes
2
answers
170
views
Selection sort does not sort the unsorted portion once no swapping position is reached?
I've been struggling with this bug for almost 2 days, but so far no success.
If anyone could point out what is wrong with my code, I would appreciate it very much.
Using my own random numbers (100, ...
0
votes
1
answer
147
views
PSET3 - Find (More) - Debugging and bubble sort issues
Pset 3 (2017): create program, find, that finds a number in an array of generated numbers. We need to implement functions for both sorting and searching the array using helper files. Since a binary ...
0
votes
1
answer
35
views
Check50 for find less tries to compile sort.c
the find and generate functions both compile and produce correct output. But when it comes to check50, I get this message:
I go and check the URL provided that shows which commands were being run ...
0
votes
1
answer
38
views
find problem with my code - CPU overload
I cannot figure out what is wrong with my code.
/**
* Returns true if value is in array of n values, else false.
*/
bool search(int value, int values[], int n)
{
// ensures that the n is non ...
0
votes
1
answer
56
views
CS50 pset3 find - Error: expected identifier, unused parameter
I am working at pset3 find - helpers.h.
The file compiles but I the command line is yelling at me:
I was searching the web for hours but cannot find the reason for these errors.
Help is much ...
0
votes
1
answer
22
views
pset3 Find: Getting compilation error when running "make find"
/**
* find.c
*
* Computer Science 50
* Problem Set 3
*
* Prompts user for as many as MAX values until EOF is reached,
* then proceeds to search that "haystack" of values for given needle.
*
* ...
0
votes
1
answer
40
views
Pset3 Find: Odd bug in binary search, some times works, sometimes I am stuck in a loop
I have a bug in this binary search code that I can't get to the bottom of. Sometimes the code works, and sometimes it just goes into an endless loop. I think I must be close, but any tips where I am ...
0
votes
2
answers
246
views
PSET3 find having trouble. Can someone help?
For some reason bubble sort is not working. Can someone help.
binary search bool search (int target, int array[],int length)
{
int end = length-1; int start = 0;
while (array[start] < ...
0
votes
1
answer
625
views
CS50 Helpers.C Find Less, No Idea What's Going On
Final Code:
/**
* helpers.c
*
* 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 ...
0
votes
1
answer
43
views
PSet3 Find (more) said to assume that array's numbers are non-negative
When I ran the check50, all the values were green except:
:( sorts {10,-6,4,8,7,-3}
expected "-6", not "\n4\n7\n8\n10\n..."
The pset said to assume that the array's numbers are non-negative. Is ...
0
votes
1
answer
72
views
pset3: sort and search work in separate files, but my helpers.c doesn't work
I dealt with sorting in a separate file first, and then I dealt with searching in another file. They seem to work okay or at least worked for the numbers I feed in, but when I put them in helpers and ...
0
votes
1
answer
170
views
pset3 find- check50 Why doesn't find returns frowning face
I am not sure where I have gone wrong with helpers.c. I passed all check50 tests except for 2 under "doesn't find".
My code is below:
code removed
What check50 returns is as follow:
:) helpers.c ...
0
votes
1
answer
67
views
pset3, find (more comfortable), use of undeclared identifier 'MAX' error
I am trying to initialize an array for counting sort in helpers.c
int count[MAX] = {0};
If i try to compile by typing "make all", i get an error message
helpers.c:52:15: error: use of undeclared ...
0
votes
1
answer
68
views
Find.c - Binary Search probable integer overflow
Here's the gist: https://gist.github.com/Securiteru/a83e4f1a028acd0b1013def793b5dcdc
And the output:
... 60697 61151 61190 61275 61460 61608 61618 61746 61750 61822 62111 62178 62183 62311 62448 ...
0
votes
1
answer
98
views
Pset3 counting sort - segmentation fault error
I am trying to implement a counting sort function for Pset3 find (more comfortable), and have written up the code below:
void csort(int values[], int n)
{
int limit = 5; // CHANGE LIMIT HERE
...
0
votes
1
answer
94
views
PSet 3: binary search help
My program is almost working, I just cannot figure out why my binary search is not working. I am pretty sure that the sorting is fine. Any help would be appreciated.
check50:
:) helpers.c exists
:) ...