Questions tagged [selectionsort]

The tag has no usage guidance.

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

could you help?

I have a problem with the selection code. it is compiler right .but not give the right order it give me the order blow : ~/sel_sort/ $ ./sort array after selcation sort : arry[0] = 4 arry[1] = 6 arry[...
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 ...
user avatar
0 votes
1 answer
48 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" /...
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; ...
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) {// ...
user avatar
0 votes
1 answer
60 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 ...
user avatar
0 votes
1 answer
42 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 ...
user avatar
0 votes
1 answer
27 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[...
user avatar
1 vote
1 answer
186 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 ...
user avatar
0 votes
1 answer
95 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 ...
user avatar
0 votes
1 answer
267 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 ...
user avatar
0 votes
1 answer
157 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 ...
user avatar
  • 3
0 votes
2 answers
61 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 ...
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 ...
user avatar
0 votes
1 answer
502 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 ...
user avatar
  • 21
0 votes
1 answer
86 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 ...
user avatar
0 votes
1 answer
445 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]...
user avatar
0 votes
2 answers
160 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 ...
user avatar
  • 13