Suppose you are asked to compute the value of b^n for n, a large nonnegative integer. The simple solution is to compute the product b x b x ... x b involved n - 1 multiples. This takes time theta(n). Give a divide and conquer algorithm for the same problem that takes time theta(log(n)). you should state that the algorithm using pseudo-code. Follow this with a short analysis to show that you have achieved theta(log(n)) time.
Note: Your pseudo-code will be using "standard" multiples (i.e. you are not trying to make the simple multiply of two numbers any faster).© BrainMass Inc. brainmass.com October 24, 2018, 10:35 pm ad1c9bdddf
This solution provides a pseudocode for computing the value of b^n for n (a large nonnegative integer).
Computer Programming Design: 5 Questions
5 Questions in basic Computer Programming Design.
I need the questions answered in full, including appropriate charting.
Here are the 5 questions:
1. Simulate the execution of this algorithm, assuming the following values are read as input for the first four variables named.
name Mrs. Blue Rain
qty 10 pairs
price $1000 per pair
What values should the computer provide as output?
2. The computer is to read values for regular hours, overtime hours, and hourly wage rate for one employee from an employee time sheet. Payment for regular hours is to be computed as rate times hours. Payment for overtime hours is to be computed at time and a half, or 1.5 times rate times hours. The computer is to compute and output the total pay for the employee for the week. Construct a program flowchart for this application.
3. Draw a program flowchart for a program that will accept one number as input. Assume this number represents some amount of yards. Compute the corresponding values of feet and inches, and output all three values - that is, yards, feet, and inches.
4. Write a program flowchart and corresponding pseudo code to prepare a tuition bill. The input will contain the student name, social security number, and total number of credits for which the student has enrolled. The bill will contain the student name, social security number, and computed tuition. Total credits of 10 or more indicate that the student is full-time. Full-time students pay a flat rate of $1000.00 for tuition. Total credits of less than 10 indicate that the student is part-time. Part-time students pay $100.00 per credit for tuition.
5. Write a partial flowchart (show nested logic only) and partial pseudo code (show corresponding code for partial flowchart) for the following scenario:
a. An ATM machine provides the User with the following options:-
- If transaction code is "D" then the Deposit process is done
- if transaction code is "W" then the Withdrawal process is done
- if transaction code is "B" then the Balance process is done
- and if the transaction code is "E" then the Exit process is done
Any other option would result is an error code/message at the screen.
Use a nested IFTHENELSE control structure only.
b. Reconsider the example above and create a partial flowchart and pseudo code using the CASE Control Structure.
c. Which Control Structure do you think is more effective and why?View Full Posting Details