Tail recursion and exception handling

Assignment Help Basic Computer Science
Reference no: EM13963483

Tail Recursion and Exception Handling

Can we use tail recursion elimination to optimize the following program?

exception OddNum;

let fun f(0,count) = count

| f(1, count) = raise OddNum

| f(x, count) = f(x-2, count+1) handle OddNum => -1

Why or why not? Explain. This is a tricky situation - try to explain succinctly what the issues are and how they might be resolved.

Reference no: EM13963483

Questions Cloud

Discuss the innovation involved in product development : Choose a product that they are interested in or provides the required information to discuss the innovation involved in its development - What aspect of the technology influenced the development and the products
Ealuation order and exceptions : Suppose we add an exception mechanism similar to the one used in ML to pure Lisp. Pure Lisp has the property that if every evaluation order for expression e terminates, then e has the same value under every evaluation order. Does pure Lisp with ex..
What is the identity of this gas : A sample of 4.00 g of gas occupies a volume of 1.47 L at 20.0 psi and - 40.0 °F. What is the identity of this gas?
Implications of false beliefs about homosexuality : Reflect on the following statement made by Stanton L. Jones in the assigned article, "Sexual Orientation and Reason: On the Implications of False Beliefs About Homosexuality"
Tail recursion and exception handling : Can we use tail recursion elimination to optimize the following program?
What is the mass of the ice cubes dropped : Two ice cubes at 0.0 oC are dropped in an insulated container containing 93.8 g of water at 27.0°C. After all the ice is melted, the final temperature of the system is 17.0 °C. What is the mass of the ice cubes dropped? Assume that the container has ..
What is the momentum amplitude for this wavefunction : What is the probability of finding the particle in the interval 0 less than or equal to x less than or equal to pi/2b? What is the momentum amplitude for this wavefunction?
Problem regarding the exceptions and recursion : Assume that if f calls g and g raises an exception that f does not handle, then the activation record of f is popped off the stack without returning control to the function f.
Trying to figure out ionic bonds and figuring out formula : Trying to figure out ionic bonds and figuring out formulas.  For example...K+1 and CO3-2 combines to form what.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  The standard deviation for fe73 to achieve six sigma quality

The standard deviation for FE73 to achieve Six Sigma quality

  Declares several circle objects

Declares several Circle objects

  Compute mttf of the system

Suppose we have an eight CPU computer with four hard drives. MTTF of each cpu is 100000 hours and the MTTF of the hard drive is 50000 hours. What is the mttf of the system?

  National institute of standards and technology

The National Institute of Standards and Technology (NIST) replaced the former NIST Special Publication 800-37, Guide for the Security Certification and Accreditation of Federal Information Systems with NIST Special Publication

  A web-based registration and cashiering system

You work for a large public university that utilizes a web-based registration and cashiering system that allows students to register for, pay for, and drop classes

  Show by induction

Show by induction that n^5- n is divisible by 5 for all n ? 0.

  Memory segment in terms of its start address

The above segment descriptor describes a memory segment in terms of its start address, its size and whether it is ALLOCATED or FREE. This descriptor is part of a list (contains a pointer to next segment descriptor). Initially, there is only one se..

  What is the best defense against social engineering

What is social engineering. What is the best defense against social engineering. What are some examples of physical security measures you can implement to protect your network

  Assume the friction coefficient between the rope and capstan

How many wraps around the capstan are required such that one person exerting 100lbs of force can keep the ship at its mooring. Assume the friction coefficient between the rope and capstan is 0.2.

  Explain the purpose of the program

If the return value of insurable in the InsureProcess module is true, the program asks for the year of the car. That year is passed to the checkYear module and returns a value of true to the insurable variable, if the car is new enough.

  Explaining multicategory case a set of samples

In multicategory case a set of samples is said to be linearly separable if there exists linear machine which can classify them all correctly.

  Information systems transforming business

How are information systems transforming business and what is their relationship to globalization? Give examples to illustrate your answer.

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