PROMOTE MY BLOG: JUST CLICK BELOW BUTTON

Search Any Paper On This Blog

Thursday, June 16, 2011

::: vuaskari.com ::: ans required cs301

 1) Consider the following pseudo code                                                                                               

declare a stack of characters
        while ( there are more characters in the word to read )
        {
           read a character
           push the character on the stack
        }
        while ( the stack is not empty )
        {
           pop a character off the stack
           write the character to the screen
        } 

       What is written to the screen for the input "apples"?
       selpa

       selppa

       apples

      

aaappppplleess

2)  Consider the following function:

void test_a(int n)

{

cout << n << " ";

if (n>0)

test_a(n-2);

}

What is printed by the call test_a(4)?

       4 2

       0 2 4

       0 2

       2 4

3)Suppose you implement a Min heap (with the smallest element on top) in an array. Consider the different arrays below; determine the one that cannot possibly be a heap:                

       16, 18, 20, 22, 24, 28, 30  

       16, 20, 18, 24, 22, 30, 28

       16, 24, 18, 28, 30, 20, 22

       16, 24, 20, 30, 28, 18, 22

4) Do you see any problem in the code of nextInOrder below:

TreeNode * nextInorder(TreeNode * p)

{

   if(p->RTH == thread)

     return( p->R );

   else {

     p = p->R;

   while(p->LTH == child)

  p = p->R;

   return p;

   }

}  The function has no problem and will fulfill the purpose successfully. 

        The function cannot be compile as it has syntax error. 

        The function has logical problem, therefore, it will not work properly. 

        The function will be compiled but will throw runtime exception immediately after the control is transferred to this function.  

 

 

--
We say, "Be one as Pakistani Nation and grow up for Pakistan's Future". Wish you all the best. Join www.vuaskari.com,
To post to this group, send email to vuaskari_com@googlegroups.com
Visit these groups:
This (Main) Group:http://groups.google.com/group/vuaskari_com?hl=en?hl=en
MIT/MCS Group: http://groups.google.com/group/vu_askarimit?hl=en?hl=en
HRM Group: http://groups.google.com/group/askari_hrm?hl=en?hl=en
Banking Group: http://groups.google.com/group/askari_banking?hl=en?hl=en
Management: https://groups.google.com/group/vuaskari_mgt?hl=en
Marketing: https://groups.google.com/group/vuaskari_mkt?hl=en
MIS Group: http://groups.google.com/group/askari_mis?hl=en

No comments:

Post a Comment

PLEASE COMMENT ABOUT YOUR VISIT AND MY SITE

Note: Only a member of this blog may post a comment.