Skip to main content

Questions tagged [general]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
4 votes
1 answer
34 views

What if binary search's split was not in the middle, but in a way the left side is twice as long as the right side?

How would the time complexity change if the binary search's split was not in the middle ((left + right)/2), but rather in such a way that the left side is twice as long as the right side? So we check ...
Mia W's user avatar
  • 41
0 votes
1 answer
17 views

Can we search on google how to use x method or built-in function in python?

If we learn to use a specific method in python or how to use a built-in function and its syntax in another website like stack overflow, is that allowed? If it is how do we reference it in our code?
Alex Sugimoto's user avatar
0 votes
1 answer
14 views

Editing helper function

I'm currently on pset6, the one about DNA. Is it allowed to edit the helper function? It kinda confuses me and I came up with another function that solves the problem I'm dealing with.
Alex Sugimoto's user avatar
0 votes
1 answer
17 views

How does continue; differ from break; in a loop

If i understand correctly, continue skips all the lines of the loops current iteration and starts again from the top whereas break exits the loop. Is this correct?
turbulenttangles's user avatar
0 votes
2 answers
989 views

PHP removal from CS50

Hello dear CS50 folks, I was wondering - just out of curiosity - why PHP was removed from CS50 ? And why choose Python instead ? If someone could give me an elaborate answer, explaining the ...
WitoldW's user avatar
  • 101
0 votes
2 answers
190 views

C data types and format specifiers

I was playing around with data types and format specifiers. Compiling the first snippet of code gives no errors but when I try to use unsigned shorts (or shorts in general) I get an error on line 12: ...
Alberto's user avatar
  • 21
2 votes
2 answers
1k views

What will realloc() do if the contiguous memory location is already occupied?

Consider- char* name1 = malloc(4 * sizeof(char)); name1 = "Mike"; Now if i want to put "Mike Smith" in the same string "name1", I need 6 more bytes of memory (one for the space and 5 for "Smith". ...
Vinz.R's user avatar
  • 39
1 vote
1 answer
5k views

When we free a dynamically allocated memory, what happens to the pointer pointing at it?

After watching section on "Dynamically allocated memory" (from Week 4) several times, I still have a question unanswered. Consider the following code- // Allocates 4 bytes of memory on heap and ...
Vinz.R's user avatar
  • 39
1 vote
1 answer
786 views

Memory allocation: recommended practices

I'm rambling a little with hacker 2 (the passwords') and, in the meantime, gained some insight about pointers, mem-alloc, 'valgrind', etc... It's been a truly great, challenging experience. But, ...
abelinux's user avatar
  • 1,170
0 votes
1 answer
212 views

Conceptualising resizing in pset5

I've just solved the resizing part of pset5 without completely understanding what is happening during the reading of the infile and writing of the outfile bit. To clarify my question, here is my code ...
pat_krat's user avatar
  • 570
1 vote
3 answers
188 views

CS50 FAQ's and answers [closed]

I've created this post so that all the FAQ's and their answers can be collected here, in order to prevent re answering the same questions over and over again, be sure to check the answers to this ...
Nib's user avatar
  • 1,176