{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv id\u003d\"yass_top_edge_dummy\" style\u003d\"width: 1px; height: 1px; padding: 0px; margin: -9px 0px 0px; border-width: 0px; display: block;\"\u003e\r\n\t\u0026nbsp;\u003c/div\u003e\r\n\u003cdiv id\u003d\"yass_top_edge\" style\u003d\"background-image: url(\u0026quot;chrome://yass/content/edgebgtop.png\u0026quot;); background-attachment: scroll; background-position: center bottom; padding: 0px; margin: 0px 0px 8px -8px; border-width: 0px; height: 0px; display: block; width: 1px;\"\u003e\r\n\t\u0026nbsp;\u003c/div\u003e\r\n\u003cstyle type\u003d\"text/css\"\u003e\r\nh1,h2,h3,h4,h5,h6{margin-bottom:0;}div.textBG p{margin: 0 0 0.0001pt;}\u003c/style\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003cp\u003e\r\n\tSorting in computer science is an important part. Almost every problem can be solved \u003cspan data-scayt_word\u003d\"effeciently\" data-scaytid\u003d\"1\"\u003eeffeciently\u003c/span\u003e if sorted data are found. There are some excellent sorting algorithm which has already \u003cspan data-scayt_word\u003d\"acheived\" data-scaytid\u003d\"2\"\u003eacheived\u003c/span\u003e the lower bound \u003cspan data-scayt_word\u003d\"nlgn\" data-scaytid\u003d\"3\"\u003enlgn\u003c/span\u003e. In this problem we will also discuss about a new sorting approach. In this approach only one operation ( Flip ) is available and that is you can exchange two adjacent terms. If you think a while, you will see that it is always possible to sort a set of numbers in this way.\u003c/p\u003e\r\n\u003ch2\u003e\r\n\t\u003cfont color\u003d\"#0070E8\"\u003e\u003ca name\u003d\"SECTION0001002000000000000000\"\u003eThe Problem\u003c/a\u003e\u003c/font\u003e\u003c/h2\u003e\r\n\u003cp\u003e\r\n\tA set of integers will be given. Now using the above approach we want to sort the numbers in ascending order. You have to find out the minimum number of flips required. Such as to sort \u0026quot;1 2 3\u0026quot; we need no flip operation whether to sort \u0026quot;2 3 1\u0026quot; we need at least 2 flip operations.\u003c/p\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003ch2\u003e\r\n\t\u003cfont color\u003d\"#0070E8\"\u003e\u003ca name\u003d\"SECTION0001003000000000000000\"\u003eThe Input\u003c/a\u003e\u003c/font\u003e\u003c/h2\u003e\r\n\u003cp\u003e\r\n\tThe input will start with a positive integer N ( N\u0026lt;\u003d1000 ). In next few lines there will be N integers. Input will be terminated by \u003cspan data-scayt_word\u003d\"EOF\" data-scaytid\u003d\"4\"\u003eEOF\u003c/span\u003e.\u003c/p\u003e\r\n\u003ch2\u003e\r\n\t\u003cfont color\u003d\"#0070E8\"\u003e\u003ca name\u003d\"SECTION0001004000000000000000\"\u003eThe Output\u003c/a\u003e\u003c/font\u003e\u003c/h2\u003e\r\n\u003cp\u003e\r\n\tFor each data set print \u0026quot;Minimum exchange operations : M\u0026quot; where M is the minimum flip operations required to perform sorting. Use a \u003cspan data-scayt_word\u003d\"seperate\" data-scaytid\u003d\"6\"\u003eseperate\u003c/span\u003e line for each case.\u003c/p\u003e\r\n\u003ch2\u003e\r\n\t\u003cfont color\u003d\"#0070E8\"\u003e\u003ca name\u003d\"SECTION0001005000000000000000\"\u003eSample Input\u003c/a\u003e\u003c/font\u003e\u003c/h2\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003cpre\u003e\r\n3 \r\n1 2 3\r\n3\r\n2 3 1\r\n\u003c/pre\u003e\r\n\u003ch2\u003e\r\n\t\u003cfont color\u003d\"#0070E8\"\u003e\u003ca name\u003d\"SECTION0001006000000000000000\"\u003eSample Output\u003c/a\u003e\u003c/font\u003e\u003c/h2\u003e\r\n\u003cp\u003e\r\n\t\u0026nbsp;\u003c/p\u003e\r\n\u003cpre\u003e\r\nMinimum exchange operations : 0\r\nMinimum exchange operations : 2\r\n\u003c/pre\u003e\r\n\u003cpre\u003e\r\n\u003c/pre\u003e\r\n\u003chr /\u003e"}}]}