answersLogoWhite

0

(i) Binary search can interact poorly with the

memory hierarchy (i.e. caching), because of its

random-access nature. For in-memory

searching, if the interval to be searching is

small, a linear search may have superior

performance simply because it exhibits better

locality of reference.

(ii) Binary search algorithm employs recursive

approach and this approach requires more stack

space.

(iii) Programming binary search algorithm is

very difficult and error prone (Kruse, 1999).

User Avatar

Wiki User

12y ago

What else can I help you with?

Continue Learning about Engineering

What are the advantages and disadvantages of searching in C programming?

If the data is sorted and every element is directly accessible, then you can perform binary search (see built-in function bsearch), otherwise you have to do linear search (which is slower).


Best first search program in c?

The best search programs to attempt writing in C are the following: Linear search (simplest), Binary search (faster) Hash search (fastest).


Write a c program for binary searching?

/* C program for binary search: This code implements binary search in */ /* C language. It can only be used for sorted arrays, but it's fast as */ /* compared to linear search. If you wish to use binary search on an */ /* array which is not sorted then you must sort it using some sorting */ /* technique say merge sort and then use binary search algorithm to */ /* find the desired element in the list. If the element to be searched */ /* is found then its position is printed. */ #include<stdio.h> main() { int c, first, last, middle, n, search, array[100]; printf("Enter number of elements\n"); scanf("%d",&n); printf("Enter %d integers\n", n); for ( c = 0 ; c < n ; c++ ) scanf("%d",&array[c]); printf("Enter value to find\n"); scanf("%d",&search); first = 0; last = n - 1; middle = (first+last)/2; while( first <= last ) { if ( array[middle] < search ) first = middle + 1; else if ( array[middle] == search ) { printf("%d found at location %d.\n", search, middle+1); break; } else last = middle - 1; middle = (first + last)/2; } if ( first > last ) printf("Not found! %d is not present in the list.\n", search); return 0; }


How do you convert A B C in binary code?

A = 1010 b = 1011 c = 1100


How do you write a c program to convert binary to decimal by using while statement?

write a c++ program to convert binary number to decimal number by using while statement

Related Questions

What are the advantages and disadvantages of searching in C programming?

If the data is sorted and every element is directly accessible, then you can perform binary search (see built-in function bsearch), otherwise you have to do linear search (which is slower).


Best first search program in c?

The best search programs to attempt writing in C are the following: Linear search (simplest), Binary search (faster) Hash search (fastest).


How do you run graphics program in C?

pro c language to implement linear search using pointers


What is binary search in data structure using c?

a tree which has atmost two nodes is called binary tree binary search tree is a binary tree which satisfies the following 1.every node in tree must be distinct 2.values in right subtree > value at root 3.values in left subtree < value at root 4.left,right subtrees must be binary search trees


How do you represent binary search and linear search in graphics using c plus plus?

Linear search usually implies the data sequence is in an unsorted order or does not provide random access iterators (such as a list). Essentially you start from the beginning and traverse through each element until you find the element you are looking for, or reach the "one-past-the-end" iterator (which means the value does not exist). With binary search you use a sorted sequence, such as a sorted array. You start in the middle of the sequence. If the value is not there, you know which half of the array the value must be in, so you start in the middle of that half. By eliminating half the array (or sub-array) each time you will either find the value or you end up with an empty sub-array (which means the value does not exist). You can also use binary search on a binary tree which achieves the same thing, but the tree must be perfectly balanced (such as a red/black tree) to be of benefit.


Write a program of binary heap in c or c language?

to implement operations on binary heap in c


Give you the algorithm of creating a new binary search tree using c?

i want to know how to give the algorithm password in a computer ?


Write a c program for binary searching?

/* C program for binary search: This code implements binary search in */ /* C language. It can only be used for sorted arrays, but it's fast as */ /* compared to linear search. If you wish to use binary search on an */ /* array which is not sorted then you must sort it using some sorting */ /* technique say merge sort and then use binary search algorithm to */ /* find the desired element in the list. If the element to be searched */ /* is found then its position is printed. */ #include<stdio.h> main() { int c, first, last, middle, n, search, array[100]; printf("Enter number of elements\n"); scanf("%d",&n); printf("Enter %d integers\n", n); for ( c = 0 ; c < n ; c++ ) scanf("%d",&array[c]); printf("Enter value to find\n"); scanf("%d",&search); first = 0; last = n - 1; middle = (first+last)/2; while( first <= last ) { if ( array[middle] < search ) first = middle + 1; else if ( array[middle] == search ) { printf("%d found at location %d.\n", search, middle+1); break; } else last = middle - 1; middle = (first + last)/2; } if ( first > last ) printf("Not found! %d is not present in the list.\n", search); return 0; }


Is c plus d squared equals 36 linear or nonlinear?

It is linear in c and non-linear in d. If both c and d are variables, then it is non-linear.


What pairs names two methods of sexual reproduction a meiois and binary dission b mitosis and meiosis c mitosis and binary fission?

mitosis and binary fission


What is a linear function?

A function of the form f(x) = mx + c where m and c are constants is linear.


Is there an instance that a linear equation is not a function?

There is one form of linear equation that is not a function, and that is when x = c, where c is a constant.