Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Selection Sort #220

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

theeducationalworld
Copy link

The provided Python code demonstrates the Selection Sort algorithm. Selection Sort has a time complexity of O(n^2). In each iteration, the code finds the minimum element’s index in the unsorted portion of the array and swaps it with the current index’s element. This gradually sorts the array from left to right. The example initializes an array, applies the selectionSort function to sort it, and then prints the sorted array in ascending order. The sorted array is obtained by repeatedly finding the smallest element in the unsorted portion and placing it in its correct position, resulting in an ordered array: [-202, -97, -9, -2, 0, 11, 45, 88, 747].

The provided Python code demonstrates the Selection Sort algorithm. Selection Sort has a time complexity of O(n^2). In each iteration, the code finds the minimum element’s index in the unsorted portion of the array and swaps it with the current index’s element. This gradually sorts the array from left to right. The example initializes an array, applies the selectionSort function to sort it, and then prints the sorted array in ascending order. The sorted array is obtained by repeatedly finding the smallest element in the unsorted portion and placing it in its correct position, resulting in an ordered array: [-202, -97, -9, -2, 0, 11, 45, 88, 747].
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant