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
Explain the Canny's Algorithm.
How does deep learning contrast with other machine learning algorithms?
What features would you use to build a recommendation algorithm for users?
What is simulated annealing algorithm?
Given a series of positive integers. Design an efficient algorithm that can detect pairs whose sum is equal to K such that K = ei + ej, and (i not equal to j).
Which is the most straight forward approach for planning algorithms?
Tell us how will you know which machine learning algorithm to choose for your classification problem?
What are disadvantages uniform cost search algorithm?
Which algorithm inverts a complete resolution strategy?
Which algorithm in ‘unification and lifting’ takes two sentences and returns a unifier?
What are the disadvantages of breadth-first search algorithm?
what are the minimum requirements for statr testing?
Sorting algorithms and time complexity of various algorithms.
list the types of linked list with aid of diagram?
Which search algorithm will use a limited amount of memory in an online search?