Questions tagged [selectionsort]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
19 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 ...
0
votes
1answer
46 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" /...
0
votes
1answer
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; ...
0
votes
1answer
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) {// ...
0
votes
1answer
57 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 ...
0
votes
1answer
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 ...
0
votes
1answer
25 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[...
1
vote
1answer
156 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 ...
0
votes
1answer
87 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 ...
0
votes
1answer
210 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 ...
0
votes
1answer
147 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 ...
0
votes
2answers
52 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 ...
0
votes
1answer
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 ...
0
votes
1answer
310 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 ...
0
votes
1answer
76 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 ...
0
votes
1answer
436 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]...
0
votes
2answers
148 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 ...