Questions tagged [selectionsort]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
33 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
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
56 views

CS 50 - pset3 find helpers: Why do binary search and selection short not work?

the command line yells at me but I cannot find out why. Any ideas what could be wrong? Here is my code: /** * helpers.c * * Helper functions for Problem Set 3. */ include include "helpers.h" /...
AlexL's user avatar
  • 5
0 votes
1 answer
24 views

I realize this code is not the nices, but wIll this code work? The code is for pset3 selection sort?

void search(int array[] , int length) { int min = 0; while (min <= length-1) { int index = min+1; if array[min] >= array[index] { min = index; ...
Tom55555's user avatar
0 votes
1 answer
126 views

pset3 helpers.c (help)

:( finds 42 in {39,40,41,42} \ expected an exit code of 0, not 1 ( it meaning I missing or have a return error??? ) bool search(int value, int values[], int n) {// ...
RedRabbit's user avatar
0 votes
1 answer
64 views

is my selection code correct?

I used printf to check the process and final result. The final result is technically correct (the array is sorted in ascending order) but I saw the behaivior of the algorithm and it doesnt look like ...
Kev Lozano's user avatar
0 votes
1 answer
44 views

Pset3 Find - error in "helper" file - 'expected expression'

This is my code for the helper.c file. The code forms part of the 'find' program. I'm getting an error: 'expected expression' re: the last 'else' statement. I have tried removing the 'else' statement ...
Android1's user avatar
0 votes
1 answer
28 views

PSET3:Find: Code works without the function, doesn't work with the function

So I am working on Selection Sort for Find, Problem Set 3. When I use a function I made called swap to exchange the values, the array is not sorted. Function snippet: if (min != i) { swap(values[...
Satanic Saint's user avatar
1 vote
1 answer
206 views

Pset 3: find - implementing selection sort function not working

Pset 3: find is a program that finds a number among an array of numbers. We are required to implement a sort and search function that were called on by another file in order to accomplish this. We had ...
joshkeisler95's user avatar
0 votes
1 answer
118 views

<Pset3 Find> Help with Selection sort code

I can't seem to see the problem with my code for Selection Sort. I'm passing all the checks for check50 except the one with an unsorted array so I'm guessing that the problem lies with my Selection ...
xSimplified's user avatar
0 votes
1 answer
322 views

pset3: selection sort code not compiling

I'm a beginner and I've been working on the code for selection sort. The code seems right: But whenever I try to compile helpers.c I keep getting this error and I can't move forward: Could anyone ...
clouding_980's user avatar
0 votes
1 answer
166 views

pset3: sort -- Selection Sort Implementation

I have been working away at my implementation of Insertion Sort for this problem set, and I've run into a predicament. I have gotten the sort function almost functional, however I'm sure we all know ...
parsec's user avatar
  • 3
0 votes
2 answers
64 views

What is wrong with my sorting algorithm?

I'm stuck. My program seems to run just fine, but when I run the CS50 check I don't get full results. I think there's something wrong with my sorting algorithm. This is my feedback if I run this ...
Joeri Venekamp's user avatar
0 votes
1 answer
66 views

Pset3 - Sort function not working

I have read other answers to this question and tried all of the different implementations. Most of the time, the numbers that generate(), well, generates become 0 after the sort. I cannot find the ...
cs50kid's user avatar
0 votes
1 answer
554 views

Finding the smallest value with Selection Sort

I think I'm stuck on finding the smallest value when employing Selection Sort. Given an array of 7 values {4, 8, 1, 5, 3, 7, 9} , this is what I get (wrongly): {3,7,1,4,5,8,9}. I understand ...
Alberto's user avatar
  • 21
0 votes
1 answer
88 views

Pset3 selection sort only correctly swaps the first value

I have a question about selection sort code I implemented. Specifically, my swap function seems to be swapping only the first value in a list of numbers through each loop. For example, if I have the ...
jwang1191's user avatar
0 votes
1 answer
450 views

pset 3's selection sort

#include <cs50.h> #include <stdio.h> #include <stdlib.h> #include <string.h> void swap(int *a, int *b){ int tmp = *a; *a = *b; *b = tmp; } int main(void){ int s = 5; int size[s]...
user1571's user avatar
0 votes
2 answers
165 views

Select Sort code not working

I am trying to sort the array below using Selection Sort procedure: array [] = {5,4,3,2,1} However, when I run the code it sort the array as 12222. It clearly stops sorting after 2. I suspect the ...
Malik's user avatar
  • 13