Questions tagged [find]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
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
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
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
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
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
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
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
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
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
130 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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
1answer
197 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 ...
1
vote
1answer
558 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
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 ...
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/...
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
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 ...
-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
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
90 views

return false in pset3 in cs50

I am stuck with helpers file due to the following: sort and search seem to be working fine, but when I try to compile helpers and find, i have the following message: helpers.c:67:1: error: expected ...
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
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
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
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
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
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
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
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 ...