Questions tagged [find]
The find tag has no usage guidance.
189
questions
0
votes
1
answer
47
views
Is this a correct way of implementing bubble sort?
I made a bubble sort code, but I want to make sure that my code is correct. My code is
void sort(int values[], int n)
{
if (n == 1) {
return 0;
}
int swapcount = 0;
...
0
votes
1
answer
25
views
next step after I made sort and search to make find work as mentionned in homework
please, I'm lost what to do next, after coding search and sort. what do i have to do to change haystack [] ?Do I have to change code in generate ? in find ? both ? is it something I have to add in ...
0
votes
1
answer
30
views
link generate.c and helper.c
please help me understand what I'm missing... why I don't have any random numbers when I enter : ./generate 10 | ./find 10 (well that the same result I have when I entered ./generate 1000 50 | ./find ...
-1
votes
1
answer
37
views
generate doesn't work - find ps3
please help me find out what's wrong with the generate function because I the same result : Usage: ./generate n [s] even if I enter an argument or even change the code ? Here is the generate code : `#...
0
votes
1
answer
29
views
Weird output compiling find
I started my code for sort, on pset 3 find, and when I try to compile it, I get an output i've never seen before, it outputs
clang -fsanitize=integer -fsanitize=undefined -ggdb3 -O0 -std=c11 -Wall -...
0
votes
1
answer
37
views
In find, I print the array before sorting it, The last number it prints out is always consistent but unrelated to the problem
It continuously prints 2147483647 as the last number of the haystack, even when I use a different seed or no seed at all. Does anyone know why?
0
votes
1
answer
35
views
pset3- find killed by server in check50
I am not sure why my code is causing the check50 to be 'killed by server' in 2 checks (below) all other checks work out correctly. :)
:( doesn't find 42 in {39,40,41,43}
\ killed by server
:( ...
0
votes
1
answer
79
views
pset3 find, failing half the checks!
so currently doing pset3 & i think my sort function is all good (i've printf'd each value & it's all in the right order), but when trying to implement binary search it's failing half the tests ...
0
votes
2
answers
130
views
bubble sort and linear search
As suggested I start with linear search to make sure the bubble sort is working. When I test my code as mentioned with ./generate 1000 50 | ./find 127, the result I have is:
haystack[0] = Retry:
...
0
votes
1
answer
38
views
pset 3 - killed by server problem
I understand my problem is with infinite loops but I would like some guidance on solving it. I am not sure if I should use a for - as I tried doing on comments - or if there is a better/more efficient ...
0
votes
1
answer
23
views
PSET3: Search Finds 0 when it doesn't exist in values
I have a file containing sorted numbers 1 to 20, on which I run the search. It finds 0 when it's not in the values. Why is this?
When int end = n; is used, 20 isn't found. However, when I use int end ...
0
votes
0
answers
84
views
pset3 why did this cause a segmentation error but only sometimes with same input?
So I was running into an issue with my counting sort algorithm throwing segmentation errors sometimes.
The offending code:
while (count < n)
{
while (counting_array[j] > 0)
{
...
0
votes
2
answers
157
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
1
answer
30
views
How to fix z++ in for loop not increasing the value of z?
I have the following code:
for (int x = 0, w = 50; x <= w; x++) {
if (count[x] > 0) {
for (int y = count[x], z = 0; z < y; z++) {
values[z] = x;
eprintf("%...
1
vote
2
answers
103
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 ...
0
votes
1
answer
134
views
Segmentation fault on pset3 (find : more comfortable)
My program got a problem when I used this command './generate 1000 50 | ./find 127' which generating random number to run it. It shows "Segmentation fault", but it works fine when I type the input ...
0
votes
2
answers
99
views
pset3 - find Why do we need a limit at 65535 to pass check50?
While debugging locally, the program executes as expected, tested with random inputs and the check50 proposed inputs. When uploading by using check50, it returns the following, never finding 42 :
~/...
0
votes
2
answers
160
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
16
views
helpers.c output error
Why is this program not returning true when value is in values?
bool search(int value, int values[], int n)
{
// TODO: implement a searching algorithm
int start = 0; int end = n-1; int k = 0;
//...
0
votes
1
answer
42
views
Error in helpers.c
I'm stuck with my pset3 helpers.c function, I'm getting the following error when I compile without the last return statement
error: control may reach end of non-void function [-Werror,-Wreturn-type]
...
0
votes
1
answer
1k
views
Assigning an empty array with malloc has a random number in it
Im trying to debug why my helpers.c in the find pset is not working perfectly. I kept getting random large numbers in my array and I kept going up the ladder in the function to the point of ...
0
votes
1
answer
126
views
pset3 helpers.c (help)
:( finds 42 in {39,40,41,42}
\ expected an exit code of 0, not 1
( it meaning I missing or have a return error??? )
bool search(int value, int values[], int n)
{// ...
0
votes
1
answer
38
views
How does exactly generate.c deliver its output to find.c?
" For instance, the command below passes 1,000 pseudorandom numbers to find, which then searches those values for 42."
./generate 1000 | ./find 42
How come generate.c passes pseudo-random numbers to ...
0
votes
1
answer
29
views
diificulty in pset3
what's problem with my code, getting following errors when running check50.
here is my code
0
votes
1
answer
45
views
Pset 3 find less comf. I'm trying to test my bubble sort but having IDE CPU related issues
I think i figured out my bubble sort so far. However, if I try to test my implementation with ./find (I added a printf in helpers to get the sorted array) , the IDE doesn't allow me to input more than ...
0
votes
1
answer
24
views
i am always getting "did not find the needle" as the output. can anyone tell me what is wrong with my code?
bool search(int value, int values[], int n)
{
int start = 0;
int end = n;
if(n<=0)
{
return false;
}
if(n>0)
{
...
0
votes
1
answer
666
views
pset3 find less comfortable helpers.c didn't found the needle!
bool search(int value, int values[], int n)
{
int left = 0, right = n - 1;
// TODO: implement a searching algorithm
while (n > 0)
{
int middle = (left + right) / 2;
if (value == middle)
...
0
votes
1
answer
676
views
cs50x pset3 find - Need help with the counting sort
can someone please look at my code and tell me where I went wrong with my counting sort algorithm (Or binary search algorithm, if that's where the problem lies...?). Please and thank you.
Binary ...
0
votes
1
answer
59
views
please help me with this binary search
for some reason this binary search code keeps returning true, when providing the haystack from generate.c, even if the "needle" isnt there. when manually inputing the haystack, the code runs perfectly....
0
votes
1
answer
617
views
pset3: expected an exit code of 0, not 1
I'm getting this error in some of my checks.
Here's my code:
bool search(int value, int values[], int n){
int mid, left, right;
left = 0;
right = n - 1;
while (left != right){
mid = (right + ...
0
votes
1
answer
29
views
C : error non-void function search - value (find)
I'm getting error non-void function search should return a value. If I add anything else to last return, such as false 1 or zero, the errors multiply. I've tried moving the indentations as well as ...
0
votes
1
answer
95
views
Pset 3: Find (more comfortable) - child exited with status 255 & exits with wrong code
I ambitiously decided to try the more comfortable version of this task, although I'm very much "less comfortable" with regard to any computer skills... Before I give up, I'd like to ask you what's ...
0
votes
1
answer
514
views
pset3 find more comfortable
i had written the C code for sort and search it is not working yet
my code for helper.c is
/**
* helpers.c
*
* Helper functions for Problem Set 3.
*/
#include <cs50.h>
#include "helpers.h"...
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 ...
0
votes
1
answer
21
views
1, red smiley with pset3 helpers, need help
Im so close to completing this program and i just need someone to look over it and tell me whats wrong. Im getting close to my wits end but if they could help me i would send them my code to look at ...
0
votes
1
answer
66
views
pset3 - find less / sort video availability
Is anyone else having issues with the sort video for pset3, under find, less comfortable?
URL is:
http://docs.cs50.net/problems/find/less/find.html, which points to: https://www.youtube.com/watch?v=...
0
votes
1
answer
70
views
PSET 3; Find, Helpers.c
So this is the begining step ive taken towards completeing the searching algorithm in helpers.c. What I wanted to know is if im heading in the right direction based off my code so far.
bool ...
0
votes
1
answer
544
views
What is const int?
Can anybody explain What is const int and How it works? It was used in the following code of the find.c
The program is as follows:
/**
* Prompts user for as many as MAX values until EOF is reached, ...
0
votes
0
answers
218
views
PSET3 \ expected an exit code of 0, not 1 (find.c)
I successfully built my program and went on to check it using check50 only to discover this
:) helpers.c exists
:) helpers.c compiles
:) finds 42 in {42,43,44}
:) finds 42 in {41,42,43}
:) finds 42 ...
0
votes
1
answer
57
views
pset3, 'Find' problem. Can't figure out what is wrong with my code
Have been solving pset3 'Find' problem for a week now. My code seems fine to me, but apparently, it is not. When I input './generate 1000 50 | ./find 127' into command line it says: 'Didn't find ...
0
votes
1
answer
95
views
Pset3 Find - Not sure what is wrong with helpers.c code
I am not sure what is wrong with the code. It seems to work on some of the criteria when using cs50's check50, but does not work on others. There also does not seem to have a pattern about the wrong ...
0
votes
2
answers
83
views
Pset3 - Find: I can't find what's wrong with my sorting algorithm...?
I have an issue with the "find" problem. When I test my program, it seems to get stuck in an infinite loop (nothing is prompted, there is just a blank space and I have to kill the program with ctrl c)....
0
votes
1
answer
27
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
36
views
Haystack not found
Hi can someone help me out the code "./generate 1000 50 | ./find 127" doesn't find the haystack. And I even removed the "./find 127" and went through the generated numbers but still didn't see the ...
0
votes
1
answer
49
views
Binary search implementation help please
I'm having a ton of difficulty implementing a binary search. I know killed by server has to do something with the while loop, I just cant seem to pinpoint it. Also, I'm not sure why it is not finding ...
0
votes
1
answer
116
views
CS50 pset3 helpers.c binary search() func problem
It seems that I have problem with recursive function call, I am not sure how to make it work, testing with ./generate 1000 50 | ./find 127 gives me segmentation fault. I believe the problem is within ...
0
votes
1
answer
43
views
find.c in Pset 3; int straw = get_int(); ./generate 1000 50 | ./find 127; Why I can't see this pseudorandom numbers?
How can I supplement this code printf("\nhaystack[%i] = ", size);that I can see the actual pseudorandom numbers that each i-th[] contain inside itself after haystack[1000] = using this command ./...
0
votes
1
answer
64
views
find.c in Pset 3; int straw = get_int(); ./generate 1000 50 | ./find 127; From where and how it takes 1000?
In the find.c there is the following code
for (size = 0; size < MAX; size++)
{
// wait for hay until EOF
printf("\nhaystack[%i] = ", size);
int straw = get_int(); // ?...
0
votes
1
answer
23
views
working with Find
Below is my code that gets values from a user and implements bubble sort to arrange the values in ascending order.
/*Code for implementing bubble sort
which arranges given values in ascending order*/
...
0
votes
1
answer
205
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 ...