2
votes
Accepted
Week 2 Merge Sort: Why is it assumed that the elements will be in order when they are merged?
Think of it this way. The unsorted list of n elements is broken into n lists of 1 element each. A one-element list is, by definition, sorted. Now, the merging begins. Pairs of lists are merged by ...
2
votes
Selection Sort: Holes in Logic
The main problem is in the following statements:
string answer = 0;
answer[i]= min_value;
Let's see if I can explain it clearly;
a variable of type string is really a typedef (an alias in other ...
1
vote
Accepted
Pset3: Tideman - Sort_pairs function
check50 doesn't care about how you implemented add_pairs when it's testing sort_pairs, so it doesn't initialize the winsize property. You'll need to remove that property, and access it in sort_pairs. ...
1
vote
Accepted
CS50x 2020 Problem Set 3 Tideman
Clearly bubblesort algorithm has been used, but in the 5th line:
preferences[pairs[i].winner][pairs[i].loser] > preferences[pairs[i + 1].loser][pairs[i + 1].winner]
The basic functionality of ...
1
vote
Pset 3 -> Counting Sort - need tips to find my error
If you array is declared with 65536 buckets, then aux_list[65536] is outside the bounds (remembering that arrays are zero-indexed). So what happens in your loop when i == 65536?
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
sorting × 13pset3 × 6
cs50x × 2
tideman × 2
pset6 × 1
speller × 1
c × 1
python × 1
game-of-fifteen × 1
fifteen × 1
binary-search × 1
search × 1
cs50x2017 × 1
index × 1
sort × 1
help × 1
bubble-sort × 1
week2 × 1
arrays × 1
loops × 1
selectionsort × 1
mergesort × 1
multi-dimensional-arrays × 1
sort-pairs × 1
counting-sort × 1