The always learning Marty’s software engineering journey

  • Functional Style Selection Sort in OCaml

    In this post I talk about what I have tried and learnt in the process of writing the functional correspondence of the imperative selection sort I wrote earlier in OCaml.  I learnt a lot in this practice because functional selection sort is not straight forward! The First Attempt At the beginning, I thought functional selection…

  • Imperative Style Selection Sort in OCaml

    Exercise 2.2-2 of the book Introduction to Algorithms introduced the selection sort algorithm.  I decided to write it in OCaml in imperative style. The selection sort algorithm sorts a list first by switching places of the smallest element of a given list with the first element of the list.  Then, it selects the smallest element…

  • The Efficiency of an Algorithm

    We need to analyze algorithms to choose the most efficient algorithm to implement.  One important aspect we look at is the running time of an algorithm, which often depends on the size of input.  (See Chapter 2-2 of Introduction to Algorithms.) Size of Input Examples in measuring the input size of a problem: The number…

  • 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 to do is to translate…

  • 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 indicates block structure.  The body…

  • Introduction to Algorithms

    What is an algorithms? From chapter 1 of Introduction to Algorithms, an algorithm is any well-defined procedure that transforms a set of input to a set of output with desired properties.  It is a tool for solving a computational problem, which specifies the desired input/output relationship. Input → Algorithms → Output The input is organized in a…

  • Implementing Communication Styles for Effective Discussions

    I came across this great article on dev.to titled ‘Communication styles – Working effectively as a team’, which is inspired by this tweet .  I recommend reading both sources but I offer a summary below.  Then I explain how to use this information to increase effectiveness of most discussions. Communication Styles The two styles of…

  • Imperative Programming in OCaml

    Imperative Vs Functional Programming So far, what I’ve done in OCaml is functional, i.e., I declare functions and the output value of a function depends only on the arguments that are passed to the function.  The data structures covered are mostly immutable (not able to change).  In contrast, with imperative programming, computations are structured as…

  • Data Structures in OCaml

    In this post I continue going through Chapter 1 of Real World OCaml.  I learnt that: Errors may be caught at compile time or at run time.  Compile-time errors are preferred to runtime errors, because it’s better to catch errors as early as possible in the development process.  An e.g. of a compile-time error is…

  • Moving on to Real World OCaml

    After finishing the first 4 chapters of OCaml from the very beginning, I feel I am ready to move on to other learning resources that assume more programming background.  After all, I can write the Fizzbuzz test now, right?  Real World OCaml and the OCaml tutorials also have the advantage of being more up to…