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

Sorting_Techniques #23

Closed
wants to merge 1 commit into from
Closed

Sorting_Techniques #23

wants to merge 1 commit into from

Conversation

Prathamesh-510
Copy link

Here I contributed the all sorting algorithms in the python.

@HarshwardhanPatil07
Copy link
Owner

@Prathamesh-510 you need to star the repo for following code of conduct!

Copy link

@riya-kumari023 riya-kumari023 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here i contribute in sorting techniques (bubble sort)

if arr[j] > arr[j + 1]:
swaps += 1
arr[j], arr[j + 1] = arr[j + 1], arr[j]
return comparisons, swaps

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

def bubbleSort( sorti ):
n = len( sorti )

for i in range( n - 1 ) :
    flag = 0

    for j in range(n - 1) :
        
        if sorti[j] > sorti[j + 1] : 
            tmp = sorti[j]
            sorti[j] = theSeq[j + 1]
            sorti[j + 1] = tmp
            flag = 1

    if flag == 0:
        break

return sorti

comparisons = 0
swaps = 0
for i in range(n):
for j in range(0, n - i - 1):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import array as arr;
def bubble_sort(arr):
n = len(arr)
flag=0
comparisons = 0
swaps = 0
for i in range(n):
for j in range(0, n - i - 1):
comparisons += 1
if arr[j] > arr[j + 1]:
flag=1
swaps += 1
arr[j], arr[j + 1] = arr[j + 1], arr[j]
if flag==0:
break
return comparisons, swaps, arr
a = arr.array('i', [1,2,6,8,9])
bubble_sort(a)

@HarshwardhanPatil07
Copy link
Owner

@riya-kumari023 and @Kavu-13 make sure you star the repo to follow Code of Conduct

@Prathamesh-510 Prathamesh-510 closed this by deleting the head repository Oct 19, 2023
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.

None yet

4 participants