By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,364 Members | 1,254 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,364 IT Pros & Developers. It's quick & easy.

Can Someone Please Help Me To Dry Run The Following Pseudo-code

P: 2
a) Dry run the following pseudo-code using the test data shown below it. Draw up a table with one column for
Expand|Select|Wrap|Line Numbers
  1.      EACH variable in the algorithm.     [12]
  2.         Input (P)
  3.         While P ≠ 0
  4.             Input (K)
  5.               T  0
  6.               For R  1 to K
  7.                 Input (X,Y)
  8.                  If X > Y 
  9.                     then T  T + 2
  10.                     else If X = Y
  11.                             then T  T + 1
  12.                         Endif    
  13.                 Endif
  14.             Endfor
  15.             Output (P, K, T)
  16.             Input (P)
  17.         Endwhile        
  18.         USE DATA 10, 3, 4, 3, 5, 2, 1, 1, 20, 4, 5, 5, 2, 2, 1, 2, 0, 0, 30, 2, 1, 2, 3, 4, 0
  19.     b)    List the outputs that are produced.    [3]
May 7 '07 #1
Share this Question
Share on Google+
1 Reply


bartonc
Expert 5K+
P: 6,596
a) Dry run the following pseudo-code using the test data shown below it. Draw up a table with one column for
Expand|Select|Wrap|Line Numbers
  1.      EACH variable in the algorithm.     [12]
  2.         Input (P)
  3.         While P ≠ 0
  4.             Input (K)
  5.               T  0
  6.               For R  1 to K
  7.                 Input (X,Y)
  8.                  If X > Y 
  9.                     then T  T + 2
  10.                     else If X = Y
  11.                             then T  T + 1
  12.                         Endif    
  13.                 Endif
  14.             Endfor
  15.             Output (P, K, T)
  16.             Input (P)
  17.         Endwhile        
  18.         USE DATA 10, 3, 4, 3, 5, 2, 1, 1, 20, 4, 5, 5, 2, 2, 1, 2, 0, 0, 30, 2, 1, 2, 3, 4, 0
  19.     b)    List the outputs that are produced.    [3]
That'll depend on the programming language that you are using.

Moving to Misc. Discussions from Member Intro.
May 7 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.