Skip to content

Selection sort completed.#1

Merged
dyiar merged 3 commits intomasterfrom
victor-goico
Jun 6, 2019
Merged

Selection sort completed.#1
dyiar merged 3 commits intomasterfrom
victor-goico

Conversation

@VictorGoic0
Copy link
Copy Markdown
Owner

No description provided.

if (arr[j] < smallest):
smallest = arr[j]
smallest_index = j
arr[i], arr[smallest_index] = smallest, current
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

good job with these!

def bubble_sort( arr ):

def bubble_sort(arr):
boolean = True
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

so proud to see you using the boolean and while loop. More than a couple people here didn't haha

arrA.pop(0)
while len(arrB) > 0:
merged_arr.append(arrB[0])
arrB.pop(0)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I like the way you implemented this. Good job

if (len(arr) <= 1):
return arr
else:
midpoint = math.floor(len(arr) / 2)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I can't remember if // does this in every language or if it is just a python thing, but len(arr) // 2 is the same as math.floor(len(arr)/2)

else:
midpoint = math.floor(len(arr) / 2)
left = arr[0:midpoint]
right = arr[midpoint:len(arr)]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

to save lines you could condense these and do left = merge_sort(arr[0:midpoint]) and right = merge_sort(arr[midpoint:])

Good job with these!

@dyiar dyiar merged commit 0ee03e9 into master Jun 6, 2019
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.

2 participants