Receive integers one by one (in sorted order) and create an array over which binary searches are performed. More...
#include <malloc.h>
#include <string.h>
#include "report.h"
Functions | |
void | construct (int n) |
Method to construct the initial search structure to contain 'sz' elements. | |
void | insert (int value) |
Method to insert an integer element into the search structure. | |
int | search (int target, int(*cmp)(const int, const int)) |
Method to search for an integer element in the search structure. | |
Variables | |
static int * | ar |
Ultimate storage destination of elements in an array. | |
static int | idx = 0 |
Current location into which element is to be inserted. | |
static int | num = 0 |
Size of the element storage, ar. |
Receive integers one by one (in sorted order) and create an array over which binary searches are performed.
void construct | ( | int | n | ) |
Method to construct the initial search structure to contain 'sz' elements.
Allocate space for an array of integers.
void insert | ( | int | value | ) |
Method to insert an integer element into the search structure.
These are handed to us in source order, so we simply place the integer in the next slot location.
value | Value to be inserted. |
int search | ( | int | target, | |
int(*)(const int, const int) | cmp | |||
) |
Method to search for an integer element in the search structure.
target | the desired target | |
cmp | the comparison function between two string elements. |
int* ar [static] |
Ultimate storage destination of elements in an array.
int idx = 0 [static] |
Current location into which element is to be inserted.
int num = 0 [static] |
Size of the element storage, ar.
Algorithm Development Kit 1.0