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

explain sub-type and sub class? atleast u have differ it into 4 points?

0 Answers   Infosys,


What is Hashing and how is it done? Pictorial form?

2 Answers   emc2, Wipro,


What is Virtual Keyword?

9 Answers   IBM, NA,


all about pointers

2 Answers  


When is a memory allocated to a class?

11 Answers  






What is the difference between inheritance and polymorphism?

0 Answers  


Write A Program to find the ambiguities in Multiple Inheritance? How are they resolved.(Virtual Functions)

0 Answers   Accenture,


Give two or more real cenario of virtual function and vertual object

0 Answers   TCS,


Why we are use # in begning of programme of c++.

2 Answers   Syntel,


#include <iostream> using namespace std; int main() { int a = 3; int c[5][5]; for (int x=0;x<5;x++) { for (int y=0;y<5;y++) { c[x][y] = x*y; } } cout << c[a][2]; }

1 Answers  


what is the 3 types of system development life cycle

0 Answers  


me get an assignent n its question is this 1.creat a set as in math i.ea={1,2} 2.insert element in it3. delete element don,t repeat any element 4.union 5. intersection of two sets plz help me i always pray for u n send me at ayeshawzd@hotmail.com f u have c++ how to program 5th addition then it is the 10.9 question in 10th chapter exercise

1 Answers  


Categories