in Programming in C edited by
2,254 views
2 votes
2 votes

Consider the following Pseudo-code segment:

k:=0

for $i_1$:=1 to n

for $i_2$ := 1 to $i_1$

:

:

:

for $i_m$:=1 to $i_{m-1}$

k:=k+1

The value of k after the execution of this code shall be

  1. $C(n+m-1, m)$
  2. $C(n-m+1, m)$
  3. $C(n+m-1, n)$
  4. $C(n-m+1, n)$
in Programming in C edited by
2.3k views

1 Answer

0 votes
0 votes

Let n=3 and m=2

so, i1:1 to 3

    i2=1 to i1

Now, when i1=1, i2 iterates only for i2=1 so k=1

      when i1=2, i2 iterates for i2=1 and i2=2so k=3

    when i1=3, i2 iterates  for i2=1,i2=2,i2=3 so k=6

=>K=6

  1. C(n+m-1, m)=C(4,2)=6, sO A is correct
Answer:

Related questions