Questions tagged [sorting]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
435 views

Pset3: Tideman - Sort_pairs function

I am trying to solve sort_pairs by including a property - int winsize - into the struct of pair. The new pair struct is: typedef struct { int winner; int loser; int winsize; } pair; I ...
Daniel's user avatar
  • 3
0 votes
2 answers
422 views

CS50x 2020 Problem Set 3 Tideman

I have been working on the Tideman problem for a while now, and am still not able to find out how to implement the sort_pairs() function. I have implemented my sort_pairs() function, but it is not ...
Shrey Tripathi's user avatar
0 votes
1 answer
43 views

Week 2 Merge Sort: Why is it assumed that the elements will be in order when they are merged?

When using the Merge Sort algorithm, I feel like everything makes sense until we start "merging" the elements back together. Why is it assumed implicitly that the process of merging will put the ...
Xia Liu's user avatar
  • 19
0 votes
1 answer
28 views

Selection Sort: Holes in Logic

#include <cs50.h> #include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { string s = get_string("Enter a number: "); string answer ...
Nikhil Bhave's user avatar
0 votes
1 answer
41 views

Pset 3 -> Counting Sort - need tips to find my error

What is wrong in my code? Why am I getting a segmentation fault? void sort(int values[], int n) { int aux_list[65536] = {0}; //map the count of values in the values list as the index of the aux list ...
Sherzod Abdujabborov's user avatar
0 votes
1 answer
54 views

Sorting a List Based on Stock Symbols in CS50x2017 Problem Set 7 Index

Would this be the way to sort a list of stock information with sorted using stock symbols as the key to sort on? new_translactions_info = sorted(transactions_info, key=lambda transactions_info: i....
Osman Zakir's user avatar
1 vote
1 answer
88 views

pset3 move() makes every tile swapped a blank tile

I rewrote almost the entire code and I finally was able to make the tiles swap. Problem is at every swap the blank tile gets duplicated and the tile swapped disappears, eventually rendering a Segfault....
Lele's user avatar
  • 67
0 votes
1 answer
59 views

Pset3 segmentation error

I am having trouble with segmentation error with sorting code. I have tried to understand how I am accessing something that is out of boundaries, but so far no ideas. It runs smoothly in cases where ...
Gert Lõhmus's user avatar
0 votes
2 answers
72 views

Why are the sorted numbers not being printed out?

I'm trying to sort and print out the results, but it is showing nothing. I'm sure my implementation of bubble sort is correct. Where do you think is the error? I also modified the helpers.h to ...
Michael Daryl Mayo's user avatar
0 votes
1 answer
29 views

How to search in effective manner?

As in Lecture video of finding a name in telephone directory we get to half and choose one half where we can find the name. But my question is when the names are random how to effectively find a name. ...
Vinayak Kohli's user avatar
0 votes
2 answers
811 views

What's wrong with this binary search implemented using recursion?

This is pset3 and I've tried making it work for numerous hours. It always returns false whether the 'needle' is found in the 'haystack' of arrays or not. When typing this in the command window: ./...
rohan's user avatar
  • 23
1 vote
1 answer
126 views

Accessing const int MAX value from helpers.c

I am trying to implement the hacker3 sorting algorithm. The one that requires a O(n). I think I have figured out the algorithm but I won't spoil it by posting any code here. My question is regarding ...
Alexandros Andreou's user avatar
1 vote
3 answers
82 views

Does our implementation of speller need to be able to handle an unsorted input dictionary?

In another post, user1723 touched on a question I had while watching the lecture, sections, and walkthrough on pset6. The question was, why would we need to sort our linked lists, when dictionaries, ...
lacygne's user avatar
  • 29