Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Assignment

1. Design an algorithm for finding all the factors of a positive integer. For example, in the case of the integer 12, your algorithm should report the values 1, 2, 3, 4, 6, and 12.

2. Does the following program represent an algorithm in the strict sense? Why or why not?

Count = 0
while (Count != 5):
Count = Count + 2

3. Rewrite the following program segment using a repeat structure rather than a while structure. Be sure the new version prints the same values as the original.

Count = 2
while (Count < 7):
print(Count)
Count = Count + 1

4. The following program segment is designed to compute the product of two nonnegative integers X and Y by accumulating the sum of X copies of Y; that is, 3 times 4 is computed by accumulating the sum of three 4s. Is the program segment correct? Explain your answer.

Product = 0
Count = 0
repeat:
Product = Product + Y
Count = Count + 1

until (Count == X)

5. Design an algorithm that, when given an arrangement of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, rearranges the digits so that the new arrangement represents the next larger value that can be represented by these digits (or reports that no such rearrangement exists if no rearrangement produces a larger value). Thus 5647382901 would produce 5647382910.

6. Four prospectors with only one lantern must walk through a mine shaft. At most, two prospectors can travel together and any prospector in the shaft must be with the lantern. The prospectors, named Andrews, Blake, Johnson, and Kelly, can walk through the shaft in one minute, two minutes, four minutes, and eight minutes, respectively. When two walk together they travel at the speed of the slower prospector. How can all four prospectors get through the mine shaft in only 15 minutes? After you have solved this problem, explain how you got your foot in the door.

7. Identify the body of the following loop struc- ture and count the number of times it will be executed. What happens if the test is changed to read "(Count != 6)"?

Count = 1
while (Count != 7):
print(Count)
Count = Count + 3

8. In what sense do the following three steps not constitute an algorithm?

Step 1: Draw a straight line segment between the points with rectangular coordinates (2,5) and (6,11).

Step 2: Draw a straight line segment between the points with rectangular coordinates (1,3) and (3,6).

Step 3: Draw a circle whose center is at the intersection of the previous line segments and whose radius is two

9. Rewrite the following program segment using a while structure rather than a repeat structure. Be sure the new version prints the same values as the original.

Count = 1
repeat:
print(Count)
Count = Count + 1
until (Count >= 7)

10. What is the difference between a formal programming language and a pseudocode?

11. What is the difference between syntax and semantics?

12. What letters are interrogated by the binary search (Figure 5.14) if it is applied to the list A, B, C, D, E, F, G, H, I, J, K, L, M, N, O when searching for the value J? What about search- ing for the value Z?

13. Write an algorithm to take a positive integer n as input and produce the sum of 1+2+..+n. Your algorithm must use while loop control

14. Write an algorithm to take a positive integer n as input and produce the sum of 1+2+..+n. Your algorithm must use recursive control.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92498365
  • Price:- $50

Priced at Now at $50, Verified Solution

Have any Question?


Related Questions in Computer Engineering

How would the stock market soars and americans wealth

How would the stock market soars and Americans wealth expands significantly affect the econmony, by analyzing in the SRAS-AD diagram and determine the effects on real GDP and the General price level.

What are the key nonprice factors that influence demand and

What are the key nonprice factors that influence demand and supply?

A simple repetitive song with varying verse the ants go

A simple repetitive song with varying verse, "The Ants Go Marching" provides a simple assignment for remembering the basic Control Structures - loops, switch statements, if-then-else statements, etc., that you learned in ...

Question recall the optimal page replacement algorithmthe

Question : Recall the optimal page replacement algorithm. The victim page chosen by the algorithm is the one that will not be used the longest period of time. Can this algorithm exhibit Belady's anomaly? Justify your ans ...

Suppose that two teams are playing a series of games each

Suppose that two teams are playing a series of games, each of which is independently won by team with probability p and by team B with probability 1-p. The winner of the series is the first team to win i games. (a) If i= ...

Suppose that a data warehouse consists of the four

Suppose that a data warehouse consists of the four dimensions date, spectator, location, and game, and the two measures count and charge, where charge is the fare that a spectator pays when watching a game on a given dat ...

Question answer both question with minimum 150 words each

Question: Answer both question with minimum 150 words each. Provide examples and references. 1. Data Anomalies - Explain in your own words using tables from your lab project. Also describe how such anomalies could be pre ...

You are starting a company on a tight budget you can get

You are starting a company on a tight budget. You can get DSL line to your office with a static IP address, but ISP does not offer any DNS services. At this point you do not want to set up your own DNS, so you want to fi ...

Pure gasoline has an energy density of 115600 btu per

Pure gasoline has an energy density of 115,600 BTU per gallon, while ethanol has an energy density of 75,670 BTU per gallon. Gasoline cost $3.70 per gallon. What would the price of E85 (85% ethanol, 15% gasoline) have to ...

You are the security manager for a mid-sized company 3000

You are the security manager for a mid-sized company (3,000 to 5,000 employees). Your company has determined that confidentiality (or privacy) and data integrity are the security services you must provide to your work fo ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As