Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


U have an array of +ve integers arranged in the descending
order . Write a functionb thast take an integer & an integer
array as an integer and returns the position of the given
integer in the array , if the integer is not present in the
array it should return -1 . the serching technique that u
use should be very efficient both in terms of time & memory.

Answers were Sorted based on User's Feedback



U have an array of +ve integers arranged in the descending order . Write a functionb thast take an..

Answer / argho

function desc
begin
Ineger i;
Array a[n];
x=1;
y=n;

1. for k=1 , loop from x to y while array[n] / 2;

temp[a]= a[n]/2

if temp[a] < i
call step 1 with argument x=1 y=n/2
else if temp[a] > i
call step 1 with argument x=(n/2)+1 y=n
else
return position
end

Is This Answer Correct ?    4 Yes 0 No

U have an array of +ve integers arranged in the descending order . Write a functionb thast take an..

Answer / siddarth pillai

public class Test
{
public static void main(String args[])
{
int[] arr = {99,56,31,22,17,11,9,2};
int no=11;

int position = checkPos(arr,no);

if(position == -1)
System.out.println("No such number exists in the array.");
else
System.out.println("Number "+no+" is at position "+position);
}
public static int checkPos(int[] arr,int no)
{
int first = 0;
int last = arr.length;
int mid = (first+last)/2;
int LoopCount = 0;
int MaxLoopCount = arr.length/2;

System.out.println("first : "+first+" last : "+last+" mid : "+mid);

while((arr[mid]!=no) && (LoopCount<MaxLoopCount))
{
if(no>arr[mid])
{
first = 0;
last = mid;
mid =(first+last)/2;
System.out.println("first : "+first+" last : "+last+" mid : "+mid);
}
else if(no<arr[mid])
{
last=arr.length;
first = mid;
mid =(first+last)/2;
System.out.println("first : "+first+" last : "+last+" mid : "+mid);
}
LoopCount++;

}
if(no == arr[mid])
return mid;
else
return -1;

}
}

Is This Answer Correct ?    2 Yes 0 No

U have an array of +ve integers arranged in the descending order . Write a functionb thast take an..

Answer / sonu

int array[]={13,232,234,12,34,56,73,21,230,240};
int max ;
max = 230;
for (int i=1;i<array.length;i++){
if (array[i]==max ){
System.out.println
("Position of no"+max +"in array is "+i);
}else {
System.out.println("-1");
}
}

Is This Answer Correct ?    2 Yes 12 No

Post New Answer

More Everything Else AllOther Interview Questions

There is a 20 X 20 array. In Each row , the tallest person is called and among them, the tallest person is A. In Each column, the shortest person is called and among them, the shortest person is B. Who is taller?

0 Answers   Deloitte,


lovers love it. friends need it. relationship start with it. and life ends with it.

0 Answers  


How many pages are in 1 coil?

0 Answers  


hi friends, i hav a basic question dat which kind of questions vil com under aptitude test part. pls answer me. i got d call letter for interview for apgvb. dis is d first interview for me i dont know how to face it n i am a bit tensed. pls help me.

0 Answers  


Can someone please help me out with interview Questions for SBI management executive exam? Is it expected to be same as SBI PO Interview, or it is expected to be a higher level interview? Please guide. Thanks in advance.

0 Answers   State Bank Of India SBI,


I am a service provider under the category of Custom House Agent. During the course of service I have to make some payments against specific shipments in account of client; the bills by other service providers port authority are raised against and in the name of the client whereas in some case(s) i have make payment as a facilitator on behalf of the client. Do I have to deduct tds on such payments which in fact are not my expediture as such payments are re- imbursed by the client.

2 Answers  


hr ask to me a question why u join a small company or a MNC company .just i m give the hr interview of a smaal company.

0 Answers  


i hav ea discripency arisin gin my ca registration for pcc course the employer under whom i am employed doesnot have seat to absorb me as an article so if i take a fresh registration then what will be the date of commencement of articleship?

0 Answers  


HAI FRIENDS DO NOT WORRY ABOUT THE SBI CLERK INTERVIEW, THEY WON'T ASK GK, CURRENT EVENTS, AND ALL. THEY ASK ABOUT SBI'S PRODUCTS, WHO IS THE CHAIRMAN OF SBI, IF YOU ARE IN JOB THEY WILL ASK ABOUT THAT DEPARTMENT. AS I WAS IN THE POSTAL DEPARTMENT I WAS ASKED ABOUT THE SB,RD, MIS, TD, SCSS, PPF A/C'S , NSC, KVP. THEY ASKED ABOUT MUTUAL FUNDS TIE UP OF SBI WITH THE DEPARTMENT . THATS ALL

0 Answers   State Bank Of India SBI,


hi, i have completed my 2 yr BE.i have got a job in IOB is there any way to continue my studies in correspondence course..

0 Answers  


what are the questions asked by interviewer for the post of logistics executive?

0 Answers  


What are the duties of an Assistant in Ministries?

0 Answers  


Categories