Simple iterative computation

Assignment Help Basic Computer Science
Reference no: EM133218692

Consider this series of numbers: 3 10 5 16 8 4 2 1 Starting with a positive integer N, this series is computed with a simple iterative computation:

If the current integer N is even, the next number is N / 2

If the current integer N is odd, the next number is N * 3 + 1

Repeat until N equals 1 This is called the Hailstone sequence and it is related to the Collatz conjecture. The conjecture states that eventually this series will converge to 'one' no matter what positive starting integer is chosen. Here is another example of the series: 26 13 40 20 10 5 16 8 4 2 1 implement MIPS assembly language program that does the following:

Prompt the user for an integer N.

Compute the hailstone sequence for the given number N and count the number of iterations required to converge to 1. You do not need to store the sequence of numbers, just compute them, print them and count the iterations.

It is possible, for large N, the computation may overflow. That is, N * 3 + 1 may produce a number larger than can be contained in a 32 bit word. Be aware of this possibility, but you do not need to detect or handle overflow in your program for this assignment.

When the sequence reaches 1, print out the number of iterations and terminate the program. • Feel free to use snippets of my multiplication code (posted on the website) to read and write to the terminal, multiply and to terminate your program. Note: there is a much easier way to multiply by 3.

Write (at least) one function that computes n*3+1. (The parameter n must be passed to the function in $a0, and the function should return n*3+1 in $v0. Properly use this function in the part of your code that computes the Hailstone sequence (using jal to call the function and jr to return from it).

You may NOT use the built-in MIPS instructions for multiply or divide. Use addition and shift instructions for multiplication and division, and the AND instruction for odd/even testing.

You must comment your code

Reference no: EM133218692

Questions Cloud

How would use those shackleton leadership : Give examples of challenges or situations you could face as a leader and discuss how you would use those Shackleton leadership lessons.
What steps might business and government teams need : What steps might business and government teams need to take in order to access the information/perspectives needed to manage the ethical landscape of such
Discuss what job analysis method would be best : Diner with One Server Behind the Counter Job Analysis - Discuss what job analysis method would be best for analyzing this job function and why
Members of the healthcare team : What actions from other members of the Healthcare Team could be considered abuse?
Simple iterative computation : Consider this series of numbers: 3 10 5 16 8 4 2 1 Starting with a positive integer N, this series is computed with a simple iterative computation
Calculates eigenvalues and eigenvectors of a matrix : calculates eigenvalues and eigenvectors of a matrix. Calculate the eigenvalues for your Wilkinson matrix. What do you notice about them?
Why is communication important in healthcare organization : Why is communication important in the healthcare organization? What is the common path of communication used in the workplace?
Report to analyze a commercial information system : Write a report to analyze a Commercial Information System (NetSuite) by explaining the related technology trend, the information system evolution, the benefits
What is the physical object you do not understand : What is the physical object you do not understand? List one thing about the physical object that you do not understand

Reviews

Write a Review

Basic Computer Science Questions & Answers

  How much is the bond worth today

Suppose a State of Texas bond will pay $5,000 ten years from now. If the going interest rate on these 10-year bonds is 2.0%, how much is the bond worth today?

  Various business and it organizational models

Which organizational variation provides the best environment for taking advantage of the SOA framework? What makes this variation advantageous?

  What is the binary number which represents a decimal

What is the binary number which represents a decimal 4 and If a digital system has 5 inputs, how many possible input combinations are there?

  Cyber security tool comparison and change management plan

Incident Response Plan, Cyber Security Tool Comparison and Change Management Plan. Discuss roles and responsibilities.

  What is disruptive technology

What is disruptive technology? Cite one example of a technology that has emerged in the last decade and what impact it has had. Who/what was affected?

  Compute the concentration ratio for the relevant market

Who are the leading firms and what are their market shares? Compute the concentration ratio for the relevant market.

  Employment strategy for maximizing firm profit

If you are the manager of the firm, what is your proper employment strategy for maximizing your firm's profit?

  A power level of 100 w is 6 db above what power level

A power level of 100 W is 6 dB above what power level?

  Definition of a class counter containing

Write the definition of a class Counter containing: An instance variable named counter of type int. A constructor that takes one int argument and assigns its value to counter A method named increment that adds one to counter.

  Which month has the smallest range

Write a report on the annual patterns you see in the ozone levels.

  Avalanche breakdown

Explain the Zener phenomenon. How does it differ from Avalanche breakdown?

  Implementation of new policies

Do you believe that training is a necessity in the implementation of new policies

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd