Skip to main content

Posts

Showing posts from July, 2011

Mediun Cut Image Compression source code in java

The median cut algorithm is a popular algorithm for color quantization, but can be applied to virtually any point clustering problem. In outline, it works as follows: * Let B be a set of boxes containing points, initially containing only a single box containing all points. * While the number of boxes in B is less than desired number of clusters... o Find the largest side length of any side of any box. o Cut that box into two boxes along its largest side in such a way that half the contained points fall into each new box. o Shrink the two new boxes so that they are just large enough to contain their points. If anyone need any help how to do without my code just post comment I will try to give proper direction to do it. CoDe ***************************************************************************** /** * @(#)box.java * * * @author sharma * @version 1.00 2011/7/8 */ public class Box { publ...

Shift Reduce algorithm source code in c for Compiler

#include #include #include #include #include using namespace std; struct stru1 { char non_ter[1],pro[25]; }cfg[25]; int n,st=-1,j,i,t=-1,m; int v,c,p=1; char str[20],stack[20],ch,tmp[10]; void match(int k); void matchl(int k); int main() { printf("Enter the number of productions:\n"); scanf("%d",&n); printf("\n"); printf("Enter the productions on LEFT and RIGHT sides:\n"); for(i=0;i \n"); scanf("%s",cfg[i].pro); printf("\n"); } printf("Enter the input string:\n"); scanf("%s",str); printf("\n"); i=0; do { ch=str[i]; stack[++st]=ch; tmp[0]=ch; match(1); i++; }while(str[i]!='\0'); c=st; v=st; puts(stack); printf("\n"); while(st) { --st; v=st; t=-1; p=0; while(v<=c) { ...

Iterative Deeping algorithm source code in C++

 Source code of iterative deeping search is given. # include <stdio.h> # include <iostream> # include <sstream> # include <algorithm> # include <string.h> # include <string> # include <math.h> # include <queue> # include <vector> using namespace std; int node,edge; vector<int>adj[100]; bool flag[100]; int dist[100],par[100],leb[100]; int bfs(int s,int e,int lev) {    int i,cur,head,tail,que[10000],l=0;    head = tail = 0;    que[head++] = s;    flag[s] = 1;    dist[s] = 0;    par[s] = -1;    leb[s] = 0;    memset(leb,0,sizeof(leb));    while(head != tail)    {        cur = que[tail++];        if(leb[cur] == lev)        {            return 0 ;      ...

A*Star Serach source code in C++

#include <iostream> #include <string> #include <map> #include <queue> #include <stack> #include <algorithm> #include <list> #include <set> #include <cmath> #include <cstring> #include <stdio.h> #include <string.h> #include <sstream> #include <stdlib.h> #include <vector> #include <iomanip> #include <ctime> using namespace std; int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; int fx,fy,dist[100][100],row,col; int distance(int x,int y,int p,int q); int heuristic(int x,int y); //vector<string>board; int board[100][100]; struct pq {     int x,y,cost,h,total_cost;     pq(int _x,int _y,int _cost)     {         x=_x;y=_y;cost=_cost;         h=heuristic(x,y);         total_cost=cost+h;     ...