Given that we have $N$ consecutive structures that can have a maximum height of $H$, where the individual height $h_i$ depends on random coin flips (for each structure, an additional height has a probability of 0.5. The probability is given by $p(h_i=x) = 0.5^{x + 1}$, except when $x=H$, then we get $p(h_i=x)=0.5^H$
Now I want to know, given $H$, what is the probability of having a random set of $N$ structures, where each structure is followed by another structure with the same height or less?
Visual Representation
Probabilities and possible structures
+---+ +---+ +---+ +---+
0.5^x H | | | | | | ... | |
+---+ +---+ +---+ +---+
... ... ... ...
+---+ +---+ +---+ +---+
0.0625 3 | | | | | | ... | |
+---+ +---+ +---+ +---+
0.125 2 | | | | | | ... | |
+---+ +---+ +---+ +---+
0.25 1 | | | | | | ... | |
+---+ +---+ +---+ +---+
0.5 0 | | | | | | ... | |
+---+ +---+ +---+ +---+
p(h_i=x) h_i 1 2 3 ... N
Structures that satisfy the search criteria
with N = 3, H = 2 (the zero height-level is always present)
(1)
+---+ +---+ +---+
| | | | | |
+---+ +---+ +---+
| | | | | |
+---+ +---+ +---+
| | | | | |
+---+ +---+ +---+
(2)
+---+
| |
+---+ +---+
| | | |
+---+ +---+ +---+
| | | | | |
+---+ +---+ +---+
(3)
+---+
| |
+---+
| |
+---+ +---+ +---+
| | | | | |
+---+ +---+ +---+
(4)
+---+ +---+ +---+
| | | | | |
+---+ +---+ +---+
...
Structures that do not satisfy the search criteria
N = 3, H = 2 (again, the zero-level is present for all structures)
(1)
+---+ +---+
| | | |
+---+ +---+ +---+
| | | | | |
+---+ +---+ +---+
| | | | | |
+---+ +---+ +---+
(2)
+---+
| |
+---+ +---+
| | | |
+---+ +---+ +---+
| | | | | |
+---+ +---+ +---+
(3)
+---+
| |
+---+ +---+
| | | |
+---+ +---+ +---+
| | | | | |
+---+ +---+ +---+
(4)
+---+
| |
+---+ +---+ +---+
| | | | | |
+---+ +---+ +---+
...
Partial Solution
To my understanding (not a math-major), the first part (all structures having the same height-level) can be calculated by
$$ p(\mbox{all same level}) = \sum_{i=1}^H 0.5^{i*n} $$
But I fail to see a possibility to calculate the second part (structures with decreasing levels). Any help is greatly appreciated.
Background
The solution to this problem finds the probability of having a Skip List with the worst setup, resulting in a search-time of $O(n)$ instead of $O(log(n))$ (and thus also an insertion- and deletion time of $O(n)$).
Edit/Addition: Building the levels of the Structures
As there are some discussions in the comments, I wanted to elaborate on the process that determines the height of each structure.
The general idea is to toss a coin multiple times. If we get heads (1) that means we add a level, if we get tails (0) that means we leave the structure at the current level and move to the next structure.
In pseudo-code, we would express the algorithm like this
lvl = 0
while coin_flip() == heads:
lvl = lvl + 1
Addition 2: Sampled probabilities
Inspired by Jens code, I wrote my own c++-function that runs 1mil. simulations per setting and computes the probabilities. You can run the code and experiment with it here: http://cpp.sh/5vtpl (alternative link at GitHub Gist).
So far I have gotten the following results
Running 1000000 simulations each:
-----------------------------------
N = 2 & H = 3 | chance = 0.671773
N = 3 & H = 3 | chance = 0.387352
N = 4 & H = 3 | chance = 0.208013
N = 5 & H = 3 | chance = 0.107015
N = 6 & H = 3 | chance = 0.054868
N = 7 & H = 3 | chance = 0.027476
N = 8 & H = 3 | chance = 0.013878
N = 9 & H = 3 | chance = 0.006773
N = 10 & H = 3 | chance = 0.003364
N = 11 & H = 3 | chance = 0.001791
N = 12 & H = 3 | chance = 0.000869
N = 13 & H = 3 | chance = 0.000439
N = 14 & H = 3 | chance = 0.000218
N = 15 & H = 3 | chance = 0.000139
N = 16 & H = 3 | chance = 0.000047
N = 17 & H = 3 | chance = 0.000022
N = 18 & H = 3 | chance = 0.000013
N = 19 & H = 3 | chance = 0.000009
