Print Page | Close Window

IT TEST ID:03

Printed From: One Stop GATE
Category: GATE AT A GLANCE
Forum Name: Test Series
Forum Discription: Discuss various Test Series available in the market before joining one.
URL: http://forum.onestopgate.com/forum_posts.asp?TID=687
Printed Date: 07Feb2025 at 6:50pm


Topic: IT TEST ID:03
Posted By: balu
Subject: IT TEST ID:03
Date Posted: 23Feb2007 at 1:03pm
 
48. What is printed by the print statements in the program P1, assuming call-by-reference parameter passing?

Program P1()
{
X=10,y=3;
func1(y,x,x);
print x;
print y;
}

func(x,y,z)
{
y=y+4;
z=x+y+z;
}

56. Quick sort is run on two inputs below to sort in ascending order

(i) 1,2,3,………n
(ii) n,n-1,…….2,1

Let C1 and C2 be the number of camparsions made for the input (i) and (ii) repectively. Then,

I have doubt in the answers of these questions.....

Can anybody help me plz...



Replies:
Posted By: manju
Date Posted: 23Feb2007 at 1:05pm
 for 1st question, ans 31,3!!!

Actual value of Y is untouched and modification is on X only,

As it is a pass by reference,

y= y+4 (this makes X =14,since pass by ref. z value is also changed to 14)

z=x+y+z(this means 3+14+14 = 31)


Posted By: vukkusila_ravi
Date Posted: 31Jul2007 at 1:37am
the answer for ur question is c1=c2 because
both takes same time complexity l.e., O(n2).



Print Page | Close Window