Lp-Ii Te Lab Manual Final
Lp-Ii Te Lab Manual Final
Class: TE
4 Artificial Intelligence
Implement depth first search algorithm
and Breadth First Search algorithm, Use
an undirected graph and develop a
recursive algorithm for searching all the
vertices of a graph or tree data structure.
CERTIFICATE
This is to certify that Mr. /Miss. _________________________________________
of Class T.E. Computer Roll No.____________________ has satisfactory completed
practical of the subject “Laboratory Practice II Lab” for 2nd semester of Academic
Year 2022 – 2023.
Date:
Prof.A.M.Dalvi Prof.S.S.Asane Prof. A. M. Dalvi Prof. (Dr.) J. B. Sankpal Subject
Teacher Subject Teacher Head of Department Principal
Performance:
Consider a library, where a member can perform two operations: issue book
and return it. A book is issued to a member only after verifying his
credentials. Develop a use case diagram for the given library system by
identifying the actors and use cases and associate the use cases with the actors
by drawing a use case diagram. Use UML tool
Library management systems also involve maintaining the database for entering
new books and recording books that have been borrowed with their respective due
dates.
System Requirements
Always clarify requirements at the beginning of the interview. Be sure to ask
questions to find the exact scope of the system that the interviewer has in mind.
We will focus on the following set of requirements while designing the Library
Management System:
1. Any library member should be able to search books by their title, author,
subject category as well by the publication date.
2. Each book will have a unique identification number and other details
including a rack number which will help to physically locate the book. 3. There
could be more than one copy of a book, and library members should be able to
check-out and reserve any copy. We will call each copy of a book, a book item.
4. The system should be able to retrieve information like who took a particular
book or what are the books checked-out by a specific library member.
Here are the top use cases of the Library Management System:
∙ Add/Remove/Edit book: To add, remove or modify a book or book item. ∙ Search catalog: To search books by title,
author, subject or publication date. ∙ Register new account/cancel membership: To add a new member or cancel the
membership of an existing member.
∙ Check-out book: To borrow a book from the library.
∙ Reserve book: To reserve a book which is not currently available. ∙ Renew a book: To reborrow an already checked-
out book.
∙ Return a book: To return a book to the library which was issued to a member. SRTTC FOE LABORATORY PRACTICE II 3
SRTTC FOE LABORATORY PRACTICE II 4
Class diagram#
∙ Library: The central part of the organization for which this software has been designed.
It has attributes like ‘Name’ to distinguish it from any other libraries and ‘Address’ to
describe its location.
∙ Book: The basic building block of the system. Every book will have ISBN, Title,
Subject, Publishers, etc.
∙ BookItem: Any book can have multiple copies, each copy will be considered a book
item in our system. Each book item will have a unique barcode.
∙ Account: We will have two types of accounts in the system, one will be a general
member, and the other will be a librarian.
∙ LibraryCard: Each library user will be issued a library card, which will be used to
identify users while issuing or returning books.
∙ Catalog: Catalogs contain list of books sorted on certain criteria. Our system will
support searching through four catalogs: Title, Author, Subject, and Publish-date.
∙ Fine: This class will be responsible for calculating and collecting fines from library
members.
∙ Rack: Books will be placed on racks. Each rack will be identified by a rack number and
will have a location identifier to describe the physical location of the rack in the
library.
Activity diagrams#
Check-out a book: Any library member or librarian can perform this activity. Here are the set of
steps to check-out a book:
Return a book: Any library member or librarian can perform this activity. The system will
collect fines from members if they return books after the due date. Here are the steps for
returning a book:
SRTTC FOE LABORATORY PRACTICE II 7
Renew a book:
While renewing (re-issuing) a book, the system will check for fines and see if any
other member has not reserved the same book, in that case the book item cannot be renewed. Here
are the different steps for renewing a book:
Performance:
Signature of the Subject Incharge:
Consider online shopping system. Perform the following tasks and draw the class diagram
using UML tool. Represent the individual classes, and objects Add Methods Represent
relationships and other classifiers like interfaces
Class diagram is a static diagram. It represents the static view of an application. Class diagram is
not only used for visualizing, describing, and documenting different aspects of a system but also
for constructing executable code of the software application.
Class diagram describes the attributes and operations of a class and also the constraints imposed
on the system. The class diagrams are widely used in the modelling of object oriented systems
because they are the only UML diagrams, which can be mapped directly with object-oriented
languages.
The purpose of class diagram is to model the static view of an application. Class diagrams are the
only diagrams which can be directly mapped with object-oriented languages and thus widely
used at the time of construction.
UML diagrams like activity diagram, sequence diagram can only give the sequence flow of the
application, however class diagram is a bit different. It is the most popular UML diagram in the
coder community.
The purpose of the class diagram can be summarized as −
Class diagrams are the most popular UML diagrams used for construction of software
applications. It is very important to learn the drawing procedure of class diagram.
Class diagrams have a lot of properties to consider while drawing but here the diagram will be
considered from a top level view.
Class diagram is basically a graphical representation of the static view of the system and
represents different aspects of the application. A collection of class diagrams represents the
whole system.
The following points should be remembered while drawing a class diagram − ∙ The name
of the class diagram should be meaningful to describe the aspect of the system. ∙ Each
element and their relationships should be identified in advance.
∙ Responsibility (attributes and methods) of each class should be clearly identified
∙ Foreach class, minimum number of properties should be specified, as unnecessary
properties will make the diagram complicated.
∙ Use notes whenever required to describe some aspect of the diagram. At the end of the
drawing it should be understandable to the developer/coder.
∙ Finally,
before making the final version, the diagram should be drawn on plain paper and
reworked as many times as possible to make it correct.
The following diagram is an example of an Order System of an application. It describes a
particular aspect of the entire application.
∙ First of all, Order and Customer are identified as the two elements of the system. They
have a one-to-many relationship because a customer can have multiple orders.
∙ Orderclass is an abstract class and it has two concrete classes (inheritance relationship)
SpecialOrder and NormalOrder.
∙ The two inherited classes have all the properties as the Order class. In addition, they have
additional functions like dispatch () and receive ().
The following class diagram has been drawn considering all the points mentioned
above. SRTTC FOE LABORATORY PRACTICE II 11
Class diagram is a static diagram and it is used to model the static view of a system. The static
view describes the vocabulary of the system.
Class diagram is also considered as the foundation for component and deployment diagrams.
Class diagrams are not only used to visualize the static view of the system but they are also used
to construct the executable code for forward and reverse engineering of any system.
Generally, UML diagrams are not directly mapped with any object-oriented programming
languages but the class diagram is an exception.
Class diagram clearly shows the mapping with object-oriented languages such as Java, C++,
etc. From practical experience, class diagram is generally used for construction purpose.
Performance:
Select a moderately complex system and narrate concise requirement Specification for
the same. Design the system indicating system elements organizations using applicable
architectural styles and design patterns with the help of a detailed Class diagram depicting
logical architecture. Specify and document the architecture and design pattern with the
help of templates. Implement the system features and judge the benefits of the design
patterns accommodated
SRT
PRACTICE II 17
SRTTC FOE LABORATORY PRACTICE II 18
Assignment No. 4
Implement depth first search algorithm and Breadth First Search algorithm, Use an
undirected graph and develop a recursive algorithm for searching all the vertices of a graph
or tree data structure.
Depth First Search or DFS for a Graph
Depth First Traversal (or Search) for a graph is similar to Depth First Traversal of a tree. The only
catch here is, unlike trees, graphs may contain cycles (a node may be visited twice). To avoid
processing a node more than once, use a Boolean visited array.
Example:
Input: n = 4, e = 6
0 -> 1, 0 -> 2, 1 -> 2, 2 -> 0, 2 -> 3, 3 -> 3
Explanation:
DFS Diagram:
Input: n = 4, e = 6
2 -> 0, 0 -> 2, 1 -> 2, 0 -> 1, 3 -> 3, 1 -> 3
Output: DFS from vertex 2 : 2 0 1 3
Explanation:
Depth-first search is an algorithm for traversing or searching tree or graph data structures. The
algorithm starts at the root node (selecting some arbitrary node as the root node in the case of a
graph) and explores as far as possible along each branch before backtracking. So the basic idea is
to start from the root or any arbitrary node and mark the node and move to the adjacent unmarked
node and continue this loop until there is no unmarked adjacent node. Then backtrack and check
for other unmarked nodes and traverse them. Finally, print the nodes in the path.
Algorithm:
Create a recursive function that takes the index of the node and a visited
array.
Below are implementations of simple Depth First Traversal. The C++ implementation uses an
adjacency list representation of graphs. STL’s list container is used to store lists of adjacent
nodes.
#include <bits/stdc++.h>
using namespace std;
void Graph::DFS(int v)
{
// Mark the current node as visited and
// print it
visited[v] = true;
cout << v << " ";
return 0;
}
Output:
Following is Depth First Traversal (starting from vertex 2) 2 0 1 3 SRTTC FOE LABORATORY PRACTICE II 22
`
Step #2 uses the Union-Find algorithm to detect cycles. So we recommend reading the following
post as a prerequisite.
Union-Find Algorithm | Set 1 (Detect Cycle in a Graph)
Union-Find Algorithm | Set 2 (Union By Rank and Path Compression)
The algorithm is a Greedy Algorithm. The Greedy Choice is to pick the smallest weight edge
that does not cause a cycle in the MST constructed so far. Let us understand it with an example:
Consider the below input graph. weight edge that does not cause a cycle in the MST constructed
so far. Let us understand it with an example: Consider the below input graph.
The graph contains 9 vertices and 14 edges. So, the minimum spanning tree formed will be
having (9 – 1) = 8 edges.
After sorting:
class Graph {
// A class to represent a graph edge
class Edge implements Comparable<Edge>
{
int src, dest, weight;
// Comparator function used for
// sorting edgesbased on their weight public
int compareTo(Edge compareEdge) { return
this.weight - compareEdge.weight; } };
return subsets[i].parent;
}
// Driver Code
public static void main(String[] args)
{
// Function call
graph.KruskalMST();
}
}
// This code is contributed by Aakash Hasija Output
Implement a solution for a Constraint Satisfaction Problem using Branch and Bound and
Backtracking for n-queens problem or a graph coloring problem.
The N queen’s puzzle is the problem of placing N chess queens on an N×N chessboard so that
no two queens threaten each other. Thus, a solution requires that no two queens share the same
row, column, or diagonal.
Let’s begin by describing backtracking solution. “The idea is to place queens one by one in
different columns, starting from the leftmost column. When we place a queen in a column, we
check for clashes with already placed queens. In the current column, if we find a row for which
there is no clash, we mark this row and column as part of the solution. If we do not find such a
row due to clashes, then we backtrack and return false.”
SRTTC FOE LABORATORY
PRACTICE II 35
1. For the 1st Queen, there are total 8 possibilities as we can place 1st Queen in any row of
first column. Let’s place Queen 1 on row 3.
2. After placing 1st Queen, there are 7 possibilities left for the 2nd Queen. But wait, we don’t
really have 7 possibilities. We cannot place Queen 2 on rows 2, 3 or 4 as those cells are
under attack from Queen 1. So, Queen 2 has only 8 – 3 = 5 valid positions left.
3. After picking a position for Queen 2, Queen 3 has even fewer options as most of the cells
in its column are under attack from the first 2 Queens.
We need to figure out an efficient way of keeping track of which cells are under attack. In
previous solution we kept an 8-by-8 Boolean matrix and update it each time we placed a queen,
but that required linear time to update as we need to check for safe cells.
Basically, we have to ensure 4 things:
1. No two queens share a column.
2. No two queens share a row.
3. No two queens share a top-right to left-bottom diagonal.
4. No two queens share a top-left to bottom-right diagonal.
Number 1 is automatic because of the way we store the solution. For number 2, 3 and 4, we can
perform updates in O(1) time. The idea is to keep three Boolean arrays that tell us which rows
and which diagonals are occupied.
Lets do some pre-processing first. Let’s create two N x N matrix one for / diagonal and other one
for \ diagonal. Let’s call them slashCode and backslashCode respectively. The trick is to fill
them in such a way that two queens sharing a same /diagonal will have the same value in matrix
slashCode, and if they share same \diagonal, they will have the same value in backslashCode
matrix.
For an N x N matrix, fill slashCode and backslashCode matrix using below formula
– slashCode[row][col] = row + col
backslashCode[row][col] = row – col + (N-1)
N=8
def printSolution(board):
for i in range(N):
for j in range(N):
print()
rowLookup, slashCodeLookup,
backslashCodeLookup):
if (slashCodeLookup[slashCode[row][col]] or
backslashCodeLookup[backslashCode[row][col]] or
rowLookup[row]):
return True
backslashCodeLookup):
return True
for i in range(N):
rowLookup, slashCodeLookup,
backslashCodeLookup)):
board[i][col] = 1
rowLookup[i] = True
slashCodeLookup[slashCode[i][col]] = True
backslashCodeLookup[backslashCode[i][col]] = True
""" recur to place rest of the queens """
slashCode, backslashCode,
rowLookup, slashCodeLookup,
backslashCodeLookup)):
return True
board[i][col] = 0
rowLookup[i] = False
slashCodeLookup[slashCode[i][col]] = False
backslashCodeLookup[backslashCode[i][col]] = False
return False
feasible solutions."""
def solveNQueens():
for j in range(N)]
# helper matrices
for j in range(N)]
for j in range(N)]
rowLookup = [False] * N
x=2*N-1
slashCodeLookup = [False] * x
backslashCodeLookup = [False] * x
# initialize helper matrices
for rr in range(N):
for cc in range(N):
slashCode[rr][cc] = rr + cc
rowLookup, slashCodeLookup,
backslashCodeLookup) == False):
return False
# solution found
printSolution(board)
return True
# Driver Cde
solveNQueens()
Output :
10000000
00000010
00001000
00000001
01000000
00010000
00000100
00100000
Introduction
Chatbot is a python based project. A chatbot is a computer program that interacts with human
conversation through voice or text. It is built using python programming.
The chatbot project is using python version 3. It is an interesting project. Python is a general
purpose high-level programming. It is useful for developing desktop GUI, websites, and web
apps. This is a command-line based project. This project chatbot is a beginner or school project.
It is coded in a simple way that every learner will understand.
When you execute the project you will see a set of questions in a command line. The chatbot will
ask a set of questions and you have to answer theme. You must start the conversation answering
the question asked by the boy. It is an entertainment-based project. In this project you must import
time and random. The bot will mostly use random input. Time is useful for adding and waiting for
the user’s response.
DOWNLOAD PROJECT:
https://code-mentor.org/chatbot-in-python-with-source-code/
PROCEDURE:
Output
The image above is the screenshot of the output. This is how you must chat with bot.It is a simple
beginner project. There is no necessary to import all the complex packages. Such as nltk, sklearn,
tkinter and many others. This project will be fruitful for beginners to enhance their skills. You will
learn new skills in this code. The project will be productive for you. Download the project and use
the code by yourself.
Benefits of Bots –
Conclusion
This article is the base of knowledge of the definition of ChatBot, its importance in the Business,
and how we can build a simple Chatbot by using Python and Library Chatterbot.
SRTTC FOE LABORATORY PRACTICE II 47
SRTTC FOE LABORATORY PRACTICE II 48
Assignment No. 8
∙ MYCIN: It was based on backward chaining and could identify various bacteria that
could cause acute infections. It could also recommend drugs based on the patient’s weight.
It is one of the best Expert System Example.
∙ DENDRAL: Expert system used for chemical analysis to predict molecular structure. ∙
PXDES: An Example of Expert System used to predict the degree and type of lung cancer ∙
CaDet: One of the best Expert System Example that can identify cancer at early stages
Characteristics of Expert System
User Interface
The user interface is the most crucial part of the Expert System Software. This component takes
the user’s query in a readable form and passes it to the inference engine. After that, it displays
the results to the user. In other words, it’s an interface that helps the user communicate with the
expert system.
Inference Engine
The inference engine is the brain of the expert system. Inference engine contains rules to solve a
specific problem. It refers the knowledge from the Knowledge Base. It selects facts and rules to
apply when trying to answer the user’s query. It provides reasoning about the information in the
knowledge base. It also helps in deducting the problem to find the solution. This component is
also helpful for formulating conclusions.
Knowledge Base
The knowledge base is a repository of facts. It stores all the knowledge about the problem
domain. It is like a large container of knowledge which is obtained from different experts of a
specific field.
Thus we can say that the success of the Expert System Software mainly depends on the highly
accurate and precise knowledge.
Knowledge Acquisition
The term knowledge acquisition means how to get required domain knowledge by the expert
system. The entire process starts by extracting knowledge from a human expert, converting the
acquired knowledge into rules and injecting the developed rules into the knowledge base.
Participant Role
Domain Expert He is a person or group whose expertise and knowledge is taken
to develop an expert system
End User It is a person or group of people who are using the expert system to
get advice which will not be provided by the expert
Perishable Permanent
Unpredictable Consistent
∙ Information management
∙ Hospitals and medical facilities
∙ Help desks management
SRTTC FOE LABORATORY PRACTICE II 54
∙ Employee performance evaluation
∙ Loan analysis
∙ Virus detection
∙ Useful for repair and maintenance projects
∙ Warehouse optimization
∙ Planning and scheduling
∙ The configuration of manufactured objects
∙ Financial decision making Knowledge publishing
∙ Process monitoring and control
∙ Supervise the operation of the plant and controller
∙ Stock market trading
∙ Airline scheduling & cargo schedules
Summary
∙ An Expert System is an interactive and reliable computer-based decision-making system
which uses both facts and heuristics to solve complex decision-making problem ∙ Key
components of an Expert System are
1) User Interface, 2) Inference Engine, 3) Knowledge Base
∙ Key participants in Artificial Intelligence Expert Systems Development are
1) Domain Expert 2) Knowledge Engineer 3) End User
∙ Improved decision quality, reduce cost, consistency, reliability, speed are key benefits of an
Expert System
∙ An Expert system can not give creative solutions and can be costly to maintain. ∙ An Expert
System can be used for broad applications like Stock Market, Warehouse, HR, etc If you want to
learn about Artificial Intelligence, here’s a free tutorial you’ll want to check out: AI Tutorial
Student Information Management System In C++ With Source Code
Project: Student Information System
Student Information System is based on the concept to generate the Student’s Information records
and to add & update it. Here User can add their Student’s detail with their courses safely and it’s
not time-consuming. This System makes easy to store records of each and every employee. The
whole project is designed in ‘C++’ language and different variables and strings have been used
for the development of this project. This mini project is easy to operate and understand by the
users.
DOWNLOAD PROJECT:
https://download.code-projects.org/details/a98005e8-1910-4dd5-b893-f925404d99e8
OUTPUT: