Algorithm Analysis - Essay Prowess

Algorithm Analysis

Consider the following pseudocode of a function which takes an integer n=0n=0 as input.

Function bar(n)
Print ‘*’;
if n == 0 then
for i = 0 to n – 1 do

Let T(n) be the number of times the above function prints a star (*) when called with input n = 0. What is T(n) exactly, in terms of only n (and not values like T(n – 1) or T(n – 2))? Prove your statement by induction.

%d bloggers like this: