Longest path search algorithm
The code tries to find a path that gives profit, for example. If we got a tree with three nodes that are all connected we want to find a path that leads to that we have to pay less each time we walk it.
Logitech Marble Mouse Scroll Driver (MarbleMagic)
I recently bought a Logitech Marble Mouse which is a optical trackball mouse.
K largest subsequences in a set of integers (negative and positive)
The problem here is that we want to find the K largest subsequences of s set i of integers between -infinity and infinity. This implementation is done in haskell but can easily be made in another language, more easily then also. We start by defining our sorting method that we are going to use to sort the result. Notice: In this implementation the result of each subsequence is given by a tuple with three values, (Int, Int, Int) lets say (x,y,z) were x is the total sum of the subsequence between index y and index z. Here in the ins method we insert the element x before y if it is less or equal to y (notice names have nothing to do with above declaration of (x,y,z), they are new!). And if this is not the case we insert x later in the array of values (ys).
Insertion sort, Bucket sort and Merge sort
So, maybe you have been asking yourself how to best implement sorting functions in PHP or some similar language like Java. Here I will shortly walk you through three different sorting functions that is easily implemented in PHP. As PHP isn’t really the optimal language for sorting or such I suggest implementing a C solution or similar to gain optimal advantage of the language itself. Let’s start with the code. Code and explanation after the break.
Haskell, The beginning
Well, I started a course in Haskell, beginning to get to the end of the course and thought that I would add some small code-snippets here for guidance.