C# coding challenge #1: MicroSort


Starting now i’m going to be (hopefully) posting some tricky coding challenges on here for people to solve

The first challenge will be: Create the smallest, fastest, most versatile sorting algorithm you can using the following class template:

using System;
using System.Collections.Generic;
public class mySort <T> where T : IComparable<T>
int ax;
int bx;
int cx;
T dx;
Stack<int> stack= new Stack<int>();

public void Swap(T[] array)

public void Sort(T[] array)


Rules (Easy):

  • **ONLY** the areas marked by //TODO may be altered (that means no additional function definitions or changes to function signatures etc)
  • No local variables
  • Stack will start empty
  • Stack must end empty
  • Array must be sorted when the function returns
  • Static functions can not be used

Rules (Medium)

  • Everything from easy
  • Only recursion can be used for control flow. (thank you, Tarik Kaya, for suggesting this)

Rules (Hard)

  • Everything from medium
  • Replace the stack with a fixed-length array

Good Luck


Initial stats for the reference implementation:
reference file length:
100 lines of normally formatted code (braces on separate lines + one statement per line, except for if conditions)

via WordPress for Phone app.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s