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

Does anyone know some strategies for the free android game Grand Battle? Need you help!! I really love the game Grand Battle, and I fell excited when I defeat the enemies and protect my base as a commander. Now I think I need some strategies to improve my performance and to lead a strong army, could anyone help me? Thank you so much!

1 Answers  


discuss the early formation of Northern NGOs and critically outline their main areas of concentration

0 Answers  


how many name can u make of this ' Hena'

1 Answers  


What is the stock exchange name of China?

4 Answers   ICICI,


can insert multiple value in sqlplus after create a new table? if yes then how?

0 Answers  


i cleared the sept IBPS, and have applied for the interviews..please guide me on what type of questions might be asked by the panel...what dress code should i follow?

0 Answers   IBPS,


39. In the following sentence, “famous” is the complement. What kind of complement is it? “In 1975, Margaret Thatcher became famous as the first woman leader of the British Conservative Party." (1 point) A. predicate adjective B. direct object C. predicate nominative D. indirect object 40. Choose the answer that correctly identifies the underlined word. “The ice fields of the north are still relatively barren.” (1 point) A. direct object B. indirect object C. predicate nominative D. predicate adjective 41. Choose the answer that correctly identifies the underlined word. "The grain of the western prairies is a major source of income." (1 point) A. direct object B. indirect object C. predicate nominative D. predicate adjective 42. Choose the answer that correctly identifies the underlined word. “Western Canada also gives us the art of the Kwakiutl Indians.” (1 point) A. direct object B. indirect object C. predicate nominative D. predicate adjective 43. In the following sentence, what kind of phrase is “to play basketball”? “Porpoises have been trained to play basketball.” (1 point) A. prepositional B. participial C. infinitive 44. In the following sentence, what kind of phrase is “to the library”? “I will be going to the library soon.” (1 point) A. prepositional B. participial C. infinitive D. gerund 45. In the following sentence, what kind of phrase is “Moving away”? “Moving away made my little cousin sad.” (1 point) A. prepositional B. gerund C. infinitive D. participial 46. What is the tense of the underlined verb in the following sentence? “I will be studying his painting techniques this summer.” (1 point) A. present emphatic B. present perfect progressive C. future progressive D. present progressive 47. What is the verb mood of the sentence? Wear your coat when you are in the snow. (1 point) A. indicative mood B. imperative mood C. subjunctive mood

1 Answers   College School Exams Tests,


What is the colour of Black box

3 Answers  


differences between indians and americans

0 Answers  


i am an electrical engineering student(2nd year),is in plant training necessary at the end of 2nd year?what is correct time?where should i do in-plant?

0 Answers  


Hi every buddy my name is phani kumar Really i have a big problem u guys should help me regarding this thing .My Friend attended for vizag Magament Trainee but the thing is he forgot the hallticket number and registration number papers .is there any chance to get the hall ticket number?

0 Answers  


What is the importance of technology in studies?And how much?

1 Answers   Wipro,


Categories