Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

JOURNAL

IN THE MAJOR COURSE

ARTIFICIAL INTELLIGENCE

SUBMITTED BY

MR. KASH SHARMA

SYDS

Rollno SDDS050A

SEMESTER III

UNDER THE GUIDANCE OF

ASST. PROF. HIRAL SACHALA

ACADEMIC YEAR

2023 - 2024
CERTIFICATE

This is to certify that MR. KASH SHARMA of Second year B.SC.DS Div.:
A, Roll No. SDDS050A of Semester III (2023 - 2024) has successfully
completed the Journal for the Major course ARTIFICIAL
INTELLIGENCE as per the guidelines of KES’ Shroff College of Arts and
Commerce, Kandivali(W), Mumbai-400067.

Teacher In-charge Principal


ASST. PROF. HIRAL SACHALA Dr. L Bhushan.
INDEX
Sr. Practical Practical Name Page No.
No. No.
1. 1 Implementation of DFS 4
2. 2 Implementation of BFS 5
3. 3 Implementation of A* 6, 7
4. 4 Write a program to convert text to speech in python using 8
AI library
5. 5 Write a program to convert speech to text in python using 9
AI library .
6. 6 Implementation of N Queen problem 10, 11
Practical No. 1:
Aim : Implementation of DFS
Objective: students will able to learn use of DFS algorithm of AI

DFS algorithm

1. Start by putting any one of the graph's vertices on top of a stack.

2. Take the top item of the stack and add it to the visited list.

3. Create a list of that vertex's adjacent nodes. Add the ones which aren't in the visited list to the
top of the stack.
4. Keep repeating steps 2 and 3 until the stack is empty.

Example

We use an undirected graph with 5 vertices. We start from vertex 0, the DFS algorithm starts by
putting it in the Visited list and putting all its adjacent vertices in the stack. Next, we visit the
element at the top of stack i.e. 1 and go to its adjacent nodes. Since 0 has already been visited,
we visit 2 instead. Vertex 2 has an unvisited adjacent vertex in 4, so we add that to the top of the
stack and visit it. After we visit the last element 3, it doesn't have any unvisited adjacent nodes,
so we have completed the Depth First Traversal of the graph.

Program
Practical No. 2 :

Aim : Implementation of BFS


Objective: students will able to learn use of BFS algorithm of AI

BFS algorithm

1. Start by putting any one of the graph's vertices at the back of a queue.

2. Take the front item of the queue and add it to the visited list.

3. Create a list of that vertex's adjacent nodes. Add the ones which aren't in the visited list to the
back of the queue.
4. Keep repeating steps 2 and 3 until the queue is empty.

Example

Let's see how the Breadth First Search algorithm works with an example. We use an undirected
graph with 5 vertices. We start from vertex 0, the BFS algorithm starts by putting it in the
Visited list and putting all its adjacent vertices in the stack .Next, we visit the element at the
front of queue i.e. 1 and go to its adjacent nodes. Since 0 has already been visited, we visit 2
instead. Vertex 2 has an unvisited adjacent vertex in 4, so we add that to the back of the queue
and visit 3, which is at the front of the queue. Only 4 remains in the queue since the only
adjacent node of 3 i.e. 0 is already visited. We visit it. Since the queue is empty, we have
completed the Breadth First Traversal of the graph.

Program:
Practical No. 3 :

Aim : Implementation of A*
Objective: students will able to learn use of A* algorithm of AI

A * algorithm

Create a priority queue (open list) and add the starting point 'S' to it with a cost of 0.Create a
closed list to keep track of visited nodes.While the open list is not empty:

a. Pop the node with the lowest cost (including both the cost to reach the node and the estimated cost
to reach the goal) from the open list. Let's call this node 'current'.

b. If 'current' is the goal node 'G', you have found the shortest path.

c. Otherwise, for each of the four possible neighbor nodes (up, down, left, right) of 'current':

i. If the neighbornis an obstacle or is in the closed list, skip it.


ii. Calculate the cost to reach the neighbor from 'current'.
iii. Calculate the estimated cost to reach the goal from the neighbor using a heuristic (e.g.,
Manhattan distance).
iv. If the neighbor is not in the open list or has a lower cost, update its cost and add it to
the open list. d. Add 'current' to the closed list.

Program:
Practical No. 4:

Aim : Write a program to convert text to speech in python using AI library

Objective: students will able to implement AI library

pyttsx3 is a text-to-speech conversion library in Python. Unlike alternative libraries, it works


offline and is compatible with both Python 2 and 3. An application invokes the pyttsx3.init()
factory function to get a reference to a pyttsx3. Engine instance. it is a very easy to use tool
which converts the entered text into speech. The pyttsx3 module supports two voices first is
female and the second is male which is provided by “sapi5” for windows. It supports three TTS
engines :

• sapi5 – SAPI5 on Windows


• nsss – NSSpeechSynthesizer on Mac OS X
• espeak – eSpeak on every other platform program
Program:
Practical No. 5:

Aim : Write a program to convert speech to text in python using AI library .

Objective: Students will able to implement AI library

Speech Recognition: is an important feature in several applications used such as home


automation, artificial intelligence, etc. This article aims to provide an introduction to how to
make use of the SpeechRecognition library of Python. This is useful as it can be used on
microcontrollers such as Raspberry Pi with the help of an external microphone.

Program :
Practical No. 6:

Aim : Implementation of N Queen problem

Objective: students will able to solve N Queen problem

N - Queens problem is to place n - queens in such a manner on an n x n chessboard that no queens


attack each other by being in the same row, column or diagonal.

Program :

You might also like