Skip to content

Reverse_Seletion_sort #12092

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions sorts/Revesesort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
def reverse_subarray(arr, start, end):

Check failure on line 1 in sorts/Revesesort.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (N999)

sorts/Revesesort.py:1:1: N999 Invalid module name: 'Revesesort'
while start < end:
arr[start], arr[end] = arr[end], arr[start]
start += 1
end -= 1

def reverse_sort(arr):
n = len(arr)

Check failure on line 9 in sorts/Revesesort.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (W293)

sorts/Revesesort.py:9:1: W293 Blank line contains whitespace
for i in range(n):

Check failure on line 11 in sorts/Revesesort.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (W293)

sorts/Revesesort.py:11:1: W293 Blank line contains whitespace
max_index = i
for j in range(i + 1, n):
if arr[j] > arr[max_index]:
max_index = j

Check failure on line 16 in sorts/Revesesort.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (W293)

sorts/Revesesort.py:16:1: W293 Blank line contains whitespace

Check failure on line 17 in sorts/Revesesort.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (W293)

sorts/Revesesort.py:17:1: W293 Blank line contains whitespace
reverse_subarray(arr, i, max_index)

# Example usage
arr = [64, 88, 96, 1, 11]
reverse_sort(arr)
print("Sorted array:", arr)
Loading