Java Engineering Programs Blog

turing Machine program in java for equal no of 1’s and 0’s

turing Machine program in java for equal no of 1’s and 0’s

import java.io.*; import java.lang.*; class turing_machine { public static void main(String args[])throws IOException { int i,n1,n,j,z,count=0,count1=0,turing_machine1; DataInputStream in=new DataInputStream(System.in); System.out.println(“Enter Input to turing machine”); String s; s=in.readLine(); turing_machine1=s.length(); char a[]=s.toCharArray(); System.out.print(“String->”); for(i=0;i<turing_machine1;i++) { System.out.print(“\t”+a[i]);...

Push Down Automata  program in java for Equal no of a’s and b’s

Push Down Automata program in java for Equal no of a’s and b’s

import java.io.*; class pda { public static void main(String args[])throws IOException { String s; int i; int pass=0; DataInputStream in=new DataInputStream(System.in); System.out.println(“Enter String”); s=in.readLine(); char ar[]=s.toCharArray(); Stack ob=new Stack(); for(i=0;i<s.length();i++) { if(ar[i]==’a’) ob.push(ar[i]); else...

finite-state machine program in java For String abab (TCS)

finite-state machine program in java For String abab (TCS)

import java.io.*; class FSMS1 { public static void main(String args[])throws IOException { int n=0,i,f=0; DataInputStream in=new DataInputStream(System.in); String fsm; System.out.println(“Enter fsm input”); fsm=in.readLine(); System.out.print(“fsm table “); System.out.println(“\ta\tb”); System.out.println(“q0\tq1\tq0”); System.out.println(“q1\tq1\tq2”); System.out.println(“q2\tq3\tq0”); System.out.println(“q3\tq1\tq4”); System.out.println(“q4\tq4\tq4”); System.out.println(); System.out.print(“State...

non restoring division algorithm in java

non restoring division algorithm in java

import java.io.*; class NONRESTORING { public static int[] lshift(int s1[],int s2) { int s[]=new int [4]; for(int i=0;i<3;i++) { s[i]=s1[i+1]; } s[3]=s2; return(s); } public static int[] add(int A[],int B[]) { int s[]=new int...