hangpu3034

hangpu3034

Lv2

Hangpu 3034

0 Followers
0 Following
0 Helped

ANSWERS

Published15

Subjects

Project Management1History1English2Science1Psychology1Computer Science1Accounting2Calculus1Biology1Physics2Economics1Chemistry1

The Problem: Implement the recursive multiplication algorithm in Lecture 8 (slide 14 ) and Section 5.5 (p. 233 ) of our textbook. Note: test your code carefully - subtle considerations need to be taken with stopping conditions, which the textbook does not address.

The Recursive Multiplication:
Algorithm:
1: function Recursive-Multiply (x,y)
2: x=2^(⌊n/2βŒ‹)x_h + x_β„“
3: y=2^(⌊n/2βŒ‹)y_h + y_β„“
4: c_x = x_h + x_β„“
5: c_y = y_h + y_β„“
6: z_h = Recursive-Multiply (x_h, y_h)
7: z_c = Recursive-Multiply (c_x, c_y)
8: z_β„“ = Recursive-Multiply (x_β„“, y_β„“)
9: return 2^(2⌊n/2βŒ‹)z_h + 2(⌊n/2βŒ‹)(z_c βˆ’ z_h βˆ’ z_β„“) + z_β„“
- Note that we can perform multiplication by 2^x via left shift
- We can also obtain x_h, x_β„“, y_h, and y_β„“ with AND and MOD
- These are O(n), as is the addition we will need to use (i.e. we have a constant number of O(n) operations, and thus have O(n) runtime overall at the level of each function call)
- Since we split the input in half and now have only three recursive calls, our recurrence becomes T(n)=3T(n/2)+O(n)
- And this has O(n^(log_2(3))) β‰ˆ O(n^1.59), which strictly improves upon the 'grade-school' multiplication

Important: Do not use multi-threading, or any other form of parallelism, for the individual recursive function calls. The grading program expects your output in a format produced by a recursive but non-parallel algorithm. Use of parallelism in function calls will cause the autograder to deem your solution incorrect.

The Input Format: Your program will be expected to read input from a text file, the name of which should be passed as the first parameter to your program on command line invocation. All 'integers' discussed from here on out can be expected to be UTF-8 string representations of said numbers (i.e. as one would find in a .csv file). The input will come in two lines, each representing a single positive integer.

Your Program's Output: Your program will be expected to output a text file named output.txt, in UTF-8 format as described above. Call the number on the first line of the input file x, and the number on the second line of the input file y. Then each line of the output file will contain the state of one of your function calls just before the non-stopping condition return call. This line will contain the following positive integers, in the order indicated, with each separated by a single comma: n_s, x_h, x_β„“, y_h, y_β„“, z_h, z_c, z_l where:
- n_s is the number of bits at which you split the inputs
- x_h and y_h are the high bits of x and y respectively
- x_β„“ and y_β„“ are the low bits of x and y respectively
- z_h is the result returned by your recursive multiplication call on x_h β‹… y_h
- z_c is the result returned by your recursive multiplication call on (x_h + x_β„“ ) β‹… (y_h + y_β„“)
- z_l is the result returned by your recursive multiplication call on x_β„“ β‹… y_β„“
- That is, we can write:
- x = 2^(n_s) x_h + x_β„“
- y=2^(n_s) y_h + y_β„“
- x β‹… y = z = 2^(2n_s) z_h + 2^(n_s)(z_c βˆ’ z_h βˆ’ z_β„“) + z_β„“

Some points:
- The input and output format is in (UTF-8\ASCII string) base-10.
- The following examples assume you treat the numbers as binary once they are stored as unsigned integers
- When you split the input, the difference between between the number of bits in the high half and low half should be one if n is odd, and zero if n is even
- The following examples choose the value of n_s based on the minimum of x and y
- The following examples assume that n_s ≀1 is the stopping condition if for odd n, the lower half has more bits
- The following examples assume that n_s = 0 is the stopping condition if for odd n, the higher half has more bits
- The recursions were called in this order: (a) First center, z_c, (b) Second high, z_h, (c) Third low, z_β„“

Examples:
Here is what the output looks like if for odd n, the lower half has more bits:

Input:
17
11
Output:
2, 1, 1, 1, 1, 1, 4, 1
2, 4, 1, 2, 3, 8, 25, 3

Input:
45
27
Output:
2, 2, 2, 1, 2, 2, 12, 4
3, 5, 5, 3, 3, 15, 60, 15

Input:
192
237
Output:
2, 3, 0, 6, 3, 18, 27, 0
2, 3, 0, 3, 2, 9, 15, 0
14, 12, 0, 14, 13, 168, 324, 0

Write code in Python (python 3.8.10)

Answer:The given problem requires implementing the recursive multiplication al...
Answer:To create a simple stress reduction plan, follow these steps: 1.Identif...
Answe: velocity=distance/time
Answer: The corresponding Hardy-Weinberg equation for genotypic frequency is: ...
Answer: Personal Learning Plan: Data Analysis: I want to learn how to understa...

INSTRUCTIONS: Review the questions from each section below. You can answer the questions in your mind or you can use the space provide after each question to write out your thoughts.

Use β€œI am” and β€œI have” statements to respond to each question related to who you are in 5 years. Once you've answered the questions, take all the information, and combine it into one clear Vision Statement of who you are.

Your Vision Statement is due by 5pm. Submit it as a PDF file.

** NOTE - You are not required to answer all questions, they are to help you build your Vision Statement. **

What life do you envision for yourself 5 years down the road?

CAREER

What does your job/business look like?

How many weeks are you working throughout the year? I am How much money are you making annually in your job? I have How many hours are you working each week? I am

What awards or promotions have you received?

What major accomplishments have you completed?

NETWORK

What does your tribe look like? Who do you surround yourself with? What activities are you doing with them?

How do the people you surround yourself with contribute to your life and how are you contributing to theirs?

What events or masterminds are you going to and what are you looking forward to learning and improving in by attending them?

How often are you volunteering or donating (time or money) to charities and causes you’re passionate about?

RELATIONSHIP

What do your relationships look like with?

Your family, friends, spouse/partner, employees, colleagues, social circle

Who are your mentors?

Who are you mentoring?

Who do you need to meet or be around to achieve your 5 year vision?

WEALTH/FINANCES

How much money do you have available in your checking/savings account? How much money do you have in your retirement accounts?

What kind of retirement accounts are you investing in?

What is your current Net Worth?

How much passive income are you making from your investments? What are you investing in for passive income?

What skills or disciplines have you mastered to improve your wealth?

Do you have an estate plan, trust, or will to protect your wealth?

LIFESTYLE

What kind of car are you driving?

What kind of house are you living in? Where is it located? What does it look like inside?

How many weeks are you traveling? With whom? To where?

What bucket list adventures have you checked off?

What special gift(s) have you bought yourself or given to others?

What are you most looking forward to accomplishing in the coming years with your lifestyle goals?

HEALTH

What does your daily routine look like?

What is your ideal weight and body fat%? How often are you working out or exercising? What kind of activities are you doing?

Describe how you take care of your emotional wellness being?

Do you meditate? How often?

How are you managing your spiritual health or faith?

How does your body look and feel?

INSTRUCTIONS: Now that you have a clear picture and can visualize how you would like your dream life to look in 5 years’ time, take time to write out your vision in more detail. The clearer you see your vision, the easier it will be to make it a reality. Bring this vision to life by writing it out in story format as if it is already happening. Use β€œI am” and β€œI have” statements.

VISION STATMENT

Answer:In five years, my life is amazing. I have a fulfilling job that I love,...
Answer:No, the accrual concept in accounting is different from accounting on a...
Answer:Provision: Saving money for expected expenses. Contingent Liability: Po...
Answer,:Transformational Leadership: Inspires and motivates employees to excee...
Answe:Health, relationships, personal growth, purpose, happiness, environment,...
Answer:science can be defined as a systematic way of studying and understandin...
Having government regulations and laws for business leans more towards B. Soci...
Step-by-step explanation:To evaluate the line integral, we need to calculate t...
Here are the full calculations for both scenarios: When 𝑀𝑒 = 0.95 (the solutio...
Answer: Step-by-step explanation:Calcium is a vital mineral that plays a cruci...

Weekly leaderboard

Start filling in the gaps now
Log in