Ultimate Engineering Study Guide - Questions & Answers
Given the last NINE digits. Write out minterms with these numbers as subscripts of mi. You may remove the duplicated terms.Given the NINE numbers are 5, 1, 1, 4, 6, 0, 0, 4, and 2. By removing a duplicated number 1, '4', '0', the minterms are m0 and m4.Then, answer the following SIX questions.(a) Suppose there are FOUR input variables a,b,c, and d, and one output F1. OR the aboveminterms together to obtain a canonical SOP. Write down the canonical SOP of F1.(b) ADD 4 to each subscript of the minterms in (a) to get a new canonical SOP F2. Writedown the canonical SOP of F2.(c) Convert the canonical SOP of F2 obtained in (b) to its equivalent canonical POS.(d) Construct the truth table of the Boolean function of F1 and F2 obtained in (a) and (b).(e) Write out the corresponding K-maps of the Boolean function of F1 and F2.(f) Try to simplify the Boolean function of F1 and F2 by K-map obtained in (e).
The idea is to implement a class for complex numbers. As a reminder, a complex number can be expressed in the form a+bi, where a and b are real numbers, and i is the imaginary unit (which satisfies the equation i 2=1). In this expression, a is called the real part of the complex number, and b is called the imaginary part. If z=a+bi, then we define real(z)=a, and imag(z)=b. Some of the operations defined on complex numbers are shown below: - Addition: (a+bi)+(c+di)=(a+c)+(b+d)i - Subtraction: (a+bi)(c+di)=(ac)+(bd)i - Multiplication: (a+bi)(c+di)=(acbd)+(bc+ad)i - Division: (a+bi)/(c+di)=(ac+bd)/(c 2+d 2)+(bcad)/(c 2+d 2)i - Conjugate: a+bi=abi - Negative: (a+bi)=abi - Modulus: a+bi= a 2+b 2You have to write a class for complex numbers. This class must be called Complex. A basic skeleton of the class is given as a starting point. Your class must be complete enough for a professional use. For example, your class must provide at least one constructor, accessors and mutators, methods add, subtract, multiply, divide, conjugate, negative, modulus, toString, etc. Two static methods (getDecPlaces and setDecPlaces) must also be provided as a way to control the number of decimal places used in method toString to represent the real and imaginary parts of the complex numbers. By default, the number of decimal places will be 2 . To test your complex class, a user will be allowed to enter the following commands from the keyboard: initial value of realPart +i magPart i. value of this variable should not be used until it has been assigned a value. realPart +imagP art i. of decimal places. For example, if the number of decimal places is 4 , complex numbers will be shown as: 0.7500+9.2800i,3.4500+7.9925i,8.55006.4500i in the existing variable varResult store the result in the existing variable the result in the existing variable varResult 9. negative : Change the sign of the real and imaginary part of the complex number stored in variable varName 10. conjugate : Change the sign of the imaginary part of the complex number stored in variable varName 11. decimal : Set the number of decimal places when displaying a complex number. The default value is 2 . Write a second class called TestComplex that will read the commands from the keyboard and display the result on the standard output. Input Format The input will consist of several lines. In each line, there is a valid command. The commands have to be processed until reaching the end-of-file. Constraints Unfortunately, Hackerrank does not allow us to create 2 files. In the ideal solution, we should have a file called Complex. java for the class that manages the complex numbers, and another file called Output Format The output of the show commands. For more details, see the test cases. Sample Input 0 Sample Output 0 1.65005.7600i Sample Input 1 define c1 1.2567.83 define c2 0.452.078 define prod multiply prod c1 c2 show prod decimal 4 show prod Sample Output 1 16.840.91i16.83590.9135iSample Input 2 Sample Input 2 define c1 1.24.5 define c2 7.83.2 define c3-3.4-0.8 define c4 3.32.8 define tmpl multiply tmpl c1 c2 decimal 5 show tmp1 define tmp2 multiply tmp2 c3 c4 show tmp2 add tmp1 tmp1 tmp2 decimal 2 show tmpl decimal 6 show tmpl Sample Output 2 5.04000+38.94000i 8.9800012.16000i 3.94+26.78i 3.940000+26.780000i 5.04000+38.9 8.9800012 3.94+26.78i 3.940000+26 define c1 4.202.32 define c2 0.2523.35 define result divide result c1 c2 show result negative result show result decimal 3 show result decimal 4 show result decimal 5 show result decimal 6 conjugate result show result Sample Output 3 0.591.30i0.59+1.30i0.595+1.298i0.5949+1.2985i0.59486+1.29848i0.5948611.298479i
Question 3 Not yet answered Marked out of 5.00 P Flag question [5 points] Which of the following statements about fopen is incorrect: a. When used with fopen0, the mode " r " allow us to read from a file. b. fopen0 returns EOF if it is unable to open the file. c. fopen0 function is used to open a file to perform operations such as reading, writing etc. d. fopen0 returns NULL if it is unable to open the file. Question 4 Not yet answered Marked out of 5.00 Flag question [5 points] What are the C functions used to read or write text to a file? a. fscanf, fprintf b. fread, fwrite c. readf, writef d. scanf, printf Question 5 Not yet answered Marked out of 5.00 Flag question [5 points] a list means accessing its elements one by one to process all or some of the elements. a. None of these b. Creating c. Linking d. Traversing Question 6 Not yet answered Marked out of 5.00 P Flag question [5 points] For a non-empty linked list, select the code that should be used to delete a node at the end of the list. lastPtr is a pointer to the current last node, and previousPtr is a pointer to the node that is previous to it. a. lastPtr->next = NULL; free(previousPtr); b. previousPtr > next = NULL; delete(lastPtr); c. previousPtr > next = NULL; free(lastPtr) d. lastPtr->next = NULL; delete(previousPtr); Question 8 Not yet answered Marked out of 5.00 P Flag question [5 points] Which one of these operations requires updating the head pointer? a. Deleting the last node, and the list has only one node. b. Multiplying by two all the data fields. c. Inserting at the end (list is not empty) d. Printing all the data fields in the list [5 points] Consider the following linked list: 25>10>30>40>35>60>55. What will the below function print when called with a pointer to the first node of the above list? void fun(Node* head) \{ Node ptr = head; while (ptr next ! = NULL ){ printf("\%d", ptr data ); \} a. 25103040356055 b. Error or no output c. 251030403560 d. 25 an infinity of times
You are mapping a faraway planet using a satellite. The planet's surface can be modeled as a grid. The satellite has captured an image of the surface. Each grid square is either land (denoted as ' L '), water (denoted as ' W '), or covered by clouds (denoted as ' C '). Clouds mean that the surface could either be land or water; you cannot tell. An island is a region of land where every grid cell in the island is connected to every other by some path, and every leg of the path only goes up, down, left or right. Given an image, determine the minimum number of islands that is consistent with the given image. Input Each input will consist of a single test case. Note that your program may be run multiple times on different inputs. The first line of input contains two integers, r and c(1r,c50), which are the number of rows and the number of columns of the image. The next r lines will each contain exactly c characters, consisting only of ' L ' (representing Land), ' W ' (representing Water), and ' C ' (representing Clouds). Output Output a single integer, which is the minimum number of islands possible. Sample Input 1 Sample Output 1 Sample Input 2