Question
What is the primary difference between recursion and
iteration in programming?Solution
Recursion involves a function calling itself until a base condition is met. Each recursive call creates a new stack frame, leading to memory usage that grows with the depth of recursion. Iteration, on the other hand, uses loops and does not involve stack frame creation, making it more memory-efficient in many cases. Why Other Options Are Incorrect: 1. Recursion uses loops for repetition, whereas iteration does not: This statement reverses the roles. Recursion relies on function calls for repetition, while iteration explicitly uses loops (for, while). 2. Iteration cannot solve problems that recursion can solve: Iteration can replicate recursion's functionality by using stacks or queues explicitly. Recursion is often a stylistic or practical choice, not a limitation of iteration. 3. Recursion is always faster than iteration: Recursion can sometimes be slower due to stack overhead and repeated function calls. Tail-call optimization can mitigate this in some languages, but generally, iteration is faster for equivalent tasks. 4. Recursion does not require a base case, while iteration requires a condition: Recursion must have a base case to terminate; otherwise, it leads to infinite calls. Iteration, too, requires a stopping condition, such as a loop exit condition.
The area of the largest triangle inscribed in a semi-circle of radius R is-
A triangle ABC is inscribed in a circle with radius 10 cm. The sides of the triangle are AB = 12 cm, BC = 16 cm, and AC = 20 cm. Find the area of the tr...
If the ratio of side of a ∆ is 3:4:5, and a ┴ from opposite vertex drawn to the biggest sides at D, if the length of biggest side is 10 then find ra...
What will be inradius of an equilateral triangle of side 10 cm?
The length of the each side of an equilateral triangle is 28√3 cm . The area of circumcircle, (cm 2 ) is
B1 is a point on the side AC of ∆ ABC and B1B is joined. line is drawn through A parallel to B1B meeting BC at A1 and another line is drawn through C ...
In ∆ABC, AB = 5cm, BC = 10cm, and AC = 13cm then find out the value of cos A.
Angles of a triangle are in the ratio 2 : 3 : 7. Find the sum of the smallest and largest angle of the triangle.
An angle is equal to 3/7 of its supplement. The angle is :