edited by
2,252 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)$
edited by

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

2 votes
2 votes
2 answers
1
go_editor asked Jul 7, 2016
4,147 views
The mechanism that binds code and data together and keeps them secure form outside world is known asAbstractionInheritanceEncapsulationPolymorphism
2 votes
2 votes
1 answer
2
go_editor asked Jul 7, 2016
2,772 views
The strategy used to reduce the number of tree branches and the number of static evaluations applied in case of a game tree isMinmax strategyAlpha-beta pruning strategyCo...
2 votes
2 votes
1 answer
3
go_editor asked Jul 7, 2016
1,237 views
Match the following with respect to java.util.$\ast$ class methods :$\begin{array}{clcl} \text{(a)} & \text{Bit Set} & \text{(i)} & \text{Time zone getTimezone()} \\ \t...
3 votes
3 votes
2 answers
4
go_editor asked Jul 7, 2016
3,010 views
The upper bound of computing time of m colouring decision problem is$O(nm)$$O(n^m)$$O(nm^n)$$O(n^mm^n)$