|
Algorithms_in_C 1.0.0
Set of algorithms implemented in C.
|
#include <assert.h>#include <inttypes.h>#include <stdio.h>Macros | |
| #define | ELEMENT -10 |
| for assert | |
Functions | |
| int64_t | binary_search (const int64_t *arr, const uint16_t l_index, const uint16_t r_index, const int64_t n) |
| used to perform the binary search over the given array | |
| int64_t | exponential_search (const int64_t *arr, const uint16_t length, const int64_t n) |
| used to perform the exponential search over the given array | |
| static void | test () |
| used to run the self-test implementations | |
| int | main () |
| Main function. | |
| #define ELEMENT -10 |
for assert
for int64_t, uint16_t for printf
| int64_t binary_search | ( | const int64_t * | arr, |
| const uint16_t | l_index, | ||
| const uint16_t | r_index, | ||
| const int64_t | n | ||
| ) |
used to perform the binary search over the given array
Function: binary_search.
algorithm that search the index of the given item
recursive function that search the given element in
| arr | array where search the element |
| l_index | start index of the array (arr) to apply the algorithm |
| r_index | end index of the array (arr) to apply the algorithm |
| n | element to find in the array (arr) |
| int64_t exponential_search | ( | const int64_t * | arr, |
| const uint16_t | length, | ||
| const int64_t | n | ||
| ) |
used to perform the exponential search over the given array
Function: exponential_search.
algorithm that search the index of the given item
recursive function that take an array and quickly find the range
| arr | array where search the element |
| length | the total length of the given array (arr) |
| n | element to find in the array (arr) |
| int main | ( | void | ) |
|
static |
used to run the self-test implementations
Self-test implementations.