Data Structures and Algorithm - 0(1)
Data Structures and Algorithm - 0(1)
STRUCTURES
Prof. Adrian V. Antopina, BSIM, LPT
Central Philippine University
College of Computer Studies
Copyright 2015
Data Structure
There are three cases which are usually used to compare various data
structure's execution time in a relative manner.
Worst Case − This is the scenario where a particular data structure
operation takes maximum time it can take. If an operation's worst
case time is ƒ(n) then this operation will not take more than ƒ(n) time
where ƒ(n) represents function of n.
Average Case − This is the scenario depicting the average
execution time of an operation of a data structure. If an operation
takes ƒ(n) time in execution, then m operations will take ƒ(n) time.
Best Case − This is the scenario depicting the least possible
execution time of an operation of a data structure. If an operation
takes ƒ(n) time in execution, then the actual operation may take time
as the random number which would be maximum as ƒ(n).
Data Structures - Algorithms
Basics
Algorithm is a step-by-step procedure, which defines a set of
instructions to be executed in a certain order to get the desired output.
Algorithms are generally created independent of underlying languages,
i.e. an algorithm can be implemented in more than one programming
language.
From the data structure point of view, following are some important
categories of algorithms −
Search − Algorithm to search an item in a data structure.
Sort − Algorithm to sort items in a certain order.
Insert − Algorithm to insert item in a data structure.
Update − Algorithm to update an existing item in a data structure.
Delete − Algorithm to delete an existing item from a data structure.
Characteristics of an Algorithm
Step 1 − START
Step 2 − declare three integers a, b & c
Step 3 − define values of a & b
Step 4 − add values of a & b
Step 5 − store output of step 4 to c
Step 6 − print c
Step 7 − STOP
Algorithms tell the programmers how to code the program. Alternatively, the
algorithm can be written as −