0% found this document useful (0 votes)
325 views17 pages

Data Structures Used in Artificial Intelligence

This document will give an overview of the Data structures used in various AI algorithms

Uploaded by

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

Data Structures Used in Artificial Intelligence

This document will give an overview of the Data structures used in various AI algorithms

Uploaded by

vdjohn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

DATA STRUCTURES IN

ARTIFICIAL INTELLIGENCE

Dr.S.Veena
Professor
Computer Science and Engineering
SRMIST
Topics
• Definition of Artificial Intelligence
• Introduction to Data Structures
• Stacks
• Queues
• Trees
• Graphs
Artificial Intelligence
• Artificial intelligence is the science of making machines
that can think like humans. It can do things that are
considered "smart."
• AI technology can process large amounts of data in
ways, unlike humans.
• The goal for AI is to be able to do things such as
recognize patterns, make decisions, and judge like
humans.
Artificial Intelligence - Examples
Data Structures in AI
• Data structures are ways of organizing and storing data in a computer
memory,
• Some popular data structures for AI include arrays, lists, stacks, queues, trees,
and graphs.
• Arrays are fixed-size collections of elements of the same type, useful for
storing sequential data.
• Lists are dynamic collections that can contain different types, perfect for
data that needs to grow or shrink.
• Stacks use the last-in, first-out (LIFO) principle and are suitable for
processing data in reverse order.
• Queues utilize the first-in, first-out (FIFO) principle and are ideal for
handling data that needs to be processed in order.
• Trees are hierarchical collections of nodes with parent-child relationships
and work well with data that has a natural structure.
• Graphs are collections of nodes connected by edges and can represent
complex relationships such as networks or maps.
Stacks
• Stack - Last In First Out (LIFO) lists
 An ordered list; a sequence of items, piled one on top of the other.

 The insertions and deletions are made at one end only, called Top.

 If Stack S = (a[1], a[2],…….a[n]) then a[1] is bottom most element

 Any intermediate element (a[i]) is on top of element a[i-1], 1 < i <= n.


 In Stack all operation take place on Top.

• The Pop operation removes item from top of the stack.

• The Push operation adds an item on top of the stack.


Stack - Example
Queue
• Queue - First In First Out (FIFO) lists
• An ordered list; a sequence of items; there are restrictions about how items can
be added to and removed from the list.
• A queue has two ends.
• All insertions (enqueue ) take place at one end, called Rear or Back
• All deletions (dequeue) take place at other end, called Front.
• If Queue has a[n] as rear element then a[i+1] is behind a[i] , 1 < i <= n.
• All operation takes place at one end of queue or the other.
• The Dequeue operation removes the item at Front of the queue.
• The Enqueue operation adds an item to the Rear of the queue.
Queue - Example
Tree
• Tree is a way of organizing objects, related in a hierarchical fashion.
• Tree is a type of data structure in which each element is
attached to one or more elements directly beneath it.
• The connections between elements are called branches.
• Tree is often called inverted trees because it is drawn with the
root at the top.
• The elements that have no elements below them are called
leaves.
• A binary tree is a special type: each element has only two
branches below it.
Tree - Properties
• Tree is a special case of a graph.
• The topmost node in a tree is called the root node. At root node all operations on
the tree begin.
• A node has at most one parent.
• The topmost node (root node) has no parents.
• Each node has zero or more child nodes, which are below it .
• The nodes at the bottommost level of the tree are called leaf nodes.
Since leaf nodes are at the bottom most level, they do not have
children.
• A node that has a child is called the child’s parent node.
• The depth of a node n is the length of the path from the root to the
node.The root node is at depth zero.
Trees - Example
Graph
• A tree is a graph in which any two vertices are connected by exactly
one path. Alternatively, any connected graph with no cycles is a tree.
• Graphs are collections of nodes connected by edges
and can represent complex relationships such as
networks or maps.
Algorithms for AI
• Algorithms are sets of instructions that tell a computer how to
solve a problem or perform a task.
• The right algorithm for an AI problem can dramatically improve the
speed, accuracy, and scalability of code.
• For example, sorting algorithms such as bubble sort, insertion sort,
merge sort, quick sort, and heap sort are useful for organizing and
comparing data
• Search algorithms like linear search, binary search, breadth-first
search, depth-first search, and A* search can be used to locate and
retrieve data.
• Optimization algorithms like gradient descent, genetic algorithm,
simulated annealing, and particle swarm optimization can help find
the best solution to a problem.
• Finally, machine learning algorithms like linear regression, logistic
regression, k-means clustering, support vector machine, and neural
How to use data structures and algorithms in AI

• To use data structures and algorithms in AI, the user need to understand the nature
and requirements of your problem and the characteristics and trade-offs of the
options.
• To help the user to choose and apply data structures and algorithms in AI, it's
important to first define your problem, analyze your data, select a data structure,
select an algorithm, and then evaluate your solution.
• Defining the problem means outlining the goal of your AI system, the inputs and
outputs, as well as the constraints and assumptions.
• Analyzing the data requires understanding its type, size, distribution, how it is
stored/accessed/processed/manipulated.
• Selecting a data structure involves considering its suitability for data
type/size/operations, advantages/disadvantages, implementation/testing.
• The same goes for selecting an algorithm - it should be suitable for problem
goal/data structure/performance criteria with advantages/disadvantages that are
implemented and tested.
• Finally, evaluating the solution means assessing how well it solves the problem,
its speed/accuracy/scalability, and how it can be improved.
Examples of data structures and algorithms in
AI
• For example, image recognition involves identifying and
labeling objects in an image, which can be solved using an array
to store the image pixels, a tree to store the image features,
and a neural network to classify the image.
• Pathfinding is the problem of finding the shortest or cheapest
path between two points on a map, which can be solved by using a
graph to store the map nodes and edges, a queue to store the
frontier nodes, and A* search to find the optimal path.
• The traveling salesman problem is solving for the shortest or
cheapest route that visits a set of cities and returns to the
starting point; this can be done by using a list to store the city
names and distances, a stack to store the current route, and a
genetic algorithm to find the optimal route.
Benefits of data structures and algorithms in AI
• Using data structures and algorithms in AI can bring many
benefits to your system and your development process, such as
efficiency, accuracy, and creativity.
• Data structures and algorithms can help optimize the use of
computer resources, reduce time and space complexity,
and improve performance and scalability.
• Additionally, they can help improve the quality and reliability
of your system by handling errors, uncertainties, and outliers in
your data.
• Moreover, data structures and algorithms can help explore
new possibilities for your problem by modeling complex and
dynamic data and creating innovative and adaptive systems.

You might also like