My answer for insertion sort excercise#11
Open
m1ng2e wants to merge 78 commits intoinsertion-sort-exercisefrom
Open
My answer for insertion sort excercise#11m1ng2e wants to merge 78 commits intoinsertion-sort-exercisefrom
m1ng2e wants to merge 78 commits intoinsertion-sort-exercisefrom
Conversation
added - exercise for insertion sort
Merge Sort Exercises
Shell Sort Exercise
Selection sort exercise
ENH: added depth first search
ENH: added BFS Code
Range update on odd numbers function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I think the solution may have issues, so I attached my solution.
`def selection_sort(arr):
size = len(arr)
def grouper(sequence, key):
groups = []
uni_list = []
for x in sequence:
uni_list.append(x[key])
def selection_sort_key(arr, key):
size = len(arr)
def selection_sort_multilevel(arr, preference):
x = 0
key = preference[x]
size = len(arr)
for i in range(size-1):
min_index = i
for j in range(min_index+1, size):
if arr[j][key] < arr[min_index][key]:
min_index = j
if name == 'main':
elements = [
{'First Name': 'Raj', 'Last Name': 'Nayyar'},
{'First Name': 'Suraj', 'Last Name': 'Sharma'},
{'First Name': 'Karan', 'Last Name': 'Kumar'},
{'First Name': 'Jade', 'Last Name': 'Canary'},
{'First Name': 'Raj', 'Last Name': 'Thakur'},
{'First Name': 'Raj', 'Last Name': 'Sharma'},
{'First Name': 'Kiran', 'Last Name': 'Kamla'},
{'First Name': 'Armaan', 'Last Name': 'Kumar'},
{'First Name': 'Jaya', 'Last Name': 'Sharma'},
{'First Name': 'Ingrid', 'Last Name': 'Galore'},
{'First Name': 'Jaya', 'Last Name': 'Seth'},
{'First Name': 'Armaan', 'Last Name': 'Dadra'},
{'First Name': 'Ingrid', 'Last Name': 'Maverick'},
{'First Name': 'Aahana', 'Last Name': 'Arora'}
]
preference = [ 'First Name' , 'Last Name' ]
selection_sort_multilevel(elements, preference)
print(elements)`