Download as pdf
Download as pdf
You are on page 1of 2
M S ain Va eres UT-HEM [ADVANCED EDUCATION PROGRAM, — aaa GNea A Tolono eR 2 em az eT mone s = oe + pie oon S| Pl ‘The returned value of phe funtion is 3 \ ‘ \ (Question 3 String (2 marks) x es ei 5, pie 1 Aeon to cxtrode by encotirs ssequencet of FORIERHNE oS Fibs charkses_ A seaicnce compiser at east to iztical characters, Eachiasp=nce ‘ isencoded by a pair of is length and character \ For example, given s'= “aadbecdddller™ 5 senguences as “aaa”, Mee’ and “dia 3 Jana fs encoded as 13a". Yee is encoded as "20", Madea is encoded as “42 Hence, 55 g then compressed as “fab204:4 3B ; pay of Structs @ marks, 140.5405) Question 4 — Struct a another struct for points (ders) fa. Define a soruct im C+ for squares (hin yudng) and jn the Cartesian coordinate system, tb, Write a fonction to input an array of m souares. dé: Write a-fimetion theé retiins TRUE if. point falls within « square, FALSE otherwise. Question $= Recursion (1 mark +1 bonus mark) ‘i Design a tecursive salulon (with general resivsve definition and non-recursive b eget. snches) to count the number of occurrences of a specific element in ananay of fBramiple given’an army A= {1,1,4;2,2, 1}, te search element is 1, Then, the m of oeourences of the clement is 3 “Write 4 recursive friction to sulve the above problem. —END— Instructor

You might also like