You are on page 1of 25
COMPUTATIONAL THINKING FOR STRUCTURe, t WEEK-6 Pre Lab: . shotemenfs Gute b> Shovema: What is the meaning of nested loops? 8 Rated toot ae He beeping ' Tab % uy roled Loop ave ole calle oy “Loep Eistle tons the Brrer wor G moked” Pryde Hie outer Lory. ‘They Ate uy, thin Por each Pais Wough tte cult teop, . - STIR GAG SRT toner Bs fir ap, the Sait, pdatlry U He POU @ Ee Qynkars year og By cvh Qrttido wlatle He deere’ hoppem: So aditle UG oft cottol OoPy bol WHE Amal ch awire dy, aes ze ~ lebhitegh ; wa oe a ae — ph elye A Bhsike OR ~~ terbttate Nor What isthe ciference between Left shift and right shift operator.? . aw ce hh Ce Whe teph Thins, re The KE SWE operefor U Brel wir omptlar Wreger b qpludent fe vache 4 power a, “the nbht SBE epeator U vanble ame De Te yu shifting a Frbeger plo another “Wega % guolort vo dlutcliy te Vhegers by a uth anotier Steger , Difference between bitwise AND, OR and NOT operator The KC bPkutse AND) dalees 2 pumibes ardl opsiands AND Om coy LA oy the [Ukkebe OR) beled 9 umber dnd greta: OR tats LIE Rubs “Ba -(bMuhcef NOT) faked cv number aned epron4 Alor wy WREB LEME eran? ; “the letse KOR | RD compotes each bi 9 dy Aidt opty fo sue correponding bik gq selond oped DP He bof Pore a polo sr gach Hee BEL Pr the athe tl Bot, tu correpondiing yeutt AL oO seh fe 1. gthwie Le Comesporclfhy wetulh bf U ach -p Oo, Page 140 of 368 COMPUTATIONAL THINKING FOR STRUCTURED DESIGN Price) Date ofthe Session: ff ‘Time of the Session:_to Problem 1: U On the eve of Diwali, Hart is decorating his house with a serial Tight bulb set. The serial light bulb set has N bulbs placed sequentially on a string which Is programmed to change patterns every second. If at least one bulb in the set Is on at any given instant of time, how many different patterns of light can the serial fight bulb set produce? Note: Lighting two bulbs +-* is different from **- Practice Link: httnsi//bitWy/CTSD-WOSP18 Sample Input & Output Algorithm, STEP) S Stier STEP 2: READ NV STEP 33 CALLULATE: Sep ur BP Cfeste) STEP €s CALCULATE * M4 Larue 29/4 wooo ter SRP 6) Gor ATEP 4 SBF 2) CALCULATE Bowser ONS = ps STEP S2 PRINT any SXEP gs SOP tor Flowchart >| COMPUTATION yy, iy iy r Execution: apSrebude es bAfDY A > Sak povoor Ae wy Gute 9,5 sans 7, Br (Tov fem eS ie) iC ans «(ava *9) 7, e200 Blan orks Fat mor C) Cow Rd ny PRE (* Erker number 4 bulbs: %)¢ StanP( “Ad An 4 Prtabes cd \n™) power (n)~ 1) 5, | sehum 0% D: Test case Table: | Testeaselt | Testcase Type | In Input | Expected | Output after | Testease Result: output execution | pass/fail COMPUTATIONAL THINKING FOR STRUCTURED DESIGN, (Pvc) Date ofthe Session: ff Time ofthe Session: to Problem 2: ; Hari wants to construct a staircases pattern using the ‘#’ symbol. He is very busy at # CRT training. Your task is to help Hari to print this staircase pattern HH , verso HEE actice Link: https://bitw/CTSD.WOSP! Pract nitpsi//bitW/CTSD.-WOSPLS sen Sample Input & Output [—sne] nee] Output S \ st ma ae 2 2 | ae Algorithm J , . Ger th sTpRT SEP wrenterrar jor SEP >: GREADN STEP 32 REIGN TstfoL ee) SEP WEP (Feon) srep EIDE (par nr?d SEP 6: Pewr * & ster PACs are pL a+ SEP 81 De ( ferty SIEP 9) PRINT Flowchart StpRT Sona / or SEP hy eapespaTe foe STEP tri word WEP & SEP is: erp, Page 143 of 368 ce COMPUTATIONAL T4544 NG te, %, Execution: #Iaclude Zo /d2o WS Ae westn C) c Pak 1, Ws panitC“Enlr woo ser) ScamP-C°%d “UA h)> Rv(2eriten 5 Jat) v Row (By ken HE) ern’ “JS Bor (B=) Feet 5 f +4) prink PC HE): PRAKEL™ AW" )S } veluvn OF TesteaseTable: Testcase# | Testcase Type | Input | Expected | Output afier | Testcase Revit [output | execution | Pass/tait # 44 fase at flap | arse | fis sg he afi Poss COMPUTATIONAL THINKING FOR STRUCTURED DESIGN De® Date of the Session: _/_/. Time of the Session:_to Problem 3: Sony is writing tables by inputting two numbers (e.g., 4 and 9) and display their mathtables up to 10 and she is not interested to display the values when multiplier and multiplicand are the same. So, by skipping that condition she must display the table. SX1=5 6x1=6 9x1=9 6X5=30 Ps 0. P .e 8 Note: better to practice with for, while and do. while constructs. Sample Input & Output Ene | tnpat Output 1 t S| Smteq -++ Seq: oo exes doe _| 2 & Axto@ --- Geos Be Oxee We ‘we? tL) START Ser 2. REaor STEP B ASGns Pe] Step uy pp (kes to) Sap LOSS, SEP €: De Chl=ny SEP 6! PRINT Af roslee 2: Goro sept Page 145 of 368 COMPUTATIONAL THINKING FOR Sth Execution: #indude cstdfo. ks Tae matn( ) { Sink n,f- PR awe" Eno a Aeleget : “Ys ScanPL SY J” &nJe for Cisis Te ri0oy 4d) Veit en 5) rebel’ ed « Lhe dnt Vine!) Yeu, OF | Testease Res Test case Table: oe aa om | tea | escatin| Pas (ll oeezall LBs 1G ee Le 1268-790) hb 1 O (yj longi rs9 him 30] pars valuator’s Observation jarks Secured out of | | Signature of the Evaluator Date of Evaluation: © COMPUTATIONAL THINKING FOR STRUCTURED DESIGN Date of the Session: /__f___ Time of the Session:_to Skill-1 Problem 1: Given a base-10 integer, n, convert it to binary (base-2). Then find and print the base-10 integer denoting the maximum number of consecutive 1's in n's binary representation. When working with different bases, it is common to show the base as a subscript. Practice Link: https://bit.ly/CTSD-WOSP16 cre ee Sacred 2 3a loo0 10 {2 cy | tooo 000 peor sept) STDRT sep py actran f= STEP 3. Reap sveP t) te (nro) swe §: cALCoLaTe =bL?TSn%2r 2n)hr7 itr GEP 6: HOTO STEP & STEP 2: ASIEN trie! Sep & pe (f>= 0) SEP Us PRIDE pI’) SEP 10) CALCULATE FS 1 SEr ud @pre ster ¥ SEP 12) Bor Uxecutton: Ht Swelude 2okdPo vhs Pal matae ) t Ft Foon bf reels PREP C™ Sala numbers“)? Scan *%d An SS COMPUTATIONAL ARt PC An Ye binary mumnbere] wad = 4 tohk£le (n> 0) bCd= Zr; nenfry Pere 4 Ry (% Uf Gree yt) poabec* dd “bOI DE veburnn 0% Test case Table: Testcaset | Testcase Type | Input | Expected | Output after | Testease Result: output execution: Pass/fail 1 2o | lore | lo1e0 Pors 2 30 | fio | ttere _ fay 3 UO | love L@(p0o Dos THINKING FOR stp ip (Sie COMPUTATIONAL THINKING FOR STRUCTURED DESIGN Date of the Session: _ = Time of the Session:__to Problem 2: hhh Juliet Is the college topper, so she has given a challenge to Romeo, The challenge is to print the given star pattern. tek tee Your task is to help Romeo to successfully print the given star pattern. neh he sample Input & Output a * [Sno Input Output anna — ye - % : Algorithm Ser! steer SIEP 81 GpT STEP & e DN Bee SURES SBP A geop creP 32 Retran f SEP ur PP (i> 21) Ser 6 pe Get) STEP 6. hpipy STEP 21 Goro wep & Flowchart Se Cosmet) ' _ wine eRe | V7 Page 149 of 368 COMPUTATIONAL THINKING FORStay, Execution: netuhe Eshdéo. bs Wk mode > £ Sut nQ5 PEPE Cater rowsise ¢ “Vs Rael (Xd An) § Ry (Zeng trruan 1) ¢@ ter Gant fees +5) ela Se i PHP WS 1k BS 4 ve et yotuyn 07 | Test case Table: — Testcaset | TestcaseType | input | Expected | Output after | Testcase Result: output | execution —_| Pass/fail ca ea > 34 _te Past ane [ 2 £ . Nod pe 2-1 = = z fas COMPUTATIONAL THINKING FOR STRUCTURED DESIGN sic ate of the Session: Time of the Sestion:_to Problem 3: Anjani’s favorite subject in B.Tech first year is DLP. Her teacher has given a problem as Homework. Help Anjani to analyze the circuit and find the total resistance of the same. Consider a closed circuit containing ten resistors connected in series with resistances ~ 10, 12, 15, 24, 36, 46, 54, 65, 55, 17 respectively. Find the total resistance of the circuit. sample input & Output [Sire] tnput - it sous I tiie, [esses rte rp eee Algorithm sien ; sep ty anpey . ‘ STEP >) ACER Ves 0 yP>0 . STEP 2 BP ere) sveP UN ERP af?) ST £) CALULATE eases af?) fee FER 6s &etO SEP 3 SEP SPRINT ves SRP H eve Flowchart | | page-15T. al 368 COMPUTATIONAL THINAING 108 5, Me Execution: sWholude estdfarhs Ab made) c ft afin)? wos PREPS Enon tue veu'ttonas 4)! for (2205 21s 444 )° ScomP( hd", & ari Sys Wsara PIs 3 . PRL “the weatalomceer Yo %d “Vyen’) 5 aie Yelurn 0% Testcase Table: Output after | Testcase Result: “Testcasel | Testcase Type | Input | Expected output — | execution Pass/fail yf whet| fo ; _ met | ID do Pan, | 3 f ya—3p|_ JO 20 (los J COMPUTATIONAL THINKING FOR STRUCTURED DESIGN (Se pate of the Session: Skill-2 Problem 1: ‘Time of the Session:_to Jack is a talkative student in the class. His teacher wants to make him busy oN by assigning some work. So, she asks him to consider two variables and interchange the values of the variables, The teacher instructs him not to & b use any temporary variables and to perform the task using bitwise Led t operators only. Help Jack in Completing the task, ‘ sample input & Output pee er out 7 - "| wire - le [= Neat Algorithm - ser 1S START Sep READ OR sign STE? 3° CALLULATE Aza%rb ‘ bears, Ox ar), SEP & PRINT ob STEP stor Flowchart Page 153 of 368 COMPUTATIONAL THINKING FORSTRI, Execution: tHProladeestd.de ls Mb mata | ) t RE obs PFE glee bye values 9 cv ret oy StamP (M%ad Ydsdedb)S Prin FPO “See, chm hafotr Swoop ba - 1470 oy Ararbs bs wr b5 O=e™ bs PEt PCa ptemend d— Ud “ab. Yebuwyt 0} Test case Table: Teaieaah | Tetra pa | pat | Expected] Output after] Testeaze Remus | | output execution Pass/fail tf li [22ap | 26,10 Pawo | e121 | 2), | Row ea Hn ted tear [yy Oe Date of the Session: __ /_/. Time of the Session: 00 Problem 2: ‘i pee re Cities on a map are connected by several roads. The number of roads between each city is in an array and city 0 is the starting location. The number of roads from city 0 tocity 1 is the first value in the array, from city 1 to city 2 is the second, and so on. pte s @ How many paths are there from city 0 to the last city in the list, modulo 12shsos¢ Example . “ 4 N=4 Routes= [3,4,5] roads to city 3. The total number of roads is There are 3 roads to city 1,2 roads to city 2 and 5 3x4x5 mod 1234567= 60. Practice Link: https://bit.!y/CTSD-WOSPLL ‘sample Input & Output Sno z gorithm : rep 1) etPPT : att STEP 2) READ A SEP Bt STEP 2» ASIEN AY >/ Eee eed STEP UV ATOP sere Te (met) SP SPEND «@ STEV Gs GALCULATE Ory oe Ona = 122 GEG? he FP > Goro ster 4 Flowchart =| | a \ tose > “scom PL n--¢ “YfUd Ae 9% any # = § msy, 2 EdaS O27 Pont PC® Ud eh, aed Jf yeburn 05 Testease Table: COMPUTATIONAL THINKING FOR Sta, [perce TeneaseType | Waput | Expected | Output ater] Testeare Result 1 output | execution | Pass/all | . : SS ae. £0 Pan | 1302 | 30. 20 pay a Iywoal Io | @O | Pare COMPUTATIONAL THINKING FOR STRUCTURED DESIGN (syle) Co Timo of the Sessfon:_:t0 _ Problem 3: Vimal found a pattern in the numbers that were present on his textbook cover page. ‘There Is a sequence inthese number whose n'” term is Tn = n2 ~ (n - 1) Now he wants to calculate the sum of first n numbers for the series x" Spe Trt T2 ATS 404 Ty Find Sn mod (109 +7) ‘ practice link: httpsi//bIt.lV/CTSD-WosP10 Sample Input & Output 1 S.n0 input ‘Output r \ qT _ ae : L 64 Algorithm: SRP STRAT sreP? 2) READ w SE? 2: CALWLATE > Pow (9,9) 2 SIE? UD PRINT pox SBP C ike Flowchart we Page 157 of 368 COMPUTATION FHINKING FOR STIye Execution: trinclude tstdvo. h> AT ndludeematet hd fb mot) Pak (a x : wind (Ener lor foams “D5 Seomp Yd“ fea Ke Pow Cty Wrz , , , PEALLCN ZU \n*, foot (@ 10, 27%. 0 \Y. ) 4 yelun n 0 $ td \ Testease Table: . e TF ] Expecte ‘Output after | Testcase Result rascaon | Tentease Tyne | nrut | Execs ¢ | Mtecution | Pass/tail | | 1 | fuk | Sen] 230% | Pou A | | ows Zed [20 | go | ueo—__+ = 2 [sy _lagte | 226 Por. (For Evaluator’s use only) ¥ Evaluator’s Observation _ | Marks Secured: out of — I | Full Name of the Evaluator: | | | I ‘Comment of the Evaluator (if Any) | Signature of the Evaluator Date of Evalut! | l COMPUTATIONAL THINKING FOR STRUCTURED DESIGN | 6@ Date ofthe Session: __ /_ Time of the Session: skih3 Problem 1: Mothi’s Computer teacher taught hin the number systems and conversions. Your task is to help Mothi to perform the following: Given two integers left and right that represent the range [left, right), return the bitwise AND of all numbers in térange, inclusive of left and right Practice Link: hitpsi//bitW/CTSO-WO6P1 Sample Input & Output Algor SEP 1) oTRRT- STEP 2 READ OL SEEP 3) ANION guro Seer 4) EF Cats b) ser 8 stor SEP $: CALCULATE Ore! bezel Qn +t SEP 62 Bow step 4 JEP PRINT pep ace b Flowchart Y Page 159 of 368 Be | COMPUTATIONAL THMNING FON Necution: Bete cadded ho YE Caak ef, he hh) ak sib 59> a Caabh a yh) lebk oe 2) MYR p> eT? . ShePR vt 3 yeh tehh oe shilts ¢ t Sah maka 0)" t he ab, am: «- AinkeC Enya nueiboe ); SeomPC* Hatad “ha REIS ois = yorge La,h) Dante toms tad *, amt) f velun 07 Testcase Table: Toseaaa| Testease Type | Input | Expected | Outputafter | Testcase Result: output | execution | Pass/fail Pao | bhx| ge | Pa, E e [a 8] KS far, 4 3 7] » 61 oO Porn COMPUTATIONAL THINKING FOR STRUCTURED DESIGN GO pote ofthe Session: — noes Time of the Session:_ to problem 2: faplement pow(x, n), which calculates x raised to the power (i.e, 2). puactce Unk: bitly/€TS0-WO7022 sample input & Output Input wa Qy10. 5.n0 Algorithm sve 11 START ste? 2) RERP Ob SEP 3S ASSEN Power? fF peo ser «Re (Feb) STEP St CRLCULATE Powers = fan Yer 6) Gvw swer ¥ SEP PPRIMT owed sree & STP Flowchart Page 161 of 368 | COMPUTATIONAL THINKING Fons Execution: : Whotde Zshdfo-hs Pik mado) Sah a bh, t 4 amy F , Aowser et, PELL C Qysor ‘howe cma aya ponent “IO Hemel Rd LS ahh for (Rees Pegs prev) q 3 PHP Yd) power) f Jelum o7 Pore ba 95 Testcase Table: ae Imput | Expected | Output after | Testcase Results ‘output: execution Pass/fail T | &u | Wwe | core ee (ay 412} cory Coy p 3-1 __T wal gee are} — Pay ee COMPUTATIONAL THINKING FOR STRUCTURED DESIGN sie Date of the Sessions 77 Time of the Session: to Problem 9 Tim Is interested to explore different ways of solving problem. ether a given number ig even or odd ; aIs0 called conditional operator) and re ae using temary operator ( modulus (arithmetic operator), Now his {riend says it Is possible a ie to do Wt by bitwise operator, Help Tim in solving this new ay” iy challenge of checking if @ number Is even of adel using bitwise a operator : ae Sample Input & Output Sino pA eee Algorithm STEP ty StARE SWE ay REDD A STEP 3. ge (ndte= 1) STP PRINT Ever SB §> Ce Rwist STEP 6) PRINT Odd STP 2 @sS0P Flowchart Page 163 of 368 Execution: Hincludee stdfo+ hs Ge main 0) Barnes em e Basepe ”, , SeamP lS Gd" An) fe (ne ren 1) Prk (“odd Ue che OMMrel*Evonr Ys velum O; festcase Table: ~ COMPUTATIONAL THINKING Fon Hy, Tesiatat | TenaseTpe [input | Etpested | Output after Testcase Result i (2 | Soon re ee u 14 odd Odd | Pads 2 2> | ov Odd Pars (For Evaluator’s use only) Comment of the Evaluator (if Any) Evaluator’s Observation Marks Secured: out of __ Full Name of the Evaluator: Signature of the Evaluator Date of Ev2

You might also like