0% found this document useful (0 votes)
30 views17 pages

PPA Answers

The document outlines a problem-solving methodology that includes defining the problem, gathering facts, identifying alternative solutions, and implementing changes. It discusses various techniques such as brainstorming and the Divide and Conquer method, along with their advantages and disadvantages. Additionally, it touches on the program development cycle and the representation of two-dimensional arrays in memory.

Uploaded by

mansichaware9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
30 views17 pages

PPA Answers

The document outlines a problem-solving methodology that includes defining the problem, gathering facts, identifying alternative solutions, and implementing changes. It discusses various techniques such as brainstorming and the Divide and Conquer method, along with their advantages and disadvantages. Additionally, it touches on the program development cycle and the representation of two-dimensional arrays in memory.

Uploaded by

mansichaware9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 17
2 Problema Salwing Qtepg e- { Defining the oblem — \n almost ever puohlem Avluing mUthodolugy, the sist “step dutined a seni the punblemn \t_uin the moa Pad bs dt and -the most mpaniidnd of Ateps. [tf _[nvalves diagnosing jhe abahoa pe Shot shy fora»! an “the aod pxaltem and nd on wa Auimptonrs 2. Crathen fact) — | a) Define Koy tov 8) Cnpyassive Y aS umptiong —_____ th ne else. \ u-e f bt 1 a) Grek the wWewpont of others 3. Idenifu alternative ways to sol the Problem — ve to idinte (ole 2@luytronn a ae problem aithy wtar oe entinnatty. af mepriseniing the pyoblim 4 ation Syo_the the initial Atate, the operat ons aed Lction jon J om Of Groton ( flow ehant ) a — _ Algouitihmn Gand j\ Ste - - a)Acept 'n? Dccont nn / atu i= 0 | W) Acco pt of Lizo J c) izi4l ip i then Z Acces off gore mans alr] 4) ig ag wom = a0 Ht je 4+ | | jo) yen wJpnind e007 13) Stop emmoadic -win) — & eros wi 0 Posmay ACO UUNG e\ Means Yends a\ fractignal mershool e) i how edge boseodl “y Implement Y cols ake — ealecd OAL alt dions option apt aad sy Weave ” ) ion The evalasal on oy Yous” implementation oh tohether nat sou jallawed the Ateps. but on uphethea ol not —— goals Ge mel. 5 Obsovwe the agkstion — Qe- MmLlanutemont) +0 corfirmn that Change” Sova taken place . a) Check to evisu that the change not Yegqott m™ b) Proutcdoe “Avugici ar madtion tyaining Av thad ch pad. and LY duatained - QR n_ the lua proces’ os : Lwaowthm Bf | Gwearas _aroong 2 _L 0 1 ) Stank ™ a) lngut voliuc a,b. ¢ > _3) mans 0 uy) a sb asian am +p man othewie 20 cidn b 40 mon. ~ man 5) ik oc man, agian C to 6) Boplan man S a) tno d 3] Sum oe dias \ a nurober : Algoxtith an v Flo che Stout pe St Od ZAtupt num | \Accept numby \ Stumm =O weild= npn /o10 [gum =o] Auras Sturn + Lol T 6) w= nllo a > DS, n> 0 ,then go fo step 4 De 8) Pain suum ger F10 9%) Stop dct yy [Tuer Sumsid] yo t CSRS a4 flo wchcul Nv Meanin a | TL] | Proces _An operation i | ___dh action stp. f — ft $ Co) Teaminaton | fl Stasd om Stop ay ! paint sn a PHoctss Vi | Decision Hon ok fi blanca io the LE Tf | psocess Ei Data (1/0) inditcrts data inputs | i rand cuspuls tosand i pom pxocess: | Ei O _Conne chow | A d 2p rum By \ | one _point to 1 i anothyr. ti Fi = | Flow line Indicates the f | | lows. % if ! ipdate glen _ | Prectepinecl Vocus PP —fonmaty Agecd 1. | Sub = process i; { <-> eporosion A _prepavation 0A it Sok - wp proccss f) Step | 2 Alo tho to ppart a _dinge—cliqus t No anto_ wWonds IN y) ld = A‘ 10 — ties vevxlO 4+ Id A —— L c+ [= on ce | [2 2 Jwo SS - i) Start a DNinpud v»umbet (n) = 2) 1F wn <9, then 90 jo step 4 — 7 iAs? auntdh cape td _paty>— pte S = wip Corres Pon dung pond ve Pipe ion APund the word enareathhog ¢) Step = gu = 3 Rigpnttions ——and flue —for r wea accepted no = A\gomthm C ‘) Start a 1 a\ Accept. hum ber __ 3) weve O ) ns Fiigeechort ao \ _ ay a oF > i — an pn I - f | 1 a 7 pricrve 7 i) a Lb ii 4 Strep > {i [n= olrol +. A Def te” Algowithan aod jowehdret ri Algomithm _{ flewchart yA algonta co-te op wot pale chal ia - {si that ow | 9 “tation a (Lf el [ needed le Souw A 31+ | Pa olen . A _-flew chard consists 4s ihn al guiithin .w2_a_cleots- Complere the proce to Com nce of jnstrudcdions | Eo a faccens Pp alghas, Lntc ho by asus | 4), show the ardy ia | : MM. faloweol 1D instiuctions mut | Li Ax comet ad. ra boqu = “tr J apch| a) es Flowchart 3) An_ gorithm ina Each osluudion woy PO LL eect Spec CoO bom The bores [Oo te Ae. atyae iw nepudia’ depe ncuin che Sis pe the te oOrk to “tho inst oth ib. Le ne Lo [Algo | ina Logical TT isependent Lay ods af flow ey PAuge an ie Ins Pangrcin od pvablem “on pater’ B\Casy +o update. Diffiadd to update. | 6) es tient _yequired to | “Time Consuming to 5 | onith viite anc data | Li — wr F>p cept J Sum E 2 _ tds nk 1d gum = a Id & La lof O= O10 ae N>0 ton goto ¢) veep Sia D 3 ¢ = numba, then pink (Numb A Arm sty ang” Othiuw ise hint “Nurbe 1 port Ar Yong" ' a F} | | | I {gl Step - Flow chart | sti [3 ] \ roe 4 Tes — kd=n'‘/.1o frum = sunt ideal n= n/td Pint ) baplain 000 Measure % column meas _ ~~ ~~ SF rewachoat fon PpXime OM Not. “Aer ept nf noun aL —_Tizi] t T — art - 7 “nis paint F = Bains (Number ya prime] Ji=f4) Ses) ry J Alowchoat — fax fiboma.cci gouty OH nol j 1 | — iidd ‘s elements a i . A an array re stored in continuous memory locations. It can be represented i ented in memory using any of the following two ways: 4, Column-major order 2, Row-major order + A2-dimensional array is havin, indi ich fi 5 A orth second spec to the ing tee inal, of which frst species the number of rows For example, int A[3][4]; + The above declaration tells us that, A is 2-D array having 3 rows and 4 columns. The row and column arrangement of 2-D array forms a matrix like structure. For example, int A[3] [4] = { {19, 20, 31, 41}, {50, 51, 71, 89}, {90, 91, 95, 99} i «The array ‘A’ is represented as follows: Columns 1 Fig. 2.18: Representation of matrix in eh iit sneay, since MEMOTY Of COMPLtep fe are tw0 possible arrangemen =” rer ave TWO aemene ramming Prineipns and Actually, the above matrix elem only be viewed as sequential Uni elements in memory. namely ROW 's employed by high nguages ike Pascal used memory. T ‘major order 206 Elements ee 1 Column-major order. ‘Subserpt ADA etc. Column-major orde in FORTRAN and various dialects of BASIC. In Row-major form, all the elements of ted, then the of the second row and so 0 fepeated til the last row. A two dimensional array, where the elements are stored row by row is said 10 have row major order of the array. In this method, the elements are stored row wise, ie. n elements of first row are locations, n elements of stored in next n locations = and so on. For example, A 3x4 aray will bbe stored as below. For example, the previous array Al3 with the array cells continuously stored 2s 00102 104 106 10810 >l=[»]«|»|s [Row eb Rows) ——af—— Row’? ——+] Fig. 220 The numbers written above the array calls ranging from 100 to 122 shows the memory ‘offset. Here by definition each integer takes two bytes. Hence, the ditference between two adjacent offsets is two. ‘The linear offset from the beginning of the array to any specific element Alrow] {column} can be found as offset=(row*n+column)*2 where, ‘nis the numberof columns inthe array “C language labels the first element of array index by zero, Row 1, Column 2 in matritA is represented by AOI Fig. 239: Row-major form of an array would be stored in memory in Row-major order wn below. 416 118120122 ee | [or [os | 9 4eye2 =12 202, whieh snot fie. 100+ 2) 02, which is nothing but base address + offset is at 122 which is equal to base address + offset Elements sSupseapt sin Column-major form, all the elements of st column are printed, then the elements of the id 50 on. This will z 3 ery. + In this method stored column wise, Le. m elements of first column are stored in first m m elements of second and soon, the aray cells contiguously stored as shown below. too 102 104 106108110112 «l*lo]=[s|s (cau ok cotumn =p — Caan ale Coker 3 Fig. 222 ee 2.26 ming Principles and Algorithm The numbers written in Fig. 2.22 in array cells shows the memory offset The difference between two adjacent offsets is two. The linear offset from the beginning of the array to any specific element Alrow] [column] can be found as: offset = (row + column *n)*2 where, 'n’ is the number of rows in the array. 1. The offset for AlZI[1] (ie 91) Is computed as follows: offset = (2+1*3)*2 offset = 5*2=10 The element 91 (ie. Al2I{UI is at 110, which is nothing but base address + offset (ie. 100 + 10). 2. The offset for Al2][2} (ie. 95) is computed as follows: offset = (2+2*3)*2 offset = 8*2=16 95 (ie. A2}{2] is at 116, ss + The element which is nothing but base addre: offset (i.e. 100 + 16). The program ajor and column- for printing row" major representation of a matrix array is as follows. Flowchart: ptno, oT rows and columns, Le. mand n Fig. 2.23 CU,

You might also like