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

Implement an Insertion-Sort Reducer #1

Open
nikhedonia opened this issue Oct 29, 2018 · 0 comments
Open

Implement an Insertion-Sort Reducer #1

nikhedonia opened this issue Oct 29, 2018 · 0 comments
Labels
good first issue Good for newcomers

Comments

@nikhedonia
Copy link
Collaborator

nikhedonia commented Oct 29, 2018

Sort can be implemented via scan by performing an inserting incoming elements into a vector.
To find the right position to insert can be found using a binary search.
This approach would lead to a runtime complexity of O(n log n).

potential API:

 range() 
   >> scan( vector<int>{}, sort() )
   >> drop(4)
   >> take(1);
   // should return {4,3,2,1,0}

To limit the size of the buffer, a higher order function may be handy eg.:

  range()
     >> scan( vector<int>{}, sort() | slice(10) );
@nikhedonia nikhedonia added the good first issue Good for newcomers label Oct 29, 2018
@nikhedonia nikhedonia changed the title implement insertion sort Implement an insertion-sort reducer Oct 29, 2018
@nikhedonia nikhedonia changed the title Implement an insertion-sort reducer Implement an Insertion-Sort Reducer Oct 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant