Вы находитесь на странице: 1из 14

DATA STRUCTURE

WHAT is Data Structure


Data Structure is a particular way of
organizing data in a computer so that
it can be used effectively.

It makes the computer fetch and


store data effectively.
eg . Library
Why we study DS
The program comprise two things
Data -- computer data is
processed information or
stored by a computer.

Algorithm -- describe the way data is


to be transformed.

Reason adding structure to our data


can make the algorithm much
simpler, easier to maintain and
often faster.
Types of Data Types
Primitive Data Type basic data type
used in a programming language
eg . Int , char , boolean, etc.
Non primitive data type also called
composite ,compound data type.
Constructed by using programming
languages primitive data type.
eg . Array, Record ,union ,etc.
Abstract Data Type mathematical model of
a set of data values or information that
share similar behaviour or qualities and
that can be specified and independent
of specific implementation.
eg. Stack , Queue, Tree , Graph, etc.
Basic operations in Data Stucture
Data are processed by means of certain
operations which appearing in the data
structure.
Data has situations basically depends on the
frequency with which specific operations are
performed.
Basic operations are;

Traversing accessing each record only


once
so that certain items in the
records may be processed.
Searching Finding the location of particular
record with a given key value or
find the location of all record which
satisfy one or more conditions.
Inserting Adding a new record to the
structure.
Deleting Removing the record from the
structure.
Sorting -- Managing data or record in some
logical order.
Merging -- Combining the record in two
different sorted files into a single
sorted file.
ARRAY
Array is a container which can hold a fixed number of
items and the items should be of same data type.
Why we need array;
when the program need to manipulate many
variable of similar forms of data
As the complexity of the data structure increases it
becomes more easy to deal with the data.
Terms of Array;
Element Each item stored in an array.
Index -- Each location of an element in an array has

a numerical index which is used to


identify
the element.
Array Representation
int array1[3]={1,2,3}

BASIC OPERATION
Traverse
Insertion
Deletion
Search
Update
Insertion Operation
Insert one or more elements

eg.
LA-linear array
N elements
K- positive integer , k<=N
Alg;
1.Start
2.Set J=N
3.Set N=N+1
4.Repeat step 5 and 6 while J>=K
5.Set LA[ J+1]=LA[ J ]
6.Set J=J+1
7.Set LA[k]=ITEM
8.Stop
Deletion Operation
removing and reorganizing
element of an array
ALG
LA-linear array with N elements, K<=N

1.Start
2.Set J=K
3.Repeat step 4 and 5 while J<N
4.Set LA[ J-1]=LA[ J ]
5.Set J=J+1
6.Set N=N+1
7.Stop
Update Operation
updating an existing element of
array at
a given index.
Alg;
LA-Linear array, N-element,
K- Positive integer
1.Start
2.Set LA[K-1]=item
3.Stop
Searching Operation
searching based on index or value
LA-Linear array, N-element,
K- Positive integer
Alg;
1.Start
2.SET J=0
3.Repeat step 4 and 5 while J<N
4.If LA[ J] is equals item then goto step 6
5.Set J=J+1
6.Print J, Item
7.Stop
STRING
String in an one dimenstional array of
characters terminated by a Null
character
Eg . Char
greetings{6}={h,e,l,l,o,\o}
Null character represents the end of
an
string-\o
SOME FUNCTION

Strcpy(S1,S2)
Strcat(S1,S2)
Strlen(S1)
Strcmp(S1,S2)
Strchr(S1,ch)
Strstr(S1,S2)

Вам также может понравиться