There are numbers from 1 to n, which are inverted such that
it results in numbers from n to 1. If only two consecutive
numbers are stampled at a time and are inverted, how many
moves are required?
Answer Posted / venomvendor
Answer is
Sigma(count), where count ranges from [1 to {n-(swap per time -1)}]
n-(swap per time - 1)
Σ i
i=1
Image Notation >> http://imgur.com/6HkcXzP
In this case.
n = n
swap per time = 2
Substituting this, we get
n-(2 - 1)
Σ i
i=1
n-1
Σ i
i=1
1+2+3+ . . . + (n-1)
if n = 5
Total swaps would be
1+2+3+4 = 10
| Is This Answer Correct ? | 6 Yes | 0 No |
Post New Answer View All Answers
How does deep learning contrast with other machine learning algorithms?
Explain the Canny's Algorithm.
Explain the concept behind dead lock avoidance, banker's algorithm.
Write an algorithm to traverse a knight covering all the squares on a chessboard starting at a particular point.
What features would you use to build a recommendation algorithm for users?
A* algorithm is based on which search method?
What is software cycle? Give a diagrammatic representation?
What are the disadvantages of depth-first search algorithm?
Draw a flowchart to find the average of four number?
List the different algorithm techniques in machine learning?
Name search algorithm technology?
what is software cycle?give a diagramatic representation
Consider the following algorithm: for ( i = 2 ; i <= n ; i++) { for ( j = 0 ; j <= n) { cout << i << j ; j = j + floor(n/4) ; } } (a) What is the output when n = 4 (b) What is the time complexity T(n). You may assume that n is divisible 4.
What is simulated annealing algorithm?
What are disadvantages uniform cost search algorithm?