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
6 Respostas
+ 1
Can you show us what you have come up to?
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
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.
0
Can you tell me method or write line of code which will count each step of sorting
0
First things first:
1. Do you have any sorting algorithm?
2. Which languange are you working on?
0
For now i didnot choose algoritm, i am using C++