Questions tagged [algorithm]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
1 answer
384 views

What's the most efficient prime-finding algorithm? (Week 1 Practice Problems)

In the Prime practice problem, there's a thought question that says: Can you make the prime-finding algorithm more efficient than checking if a number is divisible by every number between 2 and 1 ...
Anas Amer's user avatar
0 votes
1 answer
102 views

practice problems week 3. Sort temperature. And my result is all the temperature is sorted but the name of the city is not

void sort_cities(void) { // Add your code here for (int i = 0; i <= NUM_CITIES - 1; i++) { if (temps[i].temp < temps[NUM_CITIES - 1].temp) { int temp = ...
Nathan Doan's user avatar
0 votes
1 answer
34 views

I keep getting an error or my code doesn't run , what should i do?

I am trying to use selection sort to sort the list in descending order and I have been on it , just having absolutely no progress. I don't know what to do anymore! This is my latest trial // Practice ...
Gold Isaac's user avatar
0 votes
1 answer
96 views

Can you help me to understand why does the output of time function vary every time while applying it on same file with same sort type?

When I run for example (time ./sort1 random5000.txt) it gives me real, syst, and user time. But if I run the same command again it will gives me different time results! I can't understand why this ...
Aya Othman's user avatar
0 votes
1 answer
116 views

PS2 Caesar Algorithm

#include <stdio.h> #include <cs50.h> #include <string.h> #include <ctype.h> #include <stdlib.h> int main (int argc, string argv[]) { //Terminates if Command-line ...
yoyo Ahmed's user avatar
0 votes
3 answers
42 views

Why are algorithms mentioned in week 2

In week 2 David mentions Algorithms e.g. Bubble sort, Binary search etc... But why are they important? and where do they fit into the bigger picture? I only did the Caesar cypher and Vigenere cypher ...
Ryan Hinchliffe's user avatar
0 votes
1 answer
61 views

Iterative vs Recursive

I have searched in many resources on web and most of them claim, that iterative way of problem solving is faster. Plus, as I understood, recursive should require more memory during processing. My ...
LCK's user avatar
  • 5
0 votes
0 answers
143 views

FATAL: varcache miss for varobj var50.0 while using debug50

I am trying to debug a code but whenever I try to run gdb I'm getting FATAL: varcache miss for varobj var50.0 #import <stdio.h> int main(){ int n; scanf("%d",&n); int arr[1000]...
user282's user avatar
0 votes
1 answer
27 views

Can anyone explain that attendence algoritm of week 0 lecture?

The week 0 lecture of CS50 edx. I was not able to understand how did we come to 546 student.
Rishabh Gupta's user avatar
0 votes
3 answers
1k views

pset 1 credit.c invalid cards are valid by cs50

It was said that you can verify if the credit card number is valid by using Luhn’s algorithm. If you done mathematical operations right, after them, you know if the card is valid if the last digit in ...
Petar Popovic's user avatar
0 votes
1 answer
33 views

Do While loop not executing for pset3

I am working on Pset3 for a binary search algorithm. Below is my code (NOTE: the logic is not finished): bool search(int value, int values[], int n) { //binary search algorithm int min = 0; int max = ...
jaguar's user avatar
  • 70
0 votes
1 answer
234 views

Greedy; Pset 1 - Trouble creating modulo algorithm

int q=coins/25; //gives number of quarters int mq=coins%25; gives modulo quarters int md=mq/10; int mn=md/5; int mp=mn/1; printf("%d, %d, %d, %d,", q+md+mn+mp); So I've been able to prompt the user ...
Gooddb67's user avatar