Basic Sorting Algorithms


I’m studying for my master’s degree at the moment and in my spare time I rebuilt some of the basic sorting algorithms I learned. There are many more, but I wrote a few of them to gain some insight and because it’s fun :). The algorithms are far from optimized for real-life usage, but the mechanics are correct.

I built the following algorithms:

  • Bubble sort
  • Insertion sort
  • Merge sort
  • Quicksort
  • Quicksort with median 3
  • Randomized Quicksort

All the algorithms are built in such a way that they can sort any object type. To make this possible I used delegates to pass to the algorithms so they can extract the properties of the object that you need to sort on. To show how it works I’ve added a testing solution. It’s a simple console application that sorts arrays of given size and times how long it takes the algorithm to finish.

The source code can be found on Github, or in the downloads (top navigation bar).

If you have any questions, comments are open! 🙂


Notify Icon C#

Hi there,

I’ve been building an application that shows that little yellow balloon in the right corner (your system tray). I just wanted to share how I accomplished it.


1. First of all you need to instantiate an object NotifyIcon

You can give NotifyIcon an icon that shows in the system tray by adding any .ico file to a Resource file in your project. You can then reference this resource file. An other important property of the object is the .Visible property. This tells the icon.. if it’s visible in the system tray. You also might want to add a handler to the .DoubleClick. I’ve done this to show a dialog to change settings of the little program in question.

_notifyIcon = new NotifyIcon { 
              Icon = Mail_Checker.Resources.Icons.mail, 
              Visible = false 
_notifyIcon.DoubleClick += ToggleSettingsDialog;

//The handler
private void ToggleSettingsDialog(object e, EventArgs ea)
    if (WindowState == WindowState.Minimized)
        this.WindowState = WindowState.Normal;
        _notifyIcon.Visible = false;
        this.WindowState = WindowState.Minimized;
        _notifyIcon.Visible = true;

2. Adding a right-click menu

To add a right-click menu to a notifyicon you have to create two objects. A MenuItem and a ContextMenu.

The contextmenu is the actual menu itself, and every option in that menu has to be added manually. So first, let’s create a quit-item for the menu.

//Initialize quit-option in menu 
_menuItemQuit = new MenuItem
                    Index = 0,
                    Text = "Quit"
_menuItemQuit.Click += MenuItemQuitClick;

Next, we want to add that to the (not yet created) contextmenu so let’s do that now. As you can see, you need to cast the menuitem to an array, since the contextmenu usually takes more than 1 menu item.

//Configure contextmenu for notifyicon
_notifyIconContextMenu = new System.Windows.Forms.ContextMenu();
                                         new[] { _menuItemQuit }

And at last add that contextmenu to your notifyicon:

_notifyIcon.ContextMenu = _notifyIconContextMenu;

Now, to show a balloontip during runtime it’s as simple as calling ShowBalloonTip. The parameters below are the time-out (time it will display), the title, the message itself and the icon it shoud be given.

_notifyIcon.Visible = true;
    (5000, "Mail Checker", "Check your inbox, sir!", ToolTipIcon.Info);

Source code for the little program I built can be found on Github. Mail Notifier C# @ Github

Alarm Clock

Hey there,

I’ve spent a few days building this little alarm clock. I’ve been using a much simpler version of this for years now, and I thought it was about time I built one myself with a bit more options (more to come).

Alarm Clock screenshot

It’s as simple as this

The features:

  • Play MP3 files
  • Repeat the song when alarm is rung
  • Increase volume from set value (Don’t want to shock you in the morning don’t we?)
  • Narrate the current time on a given interval (This is a bit silent though, so I might want to fix that)

What I’d like to add in the future:

  • Playback youtube URL’s
  • Save alarms (song + time)

Update: I’ve updated the alarm clock as there were a few bugs.

You can get a download here, and the source code is available for everyone here.