# My sorting algorithm doesn't function due to unknown reason

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 succeeding elements, they switch places with each other. But for some reason my program won’t output anything… Read More My sorting algorithm doesn't function due to unknown reason

# Selection sorting. not getting the required output

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]; for(int j = i+1; j < n; j++) { if(arr[j] < min) min = arr[j]; } swap (min, arr[i]); } } >Solution : You… Read More Selection sorting. not getting the required output

# ( Python ) Can you swap the starting process of the selection sort?

from finding the minimun and put it on the left to finding the maximum and put it on the right def SelectionSort(a_list): n = len(a_list) for i in range(0, n-1): iMin = i print(a_list) for j in range(i+1, n): if a_list[j] < a_list[iMin]: iMin = j temp = a_list[i] a_list[i] = a_list[iMin] a_list[iMin] = temp… Read More ( Python ) Can you swap the starting process of the selection sort?

# Getting the time complexity of a selection sort

I created a code for selection sort, but my teacher asked me what the time complexity of my code is, so I need help to get it. I’m not sure if my code is the same with the other selection sort with a worst time case of O(n^2) and a best time case of O(n).… Read More Getting the time complexity of a selection sort

# This code is about Selection sorting but when i run the code it is not working as expected

The program only works when the no. of elements is 2 if it is more than 2 it doesn’t work. #Selection Sort L = [] n = int(input(‘Enter the number of elements\t:’)) for i in range(n): item = int(input(‘Enter item\t:’)) L.append(item) print(‘List\t:’) for i in range(n-1): for j in range ((i+1),n-1): if (L[j]<L[i]): (L[j],L[i]) =… Read More This code is about Selection sorting but when i run the code it is not working as expected