[SOLVED] ESE 224: Computer Techniques for Electronic Design II Assignment 2

30.00 $

Category:

Description

5/5 - (1 vote)

Classes, Reference Variables and the String Class
Total Score: 12 points
1 Assignment
1. Given a two-dimensional input integer array of size M x N, write a program such that if an
element in the array is 0, the entire row and column is set to 0. You can initialize the array
as follows:
int arrN[4][3] = ff5, 1, 0g, f3, 2, 4g, f39, 20, 0g, f11, 2, 49gg;
Generate the appropriate test cases, and test the program with array sizes 20 x 30. (2 points)
2. Write a function that adds two numbers. You cannot use + or any other arithmetic operator.
You will be utilizing the bit manipulation and bitwise operators in C++. (2 points)
3. Given an arbitrary ransom note, consisting of 15 􀀀 20 words and several magazines, write a
function that will return a true, if the ransom note can be constructed from the words in the
magazines, otherwise it will return a false. Each word in the magazines can only be used once
in your ransom note. The algorithm should work eciently, such as, utilizing hash tables for
storing and looking up strings. An example hash function maybe the sum of the ascii values
of all the characters in the string, modulus an appropriate positive integer. Utilize the built in
string class, and some of its methods. For testing the code, utilize the ransom note and the
magazines provided on the Blackboard in les RansomNote.dat, Magazine1.dat, Magazine2.
dat, Magazine3.dat, Magazine4.dat, Magazine5.datand Magazine6.dat.
(4 points)
4. De ne, implement and test a Complex class, which has:
(a) At least two constructors.
(b) A destructor.
(c) Several Methods with functionality as described below:
 Returns real part.
 Returns imaginary part.
 Displays the number.
 Computes magnitude.
 Computes polar co-ordinates.
 Overloads operators +, -. * and /, with the corresponding operations.
 Overloads the operator  for complex conjugate.
 Overloads the operators == and != for comparison.
The methods must make appropriate use of the reference variables, for arguments and return
types, as described in Stephen Prata, Chapter 10. For more details on operator overloading,
refer to Prata, Chapter 11. (4 points)
2 Grading
In addition to code functionality, there will be points for optimized algorithm, coding style and
comments. A few useful comments would be sucient.
3 Assignment Submission
The Assignments must be submitted on the Blackboard, and should include the following:
1. The C++ source code, with one le per problem.
2. Screen shots which show each program executing. All the screen shots maybe in a single .pdf
or .jpg le.