Questions tagged [algorithm]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
11 views

PSET 3 Plurality Print_winner function prints smallest number of votes too many times (sorting algorithm?)

I am doing Problem Set 3 Plurality. I am currently on the print_winner function. My program compiles but I'm having issues because it does not print the winner and any ties it prints whoever got the ...
0
votes
1answer
43 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 ...
0
votes
1answer
97 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 ...
0
votes
3answers
37 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 ...
0
votes
1answer
44 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 ...
0
votes
0answers
137 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]...
0
votes
1answer
23 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.
0
votes
3answers
854 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 ...
0
votes
1answer
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 = ...
0
votes
1answer
217 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 ...