diff --git a/The Last Algorithms Course You'll Need/5. Two Crystal Balls.c b/The Last Algorithms Course You'll Need/5. Two Crystal Balls.c index d3501c2..af60ea9 100644 --- a/The Last Algorithms Course You'll Need/5. Two Crystal Balls.c +++ b/The Last Algorithms Course You'll Need/5. Two Crystal Balls.c @@ -1,6 +1,19 @@ #include #include +// complexity is O(sqrt(N)) +// well we need ot find an exact moment, +// let's say "height" at which our crystal +// balls break, for that we only have 2 balls, +// so we can't do binary search, since the range +// is tooooo huge, therefore we run a linear +// growth bigger than N, but small enough to find where +// the first ball breaks, then we take the interval +// between: [the previous non-break] and [where it broken] +// and run a normal linear search +// therefore we run sqrt(n) + sqrt(n) times +// so it's O(sqrt(N) + #define SIZE 999 int two_crystal_balls_search(int array[], int size, int value)