Question

In: Computer Science

State True of False in each of the following: 9 | 20. Ceil( – 3.1 )...

  1. State True of False in each of the following:
    1. 9 | 20.
    2. Ceil( – 3.1 ) – Floor( – 4.9 ) = 2.
    3. A set and its subset cannot have the same size.
    4. It is feasible to use an algorithm with time complexity 3n for n=90.
    5. If a function is one-to-one and injective, the function is called bijective.     
    6. If × represents Cartesian product, then A×B=B×A.      
    7. In a function, we can have more than one preimage of an image.         
    8. In a function, we can have more than one image of a preimage.
    9. Finding the maximum element from a sorted array cannot be done in O(1) time.
    10. Exponential time algorithms are better than polynomial time algorithms.

           

  1. If ‘x’ and ‘y’ are the last and second-last digits of your PMU ID, find (x +5 y) and (x ∙5 y). Show the details of your work.
  1. Consider X= “last two digits of your PMU ID”. Find the following. Show details of your solution.   (X)16 = (?)2

  1. Using Caesar cipher with a key = last digit of your PMU ID, encrypt your ‘first name’.

  1. Exactly how many comparisons are needed to find ‘1’ in the following array using binary search algorithm. Explain in detail.

1 2 3 5 6 7 8 10 12 13 15 16 18 19 20 22 40

Solutions

Expert Solution

Here are answers for your questions.

True/false

  1. True. ceil(-3.1)= -3 and floor(-4.9)= -5 . So, -3-(-5) = 2
  2. False. Set is also a subset itself.
  3. False.  3^n, n=90 have 8*10^42 iterations. And it is not feasible algorithm to compute.
  4. False. One-to-one funtion is also called as injective funtion. Bijective function is a funtion which is one-to-one(injective) and onto(surjective).
  5. False. Cartesian product A × B is the set of all ordered pair of elements from A and B. So, commutative property is not applicable.
  6. True. A funtion can have more than one preimage of a image.
  7. False. A function can't have more than one image of a preimage.
  8. False. Finding the maximum element from a sorted array can be done in O(1) time. The element will be at first or last position of the array depending on the type of sort.
  9. False. Exponential time is lot worse than polynomial time.

10) For this question, I don't have your PMU ID. But I will tell you how to do it.

For example: my PMU ID = 7245568

x = 8 and y = 6.

x+5y = 8 + 5*6 = 38

x*5y = 8 * 5*6 = 240

11) for example, last 2 digits of my PMU ID 'X'= 68

Each hexadecimal(base 16) digit represents four binary(base 2) digits. Simply convert every digit of hexadeimal number to 4bit binary number. Thier concatination is the binary(base 2) value of given hexadecimal(base 16) number. (You can simply determining which powers of two (8, 4, 2 or 1) sum up to your hex digits.) Example: 2 = 0010(0+0+2+0), 5 = 0101(0+4+0+1), 7 = 0111(0+4+2+1) etc

In my case,

6 = 0110(0+4+2+0) and 8 = 1000(8+0+0+0)

Therefore (68)16 = (01101000)2

You can eliminate left most 0s in the output final output. 01101000 = 1101000

12) Caeser cipher is simply a type of substitution cipher, i.e., each letter of a given text is replaced by a letter some fixed number of positions down the alphabet. For example with a shift of 2(key), A would be replaced by C, B would become D, C would become E and so on. If it reaches the end. It will continue from begining again i.e., Y would become A and Z would become B.

let my last name is KIRAN, last digit of my ID is 4 (Do it for your name and last digit of your id).

4th letter after K = O

4th letter after I = M

4th letter after R = V

4th letter after A = E

4th letter after N = R

therefore, KIRAN => OMVER

(To cross check, decrypt the encrypted text by replacing each letter with 4th letter before the encrypted letter.)

13) 4

We need 4 comparisions to find 1 in the given array.

{ 1 2 3 5 6 7 8 10 12 13 15 16 18 19 20 22 40 }

initially L=0 and H=16 ==> M = (L+H)/2 = 8

compare Arr[8] with 1. 12 is greater than 1. ==> H=(M-1)=7 ==> M = (L+H)/2 = 3

{ 1 2 3 5 6 7 8 10 12 13 15 16 18 19 20 22 40 }

compare Arr[3] with 1. 5 is greater than 1. ==> H=(M-1)=2 ==> M = (L+H)/2 = 1

{ 1 2 3 5 6 7 8 10 12 13 15 16 18 19 20 22 40 }

compare Arr[1] with 1. 2 is greater than 1. ==> H=(M-1)=0 ==> M = (L+H)/2 = 0

{ 1 2 3 5 6 7 8 10 12 13 15 16 18 19 20 22 40 }

compare Arr[1] with 1. 1 is equal to  1.

Hurray, We found the element. Index = M = 0

Total comparisions 4

-----------------------------------------------------------------------------------------------------------------------

Hope you understood.

If you have any doubts ask me in comment section.

If you like my work, please give me a like and feedback. That helps me a lot. Thank you.

All the best


Related Solutions

Exercise 4.8. For each of the following, state whether it is true or false. If true,...
Exercise 4.8. For each of the following, state whether it is true or false. If true, prove. If false, provide a counterexample. (i) LetX beasetfromRn. ThesetX isclosedifandonlyifX isconvex. (ii) Let X and Y be sets from Rn. If X ∩Y is closed and convex then Xand Y are both closed and convex sets. (iii) LetX beanopensetandY ⊆X. IfY ≠∅,thenY isaconvexset. (iv) SupposeX isanopensetandY isaconvexset. IfX∩Y ⊂X then X∪Y isopen.
State whether EACH of the following statements are true or false. A. A fraction A of...
State whether EACH of the following statements are true or false. A. A fraction A of the Sun’s radiation gets reflected off the atmosphere. (T/F) B. The Earth surface radiates both visible and infrared radiation. (T/F)                            [ C. Most of the visible radiation from the sun is absorbed by the atmosphere. (T/F)             D. The atmosphere emits thermal infrared radiation. (T/F) E. The greenhouse effect is due to the thermal...
For each of the following, state whether True or False: If you repurchase stock at an...
For each of the following, state whether True or False: If you repurchase stock at an amount less than its original issue price, you can record a gain. If you repurchase stock and then reissue it at a higher price, you can record a gain. Interest expense is computed using the effective rate of interest, not the stated rate. Cash interest paid is computed using the stated rate of interest, not the effective rate. Non-interest-bearing notes payable have no interest...
State whether each of the following is true or false. Justify your answer! a. There are...
State whether each of the following is true or false. Justify your answer! a. There are infinitely many finite languages. b. Union of any two languages over alphabet {0, 1} is always regular. c. The value of n3 +6n2 +5n is divisible by 6 for any integer n>0. Provide a proof. d. Single state NFA can recognize only finite languages (languages with finitely many strings) e. Intersection of any language and its complement is always regular.
For each of the following statements, state whether the statement is true or false AND justify...
For each of the following statements, state whether the statement is true or false AND justify your answer. When a map-reduce job is running on Hadoop, the number of map tasks must be equal to the number of reduce tasks because each map task feeds its output to a specific reduce task. In order to guarantee the scalability of the system, each file block is replicated three times in Hadoop distributed file system (HDFS). When a map-reduce job is submitted...
A1.State whether each of the following is true or false. If false, explain why: a.In C++...
A1.State whether each of the following is true or false. If false, explain why: a.In C++ the operator for raising to a power has lower precedence than the multiplication operator b.In C++ the statement x = y = x = 0; is illegal. c.In C++ the expression x < y < z is illegal. d.In C++ the expression x <= y = z is legal. A2.Consider the following program: void main() { enum direction { EAST, WEST, NORTH, SOUTH };...
For each of the following statements, state whether you think the statement is true, false, or...
For each of the following statements, state whether you think the statement is true, false, or uncertain; and explain your answer. If an individual holds a whole-life insurance policy, it is not necessary to monitor the policy periodically. If the stock market is efficient, the best strategy is buy and hold for the long term. A young person should always buy term insurance and not whole-life insurance.
1. State whether each of the following are true or false. A thermodynamic property is always...
1. State whether each of the following are true or false. A thermodynamic property is always conserved. Internal energy change is not dependent on choice of system. Enthalpy change is path dependent. Volume change is not path dependent. Sum of heat and work is path dependent. Reversible work is path dependent. Temperature is constant for an ideal gas if internal energy is constant. Temperature is constant for an ideal gas if entropy is constant. It is possible to convert work...
3. (14) State whether each of the following is True or False. a. A smaller sample...
3. (14) State whether each of the following is True or False. a. A smaller sample could provide less sampling error than a larger sample from a given population. b. The correct critical value a lower tail hypothesis test when sigma is unknown, the sample size = 15, and alpha = 0.05 is -1.645. c. A larger sample size can reduce the potential for extreme sampling error. d. It is impossible for the population mean to equal the mean of...
Please state whether each of the following statements is TRUE or FALSE, and then explain your...
Please state whether each of the following statements is TRUE or FALSE, and then explain your choice briefly. Please start your answer by writing either TRUE or FALSE. Answers without that clear statement at the beginning, and with excessively long (more than 2-3 short sentences) explanations will be penalized. Banks can still influence the money supply if they are required to hold all deposits in reserve. In the months of November and December, people in the U.S. hold a larger...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT