answersLogoWhite

0

recursion is always slower than iteration

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

What is a factorial function in Visual Basic?

' Iterative solution Function iterativeFactorial(ByVal n As Long) As Long Dim factorial As Long = 1 For i As Long = 1 To n factorial *= i Next Return factorial End Function ' Recursive solution Function recursiveFactorial(ByVal n As Long) As Long If n <= 1 Then Return n End If Return n * recursiveFactorial(n - 1) End Function


What is the most efficient way to implement a factorial algorithm in a programming language?

The most efficient way to implement a factorial algorithm in a programming language is to use an iterative approach rather than a recursive one. This involves using a loop to multiply the numbers from 1 to the given input number to calculate the factorial. This method is more memory-efficient and faster than using recursion.


What is the definition of non recursive in c?

non recursive function is excuted faster than recrussive


What is simulation recursion in C?

The factorial f(n) = n * (n-1) * (n-2) * .. 1. For example factorial 5 (written as 5!) = 5 x 4 x 3 x 2 x 1 = 120. The function below returns the factorial of the parameter n. int factorial( int n) { if (n==1) return 1 else return n* factorial( n-1) ; }


The efficiency of using recursive function rather than using ordinary function?

For some algorithms recursive functions are faster, and there are some problems that can only be solved through recursive means as iterative approaches are computationally infeasible.


What is faster the speed of light or speed of sunlight?

That's like asking whether a car is faster than a Ford, or whether an animalcan outrun a horse.Sunlight is light, and it travels at the speed of that which it is.


Where earthquake waves travel faster whether in rock or water?

Faster in rock. the higher the density, the higher the speed.


Will the brand of the banana determine whether the banana will brown faster on the counter or in the refrigerator?

It does not matter what brand. Bananas turn brown faster in the refrigerator.


Is a female faster then a male?

It depends on the specific person. It doesn't matter whether they are male or female.


Does your body metabolize alcohol faster when you are asleep?

No, your body does not metabolize alcohol faster when you are asleep. Metabolism of alcohol occurs at a relatively constant rate regardless of whether you are awake or asleep.


Is it possible for us to travel faster than light without going to the past or the future?

It probably isn't possible to travel faster than light - whether we want to travel in time, or not.


Will a tire fill with air faster when the weight of the vehicle is removed?

A tire does not fill any faster with the weight of the car on it. Air is pressurized and fills the tire with the same speed whether it is on or off of the car.