0

sorting code

Can anyone help me to write a code which requires next let's imagine that on the Street there are living boys and girls let girls be equal to 1 and boys equal to 2 we need to write in, with cin, how many girls and boys we have (number must be less then 10000) end the program must count how many steps does it need to sort this code that from the one beginning of the street there are only girls and from the other beginning of the street only Boys so basically numbers 1 and 2 need to be sorted and the program must count how many steps do we need for this sorting

10th Dec 2018, 6:06 PM
Nika Machitidze
Nika Machitidze - avatar
6 Answers
+ 1
Can you show us what you have come up to?
10th Dec 2018, 6:22 PM
Diego
Diego - avatar
0
For the moment I have no idea how can I count how many steps were done during sorting, sorting part is not very hard there are many different sorting algorithms what I cannot do is to count how many steps were done to sort code for example ( 1 2 2 1 2 1 2 1 1 2 1 2 2 2 1 1 2 2 ) after sorting it will be ( 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 ) and if I counted right in most optimised way we need 4 steps to sort these numbers, but it's not necessary to be most optimised way
10th Dec 2018, 6:53 PM
Nika Machitidze
Nika Machitidze - avatar
0
Finding the most optimized way of sorting a given set of numbers is a really hard thing to do. I would suggest you to choose the sorting algorithm of your preference and simply count the steps it takes to sort the numbers.
10th Dec 2018, 7:38 PM
Diego
Diego - avatar
0
Can you tell me method or write line of code which will count each step of sorting
10th Dec 2018, 7:56 PM
Nika Machitidze
Nika Machitidze - avatar
0
First things first: 1. Do you have any sorting algorithm? 2. Which languange are you working on?
10th Dec 2018, 8:08 PM
Diego
Diego - avatar
0
For now i didnot choose algoritm, i am using C++
10th Dec 2018, 8:20 PM
Nika Machitidze
Nika Machitidze - avatar