Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
Filter by
Sorted by
Tagged with
2 votes
0 answers
124 views

this is my first stack post so forgive me for any social transgressions! I have an optimisation(?) issue that begins incredibly simply but has a conditions that throws the whole thing into a realm of ...
Aipsh's user avatar
  • 21
1 vote
1 answer
78 views

I am implementing a script which compares bubble sort, insertion sort and selection sort. Although all these have a time complexity of the order of N^2, selection sort is supposed to be twice as fast ...
Dana Strong's user avatar
0 votes
0 answers
70 views

sort_pairs is not returning successfully when I check the code. Can anyone help point me in the right direction? I spent quite a while on the previous functions getting them correct as I've been away ...
ModernRevolt's user avatar
2 votes
2 answers
81 views

In selection sort the outer loop time complexity will be O(n) and the inner loop time complexity will be (n(n-1))/2 then why have we added outer loop time complexity with inner loop : n + (n(n-1))/2 ...
Muskan 's user avatar
0 votes
1 answer
100 views

enter image description here I should solve the time Complexity method like this photo but I have a problem solving it for selectio sort. I solved it in general and not in detail like I wanted going ...
Sara Hamzah's user avatar
1 vote
1 answer
70 views

I have i have wrote a C program. It should use recursive selection sort but segmentation fault occurs for big input (10000 or more). Debugger says that the segfault happens in findim function, but it'...
Giuseppe Guerrini's user avatar
1 vote
2 answers
55 views

The assignment is to use selection sort by swapping nodes, not the values. When sorting algorithm changes the last node, it raises AttributeError, because it seems that first.next in def min_sort()...
Samuel Varchol's user avatar
0 votes
1 answer
37 views

import java.util.Arrays; public class RecSelect { public static void Select(int[] ar, int idx, int min, int start) { if(idx == ar.length) { return; } if(idx &...
Aakash Srivastava's user avatar
0 votes
0 answers
34 views

My question is with the counting. In my problem the number of the operations after sorting is not giving the same amount as it should. I am using the general logic for the selection sort, insertion ...
mehrab.4's user avatar
-1 votes
2 answers
68 views

I'm trying to understand why using a variable to assign the index works fine, instead of directly using the index itself in the following code snippet of the selection sort algorithm using JavaScript. ...
mehdiqe's user avatar
1 vote
0 answers
94 views

If I had a list in a party, say 10 people, and I needed to find 25% of that list of people, you could say the answer is 2.5 people. However, if I had a list of 1 person (go with it), and I needed to ...
AMorrisey's user avatar
  • 119
-1 votes
1 answer
60 views

void simpleSort(int arr[], int arrSize){ /*initial searchSpace bounds*/ int left = 0; int right = arrSize-1; int maxElem, minElem, maxElemIndex, minElemIndex; while(left <...
VivekPrasad's user avatar
-2 votes
1 answer
100 views

counter += (a1<=x); what this code statement says ? it is used in a problem to get how many numbers is lower than or equal (x) variable, this should be as comparison between a1 and a2 to get what ...
Moamen's user avatar
  • 1
0 votes
1 answer
95 views

I learn a simple selection sort algoritm and try using from javascript/typescript. and this my selection.sort algorithm in SelectionSort class export default class SelectionSort { private ...
Al Youma Akmal's user avatar
0 votes
0 answers
38 views

Hi in this code in java I want to sort the pixels of the image through their brightness in java by using inversed selection sort however there is no update in the result image. how can i make it work? ...
parinaz jafarypour's user avatar
2 votes
2 answers
994 views

I'm quite new to Rust, so I might be missing something simple. I am using Rust 1.70.0-nightly. Here is the necessary code: fn selection_sort(original_vec: &mut Vec<i32>) -> Vec<i32> ...
yees_7's user avatar
  • 338
0 votes
1 answer
130 views

I am currently implementing selectionsort. Using the code below and the driver file to test it below. I am currently trying to do micro optimizations to see what speeds it up. public static void ...
Ooh Ben's user avatar
  • 11
0 votes
1 answer
58 views

I am solving the following code challenge: Let N be the size of a list. Implement the Selection Sort algorithm with the following modifications: In odd iterations, find the element with the lowest ...
afrodev's user avatar
-1 votes
3 answers
138 views

I am reading data in from a file, and asking the user which category they would like to sort by. The file has 13 columns (starting with country, year, and continent, then a list of double statistics ...
Dylan Warcholik's user avatar
1 vote
2 answers
134 views

I am required to sort an array with selection sort. I wanted it to to sort a string array in increasing order of length of its specific string elements. It doesn't give the required output. String[] a ...
Darshit Sharma's user avatar
0 votes
0 answers
1k views

<QuickGrid TGridItem="DataRow" @ref ="Grid" Items="@rows.AsQueryable()" Pagination="@pagination"> @foreach (var col in columns) { <...
 Vangagoud2023's user avatar
0 votes
2 answers
60 views

This code is to implement selection sort in JavaScript. I tried with the array [3,2,1] but it return [1,1,1]; the array [4,5,1,2,7] return [1,1,1,2,7]. I don't know where I went wrong. Please help! ...
Linh Chi's user avatar
1 vote
1 answer
117 views

I have to make a select sort function by passing it an array and using max element to sort it, with the two functions swap and max. func Swap(x *int, y *int) { aux := *x *x = *y *y = aux } ...
natalia's user avatar
  • 67
0 votes
2 answers
105 views

I'm a complete beginner in C, and I'm trying to learn how to do this selection sort algorithm to create an ascending list. But for some reason it doesn't run, and I can't seem to figure out why for an ...
Vien Nguyen's user avatar
2 votes
2 answers
171 views

So I'm trying to implement selection sort in C# but the output isn't exactly what I'm expecting, I tried tracing the loops and even brought out the good ol pen and paper but to no avail using System; ...
Tortoise shell's user avatar
1 vote
0 answers
34 views

I have an issue building the widget in the pic, I'm trying to build a dynamic selection widget with an option to expand. Max row is 3 but there is no constrain on how much children the row could have, ...
alhussien aldali's user avatar
-2 votes
1 answer
94 views

#include <stdio.h> int main() { int arr[5]; for(int i=0; i<5; i++) scanf("%d",&arr[i]); for(int i=0; i<5; i++) { int m=arr[i]; ...
emtiaz ahmed's user avatar
0 votes
2 answers
612 views

For example, it says that in 1 sec 3000 number are sorted with selection sort. How can we predict how many numbers are gonna be sorted in 10 sec ? I checked that selection sort needs O(n^2) but I dont ...
Nafsika's user avatar
  • 47
0 votes
1 answer
28 views

public class first { public static void main(String args[]){ int arr[]={5,4,1,3,2}; for(int i=0; i<arr.length-1;i++){ int smallest=arr[i]; ...
Sidharth sharma's user avatar
0 votes
1 answer
43 views

So I have to sort a list of people's information by their ages. In case there are people of the same ages, I have to sort them by their names alphabetically. Here's my code: #include <stdio.h> #...
Dachi_3210's user avatar
0 votes
0 answers
29 views

I am reading an excel .csv file data to a struct. I am supposed to apply selection sort algorithm to this data on the basis of number of employees and then saving this sorted data into a new .csv file....
Mub Malik's user avatar
1 vote
0 answers
67 views

I am learning selection sort. Suppose I have to sort elements of a list in ascending order.We normally follow these steps -: 1- We divide (hypothetically) the list into two groups : sorted and ...
An_Elephant's user avatar
-2 votes
1 answer
76 views

While compiling the code the error is showing is conflicting type for a function I have decelerated in this code , but I can't understand where is the error.. Need help to fins the error , and how to ...
Chayan's user avatar
  • 21
-1 votes
1 answer
24 views

#include<iostream> using namespace std; int main() { int arr[] = {40,20,14,20,55,14,22,45,22,447,441,224,421,2,14,1,9}; int size = sizeof(arr) / sizeof(int); for (int i = 0; i <...
temporary's user avatar
0 votes
0 answers
15 views

As we all know that selection sort in DS is done by comparing the elements and then swapping the smallest to the beginning using a temporary variable. I have learnt a new way to swap is by just ...
jyotirban borthakur's user avatar
2 votes
1 answer
105 views

I'm trying to create a sorting algorithm, it contains a nested loop which compares each element of the array to all other elements in the array, and if an element is greater in value than any of its ...
Aryan Arora's user avatar
-3 votes
1 answer
97 views

I practice some selection sort and given a sorted list found a number with the binary search but is not working. Why output comes index -1. def selectionsort(lst, target): first = 0 last ...
Tobassum Munir's user avatar
0 votes
2 answers
147 views

I am trying to implement the Selection Sort Algorithm and here is my attempt: int select(int arr[], int i) { int j, minIndex; minIndex = i; for (j = i + 1; arr[j]; j++) { ...
Leuel Asfaw's user avatar
1 vote
0 answers
164 views

So my Professor gave us an activity where we input the amount of array and its value. Then Selection sort will be implemented and will display each pass. I manage to do the input part but only managed ...
Ellie Riggs's user avatar
-3 votes
1 answer
113 views

Which sorting algorithm work efficient for these two arrays: Insertion Sort Selection Sort Bubble Sort int arr1={16,22,11,62,45,37,62,45,3,17}; int arr2={3,6,9,12,15,17,20,22,29,35};
Shaheer Ahmed's user avatar
0 votes
2 answers
339 views

When passing an array in the selection function, I'm getting the required sorted array only for positive real numbers but for the negative numbers it is failing to do the same. static void ...
Priyanshu Naudiyal's user avatar
-1 votes
1 answer
34 views

the code is working fine till end and i am getting a sorted array, but after sorting it is again executing swap part code , but the issue is getting solved by adding else to the swap method. if(i==...
Jayasimha Reddy's user avatar
0 votes
3 answers
296 views

I am having a tough time trying to follow the logic here as to why it is not working correctly expected output : 1 5 6 8 any help is greatly appreciated Update: I got selection sort and insertion ...
SurlyGent's user avatar
-1 votes
1 answer
79 views

I have tried to measure the execution time for selection sorting an array in my code. The selection sort part is working but the benchmarking method "time" does not even get executed. What ...
Javaebeginner's user avatar
0 votes
1 answer
416 views

I understand the concept of Selection Sort (I think) but what I'm confused about is trying to code it. From my understanding of Selection Sort, you set the first element as your minimum value and then ...
Hahaha2411's user avatar
0 votes
1 answer
48 views

I want to put obj into value ex. <option value={valueSort}>// valueSort = {name: 'ASC'} for use to sort by name in my project but now the result that is [object Object]. I don't know what is ...
FTDs's user avatar
  • 3
0 votes
1 answer
69 views

static void stableSelectionSort(int[] a, int n) { for (int i = 0; i < n - 1; i++) { int min = i; for (int j = i + 1; j < n; j++) if (a[min] > a[j]) ...
Dhanush Kannan's user avatar
0 votes
1 answer
68 views

I came across this code on selection sort algorithm: ls = [2, 5, 1, -9, 10, 13, 7, 2] def selection_sort(ls): for i in range(len(ls)): imin = min(range(i,len(ls)), key = lambda x: ls[x])...
kostis tzimoulias's user avatar
0 votes
1 answer
142 views

I want to return a list where after each iteration, in the list has the number of comparisons and number of swaps. like an output such as this: [[3,1], [2,1], [6,1]] How can I achieve this? Apart from ...
quadingle the 2nd's user avatar
-1 votes
2 answers
87 views

What is wrong with this code? Not getting the right output. void selectionSort(vector<int>& arr, int n) { for(int i = 0; i < n-1; i++ ) { int min = arr[i]; ...
Ravi Kumar's user avatar

1
2 3 4 5
13