should we use linear search or binary search if elements
are placed in random order or mixed?in both cases? i need a
little bit detail ans?thnks

Answers were Sorted based on User's Feedback



should we use linear search or binary search if elements are placed in random order or mixed?in bo..

Answer / indira

We have to use Linear Search only when elms r in random or
mixed .
In order to use Binary Search u have to sort these elems
whose order of complexity is n2.
so its better to use linear search whose complexity is of o(n)

Is This Answer Correct ?    14 Yes 1 No

should we use linear search or binary search if elements are placed in random order or mixed?in bo..

Answer / pavan

binary search tecqnique is applicable only to sorted
elements because we find the mid value and then cmp it with
the key and if the key is greater than the mid value then
we scan on towards the right else towards the left
so,hencefort itwe should make use of linear search when the
elements r not sorted

Is This Answer Correct ?    8 Yes 0 No

Post New Answer

More OOPS Interview Questions

to remove the repeated numbers from the given . i.e.., if the input is 12233 output should of 123

2 Answers  


1.explicit call for destructor 2.calling function inside a constructor. 3.base *b-new derived delete b; 4.delete p what it will delete. 5.size of base class and derived class int i,in base class and int j in derived. 6.int i-20 int main() { int i =5; printf("%d".::i); { int i =10; printf("%d".::i); } } 7.object slicing 8.new 9.function overloading(return type). 10.class base() { virtuval fun() { ----- } } class derivied:public base() { fun() { ----- } } int main() { derived d; } 11.how static function will call in C++? 12.default structures are in C++? 13.constructors should be in public . 14.virtuval constructor not exist. 15.multilevel inhritence. destructor order.

1 Answers   Tech Mahindra,


Can a destructor be called directly?

0 Answers  


IS IT NECESSARY TO INITIALIZE VARIABLE? WHAT IF THE INSTANCE VARIABLE IS DECLARED final ? IS IT NECESSARY TO INITIALIZE THE final VARIABLE AT THE TIME OF THEIR DECLARATION?

0 Answers  


what is abstract class ? when is used in real time ? give a exp

5 Answers  






What is polymorphism and types?

0 Answers  


What is function overloading and operator overloading?

4 Answers  


Which is the parameter that is added to every non-static member function when it is called?

3 Answers   Accenture,


What is abstraction in oop with example?

0 Answers  


What is difference between #define and const?

3 Answers   emc2,


What is destructor give example?

0 Answers  


What does the keyword "static" mean?

4 Answers   TCS,


Categories