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

Assignment 2 - Insertion Sort #16

Open
gmertk opened this issue Nov 27, 2015 · 0 comments
Open

Assignment 2 - Insertion Sort #16

gmertk opened this issue Nov 27, 2015 · 0 comments

Comments

@gmertk
Copy link
Owner

gmertk commented Nov 27, 2015

Imagine that you are holding some sorted cards in your hand. You get a new card from the table. You have to insert it in the correct place in your hand. "Take a new card, insert in the right place. Take another new card, insert it in the right place". This is the main idea of the insertion sort.

Write an insertionSort function that takes an array and returns it as sorted by using the isOrderedBefore closure. Don't mutate the original array (don't use inout).

There is already a swap function in the standard library. However, you can just move the larger elements to the right rather than using the swap function.

Due Date: Monday 30.11.2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant