Min Heap implementation for Dijkstra algorithm

Dijkstra’s algorithm is used to compute the shortest distance between two vertices in a graph. The psuedo code for the main part of Dijkstra’s algorithm is shown below:

An extremely fast implementation for Heap which can be used in Dijkstra’s algorithm is shown below:

MinHeap implements two methods (at a minimum): Insert. Extract Min. For Dijkstra’s algorithm, it[…]

Read more

MinHeap implementation for .NET

A heap is a balanced tree which has some special properties. There are two variations of heap: MinHeap and MaxHeap. MinHeap has the property where the parent node is lesser than all the child nodes. In a MinHeap, the root node has the minimum value. MaxHeap is the opposite of MinHeap. MaxHeap has the maximum value in the root node.[…]

Read more

Getting all documents from a FAST collection

The Introduction to FAST Search API provides an introduction on how to use the FAST API. The following code explains how to get all documents from a FAST collection.

When a search query is sent to FAST, FAST prepares a result set with a maximum of 4020 documents. By passing in two query parameters: offset and hits, it is possible[…]

Read more

QuickSelect works in linear time

QuickSelect is a selection algorithm that finds the kth┬ásmallest number from a list. QuickSelect is O(n) algorithm. I built a simple prototype to verify that QuickSelect works in linear time. QuickSelect uses a random pivot to partition the array. The items to the left of the pivot are lesser than the pivot. The items to the right of the pivot[…]

Read more

Javascript inheritance in Knockout ViewModels

Knockout is an elegant way of updating the user interface using Javascript View models. Javascript has an inheritance model which allows for a View model hierarchy. As an illustration, consider the following HTML:

The name and detail properties of the View model are bound to the respective div elements. The Javascript which applies the binding is shown below:


Read more

Getting all collections stored in FAST

FAST has something called Views. Views encapsulate how content is structured, how search is performed, and how results are presented. Content is organized using Collections. A collection is a grouping of FAST Documents. Each FAST Document has a specific structure, specified by Fields. The view also stores the profile based on which documents are indexed. Search is performed depending on[…]

Read more

Ensure that the Task gets completed before exiting the Unit Test method

There are methods that return a Task<T>. While testing such methods, a common mistake is to make assert statements, without waiting for the task to complete.

While I wrote a few test methods like the above, all those test methods succeeded repeatedly. I was doing integration testing and I expected the test methods to fail. It was a while[…]

Read more

Alternate ways to invoke a REST API

.NET offers two alternate ways to access a REST API (including ASP.NET Web API). The typical way to access a REST API is using the HttpClient.

The HttpClient does a POST on the REST API and receives a JSON response. The JavaScriptSerializer is used to parse the JSON response to a custom object. The alternate way to access a[…]

Read more