4. Let x be a positive integer. Prove that gcd (4x + 1, 2x + 1)...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
4. Let x be a positive integer. Prove that gcd (4x + 1, 2x + 1) = 1. Hint: Use polynomial division to fill in the box: 4x + 1 = (2x+1) +2 Then gcd (4x + 1, 2x + 1) = gcd(2x + 1,2). This is true by the key step of Euclid's algorithm, where you trade off your original pair for the pair consisting of the smaller number and the remainder. Now explain why gcd(2x + 1,2) = 1. Remember that 2x + 1 is always an odd number. Why? Question 2: (9 Marks) A broker is trading his money in the stock market. Assume that the daily price of a specific stock along a certain period of time is given as follows: Price [200, 500, 800, 100, 300, 50] all in $. This means that the price of the stock is $200 in the first day, $500 in the second day, and so on. You are allowed to buy and sell the stock only once, which means that if you buy it on the 1st day (i.e. $200) and then sell it on the 3rd day (i.e. $800) a profit of $600 will be gained. You are requested to develop an algorithm to maximize the profit in single buy and sell. Another example: int prices = {300, 450, 720, 90, 30, 50, 900, 500, 70}; Output: Buying date: day 5, at the price of 30$ selling date: day 7, at the price of 900$ Maximum Profit: 870$ Answer the following questions: Short Term Exit Long Term Buy a) Design a brute force algorithm (pseudocode) to solve the above problem (1 mark), and determine its complexity (1 marks). b) Design an efficient algorithm (pseudocode) to solve the above problem (2 marks), and determine its complexity (1 marks). c) develop a brief report to explain the difference between the two algorithms and explain why one of them is more efficient than the other. (2 marks) d) Implement the efficient algorithm using Python (2 marks) 4. Let x be a positive integer. Prove that gcd (4x + 1, 2x + 1) = 1. Hint: Use polynomial division to fill in the box: 4x + 1 = (2x+1) +2 Then gcd (4x + 1, 2x + 1) = gcd(2x + 1,2). This is true by the key step of Euclid's algorithm, where you trade off your original pair for the pair consisting of the smaller number and the remainder. Now explain why gcd(2x + 1,2) = 1. Remember that 2x + 1 is always an odd number. Why? Question 2: (9 Marks) A broker is trading his money in the stock market. Assume that the daily price of a specific stock along a certain period of time is given as follows: Price [200, 500, 800, 100, 300, 50] all in $. This means that the price of the stock is $200 in the first day, $500 in the second day, and so on. You are allowed to buy and sell the stock only once, which means that if you buy it on the 1st day (i.e. $200) and then sell it on the 3rd day (i.e. $800) a profit of $600 will be gained. You are requested to develop an algorithm to maximize the profit in single buy and sell. Another example: int prices = {300, 450, 720, 90, 30, 50, 900, 500, 70}; Output: Buying date: day 5, at the price of 30$ selling date: day 7, at the price of 900$ Maximum Profit: 870$ Answer the following questions: Short Term Exit Long Term Buy a) Design a brute force algorithm (pseudocode) to solve the above problem (1 mark), and determine its complexity (1 marks). b) Design an efficient algorithm (pseudocode) to solve the above problem (2 marks), and determine its complexity (1 marks). c) develop a brief report to explain the difference between the two algorithms and explain why one of them is more efficient than the other. (2 marks) d) Implement the efficient algorithm using Python (2 marks)
Expert Answer:
Posted Date:
Students also viewed these finance questions
-
Read the following statements. In response, state True, False or Uncertain and explain why: (a) Since resources have substitutes, nature imposes particular scarcities, not an inescapable general...
-
Excerpts from Crozier Industries financial records as of December 31, 2015, follow: The amounts shown do not include any tax effects. Croziers tax rate is 35 percent. Assume that all items are...
-
Alpha SE and Zito SE operate in the same industry. Alpha uses the straight-line method to account for depreciation; Zito uses an accelerated method. Explain what complications might arise in trying...
-
Smith manufactures coffee mugs that it sells to other companies for customizing with their own logos. Smith prepares flexible budgets and uses a standard cost system to control manufacturing costs....
-
The project manager of Good Public Relations gathered the data shown in Table for a new advertising campaign. a. How long is the project likely to take? b. What is the probability that the project...
-
Question 2 : A mine worker, on a typical day during his daily shift, is exposed to noise levels of 8 0 dB for 4 hours, 1 0 0 dB for 2 hours, and 9 5 dB for 3 hours. Calculate Lexa the 8 hour...
-
1. Which of the Following is mostIy key to be a complement to coffee? Baked Beans Decal coffee Tea Creamer 2. Assume that a monsoon destroys the coffee crop in Vietnam. one of the itrates largest...
-
The following book and fair values were available for Beech Company as of June 1: Items Inventory Land Book Value Buildings $ 300,000 816,000 2,050,000 Fair Value $ 248,250 1,085,250 2,375,500...
-
Given the structure of the EMPLOYEE table below. CREATE TABLE EMPLOYEE ( ); EMP ID number (10) primary key, FIRST NAME varchar2(50), LAST NAME varchar2(50), DATE OF BIRTH date, DATE OF DEATH date,...
-
Sweeten Company had no jobs in progress at the beginning of the year and no beginning inventories. It started, completed, and sold only two jobs during the year-Job P and Job Q. The company uses a...
-
You are developing an ASP.NET MVC news aggregation application that will be deployed to servers on multiple networks. The application must be compatible with multiple browsers. A user can search the...
-
1. For the graph S A 7 6 8 3 4 B 5 2 2 (a) Find the number edges and sum degrees of all vertices. Marks) (b) Explain why the graph is not complete. Marks) (c) Use Prim's Algorithm to find the minimum...
-
It will cost $2,600 to acquire a small ice cream cart. Cart sales are expected to be $1,400 a year for three years. After the three years, the cart is expected to be worthless as that is the expected...
-
Differentiate the following terms/concepts: a. Personality types and money attitudes b. Planners and avoiders c. Moderating and adapting to biases d. "Perfectible judges" and "incorrigible judges"
Study smarter with the SolutionInn App