Questions tagged [find]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
1answer
18 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
1answer
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?
0
votes
1answer
82 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
1answer
54 views

Pset3 2017 less bubble sort

I decided to do pset 3 from 2017 as extra practice, but ran into an issue with bubble sort. More specifically, when I run check50 on it I get: :( sorts {5,4,3,2,1} expected "1", not "\n5\n5\n5\n5\n5.....
0
votes
1answer
49 views

Check50 for find-less in ps3 shows me a './sort' error

I implemented the helpers for sort and search. Using basic implementations of quicksort and binarysearch. When I ran check50 cs50/2017/x/find/less there was a weird error for the sorting part: :) ...
0
votes
1answer
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
1answer
54 views

EOF NOT WORKING IN PSET 3 LESS FIND

CURRENTLY I AM TRYING TO SOLVE THE PSET3 LESS FIND BELOW IS MY CODE.PROBLEM IS THAT WHEN I WANT TO USE CTRL-D FUNCTION TO EXECUTE EOF FUNCTION IT DID NOT WORK.I THINK CODE ENTER IN A INFINITE LOOP BUT ...
0
votes
1answer
31 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
1answer
59 views

pset3 find more comfortable - sort works in debugger but fails check50. search works

I am sorting and passing the sorted Array to SEARCH. sort is working in debugger but not in check50 :) helpers.c exists. :) helpers.c compiles. :( sorts {5,4,3,2,1} expected "2", not "\n" :( sorts {5,...
0
votes
1answer
77 views

Pset3 Find - More confortable (counting sort algorithm)

/** * helpers.c * * Helper functions definitions for Problem Set 3. */ #include <cs50.h> #include <stdio.h> #include "helpers.h" /** * Returns true if value is in array of n values,...
0
votes
1answer
46 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
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
190 views

pset3 help with find, bubble-sort and search

I've been struggling for over a week with this and can't figure out how to get my program to pass check50. I'm getting very interesting mixed results from check50: :) helpers.c exists. :) helpers.c ...
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
18 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
1answer
120 views

week 3 find problem

I thought I finally made the program find work, but it still won't function when I test it with help50. I have looked at the code the whole day and just cannot seem to figure out what to do to solve ...
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
52 views

find is not compiling

/** * helpers.c * * Helper functions for Problem Set 3. */ #include <cs50.h> #include<stdio.h> #include "helpers.h" /** * Returns true if value is in array of ...
0
votes
1answer
38 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
2answers
239 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
1answer
514 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
1answer
41 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
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
349 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
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
127 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
1answer
202 views

How to debug find.c?

I'm just working on find.c and helpers.c. My sort is not completely working yet and I'm trying to debug the program but the debugger is not working. Is there anything special I have to do since find....
0
votes
1answer
69 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
1answer
24 views

I realize this code is not the nices, but wIll this code work? The code is for pset3 selection sort?

void search(int array[] , int length) { int min = 0; while (min <= length-1) { int index = min+1; if array[min] >= array[index] { min = index; ...
0
votes
1answer
25 views

pset3 - find are compiling but wrong result?

solving find more comfortable and when I excute ./generate 1000 50 | ./find 127 it gives me output like this : haystack[0] = haystack[1] = haystack[2] = haystack[3] = haystack[4] = . . . haystack[1000]...
0
votes
1answer
44 views

For pset3 find binary search will this code work? If not is it close?

bool binary_search (int target, int array[]) { int end = length-1; int start = 0; // 7 0 14 // 11 8 14 // 9 10 + ...
0
votes
1answer
164 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
1answer
53 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
1answer
59 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
1answer
96 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
1answer
89 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 :) ...
0
votes
1answer
26 views

Find.c is finding numbers that aren't in the list

I got almost all of my code to work for find, it passes all of the check50s except 1, it finds 42 in {39, 40, 41, 43} My code so far is: /** * helpers.c * * Helper functions for Problem Set 3. */...
0
votes
2answers
43 views

./generate 1000 | ./find 42 failed, get_int() got nothing but program still worked

If I use ./generate 10, I can successfully printf a random list, and if I use ./find 42, there successfully comes prompts to a ask me input numbers. However, if I use ./generate 10 | ./find 42, the ...
1
vote
1answer
61 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 ...
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
417 views

Pset3, Find, search

In "Find" problem, something seems wrong with my binary search Algorithm, because in check50, helpers.c wouldn't compile, I tried to compile it, then it gave me this weird error: clang -fsanitize=...
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
1answer
76 views

Puzzled by Pset3 - find less confortable- sorting output

I just checked my code for Pset3 finds less confortable and it works but I am puzzled by some of the printf I put to debug my code. I put this just at the end of my sorting function: printf("%i %...
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
36 views

Bubble sort code works, but does not stop

I fixed my bubble sort code, and it correctly sorts the numbers, but it does not stop when it should. My code is: #include <cs50.h> #include <stdio.h> #include <stdlib.h> //#...
0
votes
1answer
4k views

'int' but the argument has type 'int * problem with sort in helpers.c

I am having a problem with returning the sorted value in the function sorted. I know it has something too do with fun pointers. On a side note, how is a function suppost return something if it's ...
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 ...