#3rdSem results out. Pass huney walas lai badhai. Back haru note it http://ift.tt/1q8Ru2E
News mirrored from: CSIT Authority
The naming format CSC-351-SE-L-05 provides the following information: Software Engineering Lab Assignment#5.
Other abbreviations indicate the following: L=LAB Assignment, T=Theory Assignment, HC=HardCopy, SC=Softcopy, R=Report
*Similar Naming convention will be used to complete and upload assignments. Assignments can be viewed and uploaded in the panel below this notice.
{SubjectCode}-{SubjectAbbr}-{LABorTHEORY}-{AssignmentNumber}-{[YourIDoptional]}
example, for Software Engineering Lab Assignment#5, use::
CSC-351-SE-L-05.docx OR, CSC-351-SE-L-05-013BSCCSIT055.docx [Giving your ID is optional].
| i | n | t | e | g | r | |
|---|---|---|---|---|---|---|
| q0 | q1 | q8 | q8 | q8 | q8 | q8 |
| q1 | q8 | q2 | q8 | q8 | q8 | q8 |
| q2 | q8 | q8 | q3 | q8 | q8 | q8 |
| *q3 | q8 | q8 | q8 | q4 | q8 | q8 |
| q4 | q8 | q8 | q8 | q8 | q5 | q8 |
| q5 | q8 | q8 | q8 | q6 | q8 | q8 |
| q6 | q8 | q8 | q8 | q8 | q8 | q7 |
| *q7 | q8 | q8 | q8 | q8 | q8 | q8 |
| q8 | q8 | q8 | q8 | q8 | q8 | q8 |
public class DFAwithdeadend {
public static void main(String[] args) {
// Implement DFA that accepts 'int' or 'integer'
int count;
String state_now="q0",
final_state1="q3",final_state2="q7";
Scanner sc= new Scanner(System.in);
System.out.print("Enter a string to test:");
String string= sc.nextLine();
HashMap i = new HashMap();
HashMap n = new HashMap();
HashMap t = new HashMap();
HashMap e = new HashMap();
HashMap g = new HashMap();
HashMap r = new HashMap();
HashMap deadend = new HashMap();
i.put("q0","q1");
n.put("q1","q2");
t.put("q2","q3");
e.put("q3","q4");
g.put("q4","q5");
e.put("q5","q6");
r.put("q6","q7");
for(count=0;count<=8;count++){
String rem_state="q"+count;
if (count!=0)
i.put(rem_state,"q8");
if (count!=1)
n.put(rem_state,"q8");
if (count!=2)
t.put(rem_state,"q8");
if (count!=3 && count!=5)
e.put(rem_state,"q8");
if (count!=4)
g.put(rem_state,"q8");
if (count!=6)
r.put(rem_state,"q8");
deadend.put(rem_state, "q8");
}
System.out.print("Tracing DFA..\nstart:q0");
for(count=0;count<string.length();count++){
if(string.charAt(count)=='i'){
state_now=(String)i.get(state_now);
}
else if(string.charAt(count)=='n'){
state_now=(String)n.get(state_now);
}
else if(string.charAt(count)=='t'){
state_now=(String)t.get(state_now);
}
else if(string.charAt(count)=='e'){
state_now=(String)e.get(state_now);
}
else if(string.charAt(count)=='g'){
state_now=(String)g.get(state_now);
}
else if(string.charAt(count)=='r'){
state_now=(String)r.get(state_now);
}
else{
state_now=(String)deadend.get(state_now);
}
System.out.print("-->"+state_now);
}
if(state_now.equals(final_state1)||state_now.equals(final_state2)){
System.out.println("\nConclusion: This string is accepted in DFA");
}
else{
System.out.println("\nConclusion: This string is not accepted in DFA");
}
}
}
OUTPUT:If you have any doubt, please feel free to inquire.

public class DfaEvenAB {
public static void main(String[] args) {
//Implementing DFA with even a and b
String state="q0";
Scanner sc = new Scanner(System.in);
System.out.print("Enter the String:");
String exp=sc.nextLine();
HashMap a = new HashMap();
HashMap b = new HashMap();
a.put("q0","q1");
a.put("q1","q0");
a.put("q2","q3");
a.put("q3","q2");
b.put("q0","q3");
b.put("q1","q2");
b.put("q2","q1");
b.put("q3","q0");
System.out.print("Tracing DFA:\nstart=q0");
for(int i=0;i<exp.length();i++){
String str=""+exp.charAt(i);
if(str.equals("a")){
state=(String)a.get(state);
}else if(str.equals("b")){
state=(String)b.get(state);
}
System.out.print("-->"+state);
}
if(state.equals("q0")){
System.out.println("\nString Accepted");
}else{
System.out.println("\nString not Accepted. Try another String.");
}
}
}
public class DfaFinder {
public static void main(String[] args) {
// Implement DFA ending with abb
String state_now="q0";
Scanner sc= new Scanner(System.in);
String string= sc.nextLine();
HashMap a = new HashMap();
HashMap b = new HashMap();
a.put("q0","q1");
a.put("q1","q1");
a.put("q2","q1");
a.put("q3","q1");
b.put("q0","q0");
b.put("q1","q2");
b.put("q2","q3");
b.put("q3","q0");
System.out.print("Tracing DFA..\nstart:q0");
for(int i=0;i<string.length();i++){
if(string.charAt(i)=='a'){
state_now=(String)a.get(state_now);
}
else if(string.charAt(i)=='b'){
state_now=(String)b.get(state_now);
}
System.out.print("-->"+state_now);
}
if(state_now.equals("q3")){
System.out.println("\nConclusion: This string is accepted in DFA");
}
else{
System.out.println("\nConclusion: This string is not accepted in DFA");
}
}
}
OUTPUT:If you have any doubt, please feel free to inquire.
TOTAL: Page Hits and Unique Sessions since June 22 nd 2014