# Swapping ints 2 We know that the insertion sort algorithm has a worth-case running time of $O(n^{2})$ in general case. What if we could bound the algorithm for specific instance of the problem. One way to do that is by checking the number of swap operations needed by insertion algorithm to sort a list.

In the permutation of $a_{1}\cdots a_{n}$ of $n$ distinct elements the list inversion are pair of elements $(a_{i},a_{j})$ such that $i and $a_{i} > a_{j}$. What is the worst-case running time if the inputs are restricted to permutations of $1\cdots n$ with at most $n$ inversions?

×
{"ft_lang_label":"__label__en","ft_lang_prob":0.89541733,"math_prob":0.999086,"size":647,"snap":"2019-51-2020-05","text_gpt3_token_len":132,"char_repetition_ratio":0.11041991,"word_repetition_ratio":0.11214953,"special_character_ratio":0.20401855,"punctuation_ratio":0.15151516,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9998964,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-01-25T15:54:25Z\",\"WARC-Record-ID\":\"<urn:uuid:cb608895-e1a4-4779-9e2e-9077a7df8b9d>\",\"Content-Length\":\"51052\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:3c5996c6-3ea4-4da6-93bf-74b37af61c3e>\",\"WARC-Concurrent-To\":\"<urn:uuid:94b76b5b-43ad-4405-aaae-7e7b2ded343c>\",\"WARC-IP-Address\":\"104.20.34.242\",\"WARC-Target-URI\":\"https://brilliant.org/problems/swapping-ints-2/\",\"WARC-Payload-Digest\":\"sha1:LPUADHMWSTRR3F7YPGKO4NLLRZ7OKN5Y\",\"WARC-Block-Digest\":\"sha1:EF4V2L5NUGPG2W3R7GT5B4ZLZTCVDNPT\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-05/CC-MAIN-2020-05_segments_1579251672537.90_warc_CC-MAIN-20200125131641-20200125160641-00103.warc.gz\"}"}