Contents tagged with Algorithms
-
Going Functional : Depth and Breadth First Search in F#
In this blog post, I will provide the depth and breadth first traversal implementation in F#. But before that lets look at the Java based implementation of these traversal mechanisms. The code is taken from Algorithms 4th Edition by Robert Sedgewick and Kevin Wayne. You can find the complete code here : http://algs4.cs.princeton.edu/40graphs/
-
Going Functional : Priority Queues in F#
In this blog post, I will provide the F# implementation for max priority queue. First the java based implementation taken from Algorithms 4th Edition by Robert Sedgewick and Kevin Wayne. You can find the complete priority queue implementation here : http://algs4.cs.princeton.edu/24pq/MaxPQ.java.html
-
Going Functional : Merge and Quicksort in F#
Continuing our functional journey, in this post I will first present the Java based implementation of merge sort followed by F# based implementation. Finally we will repeat the same steps for QuickSort algorithm. Java based implementation of the sorting algorithms is taken from Algorithms 4th Edition by Robert Sedgewick and Kevin Wayne.
-
Going Functional : Elementary Sorting Algorithms in F#
In this blog post, I will provide F# implementation for Selection & Insertion sorting algorithms. First the C#/Java based implementation of these algorithms taken from Algorithms 4th Edition by Robert Sedgewick & Kevin Wayne.
-
Going Functional : Implementing Stack using F#
In this blog post, I will port linked list based Stack ADT code in C# to F#. Given below is the C# implementation. It’s inspired from the Java based implementation provided in the Algorithms 4th Edition book by Robert Sedgewick and Kevin Wayne. The Stack ADT class is called LLStack because .Net framework itself contains Stack data structure.
-
Implementing Key Indexed Counting Sort Algorithm
In this blog post, I am going to talk about the Key Indexed Counting Sort algorithm. Unlike other generalized sorting algorithms like quicksort, merge sort etc. key indexed counting sort algorithm is a specialized sorting algorithm which works best when the following conditions are met:
-
Binary Tree : Print Path From Root To Leaves & Max Depth
Problem : Given the following binary tree, print all the paths from root node to all the leave nodes.
-
Binary Tree : Level Order Traversal
In a binary tree, node level is defined as the number of nodes which are in between the node in context & the root node. If we consider root node is at level 0, then immediate child nodes of root are at level 1 and the subsequent child nodes are level 2 and so on. Thus level order traversal of a binary tre involves processing nodes on the basis of their levels i.e. level 0 nodes are to be processed before nodes at level 1 which are to be processed before nodes which are at level 2 etc. The screenshot below shows a tree and its corresponding level order traversal :
-
Algorithms Cheat Sheet : Graph Search
Note : Below mentioned source code is taken from the book “Algorithm 4th Edition” by Robert Sedgewick. These code snippets are for personal reference. For more details on these topics you can either buy the book or refer the following site : http://algs4.cs.princeton.edu/home/
-
Upcoming Courses on Coursera
Coursera is offering free online courses on various topics such as Network, Information, HealthCare, Computer Science, Mathematics etc. Courses are grouped under these categories and they cover a wide range of topics. I recently completed a five week course called “Design and Analysis Of Algorithms” by Tim Roughgarden. Course material is good, video lectures are short, clear and downloadable. Programming exercise, Q&A, discussion forums etc are few other things that make these courses really interesting.