Up till now, we provide 9999 solutions for all subjects which include Mathematics, Finance, Accounting, Management, Engineering, Computer Science, Natural Sciences, Medicine Science, etc.

1. Write a Matlab function x = sym2TT(S) that generates a 100 milliseconds time-domain signal corresponding to a given DTMF symbol S. The set of all DTMF symbols and their corresponding frequencies are indicated in Figure 1. 2. Generate a signal xptq which contain a sequence of DTMF symbols corresponding to your cell phone number. Add a 20 milliseconds guard interval between consecutive DTMF symbols. 3. Create a signal yptq which is the signal xptq contaminated with additive white Gaussian noise with variance 0.1. 4. Store the generated signal yptq as an audio file with extension (*.wav) 5. Plot the signal yptq. Note that, this plot does not provide any frequency-domain information about yptq. 6. Use the FFT command to obtain the spectrum Y pfq of the signal yptq, hence plot the magnitude spectrum (in dB) in the frequency range 600Hz ¤ f ¤ 1700Hz. Note that, this plot does not provide any time-domain information about yptq . 7. Matlab code to create a set of spectrograms of the signal yptq using the following parameters: Overlap between the sliding windows: 50% FFT size: 214, this is the total number of samples in time-domain and in frequency-domain as well. Time-domain window size: use the following values t16, 64, 256, 1024, 4096u. Create a spectrogram for each window size (t16, 64, 256, 1024, 4096u) using a rectangular time-domain window. Figure 1: Dual-Tone Multi-Frequency (DTMF) Signalling Scheme Which window size provides a ”kind-of” optimal trade-off between time and frequency resolutions? Change the time-domain window to a blackman window and create a spectrogram for each window size (t16, 64, 256, 1024, 4096u). For a given window size, which window type (rectangular or blackman) provides a better frequency resolution ? Write Matlab code to decode the signal yptq, verify that you will obtain your cell phone number.

1 Solutions

See Answer
§ In BlueJ, create “New Project” named LASTNAME-company Use good programming style and Javadoc documentation standards Create a “New Class…” named Company to store the employee mappings of employee names (Key) to employee ids (Value) Declare and initialize class constants MIN and MAX to appropriate values Declare and instantiate a Random randomGenerator field object Declare a String field named name for the company’s name Declare a HashMap<String, String> field named employees Add a constructor with only 1 parameter named name and: Assign name field to name parameter after trim, uppercase & replaceAll   (1 or more ANY white space regular expression with just 1 single space) Initialize employees field by creating an instance of that object Add accessors getName( ) and getEmployees( ) Add accessor getTotalNumberEmployees( ) to return the total number of mappings in the collection of the employees field Add formatString(String origString) to return a formatted origString after trim, uppercase, and replaceAll in between white spaces (with single space) MUST first check if origString is null (which just returns an empty String) Add method String generateId(String name) to return the employee id generated by taking the first letter of each word in name parameter AND adding a random 3-digit integer between 100-999 (inclusive of both ends) MUST .split the parameter name into a String[ ] nameArray with regex taking into account multiple white spaces in between words in name MUST use a for loop to get the first letter in each word in nameArray MUST use class constants MIN & MAX (NO hard-code) to generate (using .nextInt) the random number used for the id in the range [MIN – MAX] Add addEmployee(String inputName) & removeEmployee(String inputName) both with void returns and: Check if (trimmed) inputName is empty or null, print “Name is INVALID” MUST use formatString for inputName (remember Strings are immutable) MUST use .containsKey to see if inputName key exists in employees and: Print “Existing: <name>” (if name already exists for addEmployee) OR …“Non-existing: <name>” (if non-existing for removeEmployee) MUST use generateId (for addEmployee) to generate employee id to .put MUST print heading with name & id, if employee add/delete is successful Add void removeIds(String id) to remove ALL mappings in employees where the value matches the id search parameter and: MUST use a local variable to keep track if a match was found MUST also have check if id parameter is null or empty MUST use formatString to format the id input parameter MUST use a for loop, .keySet and .iterator to iterate thru all employees Check if each employee id value is equal (ignoring case) to the search id MUST use the Iterator.remove to remove id matching mappings MUST print heading with name & id for EACH removed employee Only after the entire search is completed (THUS … outside of loop), check if no matches found and print “NO employees with id: <id>” Add void listEmployees() to print ALL employee names (Key) & ids (Value): MUST always print the heading “Employees for <name>:” MUST use getTotalNumberEmployees or .isEmpty to check if NO entries in employees exist and prints“NO employees” MUST use a for-each loop and .keySet to iterate thru all employees MUST print employee in format “     <name> : <id>” (w/ leading spaces)

1 Solutions

See Answer
When we test your Fraction.java we will use the given FractionTester.java file. Your Fraction.java file -MUST- work perfectly with the supplied FractionTester.java file. You may NOT modify the FractionTester to make your Fraction class work right. Starter Fraction File: Fraction.java ADD METHODS TO THIS FILE. HAND IN THIS FILE ONLY. Given/Completed Tester File: FractionTester.java DO NOT MODIFY. DO NOT HAND IN. You are to add the following methods to the given Fraction.java file public Fraction add( Fraction other) returns a Fraction that is the sum of the two Fractions. public Fraction subtract( Fraction other) returns a Fraction that is the difference between this Fraction minus the other Fraction. public Fraction multiply( Fraction other) returns a Fraction that is the product of the two Fractions. public Fraction divide( Fraction other) returns a Fraction that is the quotient of the two Fractions. public Fraction reciprocal() returns a Fraction that is the reciprocal of this Fractions. private void reduce() Does not return a Fraction. It just modifies this Fraction by reducing it to its lowest form. You must keep every Fraction reduced at all times. Every new fraction constructed it must be reduced before the constructor exits. No Fraction at any time may be stored in a form other than its reduced form. This makes the outputted value of the Fraction consistent in all cases. All methods except reduce() must be a single return statement of the form: return new Fraction(...); -OR- return (a call to another Fraction method) /* FractionTester.java A program that declares Fraction variables We will test your Fraction class on THIS tester. */ public class FractionTester { public static void main( String args[] ) { // use the word Fraction as if were a Java data type Fraction f1 = new Fraction( 44,14 ); // reduces to 22/7 System.out.println( "f1=" + f1 ); // should output 22/7 Fraction f2 = new Fraction( 21,14 ); // reduces to 3/2 System.out.println( "f2=" + f2 ); // should output 3/2 System.out.println( f1.add( f2 ) ); // should output 65/14 System.out.println( f1.subtract( f2 ) ); // should output 23/14 System.out.println( f1.multiply( f2 ) ); // should output 33/7 System.out.println( f1.divide( f2 ) ); // should output 44/21 System.out.println( f1.reciprocal() ); // should output 7/22 } // END main } // EOF /* Fraction.java A class (data type) definition file This file just defines what a Fraction is This file is NOT a program ** data members are PRIVATE ** method members are PUBLIC */ public class Fraction { private int numer; private int denom; // ACCESSORS public int getNumer() { return numer; } public int getDenom() { return denom; } public String toString() { return numer + "/" + denom; } // MUTATORS public void setNumer( int n ) { numer = n; } public void setDenom( int d ) { if (d!=0) denom=d; else { // error msg OR exception OR exit etc. } } // DEFAULT CONSTRUCTOR - no args passed in public Fraction( ) { this( 0, 1 ); // "this" means call a fellow constructor } // 1 arg CONSTRUCTOR - 1 arg passed in // assume user wants whole number public Fraction( int n ) { this( n, 1 ); // "this" means call a fellow constructor } // FULL CONSTRUCTOR - an arg for each class data member public Fraction( int n, int d ) { // you could calc the gcd(n,d) here and then divide both by gcd in the setter calls setNumer(n); // i.e. setNumer( n/gcd ); setDenom(d); // same here } // COPY CONSTRUCTOR - takes ref to some already initialized Fraction object public Fraction( Fraction other ) { this( other.numer, other.denom ); // call my full C'Tor with other Fraction's data } private void reduce() { // reduces this fraction to lowest form } }// EOF

1 Solutions

See Answer

1 Solutions

See Answer
Your room is being decorated. On the largest wall you would like to paint a skyline. The skyline consists of rectangular buildings arranged in a line. The buildings are all of the same width, but they may have different heights. The skyline shape is given as an array $A$ whose elements specify the heights of consecutive buildings. For example, consider array A such that: \[ \begin{array}{l} A[0]=1 \\ A[1]=3 \\ A[2]=2 \\ A[3]=1 \\ A[4]=2 \\ A[5]=1 \\ A[6]=5 \\ A[7]=3 \\ A[8]=3 \\ A[9]=4 \\ A[10]=2 \end{array} \] The shape specified by this array is represented by the figure below. You would like to paint the skyline using continuous horizontal brushstrokes. Every horizontal stroke is one unit high and arbitrarily wide. The goal is to calculate the minimum number of horizontal strokes needed. For example, the above shape can be painted using nine horizontal strokes. Starting from the bottom, you can paint the skyline in horizontal stripes with 1,3,2,2, 1 strokes per respective stripe. Write a function: \[ \text { class Solution \{ public int solution(int [] A); \} } \] that, given a non-empty array $\mathrm{A}$ consisting of $\mathrm{N}$ integers, returns the minimum number of horizontal brushstrokes needed to paint the that, given a non-empty array $\mathrm{A}$ consisting of $\mathrm{N}$ integers, returns the minimum number of horizontal brushstrokes needed to paint the shape represented by the array. The function should return -1 if the number of strokes exceeds $1,000,000,000$. For example, given array A as described above, the function should return 9 , as explained above. On the other hand, for the following array $A$ : \[ \begin{array}{l} A[0]=5 \\ A[1]=8 \end{array} \] the function should return 8 , as you must paint one horizontal stroke at each height from 1 to 8. For the following array: \[ \begin{array}{l} A[0]=1 \\ A[1]=1 \\ A[2]=1 \\ A[3]=1 \end{array} \] the function should return 1 , as you can paint this shape using a single horizontal stroke. For example, given array A as described above, the function should return 9 , as explained above. On the other hand, for the following array $\mathrm{A}$ : \[ \begin{array}{l} A[\theta]=5 \\ A[1]=8 \end{array} \] the function should return 8 , as you must paint one horizontal stroke at each height from 1 to 8. For the following array: \[ \begin{array}{l} A[0]=1 \\ A[1]=1 \\ A[2]=1 \\ A[3]=1 \end{array} \] the function should return 1 , as you can paint this shape using a single horizontal stroke. Write an efficient algorithm for the following assumptions: - $\mathrm{N}$ is an integer within the range [1..100,000]; - each element of array $A$ is an integer within the range $[1.1,000,000,000]$. Copyright 2009-2022 by Codility Limited. All Rights Reserved. Unauthorized copying, publication or disclosure prohibited. i want answer in java8 with return statement

1 Solutions

See Answer
Consider the sliding window algorithm with \( S W S=R W S=3 \), with no out-of-order arrivals and with infinite-precision sequence numbers. (a) Show that if DATA \( [6] \) is in the receive window, then DATA[D] (or in general any older data) cannot arrive at the receiver (and hence that MaxSeqNum \( =6 \) would have sufficed). (b) Show that if \( A C K[6] \) may be sent (or, more literally, that DATA \( [5] \) is in the sending window), then ACK[2] (or earlier) cannot be received. These amount to a proof of the formula given in Section 2.5.2, particularized to the case SWS \( =3 \). Note that part (b) implies that the scenario of the previous problem cannot be reversed to involve a failure to distinguish \( \mathrm{ACK}[\mathrm{O}] \) and \( \mathrm{ACK}[5] \). Consider the sliding window algorithm with SWS $=\mathrm{RWS}=3$, with no out-of-order arrivals and with infinite-precision sequence numbers. (a) Show that if DATA[6] is in the receive window, then DATA[0] (or in general any older data) cannot arrive at the recelver (and hence that MaxSeqNum $=6$ would have sufficed). (b) Show that if ACK[6] may be sent (or, more literally, that DATA[5] is in the sending window), then ACK[2] (or earlier) cannot be received. These amount to a proof of the formula given in Section 2.5.2, particularized to the case SWS = 3. Note that part (b) implies that the scenario of the previous problem cannot be reversed to involve a failure to distinguish $\mathrm{ACK}[\mathrm{O}]$ and $\mathrm{ACK}[5]$.

1 Solutions

See Answer
Professor Borden proposes a new divide-and-conquer algorithm for computing minimum spanning trees, which goes as follows. Given a graph \( G=(V, E) \), partition the set \( V \) of vertices into two sets \( V_{1} \) and \( V_{2} \) such that \( \left|V_{1}\right| \) and \( \left|V_{2}\right| \) differ>by at most 1. Let \( E_{1} \) be the set of edges that are incident only on vertices in \( V_{1} \), and let \( E_{2} \) be the set of edges that are incident only on vertices in \( V_{2} \). Recursively solve a minimum-spanning-tree problem on each of the two subgraphs \( G_{1}=\left(V_{1}, E_{1}\right) \) and \( G_{2}=\left(V_{2}, E_{2}\right) \). Finally, select the minimum-weight edge in \( E \) that crosses the cut \( \left(V_{1}, V_{2}\right) \), and use this edge to unite the resulting two minimum spanning trees into a single spanning tree. Either argue that the algorithm correctly computes a minimum spanning tree of \( G \), or provide an example for which the algorithm fails. Professor Borden proposes a new divide-and-conquer algorithm for computing minimum spanning trees, which goes as follows. Given a graph $G=(V, E)$, partition the set $V$ of vertices into two sets $V_{1}$ and $V_{2}$ such that $\left|V_{1}\right|$ and $\left|V_{2}\right|$ differ by at most 1 . Let $E_{1}$ be the set of edges that are incident only on vertices in $V_{1}$, and let $E_{2}$ be the set of edges that are incident only on vertices in $V_{2}$. Recursively solve a minimum-spanning-tree problem on each of the two subgraphs $G_{1}=\left(V_{1}, E_{1}\right)$ and $G_{2}=\left(V_{2}, E_{2}\right)$. Finally, select the minimum-weight edge in $E$ that crosses the cut $\left(V_{1}, V_{2}\right)$, and use this edge to unite the resulting two minimum spanning trees into a single spanning tree. Either argue that the algorithm correctly computes a minimum spanning tree of $G$, or provide an example for which the algorithm fails.

1 Solutions

See Answer