Questions tagged [find]

The tag has no usage guidance.

42 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
1
vote
0answers
123 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
1answer
228 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
1answer
562 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 ...
0
votes
1answer
44 views

pset3 find code works, despite 'sort' failing

I'm very confused! I have spent many (MANY) hours working through this pset. I've gotten to the point where my code passes all check50 requirements for 'find', but it's failing the 'sort' ...
0
votes
1answer
35 views

pset3 keeps returning 1 even when it should return 0

bool search(int value, int values[], int n) { // TODO: implement a searching algorithm if (value < 0) return false; int s = 0; int e = n - 1; int m = ((s + e) / 2); while (s <= e) { ...
0
votes
1answer
57 views

CS50 Pset3/less check errors

Hi I am very frustrated since 5 days that I cannot pass check50 that keeps giving me error as: Does anyone have any suggestions? :) helpers.c exists. :) helpers.c compiles. :( sorts {5,4,3,2,1} ...
0
votes
1answer
28 views

Error with fifteen?

I am taking the Harvard ap cs5o class, and I just started the pset3's fifteen. I followed the directions to get the skeleton code from here: Problem scope After reading and following along I tried ...
0
votes
0answers
134 views

Pset 3 !! Find (less) !! Need help, please

this is my code (find.c) : #include "helpers.h" const int HAY_MAX = 65536; int main(int argc, char * argv[ ]) { if (argc != 2) { printf("Usage: %s need\n", argv[0]); return ...
0
votes
1answer
31 views

pset3 code not finding any numbers when in helpers.c

// TODO: implement a searching algorithm if(n <= 0) { return false; } int end = n; int start = 0; int middle = (start + end)/2; int found = 0; while(found == 0) { if(value == values[...
0
votes
1answer
198 views

Need Help In Merge Sort

From last couple of days I am trying to write code for Merge sort. I have completed Week3 lectures and trying to solve pset3. Need some help in my code for merge sort. The code seems to work fine with ...
0
votes
1answer
48 views

Check 50 for find

I have gotten most of my code to work for the search and sort, but I still have a few issues. One is i my for loop, I have it set to less than 100, though I need to make it less than log n, but I ...
0
votes
1answer
28 views

Binary search recursing issue

I've been working on a binary search of pset3 find, and I'm having an issue when I call the function again recursively. I believe that I know what the issue is, I'm just not sure how to fix it. When I ...
0
votes
1answer
132 views

How does one print out all existing integers in an int array?

The code below generates the following error: format specifies type 'int' but the argument has type 'int *' [-Werror,-Wformat] printf("%i", array); include include int main(void) { int ...
0
votes
2answers
104 views

Help finding segmentation fault

In my code, I get a segmentation fault some, but not all of the times that I run it. Sometimes, it sorts the code and finds the needle, sometimes it doesn't sort correctly and ends with a segmentation ...
0
votes
1answer
45 views

Help fixing bubble sort

I've been working on implementing a bubble sort, and I can get it to swap one time through the list, but I can't get it to run more than once, and I'm not sure how to implement it. I also know that ...
0
votes
1answer
42 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
1answer
28 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 ...
0
votes
1answer
28 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
1answer
75 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
1answer
34 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
0answers
83 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
1answer
127 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
1answer
22 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
1answer
60 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
0answers
214 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
1answer
25 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
1answer
21 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
1answer
63 views

linker comman failed with exit code of 1 in find.c

I was about to submit pset3 and pset4 which I have completed, but in the process of keeping my house in order by checking every code before submission, I discovered that helpers.c has developed issues....
0
votes
1answer
97 views

pset3 binary search , problems with check50

i have tried a lot but cannot find the meaning of the last two errors of check50 please help
0
votes
2answers
54 views

binary search pset 3 pointer to integer error

I am trying my hands on binary search. I get those pointer to integer errors :( Can sonmeone more experience give me a hand ? bool search(int value, int values[], int n) { int first=0; int last=n-1; ...
0
votes
1answer
81 views

Recursive Binary Search Exit Code Errors

I wrote the following recursive binary search function. No matter which exit codes I use (e.g., true, false, 1, 0, -1, "Swedish Chef"), I fail at least two of the checks I need to pass. The code ...
0
votes
1answer
387 views

killed by server

) helpers.c exists :( helpers.c compiles \ killed by server :| finds 42 in {42,43,44} \ can't check until a frown turns upside down :| finds 42 in {41,42,43} \ can't check until a frown turns ...
0
votes
1answer
233 views

pset3: The sort function does not return my code

I am stuck with the implementation of the sort function. I have written a code, but I can't check if the code is correct. This is what I have done thus far: void sort(int values[], int n) { for (int ...
0
votes
0answers
151 views

pset3 - check50 for find returns frowny face

I must be missing something on my code for pset3. When i run the Check50 i get this messages : :) finds 42 in {41,42,43} :( finds 42 in {40,41,42} \ expected an exit code of 0, not 1 After ...
0
votes
0answers
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++) ...
0
votes
1answer
46 views

Find Search Help (improved)

For pset3's findsearch, i saved the this code #include "helpers.h" bool search(int value, int values[], int n) { // removed implementation due to academic honesty rules } in helpers.c and ...
0
votes
0answers
67 views

Valgrind Error on Find

I know it's not required to run valgrind on find in pset3, but I was seeing some funky things in check50 and tried it out. The following errors appear: ==7866== 1 errors in context 1 of 2: ==7866== ...
0
votes
1answer
470 views

helpers.c not exist

When I used check50, show this bug... I understand that "helpers.c" is not compile, but in MakeFile all looks good. I'm in the step of binary search and sort. What can I do to find the error? ...
0
votes
0answers
235 views

pset3 find: Bus error (core dumped)

I finished the binary search algorithm and I get an error Bus error (core dumped) when I try to test it using the generate tool which is given. However, it works fine when I input the haystacks myself....
0
votes
0answers
135 views

I can't get search to work when value == value[n]

I'm trying to implement a recursive binary search in helpers.c. When checking my code with check50, everything works except: :( finds 42 in {40,41,42} :( finds 42 in {39,40,41,42} So obviously ...
-1
votes
1answer
31 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 : `#...
-1
votes
1answer
670 views

In pet3 , find.c

Can't understand where I went wrong.. FIND.C #include <cs50.h> #include <stdio.h> #include <stdlib.h> #include "helpers.h" // maximum amount of hay const int MAX = 65536; int ...