Questions tagged [binary]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
2k views

invalid operands to binary expression ('double *' and 'double')

I am getting error with greater than operand '>'. I am sure that q1[n] hold value that is not integer. I am not sure how to do this when the q1[n] > 0.5 then c=1. Note that q1[n] is pointer to the ...
0
votes
1answer
45 views

cs50 pset3 binary search

im not sure if my binary search code is correct, when I try to compile it I get the following message: /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/crt1.o(.debug_info): relocation 0 has ...
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
12k views

Question about binary search. Please help!

https://www.youtube.com/watch?v=5xlIPT1FRcA&t=200s I am struggling to understand how to implement binary search. According to the video, there are 14 numbers in the array. Then he goes on to ...
0
votes
1answer
515 views

CS50 Problem Set 3 Helpers.c PROBLEMS

I have been trying to solve Pset3 search and sort - looked at all possible online forums but I cannot solve it. Please help. Where am I going wrong? Is my binary search OK? What about my bubble sort? ...
0
votes
1answer
45 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
2answers
606 views

Recursive binary function returns error: control reaches end of non-void function

Working on pset3 and tried to write a separate binary search function in helpers.c so I can just call it later in the main search function. Here's my code for the binary search: bool binarysearch(int ...
0
votes
1answer
81 views

Guys,my code runs perfectly right with check 50 for binary search but doesn't show right output for ./generate 1000 50 | ./find 127.Please help

bool search(int value, int values[], int n) { int middle=(int)((n-1)/2); if(n<0) { return false; } else if(values[middle]==value) { return true; } else if(...
0
votes
1answer
63 views

binary search code showing segmentation fault

this is my code. bool search(int value, int values[], int n) { int max = n -1; int min = 0; int mid; while(n > 0) { mid = ((min = max)/2); if(values[mid] == ...
0
votes
1answer
57 views

pset3 binary search code is not compiling

this is my code for binary search. bool binary(int key, int array[], int min, int max); bool search(int value, int values[], int n) { if( n< 0) { return false; } ...
0
votes
1answer
13 views

A very basic program to find out the largest int given the number of bits used. Why is my output off?

I think im retarded. CODE: #include <stdio.h> #include <cs50.h> #include <math.h> #include <string.h> int main(void) { long long sum = 1; for (int i = 1; i < 50; i+...
0
votes
2answers
76 views

PSET3 Binary search not yielding results

I can't seem to figure this out. here's my code bool Binarysearch(int key, int array[], int n){ int end = n-1; int start = 0; while(start<=end){ int midpoint = (((end+start)/2)); if (...
0
votes
1answer
306 views

pset 3 Binary search

I'm stuck on implementing the binary search function in pset3. I am trying to do the recursion method but I am stuck and have been for hours. It seemed easy enough but I am discovering that it's more ...
0
votes
1answer
79 views

search and sort seem to work but cannot find needle in large haystack?

My code seems to work fine for binary search, checking the sorted list looks good and code passes check50. Needle is found in more limited searches (like ./ generate 500) but will not find needle in ...
0
votes
1answer
49 views

Week 3 Binary Search Video Short question

I just watched the short for binary search and I'm having trouble understanding how making a conditional of (max < min) would mean that the number is not in your array (timestamp 04:05). I get ...
1
vote
2answers
203 views

Binary Search Problems

When attempting to implement binary search, I have run into problems when compiling. If you see any problems in sort, please point them out as well. Any help would be appreciated. Here are the errors: ...
0
votes
1answer
130 views

Binary search. What's wrong?

Hi this is my binary search code, something is not working, but find what it is? Also, I think the if statements should be changed to (if, else if, else) but the compiler yells at me if I code it like ...
0
votes
1answer
24 views

grasping turning Decimal notation to Binary

Im having trouble grasping how to turn decimal notation to binary... in the video he uses 237 as the number. Then "find the largest number less than 237 with the power of 2" thanks...
0
votes
1answer
132 views

Pset3 Binary Search gets “may reach end of non-void function” error or “inker command failed with exit code 1” [duplicate]

I'm going insane! Pset3 binary search. My code seems to be correct but I keep getting errors when trying to make helpers. Find works with generate when I search for a number that exists but hangs ...
0
votes
1answer
6k views

How do I write words and sentences in Binary?

Hi I want to know how do I write a word in Binary for example word "HI" is it like this 1001000(space)1001001 or is it like this 10010001001001 (without space in between H and I) as there are two ...
0
votes
0answers
87 views

search binary search

This code does not work. I tried everything. My sort function is working (I tested it with linear search, so it's fine). I am getting "Did not find haystack" even when the value is there. bool search(...
0
votes
1answer
21 views

how do we know if the user is trying to talk about the number 65 or the letter “A”

I mean that the ASCII protocol just denotes some alphabets and character using the DECIMAL VALUE OF SOME NUMBERS. this kind of creates a problem as to what happen to those numbers. how do we know if ...
1
vote
1answer
31 views

How is the determination made as to whether a binary number is negative or positive?

I understand in a relative sense how the two's complement would return the negative. If I add 1011 and 0101, I get 0000 (with the last carried 1 dropped). But, what if the computer was only presented ...
1
vote
1answer
2k views

pset3 helpers c, linear search

bool search(int value, int values[], int n) { // TODO: implement a searching algorithm for (int i = 0; i < n; i++) { if(values[i] == value) { return i; ...
0
votes
1answer
33 views

I have a doubt about binary code

everyone! Some translators show 01100010 (is that right?) for letter B as binary code, but at CS50 2 of 8 students on the stage raised the hand (64s and 2s). While the others are 0(zero). Wouldn't ...
0
votes
3answers
306 views

Binary Notation

I am somewhat stuck in binary notation. A segment of the video "Binary" (Week 0) talks about representing decimal notation into binary notation. I.e: 10 represents the number 2, 11 represents 3, etc. ...