Skip to main content

Posts

Featured

Program 1 linear and binary search by user choice

Search #include <iostream> using namespace std ; template < class T > void lsearch ( T a , T arr [ 20 ]) { T search , count = 0 ; T n = a ; cout << "Enter the element to be searched" << endl ; cin >> search ; //int abc[5]; for ( int i = 0 ; i < n ; i ++ ) { if ( arr [ i ] == search ) { cout << search << " found at location " << ( i + 1 ) << endl ; count ++ ; } /* code */ } if ( count == 0 ) { cout << search << " not found" << endl ; /* code */ } } template < class R > void bsearch ( R b , R abc [ 20 ]) { R search , n , last = 0 , mid , first = 0 ; n = b ; cout << "Enter the element to be searched: " << endl ; cin >> search ; last = n - 1 ; while ( first <= last ) { mid

Latest posts

linear search in c++

Image

Alphabet M shape Pattern in java

Image

Bubble sort in java

Image

Alphabet Y pattern in java

Image

Concatenation of number in java

Image

Trimorphic Number in java

Image

Number Palindrome in java

Image

Palindrome of string in java

Image

concatenation in java

Image

Alphabet N pattern in java