| Home | My Account | Directories |
Back tracking:
Published on 2009-03-17 06:13:00
N-queue:Description: The objective is to place the n queens in each row in the n*n matrix such that no two queens attack each other. Algorithm:Data structures used: n- Hold the no of queens. k – Hold the track of the row. x [ ] – Hold the track of the column number. 1. Read the no of queens store in variable n 2. For i=1 to n 3. Call the place procedure 4. Stop Algorithm of place procedure //Return true if a queen can be placed in the kth row and ith column, oth
Kruskal’s Algorithm
Published on 2009-03-17 06:11:00
Description: For the given connected ,undirected graph G=(v,e),determine the weighted acyclic minimum spanning tree but are not necessarily connected, where weight is defined as the sum of the weights on all its edges. Algorithm:Data structures used: n- Hold the no of vertices in the graphcost[10][10] – Hold the cost adjacency matrix p[[10] – Hold the parent element of the nodesmincost- Hold the minimumcost of the tree 1. Read the no of nodes 2. Read the cost adjacency matrix 3. Selec
Prim’s Algorithm:
Published on 2009-03-17 06:08:00
Description: For the given connected, undirected graph G=(v,e),determine the connected weighted acyclic minimum spanning tree, where weight is defined as the sum of the weights on all its edges. Algorithm:Data structures used: n- Hold the no of vertices in the graphcost[10][10] – Hold the cost adjacency matrix d[[10] – Hold the shortest distance from source to all other nodesp[10] – Hold the path from source to destinations – Hold the nodes that are so far visited and the node