0% found this document useful (0 votes)
47 views15 pages

Final TOC

The document outlines a series of practical exercises focused on designing various finite state machines (FSMs), push down automata (PDAs), and Turing machines, each with specific aims such as accepting certain string patterns or performing computations. Each practical includes a conclusion summarizing the approach taken and rubric-based marks obtained across different criteria. The document also contains code snippets and descriptions of the algorithms used for each practical task.

Uploaded by

pruthvirajpasi42
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views15 pages

Final TOC

The document outlines a series of practical exercises focused on designing various finite state machines (FSMs), push down automata (PDAs), and Turing machines, each with specific aims such as accepting certain string patterns or performing computations. Each practical includes a conclusion summarizing the approach taken and rubric-based marks obtained across different criteria. The document also contains code snippets and descriptions of the algorithms used for each practical task.

Uploaded by

pruthvirajpasi42
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Practical – 1

Aim: Design a Finite State Machine (FSM) that accepts all strings
over input symbols {0, 1}
having three consecutive 1's as a substring.
Input:

Output:

Concution:
In this practical we draw that type of finite machine which accept any type of
language which include 0 and 1 but one condition is three 1 are consecutive. We
are draw this in our jflap software.

Rubric wise marks obtained:

Problem Completeness
Knowledge Logic
Recognition and accuracy Ethics (2)
(2) (2) Building (2) (2)
Rubrics Total
Good Avg. Good Avg. Good Avg. Good Avg. Good Avg.
(2) (1) (2) (1) (2) (1) (2) (1) (2) (1)

Marks
Practical – 2
Aim: Design a Finite State Machine (FSM) that accepts all strings
over input symbols {0, 1}
which are divisible by 3.
Input:

Output:

Concution:
In this practical we draw that type of finite machine which accept any type of
language which include 0 and 1 but one condition is this language is divisible by
3 so we can give final state and initial state of one state . We are draw this in our
jflap software.

Rubric wise marks obtained:

Problem Completeness
Knowledge Logic
Recognition and accuracy Ethics (2)
(2) (2) Building (2) (2)
Rubrics Total
Good Avg. Good Avg. Good Avg. Good Avg. Good Avg.
(2) (1) (2) (1) (2) (1) (2) (1) (2) (1)

Marks
Practical – 3
Aim: Design a program to validate strings against a given regular
expression.
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body {
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;

display: flex;
flex-direction: row;
justify-content:
center;
}
.content {
height:
auto; width:
auto;
border-radius: 20px solid black;
background-color:
paleturquoise; margin: 20px;
padding: 20px;
</style>
</head>
<body>
<div class="content">
<h1>Regular Expresion Validation</h1>
<label for="">Enter Regular Expresion</label> <br><br>
<input type="text" id="pattern" placeholder="e.g Enter Regular Exp">
<br><br>
<label for="">Enter String to Validate</label><br><br>
<input type="text" id="teststring" placeholder="e.g.123-456"> <br><br>
<button onclick="validateString()">Validate</button>
<p id="result">Result</p>
</div>

<script>
function validateString(){
let pattern=document.querySelector("#pattern").value;
let
teststring=document.querySelector("#teststring").value;
let result=document.querySelector("#result");
let p=document.querySelector("p");
try{
let regex=new RegExp(pattern);
if(regex.test(teststring)){
p.innerText= "Valid Expression"
}
else{
p.innerText="Invalid Expression"
}
}catch(e){
console.log("Error",e)
}
}
</script>
</body>
</html>
Output:

Concution:
In this practical we used concept regular expression that say that we give some
Regular Expression and our String to validate so when we press validate button
that time compiler give answer that it is Validate or Not.
Rubric wise marks obtained:
Problem Completeness
Knowledge Logic
Recognition and accuracy Ethics (2)
(2) (2) Building (2) (2)
Rubrics Total
Good Avg. Good Avg. Good Avg. Good Avg. Good Avg.
(2) (1) (2) (1) (2) (1) (2) (1) (2) (1)

Marks
Practical – 4
Aim: Implement an algorithm to minimize a given DFA.
Input:

Output:

Concution:
In this Practical we convert one DFA(Deterministic Finite Automata) to their
minimization form in our jflap software.

Rubric wise marks obtained:

Problem Completeness
Knowledge Logic
Recognition and accuracy Ethics (2)
(2) (2) Building (2) (2)
Rubrics Total
Good Avg. Good Avg. Good Avg. Good Avg. Good Avg.
(2) (1) (2) (1) (2) (1) (2) (1) (2) (1)

Marks
Practical – 5
Aim: Design a Program to convert NDFA to DFA.
Input:

Output:

Concution:
In this Practical we convert Non Deterministic Finite Automata(NDFA) to
Deterministic Finite Automata(DFA) using many other algorithm but in this we
used simple our jflap software and convert NDFA to DFA.

Rubric wise marks obtained:

Problem Completeness
Knowledge Logic
Recognitio and accuracy Ethics (2)
(2) Building (2)
Rubrics n (2) Total
(2)
Good Avg. Good Avg. Good Avg. Good Avg. Good Avg.
(2) (1) (2) (1) (2) (1) (2) (1) (2) (1)

Marks
Practical – 6
Aim: Design a Push Down Automata (PDA) that accepts all string
having equal number of 0's
and 1's over input symbol {0, 1} for a language 0n1n where n >= 1.
Input:

Output:

Concution:
PDA(Push Down Automata) we used for complex data and so we used extra
memory is stack in pda. Here first we have stack one value Z than 0 is arrive. In
stack when one is arrive so delete 0 and so on after this all operation our stack is
empathy and we give our output that this language is accepted or not.

Rubric wise marks obtained:

Problem Completeness
Knowledge Logic
Recognitio and accuracy Ethics (2)
(2) Building (2)
Rubrics n (2) Total
(2)
Good Avg. Good Avg. Good Avg. Good Avg. Good Avg.
(2) (1) (2) (1) (2) (1) (2) (1) (2) (1)

Marks
Practical – 7
Aim: Design a Program to create PDA machine that accept the well-
formed parenthesis.
Code:
def create_pda_for_well_formed_parentheses(filename):
pda_content = '''<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<structure>
<type>pda</type>
<automaton>
<state id="0" name="q0">
<initial/>
</state>
<state id="1" name="q_accept">
<final/>
</state>
<!-- Transition: On '(', push 'X' -->
<transition>
<from>0</from>
<to>0</to>
<read>(</read>
<pop>Z</pop>
<push>XZ</push>
</transition>
<transition>
<from>0</from>
<to>0</to>
<read>(
</read>
<pop>X</pop>
<push>XX</push>

</transition>
<!-- Transition: On ')', pop 'X' -->
<transition>
<from>0</from>
<to>0</to>
<read>)</read>
<pop>X</pop>
<push></push>
</transition>
<!-- Transition: Empty input and Z at top -> Accept -->
<transition>
<from>0</from>
<to>1</to>
<read></read>
<pop>Z</pop>
<push>Z</push>
</transition>
</automaton>
</structure>
'''
# Save properly
with open(filename, 'w', encoding='utf-8') as file:
file.write(pda_content)
print(f"PDA JFLAP file created successfully: {filename}")
# Run the function
create_pda_for_well_formed_parentheses("pda_well_formed_parentheses.jff")

Input:

Output:

Concution:
In this Practical we designed parenthesis based PDA. In this we simply say that
we accept same type of parenthesis not other we simply see our output that
accept all type of parenthesis.

Rubric wise marks obtained:

Problem Completeness
Knowledge Logic
Recognition and accuracy Ethics (2)
(2) (2) Building (2) (2)
Rubrics Total
Good Avg. Good Avg. Good Avg. Good Avg. Good Avg.
(2) (1) (2) (1) (2) (1) (2) (1) (2) (1)

Marks
Practical – 8
Aim: Design a PDA to accept WCWR where w is any binary string
and WR is reverse of that
string and C is a special symbol.
Input:

Output:

Concution:
Here this practical Accept strings where w is any binary, c is a special symbol,
and WR is reverse of w. So First we Push all symbols of w onto stack ,Then
reading c, start popping stack Compare popped symbols with input after c.
Accept if stack empty at the end.

Rubric wise marks obtained:


Problem Completeness
Knowledge Logic
Recognitio and accuracy Ethics (2)
(2) Building (2)
Rubrics n (2) Total
(2)
Good Avg. Good Avg. Good Avg. Good Avg. Good Avg.
(2) (1) (2) (1) (2) (1) (2) (1) (2) (1)

Marks
Practical – 9
Aim: Design a Turing Machine that calculate 2's complement of given
binary string.

Output:

Concution:
The Turing Machine moves to the end of the input binary string first. It then
moves left to find the first 1 and keeps it unchanged. After finding the first 1, it
flips all bits (0 becomes 1, and 1 becomes 0) to its left. Once it reaches the
beginning of the tape, the final result is the 2’s complement. This logic correctly
calculates the binary 2's complement as expected.

Rubric wise marks obtained:

Problem Completeness
Knowledge Logic
Recognitio and accuracy Ethics (2)
(2) Building (2)
Rubrics n (2) Total
(2)
Good Avg. Good Avg. Good Avg. Good Avg. Good Avg.
(2) (1) (2) (1) (2) (1) (2) (1) (2) (1)

Marks
Practical – 10
Aim: Design a Turing Machine which will increment the given binary
number by 1.
Input:

Output:

Concution:
The Turing Machine starts by moving to the rightmost end of the binary input. It
works backward by flipping 1s into 0s until it finds a 0, which it flips to 1 to
stop the carry. If no 0 is found (meaning all bits were 1), it adds an extra 1 at the
start. After these operations, the number is successfully incremented by 1. The
machine then accepts the new binary number.

Rubric wise marks obtained:

Problem Completeness
Knowledge Logic
Recognitio and accuracy Ethics (2)
(2) Building (2)
Rubrics n (2) Total
(2)
Good Avg. Good Avg. Good Avg. Good Avg. Good Avg.
(2) (1) (2) (1) (2) (1) (2) (1) (2) (1)

Marks

You might also like