i. ee
5 Beirne Danger Plea Forahnd, Biker
ents
~ Sain Yesu blenn Nhe | |
Near A." Cal
Bhor
* Xerox
Colour Print
& Lamination
& Spiral Binding
* Print Out
Stationary
* Golden Emboising Binding
Prvprictr Aru Tupe (0822535978)
{ Student Naan
Sujet,
+ qe
4 Book oF
PRINCIPLES OF
PROGRAMMING
AND ALGORITHMS
For BBA (CA) : Semester -1
(credit - 02)
‘As Per New Syllabus, Effective from June 2019,
‘Abhijeet D. Mankar
Price € 170.00
NONIBAL!Contents...
4 Introduction to Problem Solving
2. Simple Arithmetic Problems
4. Algorithms Using Arays
Sorting and Searching
Chopter 1...
ssa Introduction to Problem Solving
Contents .. ;
1 cont
111 eke ctalan
aaaaa] 2
4-526
112 een Shing
1122 lon Shing Se
1123 lon Sting Tee
eer Delmer Ge
Aeshna
134 Mag end Daotenins
ct
142. Foret mb
14a Aberage
144 Umsice
Apt Compe
15 =r Cond
152 Tie Cogley
152 Spee Conley
154 p'O'Netain
age Ati an FlononePly etegnenng Aetna 6BA(C)-N__12_ edits ein eg
“poem any sustonin when you hve tring pal at oF retons, ante
aesto cet asaton oars i
+ Apron 2 stuaton tat confonts someon, that equles seluion, nf hic |
the path the sen ot naly acon, |
+ problem if question estan tat mata you osc or san Thi
imps rat ou art noes to sl th ros Se arn that ou te |
‘auch fer away tf» elton Whar» quetonf 3 podem orn ea
epends onthe rr knoe ofthe rb set
+ Specialy, th tk of ding the eben cnt eight you kn
(et en dt ad wate you mato tn (ett he eas
Two apectot problem:
1. The detains for eng with the lds and the sat parts of poten
Cito an
2 Te apo for delng wth he conte and the eppocuny amas of the
pen. |
1 robin sain i procs of dng 2 latin for parla geben.
-4 Definition of Problem |
+ We cin ine pole 84 ste of dai or eating a dite gos rom a preet
con
+A polo an ene or obtaclewheh mts cut to ane od get
ppt or pepo
on
+ -Poben eet stanon conn ore hat stuns
oR
+ Aproleniss question aston nies er coniterton or zal.
4.4.2 Problem Solving
+ Problem soir the seul proces of saing iformaton rte 8 han
‘suson and generating arpa response epons
+ Teun gol of protien sohing fo ove oben # eho ta
bat ihe he ue,
+ The te 2 ube offre metal procs t wor sng problem-ohing These
irc
1 Petepalyecogtting a probir,
2 Repesring the protonia memory
3. Comer elaart inforaton tat apesto the cretion,
ety sect apf roe
5. ibang and decting te rly,
ition
Prolansoing he process of wang tough deta of a problent0 rach
sour:
Felonsohing 3 mal proes tht cles diconn, aang a sting
Freleng hog process cite:
1 Undestae he rb ammunition and ants)
2. Pana solo mong nd dso
3. Gay out plan coe generation
4 amie the esr acura sng nd quay assure,
Fig L2 hase sige man dul with wich we sociale number of. hich
hes thi! grea apn of the stum Te main ade ees 3 be OF
‘orn rds which an rub sel 234 expec.
TE] fies
1
a
zs] ()° [esl}=
Fig LiL of probe singPipl ctPopunning its BBA 1b ong
IEEE /rrotiem Solving Stops
+ Generate are widely cepted tps nthe problem sehing process own
inrg.i2
em tn
i. 1.2: Probe soking process
+ bien sohing steps ese belo:
A, Defining dentin) the problem: Io sinost ey problem sohing
rrathodoegy the is sep is defrng ot Wentyng te prota Rithe ast
cu aa the os porto al the tps ile grain the sen
sottat he fous onthe re totlem an nat nits ymptons.
Dering the Solute We fen Wink of sing a pol” inthe sn of
rang go ny 20th the poem ong et Th ced ison nd of
‘sso bat its et the ony in Some probs aot be mite erie:
we ae never Ht elite ash a the wea onautamebie tes rt
‘earence of les We can, bower reste sluons o”teatnents tt wil
mae ech ofthe rls ess har
2. Gather facts Some men of getting data
aioe ay tems.
(seat seunpin
(@) Daas the ri thro
(6) Gathevonpsnt of ihe
Peel etPennng Arne: [PBICA_13._ ota eben sehing,
3 Generate atemate options: On oy 16 ery pote soln ito reeset
‘he problem eternal Fst, By represen the rte, wil
See infomaton hts relevant ecg he gal the al te, te cpentors
and retire Operators are acions hat carg nil ate of he rblerm
im arotios The you may exter tar 2 pe of pabiem, Seep sir
Santon, ante often ar emuting the sean an at ae obi
ioee Some of tole ured re
(Systematic ia ae err.
(Prods
(teases
(Faction etd
(0) Noone saved
Implament and Evaluate: Make + it of the trent ops tht you have
geerted, Sele ote of mote sons otons om wear the top of out to
fy Does te son meet te gas and conairs set by te peblem?
Frequent the beter epon for plantain i the rune” te of punber
ttre chice Manise the inp of the slur The evan of your
implore i ot boat on nha o ot you food he ses. Bl on
“thr rt urge are me,
5. Monitor the soliton e-psy measur to confi ht change has aken
ce
(Chaco tht the charged ot espe aot e
(i) Pevie sudentifooatn ard wang so that hage can ake pe and
be ssaned
(elect onthe problem song process utd Wht would you have Sone
‘een,
IEEE protiom SoWving Techniques
Tare ae mary appches to problem sking. depenng onthe nit of the
poten ard he peop ved the pel,
ig. 13 shows rou problem sing ives
Pesos ip oe
ee ee ee
Taredersnonee | [Barannsann | [Boardman]
Fi. 13: Various robe sing bigseect sri Myotis A640: 18 __ invent tig
(9 al and Error Method chia
+ “Than ee ol by enor e's gtr mato of pi shin fo abaning
owing, bth potion iowedp an aowhon
+ Inte of comput sce. the mtd ie cal genete at Ts Er
spre smote sues wth simple prclens.
+ Til an Ener speach can be een 3 an of thet bi approach fe prin
‘ping ad contd wih an apprise ong ih arto
+ tear er gpesch to protien sling aes ning ruber of erent
seen and ung ot tose a do net wok
+The apgrosh an bea goed opin you Rae 2 eyed numberof pone
lite
+ Ticmeties cen sty pape we fav fe oweeein th rb re
Feats of Ta and Ear Method
1LSaution-oventa Ts nd eror make no tempt oor why «eon
wens merch tats slsion
2 Problem-spece Tel and eror malas no stant to gear 2 lon to
he probs
2. Nonoptima: Tl and eros an stomp to fi ton nt uns, and
rere best ton,
| Node te Imani ila enor an proce hare thee ie 0
lnowecge tte
‘évanapes:
1 syt0 implement
2 Thsmethods bata suaons whee ou have more sts.
Dindrantage
1 Tie consuming because feed on each ad eve
(0 rastorming Method Technique
+ ‘Srinsoming 2 grup creatitytevave dsged te greats slg runt of
‘due forth slot pb,
+ rinsorming is pole sing eign that ues a group of peopl to sve a
pieiem
“uo of bsitonmng eson to wa a group to define 3 peclen a fd
+ ransormig gro imolies grup woking tetas ideas. ing he
mes thas as plement hose eso jing tase des.
Pisin steaming zoe JBRACA<|__17__ itn Ptio Sling
+ storing en stn nthe otc, hen wot group meso cone am
ate aliens,
+ Rica rmios of ares problem aio in which a meer of group sportneously
Contbut erosion of pol, 4
+ Bastin wae «group people pt scion and nes we wth the
Approach of rastorming: Tete se fut bs nlsinbrarstomieg
1 Combin and Improve idee spose issn ola bt and more
empl et than erly genet es sone. baled ost
thelr of en by a reel esd.
2. Noctis oon empha hata ouptrattoming, citisn shoud be
puto tlt of edt ating what right be wong Wh a de, the
uti foas on extend or lng sein ite orale test
stage of the process. fy suspending judgment one crates 2 sppotive
oosphre ore prtians el eee generate ns es.
2%. Fees on quntity ule a mess of ecancng degen predutn aning to
fectte poten soling Prawh be maou gusty brats quay. The
‘stunt it thatthe geste he rumbet of eas generat the ester the
‘hae of puna nd lective ston
4 Una ear weeome: To gi ood ng i of se ual i
‘ae ekemed Thy ay ope naw mays of ning ard prove bt sleons
‘an repr ees Thy can be generates by leo Fon anther pasrctne OF
Setig ase aston
‘Vato ritering Tachique
1. Nominl group technique The nomial geup teique i & spe of
tristan teenage: parca havea eau synthe proces.
Iria ind o enna anes tof eae Prima sates to write
oun thar es anorymouy Then he nocesor oles he cs rah Is
voted onby the ep
2. Group pasting teblqu:Ec peso ne cel roup wes do oe len
the then pass the lace of opto the et pron sock dacion wh
is sae huh Tis ented eenbay gets ther ong ce of
ner bck ys tis ly ht he ou lve extra eabeated
fete
2. Team des mapping method Tem sa maoing maths of rtoming works
bythe med of asscatn may improve calsbeaton ad nese the
lot of des ns desea tal ards parcate nn es are
‘ejected,44 ectronebrntorming: Eaton baaormng # cpu atin
‘he manil traning Gran soming techie. tan Be dove vis ea
‘Seton rating alee mich ger op ta late on tpi
than woué roraly be pesuve ina vader tainting ssn,
LGatronie bintoming emits many of te probins of anda
‘ransorming no podictonlcking ad auton spreeron
5S. Diected bralestoming: raced besnstoriog ia vition on decroie
bransorning balrating) debt above can be one mania o th
empuie lvcngy. Dito brazing were won the sion
nun prt the seson IF know, tat eta can be ued t Peto
onan histo pros heres brining. each parker en
neste of pera taine basting ueton
{6 nia rnstorming: nial rrtoming isthe use f baring on
* slay bas. Indiv restoring typical ins uch echigus a fe
wig, espe, word assceton ana the spe web which va note
{sing tein tick peopl gram thr toh
Aaramages of rastormig:
1 Ey toundestind iki ot compa tei,
3 eoroted proper itis quay of generating ideas
4 trcoragas ete ntng netting out of te bar
5. Genrer ide and one that cn be ued ele,
& Frvdesan pperuny or wdesped paripatn and nvlement
Disadvantage of Sainstrming:
1 As this isa group ait, prtepans have to ste patent ag hve to spent
‘more tine by sng hae tl te rence by te
2 Medea or ive parties might dit Eu to expres th cy or
rents a |
(vide and Conquer Method Technique:
+The nae dean conue is Bec the probes conquered by dig ito
seri smaer pobl.
+ iit ad conqurisan approach to song spolo ati speci ee of mae
cndsanays.
+ Indie ad conser one ser a pecblam by fit dering» subos tht hes
‘hing amar veson othe sue i of pre
+ nother words, ide and conueristhe epic use of reuson to save a problem,
ingot Pagaonng Ages: EKH-| 38 maoductn Pon Seng
+ Thesivie rong sty aber problem by
1. tesing it imo sb problons ht thames eter snc othe me
‘ypeatroten,
2 Sohing tase sro independent,
3. peers combo hams
Working
Inverts by recast treaing down problem int to or more su pobens a the
‘sme or rested ype url hee armel reign soe ety,
‘Te soon tthe sb-poboms ethan combina ogi # soln othe ginal
robe,
‘Divide and Conus doy tet ype of eurance aon between
‘uncions of edt cueson: a ried inte alr portins andthe el Is
alia
Dido and Conguertecrigue te bite of fick agorthms fr a Kinds of
problems, sch a sorting (quick son marge sen) ard the te Fat Four
Trarstorms FIs ppzaton to mumereal agents commonly kn 5 Binary
sites
‘vantage f Ovid and Conqoar Tecnu
1 Solving sift probs: Die ss conquer 8 gamer tol fr sohing
concen diet poten ot egies nyo breaking the pole nto
"ub-potiens of Song the hil asad feng sub relers o the
gral poten.
2. Algorithm eficncy: The dide-nt-orguer pation often MebeIn the
‘dover o efit goths
3. Parallelism Die and conquer ageths ar natuly adap or eecision in
rutprocssor machines epecty sharedsmamcty syne. where, the
ormnarcaton of eats betwee provers dos ot nted tobe pln In
‘anc, eae tt sub peti can be etd on diferent pres
4 Mamory sees ise snconguer srs natu tnd to make ect
tse of mene aches The reson that one sgl sal enough
tg al is abot can in pple, be sed whine ech thot
‘casing te domer min meno
‘Dladvantages of Die an Conque Technique:
1 Stow Racin: Te cura fhe repeats sre ca song that of
Stang te al tack can cvs an aartge ofthe proach Te omer
‘ependsupn he implementation she wit ge enough recusereplete Ages
2. Complated fr simple probleme: Arter poten of «ide a conver
rein tht forse pols ay emo comptes tan an teine|
oro epecaly bre bw ae ae tb npemenig fr pavornce
Pega deloment cy at of phased ad steps tat reflow by pl
shea dem cop and mala 2 ro.
ring your rogiom ving 2 sequence of saps rfred to as te pgm
serdapnert
Fig. tom regan delet ete
Fig, L4 ropa deaapmenteele
‘The progr dewlpment eye naes loving steps
Step 1: Define the Problem
Te vy npr tat you unde the poten you ar tng tsb. Make se
You aane pte speatatons nelly
rom wht dt 0 Bengt no tm program and what oom Wat dt shal bea,
‘snow what proces est be doe tot
Fin, determine ht the expects tpt suposed to be and st form the
‘stp 2 Design the rogram
"her ar ver ways of dering program spn. Two commen methods a by
Aonctrs ard pnocede
2 foncht 8 gph deciton of pop deg ts yn ambisons of
‘ios standard Bovenar symbol,
We all we flowcharts to repent cal the base pregram contol seucUre
Presdecode (erly Tae cede esrb progr Gsign ig Engh Prevococe *
"vod the sn of» programming angge an tad, epi the deg
‘he peclen ston
Poot Peng
sep 3: Code the Program
+ To code 2 progam means to wee te design fom sep 2 no computer
programming ange
+ Code the pogan by enteg tio your DES ero ay et aor co your
emouter Sistem Mae aie tt you sete roan to Gk Ulery fo
‘terest step.
2 nthe nx tp of te progam dewlepmer nyu il evar te porn cede,
cals he sae progam rhe sees ade oth compte for option
4 Compl and tink the Program
The ony ngage 8 gn compe undentands i ts own machine lnguage
[machine inguage mevucton 2 inaryades tact cone foe aNd
one that conse compte a do respect ich 9381199
ach compute has a own maetce ngvage, The machine language or & Sun
worst fleet em the machine ngage of Maco whe ierent
fom the machine ngage of nM FC ands a Recaise racine ngage 0
‘a, i eet owt ae fd errsin machine rue pa
vines P(6N)-__181 oie Prt Sv
1 secu a computer unerands on own ade ange carat ext
higher mie‘e! ging nscton ety, he corp ng oom
(ales @ compiler, mst tare i el ad Nghe angus progr Ho
auilent macht anuage programs Kcompie is pal tat ay one
hee or miele! argue specie mace nguage
+ compile a wo mala cons
(Checking tytn
(Taste the codeine mec sncie ngings,
1 Foti chaste seuce preg fr sae aro Sac ero a he
(yanmar ofthe prograriming anager ay fatal yt ee (a
fos 0 see tthe comple dos not undeand the stent and cent
"ene te satenent ro mucin ngusoe he comple wl sop 8 ret you of
tera tond|
+ the compile fins no alee wants ahh ee nguge nsucton
Ino ane oF more machin language ctor Ths mine npuoe son ofthe
soars pogram thee progr,
Step 5: eect the rogram
‘nce yu have comps an nth program ou are t ict the progam,
+ Bucting he progam sual ute snl. soe al you need dois ct.
the eet option fom amen tek.Pilea Popmenig gene BAICN__us2__ tte ton
‘Step 6: Tet nd Debug th Progen
+ felfaproryam raze doe rt mean tht the progam corect.
ven 2 program gies core res ug some dt, doesnot mean tet the |
[poyea il ee core rite ing arta st ofdta
‘Thus foram sold be tested for Yaw posse st of dat and sh be
sougged wire recites.
‘Analg i» ite tf pace ection for peroming a compattin oo
hing pele
Agri i © sequence of acest be proces for geting deed outt
(alto ton gheninpt oroten
An lg cin be tought of a5 the dtl inswetns for emg out sme
‘peabon, A compute pear fast flow a squene of erat nto 1
compl ths Thi secvenc of stuns clean goth
se of Algerie
1 Ging the algnthns bse jou the prog can be developed in ay deed
langge
2 An algr s epreseriation in single gh rguage ois eye 0
Uunerstand Sorbie ean be ay and ingly sled
3. Altice cing.
Approaches fr Deiaing an Ago:
1 TopdownApprea&top-donn dein aproah tars by densi he mor
components of the ste or preg decomposing then int the fone le
‘omporets rd iterating ut he dite ier of ol cones) achive In
ine su th the tops made a eee a made at heal
Fer xampie guage.
Bottom-up Approx: & botom-p den approach sare with desing the
ost base of priv components ahd proceeds to hgh level comgonets
‘Sarg fom he vey btm th pears tht provides ayer fatto se
ingleranted
ors alert ete can be wen ung wo methods.
|. Recusv Algorithm: A ecusve alt sa lg which als sal wth
mae (r nut aus whch obtain thereat te creat op by
‘oping the same operons for he sale sil pu. More gentay #2
felon canbe ses uting rekon to salves ofthe sone poten.
‘sth sale veins rouge to easy sable cae, ten oe co te ene
orth sae robin
ertive Algorithm: n these alot, th proces can cut eet on
the iepusin ner tach deste eso,
‘risatPomemaig pom (6088. 138
4.344 Definition
icin dine igor "st orton eshing pb.
abet tn Sn
+ Asteo-bysepproceduteforsahing pate poble an ln,
on
+ Ano can be dda proces that poms sme sequence of opens
Inardertosohea ge ele
An alot ss step ytsltion to oben”
1.3.2 Characteristics
+ yl mst seh flonng rates:
2 tnt Aegon mus ave se Fatt
2 ouput as produce on cutout eat
3 Defitenest + Exh instutin mt be der nd ditt.
4. Fnteness Te agerthm muster ter fe number of pe
EHectveness + tach epson must be dite Ho shuld be fee
ve pct be pa,
1.3.3 Types of Algorithms
+ Thevatousyper of algo re rte free, Ode andcenqur, Greet thm
2d eran
Brut fre ago
These se algrhns ta we vous ronsophiated approaches to see the
press inhana
Typ. hy ae ust for sal dons, de to lige crteads in sophie
spreads bape are”
1 able so.
( Compsing the sunt numbers yd ion
(@ Stand mat mtipaon
(tne isequeri seach.‘inci Poganng 4 Am BIC _1__ itis Pte Soo es eg tons JOB,
2. Die and congue ago:
Pops the mos famous alortinicpuradigm, iideani-Conuc bad en
aning the rb ino two or mare anal s-egrans aig te sig
Teulon or # they ar single eeu, racy) ond combing the sub grote
{tn nto stan othe gal arabe
ale f and noobie:
10 Marge Son ans Quskson
(i) Tea Fourie,
(i ei’ Ma tipo,
Greedy spots
red loin vs ke te coc tht sens be athe mon. TH ely
‘otal hice «ade wth he ope ea os oy ptm aon
Scene guy agree guard to shy: roses a opi slaon
Grant algrtee are oan apie contnatonsloptnzation probes
ample of rey lero ine
(lasso i's mal pring ve lgethn
bisee' singlesouce shores pth agri,
(utr od,
Backtrack lpr:
ching is used se cles a wich'a sequence of objets ssl fom =
‘ped set 1 sequence of decor rade in asec at of eancais 33
thatthe sequence esis sare roron Often the oo day ie olson
rather than an optimal soon
amples nse
0 apt Fi sec,
Beers poten
(Trg aspen robin,
41.34 Advantages and Disadvantages
Aérantage:
1. -Anagothm ges lngugeeepencon yout te progam
2. estes proce of sono 9 gn robin, nich vey es and
simple unestaa
thas got df proce
{1635 10S velop anal an than cone into Rea a hen
iro compe progam
5. seat deta every sepingt toumlop enue
Diadranages:
1 Rletine consi,
2.11 cambesome,a¢ an sgt is disp fst wich ie comered into
fowchar td ten compute prom,
+ sluon of ee poiem soul be pain tatie mann 8 epopstep
Sem Ts pling canbe symbol epreseried wth te use of wears.
+ Monch s gph rpenaion sprog eae alg lpebilem
tobe saad
+ Honhat is an pret to which is us by programas and nat or acing
‘he vomatnfow ad the age oqenes for te proce
+ -Atouetar 2 daganmat epresetiton ht uate te sequin apuations
‘oe pelomed ooe the soon of prs,
-Aflwebat desc ht opened in wha sequence) ae rnibd ts rave &
cn pee
Flowchart ate wed in anning degning, docmneting managing 8 poses or
poyam veo as
The puzose of foment to show fow ae sequen a see o be
Peformes wo getasiton of probes,
Principles of Flowcharting:
1 Peto repsetton of fucka makes K:# comenint method of ¢
promotes ipl accra anda to cnet ropramming
takes cetiat ro path ise compete thot ary action bag ae
[halo to dele programlogcad sae a dcunetation.
isan imporor too for aning ard dering sew yar,
compte profesional ue olin types of fonhas
1. System flowchart Used shay. Ts flonan shows aes process,
sbstens eng and operate on dna te
Program flowchart. Vd by computer tegen This four shows
{rogram sruur logic ow and opretons petra
a4.441 Definition
+ We cn dfn fonchart a "samba rpresanteton of ston to be gen ask
prin
+ “Gap aprsetton of proces clad as Nowa
1+ Alon sper eesetatn of aor’
on
“Poxctaniss pictorial mba representation ofa genplan’. *
4142 Flowchart Symbols
+ veh use sacl hoes to reper fret types factors or eps in
prow
+ Foloig eb 2 sows tere fowcaring sls
“able 1.1: lochating symbol
Ssmbet | Nae tert) eal
Co [pews Aopen con sep.
© Prenat ‘it rs pon oes
Oo Decision ‘A question or branch in the process.
To [reid poses _[Atonay sentir
~ Jomo) [nner cn para xpa Oh
sed rom oe
Teen Adour ret
Cin w ca ie
conan.
Peparion__[AReperton otup eco sp
[evn tne ey
OO [ecwacer Amp ono ptt ater
CU __ [oreo comaaer | contusion at water pie
a Menge (Storage) Merge maltiproces into one.
LD [etc erecta messuenent. >
‘Symbol | Rane aert) Nesing
Cl feet aa sarap smbainonch.
Gimme acai
(east)
CO) Toovectacesssterage | Sorage ona ars dak
ag ects erent ows
Tater ces =| Anetra normal process
41.4.3 Advantages
+ Tetons advange of tochas fl
1. Proper Documentation Foch seve 3s. good program dcumenttn which
isreded ovatus upon .
2 ‘ffent Coding: Te fowchas 2 a « gue or Burnt rng the sstms
ays end rasan separ pas,
| Efient Program Maintenance: Te intannce of opting program bcomes
‘yh the hop of fewer. hag he programm to pu ellos more
ceca on ta pat
‘4. Proper Debugging Te toner has n debugpng proce,
|. Cermunicatio: Fuchs are beter nyo commun he gi oem
twaleoncemed
{6 tectve Analysis Vth help of neha. prota canbe ane a are
+ Theciaératagesintatons of nena a3 fos
1 Los of techni deta Th ero wt sane co ay be os athe
‘eda detest how te gona
2 Complex lope: Sonsins the progam lg ie gut complete. ota ce,
ouch beams comple sch.
3 Awations and Modetone: H ateons are cue, the och may
recur earning comet
| Reproduction: he owe gnbol ano be type raped of owcht
beams rei,
5. Time consuming: Depng ond conetctng » orca tne ening
Forchart eqies morte to cerstcta gatos EBKH.|__288 rset aig
ompuson (iferenc) between Aiport and Flowchart
‘Alert Howat
ee
fs spe tos Hat ae needed ta | representation fan alot
save probl,
72. An sort is decipin of Row ta] 2A ows cnt os squnce
‘ary eat & pros. An sgortken iss |_iracone rtd ager y anon
‘oe eps ose must be fellowed | to show the o¥der In whch te
cnpete he proces. iractone rat be cae
3 A alain i preci le fre of] Each sect put oto The
les) specting Now to she sone| ome xe dfrent shaper of
poten. Algo i sapwse aay] depending upon what be ct |
fe work be dons. is
“© oti ges lngvge Independent | Howchan gies agial ow
layout te program pte. program erpebien
5 arto pate 5 Dia upae
{Le tne quedo anyon | Tne consaning to wit od an 6
4.5.4 What Is Complexity?
+ Conpety of an suet a fnton of se Ing of ie poe inne
‘ich teins now mh rning meena pce ede the grt
‘ro runtoconpiion
1 suppose Msn alg and ni he ea he pt dt, The tne a pce
by he agrthm Meth to man mesure fo th eficency of MT te
ranred by oun th mumbo ey eprsone arin ng sachs
+ The complet of en agartion M te etn whch geste ring me on
crsorage req te agit tems fh sn norte nt,
+ Faquenty the storage spac require by a agri sey «muti of he dts
size ts imped Dat he te “comply shall rele oe running Sine of he
seemte,
+ banpe
nt otogameng get BBA
+ Thee statement seated ne Tecondioni ches fo rom toa es
{nd snetonf etcted mine 0 get opt The atl ruber of ements
‘reed ba 2 Wesy hat he cal ofthe oar os The nln rod
tip die OF. 5
+ Wipe ten computational compo ich ies chaacraton otha tine ore sce
Iequrenentto robe epablem ys pts ager
+f of he program eqs tro mah cosets ae tne comply an
thar space compe.
41.5.2 Time Complexity
+The in complesy oa rogram Fath the rout of compere ha it
rede nto compleen
+ Tomeaue tne cpl ofan agit, we concent on developing ery the
rnc coun ory sate
Defnton:
1 Tinecomplesty "2 mesure ofthe amount tine eqledo uct an alge
ok
+ Tete complet ofan algortimor pega the anout of tin it sed t ron
tocompeton
or
+ Tine completers, "the tne required forthe compute to run prog’.
{The act tne il oped onthe inlenetaon a hearth, eraming
\Gngnge opting te capaites fhe carpet eed te CPU spac other
hrdare crcerstcpecinion aed son
+ Tereaare me complet of am goth oe connate on dawn ony the
‘reuency court forty Semen.
T'igeriam at sea
2. Aperiam® + force Ltonsyp2
heaed
loop
feexe itonsiot
feyetions
pened
3. Moat ¢
loop
+ Fequengy cout of ae A 1. Feeney court of ago B i Frequency
court alge cst
+ Tine cpiety of nton& Of est contain lane. Tne comp of»
lop sconce a5 Of) the lacy vata Is nce or acer by
‘onan sour Tene corps of rad op aut the runber tes the
lonemot ater sce
ere the tne comply of goth AO, goth 8 i On, grt € is
on
+ Tis sears we wil tein ony tase sttements which may have te geatt
regency count1.8.3 Space Complexity
+ These conpesy of an art ox progr ihe aur memory tai ds
tonntocomleton
Detnion
1+ Space comply i ats te amount of mmr th
propa algo
computer nedsto run 2
on
1 The space complet of a algrte te aout of ema eqid to ete 6
couter >= 2 Gato tp 5
stp 8:Pie son
‘Step a0:Sop.Pinning Ato (EAIC.4 134th Shy pg mig pie JONAC9—_i8
Flowchart:
Fs Tea ge pp
Indl Tem and Common Dilfernc giv Find the N® term,
Foxrane. tl tr 2, Canon fence 4 Ten er
26 10, 1k, dB, ae
tee (rem
conor bierece
Algo
Sepissan
ep 2 en ail ter sit
ep 3: firs Common arn CO
step en nto as
step: Poti
step 6 tourer
‘Step 7 Clase =F +
Supe Pnttt
‘Step Aa to counter
‘Step 101 outers oho an Got sep
eT ae tern
in rm sept apa as pro tent ends ring Mere
Step 12:59
Flowchart :
6 Algor an flowchart pint a given sing digit uber te word.
gorithm:
Step tesa
Step 2 Real he number
Step 3 punber = Othe ge Ze Goto Sp 13
Step Ai uber = 1 ho One Gat taySpl ier = 2s pn Ws Gata SB supsten=a
Sepia steno eco Sep 3 | Sn faye Cnr?
Sp nue “Ahn pon tr, omg eee
Step 8: if nmber = 5 then print ive, Goto Step 23, ‘Sp Gv nO Comte = Pte use ote Sap.
Eepacote seen pot Se ce son sey A861
Sop trou =) eps St op 2 Sop Et cote seared
Za
Laz —@
Laz —@ 5
<> \
a7 —@ |
se {
Laer
ca
57s aii od ow Bowdon pe aa hn |
te '
Aer:
‘step: stat It
Stop 2 Renda t
Stop 3 ed bPri Nein ote 088-138 eset Se
1 Wt an lg and rw lohan to chck wheter an iter mis tiered ets: BGAN AL_139_oaste Prt Sing,
by another itagern erat. “Howhare
igor i oa
Step: Sst
Step 2 asd
sep Sed
Step Mn) = than gi ice these pet mis we i
ye
step $09.
omc
aeee | 4 wit an oth and daw fowcart to ec Sw given Wang a Habe
sep 2tandtt ‘ged ig or not
Sap: et uber = Roce:
Step tu Step tesa
Step 8 etc Wed 10 ‘tp 2: Read ee side of ingles
Specht ated sa Step Seed anther se cf anlar
Step N= NOWI0 Step Read hid eof ng ace
Sep 81 no equal then Goo Sep 5 Step Sioa « bb + eID OR(DD = a8 co
Step 30 Nib = Sum then in Numer a arsrng ier thane et ete waa + bb hen pir Ts aight eng tng
‘umber isnt ersten number (erie peat Trang lent ight angle ange
step 1509,
65.0.