Merge Sort and the Divide and Conquer Approach

Algorithm Design Techniques In earlier posts, I went through the insertion sort and the selection sort algorithms.  They both use the incremental approach.  Each step of the algorithms sorts one element, and thus the algorithms solve the problem incrementally. The divide-and-conquer is another approach.  It includes 3 steps that are…

Imperative and Functional Insertion Sort in OCaml

I wrote the insertion algorithm in both imperative and functional styles in OCaml!  I talk about the fun and challenges of each style below: Imperative Insertion Sort I strictly follow the pseudocode on p.18 of the book Introduction to Algorithms.  The pseudocode is in imperative style so all I need…

Pseudocode, Insertion Sort and Loop Invariant

Pseudocode In Chapter 2 of Introduction to Algorithms, the authors introduce pseudocode.  Pseudocode is a way to describe algorithms.  Pseudocode is not computer code and is not typically concerned with issues of software engineering (e.g., data abstraction, modularity, and error handling).  The pseudocode conventions in this book are: Syntax/format: Indentation…

Algorithms

To be an awesome software engineer, you should know the common algorithms and data structure well.  I’m starting my algorithms learning with this book.  It is commonly regarded as the best book for learning algorithms.  I’ll go through this book chapter by chapter, and work on the exercises as I…