# Questions tagged [algorithm]

The tag has no usage guidance.

12 questions
Filter by
Sorted by
Tagged with
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 ...
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 = ...
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 ...
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 ...
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 ...
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 ...
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 ...
• 5
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]...
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.
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 ...