Tagged: Search

Binary Search

One of the most interesting algorithms of research is binary search algorithm. This is the fastest algorithm (algorithm of binary trees apart) to search a data inside a group of elements. In fact it runs in a worst log2(x) comparisions before to find (or not) the data. The only prerequisite is : the set of elements where to search the data must be sorted. Below an example of this algorithm. int binary_search( int arr[], int tot_el, int data ) { /* Declaration and initialization of variables */ int el = 0; int me = 0; int count = 0; /*...

Search records and null

Find in a table, for any field of the table, how many records are NULL, and of these NULL how many separate by values of another field of the same table. Example result: TAB_NAME                      COL_NAME                      NUM_ROWS                   NUM_NULLS_TOT       NUM_NULLS_X_COLVAL               COLVAL_LE_ID ————————————————————————————- S_REPORT                        S_TAX_BRACKET_CD                        7111600   7111599   2470            631 S_REPORT                        S_TAX_BRACKET_CD                        7111600   7111599   57859         FC222200 S_REPORT                        S_TAX_BRACKET_CD                        7111600   7111599   3038882   Z2030 S_REPORT                        S_TAX_BRACKET_CD                        7111600   7111599   4012388   C8101   The S_REPORT table has 7111600 rows and has a column name S_TAX_BRACKET_CD that has 7111599 NULL rows. The S_REPORT table also has a column name LE_ID which its value are 631, FC222200, Z2030 e C8101....