Optimal Binary Search Tree

Given a sorted array keys[0.. n-1] of search keys and an array freq[0.. n-1] of frequency counts, where freq[i] is the number of searches to keys[i]. Construct a binary search tree of all keys such that the total cost of all the searches is as small as possible.

Share

Directed and Undirected Graph

This is small notes about graphs, There are two types of graphs, By just looking at below image you will understand the different of these two graphs. In a directed graph direction matters. i.e. edge V2->V3 means that edge is directed. There is only an edge from V2 to V3 and no edge from V3… Read more

Share

Matrix Chain Multiplication

Given a sequence of matrices, find the most efficient way to multiply these matrices together. The problem is not actually to perform the multiplications, but merely to decide in which order to perform the multiplications. We have many options to multiply a chain of matrices because matrix multiplication is associative. In other words, no matter… Read more

Share

Matrix multiplication notes

Here this is a small notes for matrix multiplication, It is very useful for matrix related algorithms. Lets start with normal multiplication, For example we want to multiply 2 and 3, So normally we can do 2*3 = 6 OR 3*2 = 6 here you can see multiplication is commutative. But it is not always… Read more

Share