#include #include class complex{ double re, im;/// can also use double re= 0; ////double...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
CS304 Data Structures Assignment 1: Classes and Essential Operations Worth: 10% of overall grade Due: Tuesday January 30th at 11:59 PM Setup: install visual studio 2022, create a C++ console project, and go to Debug->properties->C/C++-> Language, set 'C++ language standard' to 'Latest C++ working draft' and 'Build ISO C++' to 'yes'. This will allow you to use more recent language features. Part 1 40%: Complete the complex class from lecture 2 by implementing operator*= and operator/= overloads. You can find mathematical definitions for multiplication and division of complex numbers here. Verify that it works with a small experiment in main where you instantiate some complex numbers and multiple or divide them. Verify also that operator* and operator/ (which rely on *= and /=) work correctly. If you're feeling ambitious, you can also add functions for logarithm, exponentiation, and square root. Part 2 60% Part 2A: complete the big 5 of the Vector class from lecture_02_classes.pdf. It is currently lacking the copy constructor, copy assignment operator, move constructor, and move assignment operator. Most of these can be found in lecture_03_essential_operations.pdf. Read about why you need to implement these in 'Rule of the Big 5' link above. Write a short comment at the top of your code summarizing your understanding of why you need to implement the big 5 for the Vector class but not for the complex class. Part 2B: add the push_back (double d) member function to your Vector class. The job of push back is to append an element to the end of the vector. On the first call to push_back, you will need to allocate additional space to make room for the new element, this means expanding your vector by creating a new array of 2x the size of the existing array and then copying everything from the existing array into the new array. Be sure to delete [] the old array when this is done. Keep track of how many elements have been pushed back so you know when to expand the array again. Part 2C: Perform two timing tests comparing your vector's performance to the STL vector (#include ;) Test 1: instantiate 10,000 vectors of size 100. For each class (STL vector and your custom Vector) time how long it takes to perform this instantiation. Test 2: for each class, instantiate a vector of size 1 and add 100,000 elements to it using push_back. Time how long it takes to add these 100,000 elements to STL vector and your custom vector. You can see examples of how to program a stopwatch in C++ here. What do you observe in your timing experiments? Write comments at the top of your source code describing the results of these timing experiments. Submission: submit your source code to moodle, include any remarks as a comment in the source code at the top of the file. CS304 Data Structures Assignment 1: Classes and Essential Operations Worth: 10% of overall grade Due: Tuesday January 30th at 11:59 PM Setup: install visual studio 2022, create a C++ console project, and go to Debug->properties->C/C++-> Language, set 'C++ language standard' to 'Latest C++ working draft' and 'Build ISO C++' to 'yes'. This will allow you to use more recent language features. Part 1 40%: Complete the complex class from lecture 2 by implementing operator*= and operator/= overloads. You can find mathematical definitions for multiplication and division of complex numbers here. Verify that it works with a small experiment in main where you instantiate some complex numbers and multiple or divide them. Verify also that operator* and operator/ (which rely on *= and /=) work correctly. If you're feeling ambitious, you can also add functions for logarithm, exponentiation, and square root. Part 2 60% Part 2A: complete the big 5 of the Vector class from lecture_02_classes.pdf. It is currently lacking the copy constructor, copy assignment operator, move constructor, and move assignment operator. Most of these can be found in lecture_03_essential_operations.pdf. Read about why you need to implement these in 'Rule of the Big 5' link above. Write a short comment at the top of your code summarizing your understanding of why you need to implement the big 5 for the Vector class but not for the complex class. Part 2B: add the push_back (double d) member function to your Vector class. The job of push back is to append an element to the end of the vector. On the first call to push_back, you will need to allocate additional space to make room for the new element, this means expanding your vector by creating a new array of 2x the size of the existing array and then copying everything from the existing array into the new array. Be sure to delete [] the old array when this is done. Keep track of how many elements have been pushed back so you know when to expand the array again. Part 2C: Perform two timing tests comparing your vector's performance to the STL vector (#include ;) Test 1: instantiate 10,000 vectors of size 100. For each class (STL vector and your custom Vector) time how long it takes to perform this instantiation. Test 2: for each class, instantiate a vector of size 1 and add 100,000 elements to it using push_back. Time how long it takes to add these 100,000 elements to STL vector and your custom vector. You can see examples of how to program a stopwatch in C++ here. What do you observe in your timing experiments? Write comments at the top of your source code describing the results of these timing experiments. Submission: submit your source code to moodle, include any remarks as a comment in the source code at the top of the file.
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these algorithms questions
-
answer the question clearly You are building a flight-control system for which a convincing safety case must be made. Would you assign the tasks of safety requirements engineering, test case...
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
(a) Use the following text to derive distributions for rat and chased. Use a five-word window, including open- and closed- class words, ignore case, punctuation and sentence boundaries and weight...
-
verify that u= c ext cosx is a dimensional heat cqn. for. a soln. of suitable value of c. one
-
In order to slide a heavy cabinet across the floor at constant speed, you exert a horizontal force of 600 N. Is the force of friction between the cabinet and the floor greater than, less than, or...
-
In the absence of the accountant you have been asked to prepare a month?s cost accounts for a company which operates a batch costing system fully integrated with the financial accounts. The cost...
-
An electrical heater in the form of a horizontal disk of \(500-\mathrm{mm}\) diameter is used to heat the bottom of a tank filled with engine oil at a temperature of \(10^{\circ} \mathrm{C}\)....
-
An article in The Wall Street Journal indicated that dressmaker Fallo Me (name changed) backdated invoices to record revenue in the quarter before sales were actually made. As long as sales remained...
-
A dart is thrown horizontally with an initial speed of 11.39m/s towards a dartboard that is horizontal distance of 2.52 m from the position of the dart when it is released. What vertical distance in...
-
Roberta Santos, age 41, is single and lives at 120 San-borne Avenue, Springfield, IL 60781. Her Social Security number is 123-45-6789. Roberta has been divorced from her former husband, Wayne, for...
-
Explain two strategies to recover from the following cyber incidents? physical Security system Failure, accident. denial of service virus attack communication failure
-
How do prognostic methodologies leverage sophisticated algorithms and data analytics to generate nuanced forecasts across diverse domains, ranging from economics to climate science ?
-
To what extent does organizational culture, leadership ethos, and employee empowerment initiatives shape the fabric of operational efficiency within organizations, fostering a sense of ownership,...
-
Risk and Return Suppose you observe the following situation: Security Cooley Inc Moyer Company Beta Expected Return 1.8 22.00% 1.6 20.44 If the risk-free rate is 7%, are these securities correctly...
-
Procedure 4. Find five circular objects with different diameters. These could be objects such as a food or drink cans, balls of different kinds, a broom stick, or any other object around you. A paper...
-
A chlorine (CI) and bromine (Br) atom are adsorbed on a small patch of surface (see sketch at right). This patch is known to contain 36 possible adsorption sites. The Cl and bromine (Br) atoms have...
-
At what elevation angle does a sailor observe the highest point of a lighthouse? 25 meters high, knowing that the sailor is in his boat at a distance of 21 meters from the lighthouse?
-
What does non-recourse financing mean?
-
For each of the following situations, indicate whether the taxpayer(s) is (are) required to file a tax return for 2012. Explain your answer. a. Helen is a single taxpayer with interest income in 2012...
-
The following additional information is available for the Dr. Ivan and Irene Incisor family. The Incisors own a rental beach house in Hawaii. The beach house was rented for the full year during 2012...
-
While preparing Massie Miller's 2012 Schedule A, you review the following list of possible charitable deductions provided by Massie: Cash contribution to a family whose house burned...
-
How can you identify a real option in a decision tree?
-
In 2022, Costco Wholesale Corporation had a market capitalization of \($238\) billion, debt of \($6.5\) billion, cash of \($12\) billion, and EBIT of about \($8\) billion. If Costco were to increase...
-
In what circumstances does the real option add value?
Study smarter with the SolutionInn App