Skip to content

Contains the Programs of Topics study in Artificial Intelligence subject

Notifications You must be signed in to change notification settings

Shahzaib-D-Memon/18CS-AI

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Searching Algorithms of Aritificial Intelligence

Table of Contents

Overview

Artificial Intelligence is the study of building agents that act rationally. Most of the time, these agents perform some kind of search algorithm in the background in order to achieve their tasks.

The objective of search procedure is to discover a path through a problem spaces from an initial configuration to a goal state.

The Solution to a search problem is a sequence of actions, called the plan that transforms the start state to the goal state.

This plan is achieved through search algorithms.

Types of Searching Algorithms

App Screenshot

User Define Problem Assumption

Assumed Problem

Assume that above Graph will be used by User.

User Interface

1st Window

Fig-A: Selecting Algorithm

2nd Window

Fig-B: Selecting BFS and Defining the Graph

3rd Window

Fig-C: Selecting DFS and Defining the Graph

4th Window

Fig-D: Selecting DLS and Defining the Graph

5th Window

Fig-E: Selecting UCS and Defining the Graph

1) Uninformed Search

Also called as Blind Search or Brute Force Search.

Suitable For very limited Problem Space problems.

A blind search is a search that has no information about its domain. The only thing that a blind search can do is to distinguish a non-goal state from a goal state.

– Breadth-First search

– Depth-First search

– Uniform-Cost search

– Depth-First Iterative Deepening search

i) Breadth-First Search

Breadth-first search (BFS) is an algorithm for traversing or searching tree or graph data structures.

It starts at the tree root and explores the neighbor nodes first, before moving to the next level neighbors.

Breadth First Search explores the state space in a level by level fashion. Only when there are no more states to be explored at a given level then the algorithm move onto the next level.

BFS is complete. If there exists an answer, it will be found (b should be finite).

BFS is optimal (if cost = 1 per step). The path from initial state to goal state is shallow.

Time & Space Complexity = s O(b^d) Where "b" = Branch Factor (Number of nodes from root first expands on a set number of nodes, say b.)

& "d" = depth

Program Output

User Define Problem

Problem # 1

Traversing

Solution # 1_0 Solution # 1_i Solution # 1_ii

Searching

Solution # 1_0 Solution # 1_i

Pre Define Problems

Problem # 1

BFS Example Problem # 1

Problem # 1

Solution # 1_i Solution # 1_ii Solution # 1_iii

BFS Problem # 2

Problem # 2

Solution # 2_i Solution # 2_ii

BFS Problem # 3

Problem # 3

Solution # 3_i Solution # 3_ii Solution # 3_iii Solution # 3_iv

BFS Problem # 4

Problem # 4

Solution # 4_i Solution # 4_ii Solution # 4_iii

BFS Problem # 5

Problem # 5

Solution # 5_i Solution # 5_ii Solution # 5_iii Solution # 5_iv

ii) Depth-First Search

Depth-first search (DFS) is an algorithm for traversing or searching tree or graph data structures. One starts at the root and explores as far as possible along each branch before backtracking.

A depth first search begins at the root node (i.e. Initial node) and works downward to successively deeper levels.

An operator is applied to the node to generate the next deeper node in sequence. This process continues until a solution is found or backtracking is forced by reaching a dead end.

If you have deep search trees (or infinite – which is quite possible), DFS may end up running off to infinity and may not be able to recover.

Thus DFS is neither optimal nor complete

Time & Space Complexity = s O(b^d) {In some cases, DFS can be faster than BFS because it does not expand all nodes at a level}

Where "b" = Branch Factor (Number of nodes from root first expands on a set number of nodes, say b.)

& "d" = depth

Program Output

User Define Problem

Problem # 1

Traversing

Solution # 1_i Solution # 1_i Solution # 1_ii

Searching

Solution # 1_i Solution # 1_i

Pre Define Problem

Problem # 1

DFS Example Problem # 1

Problem # 1

Solution # 1_i Solution # 1_ii Solution # 1_iii

DFS Example Problem # 2

Problem # 2

Solution # 2_i Solution # 2_ii

DFS Example Problem # 3

Problem # 3

Solution # 3_i Solution # 3_ii Solution # 3_iii Solution # 3_iv

DFS Example Problem # 4

Problem # 4

Solution # 4_i Solution # 4_ii Solution # 4_iii

DFS Example Problem # 5

Problem # 5

Solution # 5_i Solution # 5_ii Solution # 5_iii Solution # 5_iv

iii) Depth-Limited Search

Depth-first search will not find a goal if it searches down a path that has infinite length. So, in general, depth-first search is not guaranteed to find a solution, so it is not complete.

This problem is eliminated by limiting the depth of the search to some value l. However, this introduces another way of preventing depth-first search from finding the goal: if the goal is deeper than l it will not be found.

Regular depth-first search is a special case, for which l=∞.

Depth limited search is complete but not optimal.

If we choose a depth limit that is too small, then depth limited search is not even complete.

The time and space complexity of depth limited search is similar to depth first search.

Program Output

User Define Problem

Problem # 1

Traversing

Solution # 1_0 Solution # 1_i

Searching

Solution # 1_i Solution # 1_i

Pre Define Problem

Problem # 1

DLS Problem # 1

Problem # 1

Solution # 1_i Solution # 1_ii

DLS Problem # 2

Problem # 2

Solution # 2_i Solution # 2_ii

iii) Uniform-Cost Search

Breadth-first search finds the shallowest goal state, but this may not always be the least-cost solution for a general path cost function.

Uniform cost search modifies the breadth-first strategy by always expanding the lowest-cost node rather than the lowest-depth node.

It maintain a "Priority Queue".

Program Output

User Define Problem

Problem # 1

Searching

Problem # 0 Problem # 1 Problem # 2

Pre Define Problem

Problem # 1

UCS Problem # 1

Problem # 1

Solution # 1_i Solution # 1_ii

UCS Problem # 2

Problem # 2

Solution # 2 Solution # 2

UCS Problem # 3

Problem # 3

Solution # 3_i Solution # 3_ii Solution # 3_iii Solution # 3_iv

About

Contains the Programs of Topics study in Artificial Intelligence subject

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%