Lp-II Lab Manual 2021-22
Lp-II Lab Manual 2021-22
Laboratory Practice II
(310258)
LABORATORY MANUAL
INSTITUTE To impart value added technological education through pursuit of academic excellence,
VISION research and entrepreneurial attitude.
M1: To achieve academic excellence through innovative teaching and learning process.
INSTITUTE
MISSION M2: To imbibe the research culture for addressing industry and societal needs.
M4: To produce competent and socially responsible professionals with core human values.
M4: To incorporate social and ethical awareness among the students to make them
conscientious professionals.
Department
Program Educational Objectives(PEOs)
PEO1: To Impart fundamentals in science, mathematics and engineering to cater the needs of society and
Industries.
PEO2: Encourage graduates to involve in research, higher studies, and/or to become entrepreneurs.
PEO3: To Work effectively as individuals and as team members in a multidisciplinary environment with
high ethical values for the benefit of society.
Course Objectives:
Course Outcomes:
On completion of the course, student will be able to-
• Artificial Intelligence :
CO1: Design a system using different informed search / uninformed search or heuristic approaches
Apply basic principles of AI in solutions that require problem solving, inference, perception,
CO2:
knowledge representation, and learning
CO3: Design and develop an interactive AI application
• Cloud Computing :
List of Assignments
Sr. TITLE
No. Group A
Implement depth first search algorithm and Breadth First Search algorithm, Use an
01 undirected graph and develop a recursive algorithm for searching all the vertices of a
graph or tree data structure.
Group B
04 Implement a solution for a Constraint Satisfaction Problem using Branch and Bound
and Backtracking for n-queens problem or a graph coloring problem.
Group C
Implement any one of the following Expert System
13 I. Information management
II. Hospitals and medical facilities
III. Help desks management
IV. Employee performance evaluation
V. Stock market trading
VI. Airline scheduling and cargo schedules
Group A: Assignment No 1
Problem Statement:
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.
Objective:
To understand the basic concepts of search algorithm techniques.
Outcome:
To implement the basic concept depth first search algorithm and Breadth First Search algorithm.
CO Relevance: CO1
PO/PSOs Relevance: PO1, PO2, PO3, PO4, PO5, PO9, PO10, PSO1, PSO2, PSO3
Theory Concepts:
1. Breadth First Search (BFS):
BFS is one of the traversing algorithms used in graphs. This algorithm is implemented using a queue data
structure. In this algorithm, the main focus is on the vertices of the graph. Select a starting node or vertex at
first, mark the starting node or vertex as visited and store it in a queue. Then visit the vertices or nodes which
are adjacent to the starting node, mark them as visited and store these vertices or nodes in a queue. Repeat this
process until all the nodes or vertices are completely visited
Advantages of BFS
1. It can be useful in order to find whether the graph has connected components or not.
2. It always finds or returns the shortest path if there is more than one path between two vertices.
Disadvantages of BFS
1. The execution time of this algorithm is very slow because the time complexity of this algorithm is
exponential.
2. This algorithm is not useful when large graphs are used.
Explanation:
1. Create a graph.
Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 6
Laboratory Practice II (310258) Class: TE(Computer)
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.
Vertex 2 has an unvisited adjacent vertex in 4, so we add that to the top of the stack and visit it.
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.
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.
The time complexity of the DFS algorithm is represented in the form of O(V + E), where V is the number of
nodes and E is the number of edges. The space complexity of the algorithm is O(V).
Output:
(Execute the program and attach the printout here)
Conclusion:
Hence we have implemented 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.
Viva Questions:
1. Define Graph
2. Define Directed Graph and Undirected Graph.
3. Define BFS.
4. Define DFS.
5. Differentiate between BFS & DFS.
Date:
Marks obtained:
Sign of course coordinator:
Name of course Coordinator :
Group A: Assignment No 2
Problem Statement:
Implement A star Algorithm for any game search problem.
Objective:
To understand concept A star Algorithm for search problem.
Outcome:
To implement a program for creating A star Algorithm for search problem.
CO Relevance: CO2
PO/PSOs Relevance: PO1, PO2, PO3, PO4, PO5, PO9, PO10, PSO1, PSO2, PSO3
Theory Concepts :
A star search is the most commonly known form of best-first search. It uses heuristic function h(n), and cost to
reach the node n from the start state g(n). It has combined features of UCS and greedy best-first search, by
which it solve the problem efficiently. A star search algorithm finds the shortest path through the search space
using the heuristic function. This search algorithm expands less search tree and provides optimal result faster.
A star algorithm is similar to UCS except that it uses g(n)+h(n) instead of g(n).
In A star search algorithm, we use search heuristic as well as the cost to reach the node. Hence we can combine
both costs as following, and this sum is called as a fitness number.
Step 2: Check if the OPEN list is empty or not, if the list is empty then return failure and stops.
Step 3: Select the node from the OPEN list which has the smallest value of evaluation function (g+h), if node
n is goal node then return success and stop, otherwise.
Step 4: Expand node n and generate all of its successors, and put n into the closed list. For each successor n',
check whether n' is already in the OPEN or CLOSED list, if not then compute evaluation function for n' and
place into Open list.
Step 5: Else if node n' is already in OPEN and CLOSED, then it should be attached to the back pointer which
reflects the lowest g(n') value.
Advantages:
1. A star search algorithm is the best algorithm than other search algorithms.
2. A star search algorithm is optimal and complete.
3. This algorithm can solve very complex problems.
Disadvantages:
1. It does not always produce the shortest path as it mostly based on heuristics and approximation.
2. A star search algorithm has some complexity issues.
3. The main drawback of A star is memory requirement as it keeps all generated nodes in the memory, so it is
not practical for various large-scale problems.
Output:
(Execute the program and attach the printout here)
Conclusion:
Hence we have implemented A star Algorithm for any game search problem.
Viva Questions:
1. Define Greedy search.
2. Define Uniform Cost search algorithms.
3. Give advantages and disadvantages UCS.
4. Give the applications Greedy search.
5. How A* Works?
Date:
Marks obtained:
Sign of course coordinator:
Name of course Coordinator :
Group A: Assignment No 3
Problem Statement:
Implement Greedy search algorithm for Prim's Minimal Spanning Tree Algorithm.
Objective:
To understand the basic concepts of Prim’s algorithm techniques.
Outcome:
To implement the basic concept of Prim’s algorithm using Minimal Spanning Tree Algorithm techniques.
CO Relevance: CO2
PO/PSOs Relevance: PO1, PO2, PO3, PO4, PO5, PO9, PO10, PSO1, PSO2, PSO3
Theory Concepts:
We will study what is the minimum spanning tree and how to convert a graph into a minimum spanning tree
using Prim’s Algorithm. We will learn the algorithm and python code for prim’s algorithm and an example for
better understanding. Lastly, we will study the running time complexity and applications of prim's algorithm
in real life.
Pseudo code:
T = ∅;
M = { 1 };
while (M ≠ N)
let (m, n) be the lowest cost edge such that m ∈ M and n ∈ N - M;
T = T ∪ {(m, n)}
M = M ∪ {n}
Here we create two sets of nodes i.e, M and M-N. M set contains the list of nodes that have been visited and
the M-N set contains the nodes that haven’t been visited. Later, we will move each node from M to M-N after
each step by connecting the least weight edge.
Example
Let us consider the below-weighted graph
Now, we will choose the shortest weight edge from the source vertex and add it to finding the
spanning tree.
Then, choose the next nearest node connected with the minimum edge and add it to the solution. If there are
multiple choices then choose anyone.
Continue the steps until all nodes are included and we find the minimum spanning tree.
Time Complexity:
The running time for prim’s algorithm is O(VlogV + ElogV) which is equal to O(ElogV) because every
insertion of a node in the solution takes logarithmic time. Here, E is the number of edges and V is the number
of vertices/nodes. However, we can improve the running time complexity to O(E + logV) of prim’s algorithm
using Fibonacci Heaps.
Applications:
⮚ Prim’s algorithm is used in network design
⮚ It is used in network cycles and rail tracks connecting all the cities
⮚ Prim’s algorithm is used in laying cables of electrical wiring
⮚ Prim’s algorithm is used in irrigation channels and placing microwave towers
⮚ It is used in cluster analysis
⮚ Prim’s algorithm is used in gaming development and cognitive science
⮚ Path finding algorithms in artificial intelligence and traveling salesman problems make use of prim’s
algorithm.
Output:
(Execute the program and attach the printout here)
Conclusion:
As we studied, the minimum spanning tree has its own importance in the real world, it is important to learn the
prim’s algorithm which leads us to find the solution to many problems. When it comes to finding the minimum
spanning tree for the dense graphs, prim’s algorithm is the first choice.
Viva Questions:
Date:
Marks obtained:
Sign of course coordinator:
Name of course Coordinator :
Problem Statement:
Implement a solution for a Constraint Satisfaction Problem using Branch and Bound and Backtracking for n-
queens problem or a graph coloring problem.
Objective:
To understand the basic concepts of a Constraint Satisfaction Problem for n-queens problem.
Outcome:
CO Relevance: CO3
PO/PSOs Relevance: PO1, PO2, PO3, PO4, PO5, PO9, PO10, PSO1, PSO2, PSO3
Theory Concepts:
The N-Queens problem is a puzzle of placing exactly N queens on an NxN chessboard, such that no two queens
can attack each other in that configuration. Thus, no two queens can lie in the same row, column or diagonal.
The branch and bound solution is somehow different, it generates a partial solution until it figures that there's
no point going deeper as we would ultimately lead to a dead end.
In the backtracking approach, we maintain an 8x8 binary matrix for keeping track of safe cells (by eliminating
the unsafe cells, those that are likely to be attacked) and update it each time we place a new queen. However,
it required O(n^2) time to check safe cell and update the queen.
we already ensure that the queens do not share the same column by the way we fill out our auxiliary matrix
(column by column). Hence, only the left out 3 conditions are left out to be satisfied.
The branch and bound approach suggets that we create a partial solution and use it to ascertain whether we
need to continue in a particular direction or not. For this problem, we create 3 arrays to check for conditions
1,3 and 4. The boolean arrays tell which rows and diagnols are already occupied. To achieve this, we need a
numbering system to specify which queen is placed.The indexes on these arrays would help us know which
queen we are analysing.
Preprocessing - create two NxN matrices, one for top-left to bottom- right diagnol, and other for top-right to
bottom-left diagnol. We need to fill these in such a way that two queens sharing same top- left_bottom-right
diagnol will have same value in slashDiagonal and two queens sharing same top-right bottom-left diagnol will
If the answer to any one of the following is true, we try another location for queen i on row j, mark the row and
diagnols; and recur for queen i+1.
Output:
(Execute the program and attach the printout here)
Conclusion:
Hence we have implemented Constraint Satisfaction Problem using Branch and Bound and Backtracking
for n-queens problem.
Date:
Marks obtained:
Sign of course coordinator:
Name of course Coordinator :
Problem Statement:
Implement Graph coloring problem’s solution using backtracking algorithm
Objective:
To understand the basic concepts of Graph coloring.
Outcome:
To implement the basic concept Graph coloring problem’s solution using backtracking algorithm.
CO Relevance: CO3
PO/PSOs Relevance: PO1, PO2, PO3, PO4, PO5, PO9, PO10, PSO1, PSO2, PSO3
Theory Concepts:
The graph coloring problem is to discover whether the nodes of the graph G can be covered in
such a way, that no two adjacent nodes have the same color yet only m colors are used. This
graph coloring problem is also known as M- color ability decision problem.
The M – colorability optimization problem deals with the smallest integer m for which the
graph G can be colored. The integer is known as a chromatic number of the graph.
Here, it can also be noticed that if d is the degree of the given graph, then it can be colored with
d+ 1 color.
A graph is also known to be planar if and only if it can be drawn in a planar in such a way that
no two edges cross each other. A special case is the 4 - colors problem for planar graphs. The
problem is to color the region in a map in such a way that no two adjacent regions have the
same color. Yet only four colors are needed. This is a problem for which graphs are very useful
because a map can be easily transformed into a graph. Each region of the map becomes the
node, and if two regions are adjacent, they are joined by an edge.
Graph coloring problem can also be solved using a state space tree, whereby applying a
backtracking method required results are obtained.
For solving the graph coloring problem, we suppose that the graph is represented by its
adjacency matrix G[ 1:n, 1:n], where, G[ i, j]= 1 if (i, j) is an edge of G, and G[i, j] = 0 otherwise.
The colors are represented by the integers 1, 2, ..., m and the solutions are given by the n-tuple
(x1, x2, x3, ..., xn), where x1 is the color of node i.
Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 23
Laboratory Practice II (310258) Class: TE(Computer)
Output:
(Execute the program and attach the printout here)
Conclusion:
Hence we have implemented Graph coloring problem’s solution using backtracking algorithm.
Date:
Marks obtained:
Sign of course coordinator:
Name of course Coordinator :
Problem Statement:
Develop an elementary Chatbot for any suitable customer interaction application.
Objective:
To understand the basic concepts of Chatbot.
Outcome:
To implement an elementary Chatbot for any suitable customer interaction application.
CO Relevance: CO3
PO/PSOs Relevance: PO1, PO2, PO3, PO4, PO5, PO9, PO10, PSO1, PSO2, PSO3
Theory Concepts:
What is a chatbot?
A chatbot is a computer program designed to have a conversation with human beings over the internet. It’s
also known as conversational agents, which communicate and collaborate with human users, through text
messaging, in order to accomplish a specific task. Basically, there are two types of chatbots. The one that
uses Artificial Intelligence and another one is based on multiple choice scripts.
Both types of chatbots aim to create a more personalized content experience for the users, whether that's
while watching a video, reading articles or buying new shoes.
These Chatbots hold the promise of being the next generation of technology that people use to interact
online with business enterprises. These Chatbots offer a lot of advantages, one of which is that, because
Chatbots communicate using a natural language, users don't need to learn yet another new website
interface, to get comfortable with the unavoidable quirks.
Chatbots are capable to interpret human speech, and decide which information is being sought. Artificial
intelligence is getting smarter each day, and brands that are integrating Chatbots with the artificial
intelligence, can deliver one-to-one individualized experiences to consumers.
Why chatbot?
Chatbots can be useful in many aspects of the customer experience, including providing customer
service, presenting product recommendations and engaging customers through targeted marketing
campaigns. If a customer has an issue with a
product, she can connect with a chatbot to explain the situation and the chatbot can input that
information to provide a recommendation of how to fix the product. On the recommendation side,
chatbots can be used to share popular products with customers that they might find useful and can act
as a sort of personal shopper or concierge service to find the perfect gift, meal or night out for a
customer with just a few basic questions. Brands are also using chatbots to connect their customers
with thought leaders and add personality to their products. In all cases, brands seem to be having great
success and experiencing increased engagement and revenue.
Chatbots are easy to use and many customers prefer them over calling a representative on the phone
because it tends to be faster and less invasive. They can also save money for companies and are easy
to set up.
Chatbots are relatively new and most companies haven’t implemented them yet, it’s only natural that
users are interested in them. Hence, people want to discover what chatbots can and cannot do.
The number of businesses using chatbots has grown exponentially. Chatbots have increased from
30,000 in 2016 to over 100,000 today. Every major company has announced their own chatbot and
60% of the youth population uses them daily.
These statistics prove that chatbots are the new-gen tech. No more waiting for the right time to
incorporate them into your business. The time is now. By the year 2020, nearly 80% of businesses will
have their own chatbot.
Billions of people are already using chatbots, so it’s time your business did too.
Benefits of chatbot?
Chatbots are being made to ease the pain that the industries are facing today. The purpose of chat bots
is to support and scale business teams in their relations with customers.
Chatbots may sound like a futuristic notion, but according to Global Web Index statistics, it is said that
75% of internet users are adopting one or more messenger platforms. Although research shows us that
each user makes use of an average of 24 apps a month, wherein 80% of the time would be in just 5
apps. This means you can hardly shoot ahead with an app, but you still have high chances to integrate
your chatbot with one of these platforms.
I’m sure most of you have experienced listening to the boring music playing while you’re kept on hold
2. Handling Customers:
We humans are restricted to the number of things we can do at the same time. A study suggests
that humans can only concentrate on 3–4 things at the same time. If it goes beyond that you are
bound to meet errors.
Chatbots on the other hand can simultaneously have conversations with thousands of people. No
matter what time of the day it is or how many people are contacting you, every single one of them
will be answered instantly. Companies like Taco Bell and Domino’s are already using chatbots
to arrange delivery of parcels.
If you are a business owner you are bound have a lot of employees who need to be paid for the
work they do. And these expenses just keep adding up as business grows. Chatbots are a one time
investment which helps businesses reduce down on staff required.
You could integrate a customer support chatbot in your business to cater to simple queries of
customers and pass on only the complex queries to customer support agents.
Humans react to others based on their mood and emotions. If a agent is having a good attitude or
is in good mood he will most probably talk to customers in a good way. In contrary to this the
customer will not be satisfied.
Whereas chatbots are bound by some rules and obey them as long as they’re programmed to.
They always treat a customer in the most polite and perfect way no matter how rough the person
is. Also, in the travel and hospitality industry where travelers do not speak the same language, a
bot can be trained to communicate in the language of the traveler.
Lets be honest, no one likes doing the same work again and again over brief period of time. In
Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 27
Laboratory Practice II (310258) Class: TE(Computer)
the case of humans, such tasks are prone to errors. Chatbots now help automate tasks which are
to be done frequently and at the right time.
Also, now there are numerous slack bots which automate repetitive tasks. This helps people save
time and increase productivity. For example, there are new items bought from your eCommerce
site or there is a bug reported then it sends a short summary to a slack channel.
6. Personal Assistant:
People could use Bots as a fashion advisor for clothing recommendations, or ask trading tips from
a finance bot, suggest places to visit from a travel bot and so forth. This would help the users get
a more personal touch from the chatbot. Also, the chatbot will remember all your choices and
provide you with relevant choices the next time you visit it.
Below we have compiled reasons why chatbots are important for your business and how can they
help in increasing revenues:
Most businesses these days have a web presence. But with being on the internet, boundaries of
day and night, availability and unavailability have changed, so have user expectations. This is
probably the biggest reason to use them. Bots give the user an interactive experience. It makes
customers feel they are working with someone to help resolve their issue. If done right, bots can
help customers find what they are looking for and make them more likely to return.
Customer Engagement
● Clearance Sale : Notify users about on-going clearance sale of products relevant to
the users at their nearest outlets.
● Product Finder : Enable consultative selling without the need of a call center
● It offer Notification : Notify users about offers, product launches on products/
services they’ve shown interest in, and products that’s back in stock
Along with a web presence, it has also become increasingly important for brands to have a mobile
presence - mobile apps, mobile-optimized websites. Considering how chat has been around on
the mobile for ages, most chatbot
implementations don’t need you to work on tweaking their UI, they are ready to implement and
so available to your customers immediately
You might argue that you have an app for that. Having an app for your brand is great, but having
users discover that app, download it and use it to stay engaged is not an easy deal. Instead,
implementing a chatbot - which works on the mobile browser or a messaging-app which the user
regularly uses - makes it all the more reason for a customer to be engaged with the brand
Chatbots can be intelligent. Depending on a user’s preferences or purchases, it can send products
to customers which are more likely to convert into sales. Or it can send coupons to users for in-
store purchases/discounts. Bots can also be used to link the user to your mCommerce site/app so
they can buy the product directly from the convenience of their phones
Sell Intelligently
● Product Recommendations : Push proactive recommendations to users based on
their preferences and search and order history.
● Enable order booking over chat.
The best part about bots is they are cheap. Chatbot provide the necessary infrastructure and APIs
for creating these bots. They require minimal maintenance and since it is automated, there is no
labor-intensive work that goes in there.
e. Customer Service
● Track Order : Keep users up to date with order status. Schedule or reschedule
delivery to a provided address or request to pick it up at any other Best Buy outlet.
● Stock outs : Notify users when desired product is available and place order over a
chat.
● Returns and Replacements : No waiting time to reach customer care. Customers can
instantly place request to replace or return an order.
● Seek Reviews : Reach out to users to seek reviews on the products recently bought
Gift Recommendations
● Recommend relevant gifting options to users, accessing calendar events and
According to a new survey, 80% of businesses want to integrate chatbots in their business model
by 2020. So which industries can reap the greatest benefits by implementing consumer-facing
chatbots? According to a chatbot, these major areas of direct-to-consumer engagement are prime:
Chatbots can help hotels in a number of areas, including time management, guest services and
cost reduction. They can assist guests with elementary questions and requests. Thus, freeing up
Department of Computer Engineering, ZCOER, Narhe, Pune-41 Page 30
Laboratory Practice II (310258) Class: TE(Computer)
hotel staff to devote more of their time and attention to time-sensitive, critical, and complicated
tasks. They are often more cost effective and faster than their human counterparts. They can be
programmed to speak to guests in different languages, making it easier for the guests to speak in
their local language to communicate.
Chatbots in E-Commerce:
Mobile messengers- connected with Chatbots and the E-commerce business can open a new
channel for selling the products online. E-commerce Shopping destination “Spring” was the early
adopter. E-commerce future is where brands have their own Chatbots which can interact with
their customers through their apps.
offering huge customer base with personalised services. Engage with your fans like never before with news,
highlights, game-day info, roster and more.
Chatbots and Service Industry together have a wide range of opportunities and small to big all size of companies
using chatbots to reduce their work and help their customers better.
Chatbots in Media:
Big publisher or small agency, our suite of tools can help your audience chatbot experience rich and frictionless.
Famous News and Media companies like The Wall Street Journal, CNN, Fox news, etc have launched their bots
to help you receive the latest news on the go.
Chatbot in Celebrity:
With a chatbot you can now have one-on-one conversation with millions of fans.
Prcess:
To run this project, you must have installed Python on your PC. After downloading the
project, follow the steps below:
Step1: Extract/Unzip the file.
Step2: Go inside the project folder, open cmd then type bot.py and enter to start the system.
OR
Step2: Simply, double-click the bot.py file and you are ready to go.
Output:
(Execute the program and attach the printout here)
Conclusion:
Hence we have implemented Chatbot solution for any suitable customer interaction application.
Date:
Marks obtained:
Sign of course coordinator:
Name of course Coordinator :