A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/d8/d8a/exponential__search_8cpp_source.html below:

TheAlgorithms/C++: search/exponential_search.cpp Source File

Go to the documentation of this file. 34inline

Type*

binary_s

(Type* array,

size_t

size, Type key) {

35

int32_t lower_index(0), upper_index(size - 1), middle_index;

37 while

(lower_index <= upper_index) {

38

middle_index = std::floor((lower_index + upper_index) / 2);

40 if

(*(array + middle_index) < key)

41

lower_index = (middle_index + 1);

42 else if

(*(array + middle_index) > key)

43

upper_index = (middle_index - 1);

45 return

(array + middle_index);

60

uint32_t block_front(0), block_size = size == 0 ? 0 : 1;

61 while

(block_front != block_size) {

62 if

(*(array + block_size - 1) < key) {

63

block_front = block_size;

64

(block_size * 2 - 1 < size) ? (block_size *= 2) : block_size = size;

67 return binary_s<Type>

(array + block_front, (block_size - block_front),

76 int

* sorted_array =

new int

[7]{7, 10, 15, 23, 70, 105, 203};

82 delete

[] sorted_array;

Type * binary_s(Type *array, size_t size, Type key)

Type * struzik_search(Type *array, size_t size, Type key)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4