computer sorting techniques (bubble sort)
TRANSCRIPT
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
1/30
ABSTRACT
This project deals with one of the sorting techniques, which is BUBBLE
SORT. It is priaril! concerned with ai of siplif!ing it"s prograing
ipleentation, and o#jecti$el! aied at a%ing articulation and through
anal!sis on certain ajor characteristics of each Bu##le Sorting techniques
to show how it wor%s so that desired choice can #e ade at an! point in
tie.
There is no sorting ethod that is #est in all aspect, each has its ad$antages
and disad$antages depending on the nature of input data, coputer
hardware and prograing strength. &ence an attept is ade to show the
area the sorting technique wor%s #est, so that an intelligent choice can #e
ade at an! gi$ing situation.
Sorting is the uni$ersal fundaental acti$it! and its iportance in coputer
science can ne$er #e o$er ephasi'ed
1
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
2/30
TABLE OF CONTENT
Title page I
Certification II
Dedication III
Acknowledgement IV
Abstract V
Table of content VI
CHAPTER OE
1!" Introd#ction 1
1!1 Ob$ecti%e Of &t#d' (
1!( &ignificance Of &t#d' (
1!) Definition Of Tec*nical Terms )
1!+ Detac*ed ke' )
1!, Comp#ter arc*itect#re +
1!- Vol#me of data to be sorted +
1!. Ordering of t*e data +
CHAPTER T/O
(!" 0iterat#re Re%iew -
(
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
3/30
CHAPTER THREE
)!" Algorit*m And Design
)!1 C*aracteristics of an Algorit*m
)!( 2#bble &orting 3
)!) Algorit*m for 2#bble &ort 1"
)!+ Impro%ed 2#bble &ort 11
)!, Algorit*m for Impro%ed 2#bble &ort 11
CHAPTER 4O5R
+!" Coding And Implementation 1)
+!1 Amo#nt of Information 1)
+!( Anal'sis Of 2#bble &ort 1,
+!) Program Implementing 2#bble &ort 1
CHAPTER 4IVE
,!" Concl#sion ("
,!1 Recommendations (1
RE4ERECE&
APPEDI6
)
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
4/30
CHAPTER ONE
INTRODUCTION
7ost data processing is concerned wit* sorting and searc*ing of data!
&orting data re8#ires p#tting t*e raw data in some predetermined order9
w*ic* mig*t be Alp*abetical if t*e data is set of words9 or it mig*t be in
ascending or descending order of se8#ence if t*e data is #merical!
&earc*ing means finding a specific item of data from a list of data items!
T*e tec*ni8#es #sed for t*ese processes depend %er' m#c* on t*is wa' t*e
data sorted9 and on t*e arc*itect#re of t*e comp#ter data to be sorted can be
in t*e main memor'9 magnetic disk:tape or e%en a tape streamlines!
Efficient sorting or searc*ing Algorit*m to #se!
T*ere are se%eral met*ods of sorting9 b#t one of t*e most pop#lar 7et*od is
called 25220E &ORT! T*e name dri%en from t*e fact t*at t*e sorted items
flow to t*e top of t*e list like a b#bble in water!
+
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
5/30
OBJECTIVE OF STUDY
T*is st#d' is aimed at;
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
6/30
T*is will also be of aid to sc*ools since an impro%ed tec*ni8#es increases
t*e acc#rac' and time spend on processing res#lt in sc*ools and processing
$obs!
DEFINITION OF TECHNICAL TERMS
DETACHED KEYS
In most application t*e information content of t*e records is large! On t*e
ot*er *and9 t*e ke' itself is #s#all' 8#ite s*ort9 t*at we can considerabl'
impro%e on t*e efficienc' of o#r Algorit*ms b' detac*ing t*e ke' from t*e
record and not s#bse8#entl' mo%ing t*e records d#ring t*e process of
algorit*ms! If t*e ke' is detac*ed from t*e information part of t*e record9 it
m#st be a#gmented b' t*e address of it>s associated information! T*en t*e
sorting met*od is carried o#t on t*e a#gmented ke's and t*e information
part of eac* record remains in t*e same place in t*e memor'! T*e store ma'
allow rapid access e8#all' 8#ickl' to an' of t*e records fast9 random access
e! g core stores!
0ess rapid access ma' be possible again random or nearl' so9 for e@ample
wit* t*e magnetic dr#m or disc stores!
-
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
7/30
Access ma' be possible onl' to records in a definite se8#ence as on t*e
magnetic tape!
VOLUME OF DATA TO BE SORTED
T*e %ol#me of data to be stored for sorting if %er' large will limit t*e tape of
storage t*at can be #sed9 since onl' t*e lower backing stored will be
s#fficientl' large!
COMPUTER ARCHITECTURE
T*e comp#ter arc*itect#re *as it appears to t*e #ser9 also determine t*e
sorting met*od9 t*e important effect are closel' connected wit* t*e pre%io#s
factors of comp#ter storage9 t*e wa' storage is connected and organi?ed
bot* t*e *ardware and operating s'stem! Rele%ant considerations are central
processing speed relati%e to store access time9 w*et*er t*e operating s'stem
is #sing paging or anot*er storage allocation met*od and w*at specific
algorit*ms are emplo'ed!
THE ORDERING OF THE DATA
.
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
8/30
&ome of t*e sorting met*od performance is considerabl' impro%ed if t*e
data are alread' partiall' order! It is t*erefore #se f#ll to know w*et*er t*e
data will be random9 or partiall' ordered9 or consist of se%eral ordered
s#bse8#ences!
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
9/30
CHAPTER TWO
LITERATURE REVIEW
Alread'9 a lot *a%e been done on 2#bble sort9 t*ing or books t*at can *elps
to a good or better anal'sis on 25220E &ORT!
In 2A&IC PROBRA77IB9 writing b' 2! Holmes
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
10/30
b#bble sort depends on t*e n#mber of passes9 t*e n#mber of comparisonsF!
F6G6 InF and t*at t*e interc*ange 6$G6$ F t*e' state t*at t*e
n#mber of interc*ange )n:J d$ and to it>s left; " in it>s best
)n
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
11/30
CHAPTER THREE
ALGORITHMS AND DESIGN
One of t*e f#ndamental problems of comp#ter science is ordering a list of
items! T*ere>s a plet*ora of sol#tions to t*e problem9 known as sorting
algorit*ms! &ome &orting algorit*ms are simple and int#iti%e9 s#c* as b#bble
sort! Ot*ers9 s#c* as t*e 8#ick sort are e@tremel' complicated9 b#t prod#ce
lig*tening fast res#lt!
An algorit*m ma' be defined as a finite se8#ence of instr#ction #sed in
sol%ing a problem! In ot*er words9 it ma' be defined as a prKcised stepb'
step proced#re #sed in sol%ing a problem!
CHARACTERISTIC OF AN ALGORITHM
An algorit*m possesses t*e following basic c*aracteristicsL
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
12/30
also be possible to carr' t*em o#t e! g t*e instr#ction FBo to *ellF is
prKcised9 b#t can not be carr'o#t!
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
13/30
T*#s a ke' is b#bbled #p9 in t*e second pass we work from t*e nt* list to t*e
second ke'9 since t*e first m#st be t*e first pass9 be t*e smallest ke'!
ALGORITHMS FOR BUBBLE SORT
&TEP 1;0OOP9 for k 1n1
Do &TEP& to .
&TEP (; A&&IB N.9 I
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
14/30
IMPROVE BUBBLE SORT
DE&CRIPTIO;
2#bble sort m#st be impro%ed b' remembering w*et*er or not an' e@c*ange
*as taken place d#ring a pass! In general
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
15/30
DO &TEP + TO .
&TEP +; I4 ME&
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
16/30
CHAPTER FOUR
CODING AND IMPLEMENTATION
A lot of tec*ni8#es for sorting *ad been considered w*ic* confirmed t*at
t*ere are man' wa's to sol%e an' gi%en problem! In comp#ting9 as in most
area of *#man endea%or9 we are concerned wit* sol#tion of problem! T*is
*o#ses certain 8#estions as to w*at we mean b' a good sol#tion to problem!
In t*is case9 good *as bot* 8#alitati%e and 8#antitati%e aspect! T*ere are
often certain est*etics and personal aspect to t*is b#t9 on a more practical
le%el9 we are #s#all' interested in t*e sol#tion t*at is economical in t*e #se
of comp#ting and *#man reso#rces! T*e facts t*at are to be considering
before c*oosing a sorting tec*ni8#es are;
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
17/30
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
18/30
compilers *a%e %er' small memor' capacit' in w*ic* case9 one can
begin to consider t*e simple tec*ni8#es rat*er t*an ad%ance one!
T*e 8#alitati%e aspect of a good sorting tec*ni8#e are %er' important b#t are
also necessar' to pro%ide some 8#alitati%e meas#res to complete t*e
e%ol#tion of goodness of sorting tec*ni8#es! #antitati%e meas#re are
%ariable in t*at t*e' can be #se in awa' of directing predicting t*e
performance of two or more sorting! T*is is important beca#se t*e #se of
sorting tec*ni8#es t*at is more efficient means in comp#ting reso#rces9 will
translate into sa%ing in time and mone'! &ome of t*e 8#antitati%e meas#res
#sed to determine a sorting performance are;
s initial and final position! Here t*e n#mber of p*ases is
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
19/30
order data9 t*e aspect n#mber of passes sa%ed are t*ose9 w*ic* contains t*e
fewest n#mber of comparisons9 and t*e partic#lar effect is not large!
T*e main ad%antages of 2#bble &ort is t*at it can be %er' 8#ick wit* data9
w*ic* are nearl' order in t*at no item is far from it>s initial position! T*e
n#mber of interc*ange re8#ired b' 2#bble sort is consider more t*an t*e
selection met*od! 4or eac* pass t*e e@pected n#mber of interc*ange will be
appro@imatel' *alf t*e n#mber of comparison! 4or n1 passes9 t*is gi%es t*e
n#mber of interc*ange as n
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
20/30
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
21/30
PROGRAM IMPLEMENTING BUBBLE SORT.
C PROBRA7 TO DE7O&TRATE 25220E &ORT
C TECHI5E IT &ORT& THE ITE7 I EITHER
C A&CEDIB OR DE&CEDIB ORDER
C PROBRA77ER; OMORIE 20E&&IB BOJI
DI7E&IO A72
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
22/30
/RITE
/RITE P5T 1 4OR A&CEDIB AD ( 4OR DE&CEDIB>
READ
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
23/30
CHAPTER FIVE
CONCLUSION
/it* t*e knowledge of t*e c*aracteristic and performance of 2#bble sort9 an
intelligent c*oice for a pop#lar application so t*at bo#t mone' and time are
optimi?ed!
In 2#bble &ort9 one can obser%e 8#ickl' t*at t*e best case for 2#bble &ort
occ#rs w*en t*e list is read' in order9 w*en 2#bble sort will onl' do
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
24/30
RECOMMENDATION
At t*is point9 t*e a#t*or recommended t*at since 2#bble &ort w*ic* is of
greater performance in man' aspect is rec#rsi%e9 attention s*o#ld be drawn
implementing rec#rsion in lang#ages like 4ORTRA9 CO2O0 and 2A&IC
t*at do not s#pport rec#rsion9 so t*at after c*oosing a partic#lar tec*ni8#e
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
25/30
REFERENCES
KRUSE, ROBERT L.
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
26/30
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
27/30
APPENDIX 1
FLOW CHART FOR BUBBLE SORT
(.
&TART
0OOP O IIN19(U1
INI 1
ME
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
28/30
O
E&
O
E&
O
E&
(
A
A
I&
A
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
29/30
APPENDIX 2
FLOW CHART FOR IMPROVED BUBBLE SORT
(3
&TART
0OOP O I
IN19(Us1E&ENME
-
8/12/2019 Computer Sorting Techniques (Bubble Sort)
30/30
E&
O
O
E&
O O
E& E&
2
&TOP
A2
I&
ME