This article provides a detailed analysis of the time complexity of skip lists. By breaking down the search problem, reversing the entire search process, and finding an appropriate L level, it ultimately derives the time complexity of skip lists. Based on the understanding of time complexity, it further deduces how to choose the probability p, and the reasons for choosing the maximum height in Redis and LevelDB skip lists. Finally, it tests the performance of skip lists through a simple benchmark and compares it with unordered_map.
1 comment
[ 3.3 ms ] story [ 10.5 ms ] thread