Oct 8, 2014

Shell sort

12:37 AM Posted by Unknown , No comments
//Tool: Dev C++  #include <iostream> void ShellSort( int array[], int gap, int len ); int main( void ) { int len; //int array[]= { 8, 3, 7, 9, 1, 24, 2 }; int array[]= { 42, 20, 17, 13, 28, 14, 23, 15 }; len= sizeof( array )/ sizeof( array[ 0 ] ); for( int gap= len/ 2; gap> 0; gap/= 2 ) { ShellSort( array, gap, len ); } return 0; } void ShellSort( int array[], int gap,...

Oct 7, 2014

Select sort

8:10 PM Posted by Unknown , No comments
//Tool: Dev C++ #include <iostream> void SelectSort( int array[], int len ); int main( void ) { int array[] = { 42, 20, 17, 13, 28, 14, 23, 15 }; int len; len= sizeof( array )/ sizeof( array[ 0 ] ); SelectSort( array, len ); return 0; } void SelectSort( int array[], int len ) { int temp; int min; for( int i= 0; i< len; i++ ) { min= array[ i ]; for( int j= i+ 1; j<...

Insert sort( 2 )

7:57 PM Posted by Unknown , No comments
//Tool: Dev C++ #include <iostream> void InsertSort( int len, int array[] ); int main( void ) {  int array[] = { 42, 20, 17, 13, 28, 14, 23, 15 };  int len= 0;   len= sizeof( array )/ sizeof( array[ 0 ] );   InsertSort( len, array );   return 0; } void InsertSort( int len, int array[] ) {  int temp;   for( int i= 0; i< len; i++ )  {  ...

Oct 6, 2014

Binary search

7:56 PM Posted by Unknown , No comments
//Functin: binary search //Tool: Dev C++ //notes: first, bubble sort //       second, binary search #include <iostream> void bin_search( int array[], int low, int high, int key ); void bubble_sort( int array[], int len ); int main( void ) { int array[]= { 4, 6, 22, 66, 43, 23, 90, 65, 42 }; int key; int low; int high; key= 90; high= sizeof( array )/ sizeof( array[ 0...