All Questions
19 questions
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'...
0
votes
1
answer
55
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
1
answer
299
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
1
answer
44
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
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
50
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
1
answer
255
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
2
answers
114
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
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)
{// ...
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
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
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
123
views
is this function correct? CS50 Pset3 (Find)
// TODO: implement an O(n^2) sorting algorithm
int c,i,s;
c = 0;
for (i=0; i < n; i++)
{
if (values[i] > values[i + 1])
{
s = values[i];
values[i] = values[i+1];
...
0
votes
1
answer
774
views
pset3 binary search won't find values when at end of array
As the title says, the program doesn't pass the check when 42 is the last element of the array. I've seen a related post about this issue but it did not give me enough to fix the problem. The code is ...
0
votes
1
answer
258
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 ...
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
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" ...
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, ...