Uncategorized

Max temperarue using hadoop mapreducer

MAXTEMP.JAVA import java.io.File; import java.io.IOException; import java.util.Scanner; import java.util.StringTokenizer; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.IntWritable; import org.apache.hadoop.io.Text; import org.apache.hadoop.mapreduce.Job; import org.apache.hadoop.mapreduce.Mapper; import org.apache.hadoop.mapreduce.Reducer; import org.apache.hadoop.mapreduce.lib.input.FileInputFormat; import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; public class MaxTemp { public static void main(String[] args) throws Exception { Configuration conf = new Configuration(); Job job = Job.getInstance(conf, "max temp"); job.setJarByClass(MaxTemp.class);… Continue reading Max temperarue using hadoop mapreducer

Advertisements
Uncategorized

Traveling salesman problem using dynamic method

#include<stdio.h> int a[10][10],visited[10],n,cost=0; int tsp(int c) { int cnt, near_city = 999; int min = 999, temp; for(cnt = 0; cnt < n; cnt++) { if((a[c][cnt] != 0) && (visited[cnt] == 0)) { if(a[c][cnt] < min) { min = a[cnt][0] + a[c][cnt]; } temp = a[c][cnt]; near_city = cnt; } } if(min!= 999) { cost… Continue reading Traveling salesman problem using dynamic method

Uncategorized

BelmonFord

    #include<stdio.h> int main() { int V, edge[20][2], G[20][20],i, j, k=0; printf("\nBELLMAN FORD"); printf("\nEnter the no of vertices: "); scanf("%d", &V); printf("\nEnter graph in matrix form: \n"); for(i=0;i<V;i++) { for(j=0;j<V;j++) { scanf("%d",&G[i][j]); if(G[i][j]!=0) edge[k][0]=i,edge[k++][1]=j; //add edge } } if(bellman_ford(G, V, k, edge)) printf("\n No negative weight cycle "); else printf("\n negative weight cycle is… Continue reading BelmonFord

Uncategorized

implement Pass-I of two pass assembler for symbol processing DS and DC statements

Problem Statement:WAP to implement Pass-I of two pass assembler for symbol processing considering following cases: i)Forward References ii)DS and DC statement iii)Error Handling */ #include<stdio.h> #include<string.h> #include<stdlib.h> int r=0,p=0,s=0,b=0; int i,k; FILE *fp; char line[20]; int cnt; char word[10]; int wc=0; int lc; int q=0; //Symbol counter struct opcodetable { char opcode[10]; char type[4]; char… Continue reading implement Pass-I of two pass assembler for symbol processing DS and DC statements

Uncategorized

implement Calculator using lex and yacc

calculator.y %{ #include<stdio.h> %} %token NUMBER %left '-''+' %left '*''/' %nonassoc UMINUS %% statement:exp {printf("=%d",$1);} ; exp:exp'+'exp {$$=$1+$3;} |exp'-'exp {$$=$1-$3;} |exp'*'exp {$$=$1*$3;} |exp'/'exp {if($3==0) { yyerror("\n Divide by zero"); return ;} else $$=$1/$3; } |'-'exp%prec UMINUS {$$=-$2;} |'('exp')' {$$=$2;} |NUMBER {$$=$1;} ; %% int main() { yyparse(); } int yyerror(s) char *s; { printf("%s",s); return… Continue reading implement Calculator using lex and yacc

Uncategorized

Implement Pass2 Of 2 pass assembler generate machine code table process symbol table

/* * a.c * * Created on: 12-Apr-2018 * Author: garry */       /* * a2.c * * Created on: 08-Feb-2018 * Author: student */ #include<stdio.h> #include<string.h> FILE *fp; int i,j,p=0; int q=0; //for symbol index struct symboltable { char symbol[10]; int address; }symbol[10]; struct machinecode{ int address; char mc[5]; char oper1[5]; int… Continue reading Implement Pass2 Of 2 pass assembler generate machine code table process symbol table

Uncategorized

Implement Pass2 of 2 pass assembler for generating Machine Code table

#include<stdio.h> #include<string.h> FILE *fp; int i,j,p=0; struct machinecode{ int address; char mc[5]; char oper1[5]; int oper2; }mc[10]; struct intermediatecode { int address; char type[20]; char mc[10]; char oper1[10]; char oper2type[10]; int oper2id; }IC[30]; struct literaltable { char literal[10]; int address; }littable[30]; int pooltab[10]; void readIC() { fp=fopen("ic.txt","r"); while(!feof(fp)) { fscanf(fp,"%d %s %s %s %s %d",&IC[p].address,IC[p].type,IC[p].mc,IC[p].oper1,IC[p].oper2type,&IC[p].oper2id);… Continue reading Implement Pass2 of 2 pass assembler for generating Machine Code table

Uncategorized

Implement Pass1 assembler of 2 pass assembler for generating IC and Literal table

  #include<string.h> #include<stdio.h> #include<stdlib.h> void wc1(); void wc2(); void wc3(); struct opcodetable { char opcode[10]; char type[5]; char mcode[5]; char length[3];   }op[10];   struct registertable { char regname[6]; char mcconstant[3]; }reg[10];   struct literaltable { char literal[4]; int address;   }littable[10]; struct intermediatecode { int address; char type[5]; char mc[5]; char oper1[6]; char oper2type[5];… Continue reading Implement Pass1 assembler of 2 pass assembler for generating IC and Literal table

Uncategorized

Write a program to find Maximum and Minimum element in an array using Divide and Conquer strategy and verify the time complexity.

#include<stdio.h> int a[20]; int min,max; void minmax(int i,int j) { int min1,max1,mid; if(i==j) { min=a[i]; max=a[i]; } else { if(i==j-1) { if(a[i]<a[j]) { min=a[i]; max=a[j]; } else { min=a[j]; max=a[i]; } } else { mid=(i+j)/2; minmax(0,mid); max1=max; min1=min; minmax(mid+1,j); if(min1<min) { min=min1; } if(max1>max) { max=max1; } } } } int main() { int i,n;… Continue reading Write a program to find Maximum and Minimum element in an array using Divide and Conquer strategy and verify the time complexity.

Uncategorized

Write a program to solve optimal storage on tapes problem using Greedy approach.

#include<stdio.h> int i,j,n,t=3; //i j for counters, n for number of programs, t for no of tapes int p[30],l[30],temp,m,tape[10][10],tape1[30][30]; //p[] stores program no,and l[] stores program length int itemcount[10]; //to store no of items in each tape int c1=0,c2=0,c3=0; float mrt[10]; void getval() { printf("Enter no of programs\n"); scanf("%d",&n); printf("Enter number of tapes"); scanf("%d",&t); for(i=0;i<n;i++)… Continue reading Write a program to solve optimal storage on tapes problem using Greedy approach.