Is this an example of head or tail recursion

Assignment Help Programming Languages
Reference no: EM13315323

Q1) Consider the following code;
(define (add1-iter a-list)
(define (add1-helper curr-list result-list)
(if (null? curr-list)
result-list
(add1-helper (cdr curr-list)
(cons (add1 (car curr-list))
result-list))))
(add1-helper a-list '()))


Is this an example of head or tail recursion? Why?

Q2 )Referring to the code in Part 1, use the substitution model to illustrate what the result of calling (add1-iter '(1 2 3)) will be. Why is the list reversed ?

 

Reference no: EM13315323

Questions Cloud

Recombination era-electromagnetic-weak force combined : Galaxies are moving apart, with a velocity proportional to the distance between them. The "Recombination Era" is when the electromagnetic and weak force combined into a single force. Time appears symmetric under all forces except the strong force.
Find its translational kinetic energy : A solid bowling ball with a radius of 10.9 cm and a mass of 7.1 kg rolls along a bowling alley at a linear speed of 3.0 m/s. What is its translational kinetic energy
Determine the speed of the hoop : A hoop and a disk, both of 0.86- m radius and 5.0- kg mass, are released from the top of an inclined plane 3.5 m high and 9.0 m long. What is the speed of the hoop
Find the minimum torque that must be applied to second hand : A clock has a second hand whose tip rubs against the inside of the glass cover. what is the minimum torque that must be applied to the second hand
Is this an example of head or tail recursion : Referring to the code in Part 1, use the substitution model to illustrate what the result of calling (add1-iter '(1 2 3)) will be. Why is the list reversed ?
The weak force is stronger than gravity : Astronomers coined the term “Big Bang” in an effort to popularize the theory. Dark matter is a force that counters gravity and accounts for the increasing rate of expansion of the universe. Astronomers generally concede that dark matter mostly consis..
Determine how much force is required : An iron disk has a radius of 0.445 m and a mass of 367 kg. The disk is mounted on its axis so that it is free to spin. If the torque is applied at the edge of the disk, how much force is required
Compute the angular acceleration of the wheel : A torque of 14Nm is applied to a heavy wheel whose moment of inertia is 34 kgm2. What is the angular acceleration of the wheel
Recruited into terrorist organizations : Are there any common sociological and/or psychological characteristics of the people who are recruited into terrorist organizations? What are factors that may contribute to a person’s decision to join a terrorist group

Reviews

Write a Review

Programming Languages Questions & Answers

  Input number by user and display positive and negative

Input a number entered by the user and display "positive" if it is greater than zero, "negative" if it is less than zero, and "zero" if it is equal to zero.

  Create program which models snake-s behavior

Create a program which models snake's behavior in the given scenario: A snake is moving toward hole. Each time it moves, snake cuts distance between itself and hole by its own body length

  Design a c# windows phone 8 application

Design and implement a C# Windows Phone 8 application based on the SoundBoard app in the Windows Phone 8 Development for Absolute Beginners textbook.

  Formulate integer programming model for permanent operators

Company wishes to know number of permanent and temporary operators to hire to minimize costs. Formulate an integer programming model for this problem and solve it by using the computer.

  Application to inputs five numbers given between a range

Write an application that inputs five numbers, each between 10 and 100, inclusive. As each number is read, display it only if it's not a duplicate of a number already read.

  Program to store highest value using two-dimensional array

Write down a program which uses the two-dimensional array to store highest and lowest temperatures for each month of the year.

  Write program which lets user enter charge account number

Write the program which lets user enter a charge account number. The program must determine if number is valid by checking for it in following list.

  Program to display total sales salesmen

Display total sales per (6) salesmen. Place first and last names for (6) salesmen in array. When you display your final output, print salesman's last name only.

  Invoke method to tell air conditioner object to turn on

Assume there is a reference variable myAC to an object of this class, which has already been created. Using the reference variable, invoke a method to tell the air conditioner object to turn on.

  Write an algorithm that converts a linear measurement

Write an algorithm that converts a linear measurement in feet and inches into meters. One inch is equivalent to 2.54 centimeters.

  Design program which ask the user for positive interger

Design a program which ask the user which application to do: after choosing from factorial or triangle(magicSquare), the program must then ask again the user for a positive interger.

  Write program using array to show fifo queue

Write program using any language which uses the array to demonstrate simple FIFO queue with 10 job entering the queue and 5 jobs removed from the queue by the server.

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