0% found this document useful (0 votes)
4 views8 pages

22ai302 LM2

Anna university AI lesson

Uploaded by

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

22ai302 LM2

Anna university AI lesson

Uploaded by

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

22AI302 – DATA STRUCTURES- I

UNIT I & FOUNDATIONAL DATA STRUCTURES

2. DATA STRUCTURES HIERARCHY, TYPES OF DATA-


SINGULAR DATA & PLURAL DATA

2.1 Data structures hierarchy


Types of Data Structures:
1. Primitive Data Structures
Primitive data structure is the data structure that allows you to store only single data type
values.
2. Non-Primitive Data Structures
Non-Primitive data structure is a data structure that allows you to store multiple data type
values. integer, boolean, character, float, etc. are some examples of primitive data
structures.

Primitive Data Structures


Integer: Whole number Ex: -32,0,32
Float: Decimal value Ex: -1.2345, 1.2345
Character: Represent within single quotes Ex: ‘a’, ‘d’
Boolean: True or False Ex: 0,1

Non- Primitive Data Structures


The non-primitive data structure is further classified into two parts i.e. linear data structure
and non-linear data structure
Linear Data Structure:
The linear data structure is nothing but arranging the data elements linearly one after the
other. Here, we cannot arrange the data elements randomly as in the hierarchical order.

o Array: An array is a data structure that can hold the elements of same type. It cannot contain
the elements of different types like integer with character. The commonly used operation in
an array is insertion, deletion, traversing, searching.

For example:
int a[6] = {1,2,3,4,5,6};

Stack: Stack is a data structure that follows the LIFO (Last In First Out). All the operations
on the stack are performed from the top of the stack such as PUSH and POP operation. The
push operation is the process of inserting element into the stack while the pop operation is
the process of removing element from the stack. The stack data structure can be implemented
by using either array or linked list.
Queue: Queue is a data structure that can be implemented by using array. The difference
between the stack and queue data structure is that the elements in the queue are inserted from
the rear end while the elements in the queue are removed from the front end

Linked List: linked list consists of nodes where each node contains a data field and a
reference(link) to the next node in the list.
Non-Linear Data Structure:
o A non-linear data structure is another important type in which data elements are not arranged
sequentially; mainly, data elements are arranged in random order without forming a linear
structure.

Tree:

o The tree is a non-linear data structure that is comprised of various nodes. The nodes in the
tree data structure are arranged in hierarchical order.

Graph

o A graph is a non-linear data structure with a finite number of vertices and edges, and these
edges are used to connect the vertices.

o The graph itself is categorized based on some properties; if we talk about a complete graph,
it consists of the vertex set, and each vertex is connected to the other vertexes having an edge
between them.
Trie

• A trie (derived from retrieval) is a multiway tree data structure used for storing strings over
an alphabet. It is used to store a large number of strings. The pattern matching can be done
efficiently using tries

Hash Table
Hash Table is a data structure which stores data in an associative manner. In a hash table,
data is stored in an array format, where each data value has its own unique index value. Access of
data becomes very fast if we know the index of the desired data.
Singular Data:
Singular data can store only one value
Integer: Whole number Ex: -32,0,32
Float: Decimal value Ex: -1.2345, 1.2345
Character: Represent within single quotes Ex: ‘a’, ‘d’
Boolean: True or False Ex: 0,1

Singular Data Specialized:


Singular Specialized data contains 5 types

1. String
2. Date
3. Complex Numbers
4. GPS co-ordinates
5. Objects

1. String:
String is a sequence of characters terminated with a null character \0. For example: char
c[] = "c string"; When the compiler encounters a sequence of characters enclosed in the
double quotation marks, it appends a null character \0 at the end by default.

2. Date:
The date and time in a computer is determined according to the number of seconds or
clock ticks that have elapsed since the defined epoch for that computer or platform.

3. Complex Numbers
A complex number is a number of the form z = a + bi that is a number which has a real
and an imaginary part. E.g. 3+2i, 6 − 3i, −2+4i.
4. GPS co-ordinates
GPS coordinates are a unique identifier of a precise geographic location on the earth,
usually expressed in alphanumeric characters. Coordinates, in this context, are points of
intersection in a grid system. GPS coordinates are usually expressed as the combination of
latitude and longitude.

5. Objects
Anything that is visible or tangible and is relatively stable in form. a thing, person, or matter
to which thought or action is directed: an object of medical investigation.
Plural Data:
Plural data is a data contains two or more values

1. Array
2. List
3. Hashes

1. Array
An array is a collection of similar data elements stored at contiguous memory locations. It
is the simplest data structure where each data element can be accessed directly by only using
its index number

An array is a variable that can store multiple values.

For example, if you want to store 100 integers, you can create an array for it.

2. List
o List is a data structure that stores elements in an ordered and sequential manner. A list can
store repetitive elements which means a single element can occur more than once in a list.
o The list can be called Dynamic size arrays, which means their size increased as we go on
adding data in them and we need not to pre-define a static size for the list.
o For example, numbers = [ 1, 2, 3, 4, 5]
3. Hashes
Hashing is a technique or process of mapping keys, and values into the hash table by
using a hash function. It is done for faster access to elements. The efficiency of mapping
depends on the efficiency of the hash function used.

You might also like