Lecture On AI
Lecture On AI
• Lecture 1
• DR RAHUL MISHRA
• IIT PATNA
Data
2
Data ● In order to be useful, data must be
organized, analysed, and interpreted.
3
Data Structure
● Data may be organized in many different ways; the logical or mathematical model
of a particular organization of data is called a data structure.
4
Data Structure
5
Data Structure
● Arrays
❖An array is a data structure that stores a collection of elements, all of the same
type, in contiguous memory locations.
❖The elements in an array are accessed using an index, which is an integer value
that represents the position of the element in the array.
❖Arrays are commonly used for a variety of tasks, including storing and
manipulating collections of data such as lists, tables, and matrices.
6
Arrays
❖It can also be used to represent data structures such as stacks, queues, and trees.
❖In most programming languages, arrays have a fixed size, meaning that once an
array is created, its size cannot be changed.
❖Some languages also support dynamic arrays, which can grow or shrink in size as
needed.
❖Arrays are a fundamental data structure in computer programming and are used
extensively in a wide range of applications, including scientific computing, data
analysis, and web development.
7
Linked Lists
• A linked list is a linear data structure in computer science that is used to store a sequence of elements or
nodes.
• Linked lists are not stored in contiguous memory locations. Instead, each element or node in a linked list
contains a reference to the next node in the sequence.
• The first element in the sequence is called the head of the linked list, and the last element is called the
tail. Each node in a linked list contains two fields, one for storing the data and the other for storing a
reference to the next node. The last node in the list has a null reference as its "next" field to signify the
end of the list.
• There are several types of linked lists, including singly linked lists (where each node has a reference to
only the next node), doubly linked lists (where each node has a reference to both the next and previous
nodes), and circular linked lists (where the last node in the list has a reference to the first node, creating
a loop).
8
Data Structure
● Tree and Graph
❖ A tree is a hierarchical data structure consisting of nodes connected by edges. It is a special type
of graph where each node has exactly one parent, except for the root node which has no parent.
A tree is a recursive data structure because each node can have its own subtree. Trees are
commonly used to represent hierarchical structures, such as file systems, organizational charts,
and family trees.
❖ A graph is a collection of nodes, also called vertices, that are connected by edges. Unlike a tree, a
graph can have multiple edges between the same pair of nodes and can also have cycles, which
are loops that start and end at the same node. Graphs are used to represent complex relationships
between objects or entities, such as social networks, road maps, and computer networks.
9
Stack and Queue
A stack is a data structure that stores elements in a last-in-first-out (LIFO) order. This
means that the last element added to the stack is the first one to be removed. Elements can
only be added or removed from the top of the stack. This makes a stack useful for tasks
such as keeping track of function calls in a program, undoing operations in a text editor, or
processing expressions in a calculator.
A queue, on the other hand, is a data structure that stores elements in a first-in-first-out
(FIFO) order. This means that the first element added to the queue is the first one to be
removed. Elements can only be added at the back of the queue and removed from the front.
This makes a queue useful for tasks such as processing requests in a web server, printing
documents in a printer, or handling messages in a message queue.
10
Data Structure Operations
11
Linear and Non-Linear Data Structures
12
Linear and Non-Linear Data Structures
13
14
15
16
17
18
19
20
21