# Amortized analysis using potential function [Exercise from *Introduction to Algorithms*]

I need some help with the following problem from Introduction to Algorithms by Cormen, Leiserson, Rivest, Stein:

Consider an ordinary binary min-heap data structure with $n$ elements that supports the instructions INSERT and EXTRACT-MIN in $O(\lg n)$ worst-case time. Give a potential function $\Phi$ such that the amortized cost of INSERT is $O(\lg n)$ and he amortized cost of EXTRACT-MIN is $O(1)$, and show that it works.

I'm not sure how to define the potential here. Especially since everything looks so "symmetric".

I mean, I get that one can only do as many EXTRACT-MIN operations as one does INSERT operations, and so if we have $k$ INSERT operations and $\ell$ EXTRACT-MIN operations total, then the time this takes is surely not bigger than doing the INSERT first and the EXTRACT-MIN operations later. And so I guess, the time for all operations is

$$\begin{align} t(k+\ell) &\le (\lg 1 + \lg 2 + \dots + \lg k) + (\lg k + \lg (k-1) + \dots + \lg (k-\ell+1)) \\ &= 2\lg k! - \lg \ell! \\ &= O(k\lg k) \end{align}$$

Hence we can assign $O(\lg k)$ to every insert operation and $O(1)$ to every EXTRACT-MIN operation (?).

So the result at least makes some sense. But I still don't know how to do it formally using a potential.

Thanks for your help! =)

-
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 9, "mathjax_display_tex": 1, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": false}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9369534850120544, "perplexity_flag": "middle"}