Data Structure and Algorithm W1
Data Structure and Algorithm W1
Structure
and
Algorithm
What are Data
Structures and
Algorithm?
2
is about how data can be
stored in different structures
and also about how to solve
different problems, often by
searching through and
manipulating data
structures.
3
Data Structures
It is a way to store data.
We structure data in
different ways depending
on what data we have, and
what we want to do with it.
4
5
6
Data structures give us the
possibility to manage large
amounts of data efficiently
for uses such as large
databases and internet
indexing services.
7
Data Structure and
Algorithm is about finding
efficient ways to store and
retrieve data, to perform
operations on data, and to
solve specific problems
8
•Decide which data
structure or algorithm
is best for a given
situation.
9
•Make programs that
run faster or use
less memory.
10
•Understand how to
approach complex
problems and solve
them in a systematic
way.
11
Where is Data Structures
and Algorithms Needed?
12
•For managing large
amounts of data,
such as in a social
network or a search
engine.
13
•For scheduling
tasks, to decide
which task a
computer should
do first.
14
•For planning
routes, like in a
GPS system to
find the shortest
path from A to B.
15
•For optimizing
processes, such as
arranging tasks so
they can be completed
as quickly as possible.
16
•For solving complex
problems: From
finding the best way to
pack a truck to making
a computer 'learn'
from data.
17
There are two types of
data structure available
for the programming
purpose:
18
•Primitive data
structure
•Non-primitive data
structure
19
•Primitive data structure
is a fundamental type of
data structure that stores
the data of only one type
20
•Primitive data structure
is a fundamental type of
data structure that stores
the data of only one type
21
•Integer
•It contains the numeric
values. It contains the whole
numbers that can be either
negative or positive.
22
•Float
•The float is a data type that
can hold decimal values. When
the precision of decimal value
increases then the Double data
type is used.
23
•Boolean
•It is a data type that can
hold either a True or a False
value. It is mainly used for
checking the condition.
24
•Character
•It is a data type that can
hold a single character value
both uppercase and
lowercase such as 'A' or 'a'.
25
•non-primitive data
structure is a type of data
structure which is a user-
defined that stores the data
of different types in a single
entity.
26
•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
27
•int a[6] = {1,2,3,4,5,6};
28
•String: String is
defined as an array
of characters.
29
char name[100] = "Hello javaTpoint"
;
char name[100] = {'H', 'e', 'l','l','o
',' ', 'j', 'a', 'v', 'a', 't','p', 'o', 'i', 'n',
't' }
30
•The difference between the
character array and string is
that the string data
structure terminates with a
'NULL' character, and it is
denoted as a '\0'.
31
•Stack
• Stack is a data structure
that follows the
principle LIFO (Last In First
Out).
32
•Stack
•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
33
•Stack
•can be implemented
by using either array or
linked list.
34
•Queue
Queue is a data
structure that can be
implemented by using
array.
35
•DIFFERENCES
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.
36
37
Primitive data structure Non-primitive data
structure
Primitive data structure is a Non-primitive data
kind of data structure that structure is a type of data
stores the data of only one structure that can store the
type. data of more than one
type.
Examples of primitive data Examples of non-primitive
structure are integer, data structure are Array,
character, float. Linked list, stack.