0% found this document useful (0 votes)
18 views

Data Structures

This document summarizes key concepts about data structures and algorithms. It discusses how data can be organized into fields, records, and files. A record contains a collection of field values for a given entity. A file contains a collection of records. It also describes linear and non-linear data structures, as well as common data structure operations like traversing, inserting, deleting, searching, sorting, and merging. The document concludes by explaining the three types of algorithmic flow: sequential, conditional, and repetitive.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Data Structures

This document summarizes key concepts about data structures and algorithms. It discusses how data can be organized into fields, records, and files. A record contains a collection of field values for a given entity. A file contains a collection of records. It also describes linear and non-linear data structures, as well as common data structure operations like traversing, inserting, deleting, searching, sorting, and merging. The document concludes by explaining the three types of algorithmic flow: sequential, conditional, and repetitive.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Mobie

Name =MobRe
Company = Apple
Price =40000
Ram = 8GB
Rom: = 6lGB
OS =iOS
Lalllching Date = 7th June 2020
Data :
Data are simply values or set of values.
Data Item : is a single unit of values.
1. Group Items : Data itmes those can divided into sub itmes.
Ex. Flil Name : Frst Name, ~dde Name. Last Name
Ati"ess : place, city. cistrict state, country
Date of Brth : Day. Month. Year
2. Elemenrty Items : Data items those can not be divided into sub items.
Ex. Age: 17
Mobile: 989xxxxxxx
Pil code : 442907
16
Age= 16
The term "information" is also used for data with given attributes.
Information means meanigful data
Age= -45
more attritbutes
Saml<sha Class:
City:
18
Gender:
: 14_/m
1L - _ ___.J Mobile No.
_/_2002

Feild: 'Field' is single elementary unit of


information representing an attri>ute of entity.
Class: 12th

oll No. = 103


Name: Name: Name:
Gender: Gender: Gender:
Age: Age: Age:
DOB: DOB: DOB:

Record : A record is a collection of field values


of a given entity File : A file is a collection of records of
the entities.
e: Name: Name:
ender: Gender: Gender:
ge: Age: Age:
. DOB: DOB:
Mobie Ntmber. Mobie Ntmber:

Record : A record is a collection of field values


of a given entity File : A file is a collection of records of
the entities.
A record in a fie may contain several fields. There are certain fields having unique value.
Such a field is called prinary key.
n above fie_
"Roll No•. is a prinary key
So data can be stored in feids. records and fies_
Apart from fields. records and fies. the data can also be organised into
more complex types of structures.
Data can be organised ii dfferent ways.

" The logical or mathematical model of a particular organisation


is called a Data structure."

Lilear Data struchre / ~


Non-Linear Data structtre
So data can be stored in feids. records and fies_
12th Comp. Sci. II: Chapter-5 Ml fies. the data can also be organised into
I Network Architectures I Protoc.i'. :tures.
Networking Technology
~ tworb Architectures :
!rent ways. n fOMPUTER
~ CIENCE
Protocols:
Connectivity devices :
~matical model of a particular orge2l _
is called a Data structure."

Lilear Data strucltre /


1 Array
~ Non-Linear Data structlre
2. Poi'lter array 1 Tree
lRecord 2. Binary Tree
4. Li1ked Ust
Data Structure operations :
Array : Collection of homogenious(sa,ne type) elen1ents is called as Arra,·.
( 8, 10, 5, 36, 7, 32, 4 ) without decimal point (Integer Numbers)
( 1.2, 6.3, 0.5, 9.5, 8.9) with decimal point (Real Numbers)
Eg. Data L 52
I 14 23
I 7
I 27 J
Size/ Lenglh = 5
0 1 2 3 4
Index Numb~ [> 1 4 5
2 3
Dala[1) • 52
Dala[2) =14
Dala[3) =23
Dala[4) =7
Dala[5) =27
Data Structure Operations : there are totalslx data structure operations.
1. Traversing : Accessing each element of Arra )' (S tructure) once so that II can be processed.
2. Inserting : Adding new element Into the structure
3. Deleting: Removing element from the structure
4. Searching: Finding the locat ion of element
5. Sorting: Arranging elements in some logical order ( 7, 12, 14, 23, 27, 52 )
6. Merging: Combining two files into single f ile. ( 4, 8 1 3, 10)

( 7, 12, 14, 23, 27, 52, 4, 8, 3, 10 )


Algor ithimi c notat ion

An algori tm is a finite step by step list of u ell define d instru ctions for
sol\ ing a partic ular problen1, First Part
. / 7 ~ame of the Algorit hm
. .
Eg. Add1t1on of two int numb ers / List of the variabl es
Let _!_and Bare two int numbe rs. Purpose of the Algorit hm
Jhjs algorit hm will calcul ate SUM of these two numbe rs.
Step 1. Start - - - - - - ~ Second Part
2. Read A and 8 it ,. 10 e • 20 Lisi of steps
3. Calculd te Sl,M a: A + 8 !)LJ~I • 10 • 20 Steps are executed one after
4. Displa~ SUM the other
5. Stop Data / values may assigmed to variables
by using read statem ent
Display statmen1s displayed result or
,,alue of the variabl e
Algorithimic notation
An algoritm is a finite step by step list of well defined instructions for
solving a particular problem, ~ First Part .

Eg. Addition of two int numbers / N~me of the Al_gor1thm


/ List of the variables
Let _!_and_!!_are two int numbers. Purpose of the Algorithm
This algorithm will calculate SUM of these two numbers.
Step 1. Start - - - - - - ~ Second Part
2. Read A and B A = 10 B = 20 List of steps
3. Calculate SUM = A + B SUM = 10 + 20 Steps are executed one after
4. Display SUM 30 the other
5.Stop Data / values may assigmed to variables
by using read statement
Stop slatment complete the algorithm Display statments displayed result or
value of the variable
!control StucturesJ
There are three t} pes of flow of control (or logic)
1. Sequenlial flow (Sequential / lnear logic)
2. Conditional flow (Selection logic)
3. Repetltlvel flow (Iteration logic)

1. Sequential flow (Sequential / Unear logic)


In sequential flow the modules are executed one after the other
Each modeule is a set of steps
Diagra m I Module A J Eg. 1. Addtion of any two numbers
2. Area of circle/ triangle / rectangle etc.
I Module B J 3. A\'erage of three numbers
[Module C J
2. Conditional flow (Selection logic)
In condit ional flou , one or other module is selected upon depending on condit ion.
There are three conditional structures
i) Single alternative (Simple if)
Form / Syntax Diagram
IF (condtlons), then:
[MODULE A] \.IOOOLC 4
[End of IF structure ]
Form / Syntax Diagram
IF (condtlons), then:
[MODULE A] \tOOULE i\
[End of F structure ]

ii) Double alternative (if..else)

Form / Syntax Diagram


IF (condtlons), then:
[MODULE A] ">---U \tOOULE i\
ELSE:
[ MODULE B]
[End of F structure ]
iii) Mult iple alternati\1 e (Nested if..else)
Form / Syntax
IF (condtlon 1), then :
[MODULE A]
ELSE: IF (condtlon 2), then
MODULE B]
ELSE:
[ MODULE C]
[End of IF structure ]
3. Repetitive flow (Iteration logic)
Her e certa in \1ollulc is e, erut cll r epetl.1I) unit ) condition sat isfies.
i) While loop
Form / Syntax Diagram
t
lntlalze counter
Repeat MODULE A While (condtlon)
(MODULE A]
lncrement/Decrememt counter
(End of Wlile]
n INlldu f OWllrr

cOINII CIIIJ _ .,

I lftrr,-r..
_r __ ., J !"'
\I OOU( 4

l
ii) for loop
Form / Syntax
Repeat for K = R to S By T
[MODULE)
IEnd of for loop)

Herc
K is inde, \ a rib ale. (loop / Counter\ ariable)
Initial \alue of K is Rand
fi nal \'a lue is S.
T is increment.

Working and diagram off or loop is same as the while loop


Roots of quadratic equat ion
ax 2 + bx + c = 0 where a Is not equal too
X1andX2= -b =JE}
2a

Roots and their nature d = b•b·4•a•c


i) If d <0 i.e. negative : roots are imaginary sqrt(-ve) sqrt(-4) ?
ii) If d == 0 i.e. zero: roots are real and equal sqrt(O) x1 = x2 = ·b/ (2. a)
Ill) If d >0 I.e. positive: roots are real and dfferent sqrt(4)
+2 -2
Roots of quadratic equation :
Let A, Band Care coefficient of quadratic equation and tlis algorithm wil
find real roots of quad. Equation.
1) Start
2) Read A, B, C ELSE: IF (D == O) then
J) IF (A == 0) then I) Dlspla, Roots are Real and equal
I) Dlspla, Its linear equation H) Calcualte XI = X2 = •B / (2 * A)
U) X = •C / B ffl) Dlspla, Xt and X2
ffl) Dlspla, X ELSE
ELSE I) Dlspla, Roots are real and different.
{ II) Calculate XI= (•B + sqrt(D)) / (2 * A)
I) Cadulate D = B*B-4*A*C Ill) Calculate X2 = (•B • sqrt(D)) / (2 * A)
II) IF(D < o ) then Iv) Dlspla, Xt and X2
a) Dlspla, Roots are lmaglnar,
If) Stop
To Display Word "Computer Science" 5 times
1) Start
2} Display •computer Selene••
s) Display ·computer Selene••
4) Dis play •computer Selene••
s) Display •computer Selene••
6) Display "Computer Science"
7} Stop
To Display Word "Computer Science" 5 times
1) Start
2) lnltlaUze Counter
set K =1 K = 1, 2, 3, 4, 5
J) Repeat steps 4th and 5th While (K <= 5)
4) Dlsplas, •computer Science•
5) Increment Counter
K =K + 1
K =K + 1 =1+ 1
6) Stop =2
To Display Word "Computer Science" 5 t imes
1) Start
2) lnltlaUze Counter
---:--::1
set K =1 K = 1, ~ 3, 4, s
J
J) Repeat steps 4th and 5th While (K <= 5)
4) Dlsplas, •computer Science•
5) Increment Counter
K =K + 1
K =K + 1 =1 + 1
6) Stop =2

1) Start
2) Repeat step 3rd for K = 1 to 5 by 1 ~
3) Display "Computer Science"
4) Stop

You might also like