questions (20 points) b. Section B: Answer any 2 out of 3 (30 points) Answer the following questions by filling the blanks: 1. Creating an instance of a class in SCALA requires using the keyword class. 3. The keyword 4. The programing paradigms. Example Problems: SECTION - A Answer all questions in this section. Each question carries 2 points. _object in SCALA provides access to the private members of its companion 5. The collection of actions (do things that an object can do are called its Answer the following quessicas by choosing the most relevant optica: 6. Using DeMurgan's rale, state the negation of the statement: "The car is out of gas or the fuel line is plugged." D0 D2 associates an object to an identifier that cannot be reassigned paradigm brings in the concepts of objects and messages to other the 1 n 4 D The car has pas or the fuel line is unplugged The car has gas and the fuel Inc is unplugged The car is out of gas and the fuel line is plagged The car is out of gas or the fuel line is plugged 7. If A, B are two sets such that |A| = 8 and |B| = 9, then what are the possible values of An B? Multiple answers can be connect. 8. Write the following expression are equal to (p⇒ q) DqP [-p (pv q)] => q -- 9. if p is a prime then p can be congruent to which of the following modulo 12.
Final Examination Prep Moodle Examination scheduled between July 5-6%, 2021 П2 03 07 10. Write the following expression are equal to (p ⇒ q). There could be multiple answers. gp □p¬q (qp) ^ (¬p⇒ ¬q) Noar of the above 11. Using indaction, prove or disprove that w²5n+ 13 when n 2 1. 12. Using induction, prove or disprove that Vn 2 1,1 + 2 +--+n=n(n+1)/2 13. Does each of these lists of verdoes form a pach in the following graph? sebeb seadbea e,bad,b,c □ebdase 1. Sappose that "I Love New Jersey" T-shirts come in five different sizes: S, M, I., XI., and XXI. Further suppose that each sixe comes in four colors, white, rod, green, and black, except for XI, which comes only in tal, green, and black, and XXI, which comes only in green and black. How many different shirts does a souvenir shop have to stock to have at least one of each available size and color of the T-shirt? ☐20 19 11 15 П 13 2. How many ways can a pemon visit 3 cities, each of them 4 times such that he starts and ends at different cities? 3. Solving mathematical recursive relations. Section B: (The following questions will be grouped - you will be expected to choose any 2 groups to answer any 2 out of 3 = 30 points) (4) Use mathematical induction to prove that 74² + ²¹¹ is divisible by 57 for every nocnegative integer 71. (b) Devise a program in SCALA to generate the Fibonacci series of length w, that is tail optimized Page 2 of 3 Final Examination Prep Moodle Examination scheduled between July 5-6%, 2021 (c) Show that if n is an integer greater than 1, then r can be written as the product of primes. (d) Devise a recursive algorithm for computing b" mod m, where b,n, and mare integers with m 2 2,n 20, and 1 ≤b<m. (e) Determine the recursive relationship and write the corresponding Scala fanction to determine the number of strings of length i fusing the alphabet (A,T.C,G)) - that do not have any consecutive characters. Implement a Scala function to determine the number of sequences of (0,1) of length 1, that do not have any consecutive ones. Determine the Big O of your implementation. (Submit your SCALA code for each question including code of the main class that creates the instances over MOODLE) NOTE: The following Class / Abstract Data Type (ADT) for a 2-dimensional matrix called MyMatrix.scal, is applicable to all questions. import Array.__ clase MyPatrixini Tnt, i Tnt){ variable Matrix var Nat- ofDim(Int](n,n) anction to read a matrix det rencat = { fori < 0.ta(n-1){ for(1 < 0.to(n-1)( println("Enter value of 155, $j):"1 Kat(i) sesla.ia.stdin.readInt.) } def printMat - println("the Katrix is of size ($0,5") println("Whose values are as followe") fari.t-1)] Eart.60m-11) printi Kat:1)(5)+") printing) 3 } //seding two natrices def other: MyMatrix]: Unit -{ for 1-0.ton-1)( for(j < 0.to(n-1){ Kat(ili Matti)(1+ other.Mas(11) 3 Question 1: Add the following functionality: Multiplication Question 2: Add the following functionality: Extend ADT to handle 3-Dimensional Marr (Read, Print, and Add two 3D matricies)
Final Examination Prep Moodle Examination scheduled between July 5-6th, 2021 Instructions • The exam is "comprehensive" The exam is for 1hr and 30 mins Maximum points 50 • The exam will consist of 2 sections 2. A a Section A: Answer all Final Examination Prep Moodle Examination scheduled between July 5-6th, 2021 Instructions • The exam is "comprehensive"
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am