An attempt to merge sort functionally in C#

In a month I’ll be starting a new job which will be focused on big data using Scala and Apache Spark.
In preparation, I’ve been re-familiarising myself with Scala by implementing various of the most common data structures and algorithms in Scala.

When comparing how C# (my current occupation programming language) programmers and Scala programmers implement the merge sort, I noticed they are usually quite different in approach. This is partly due to C# and Scala implementing their list data type very differently.
So to help me with my understanding of the merge sort, I decided to try and write it in C# in a way that people generally implement it in Scala.

This github link shows what I came up with.
https://github.com/CSGrimey/MiscSnippets/blob/master/Code/Algorithms/MergeSort.cs

I think this has helped my understanding of the logic and implementation of the merge sort, so I may continue doing this with other algorithms. As that forces me to really understand what is going on instead of memorising the code.

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s