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


Please Help Members By Posting Answers For Below Questions

Explain the Canny's Algorithm.

598


How does deep learning contrast with other machine learning algorithms?

539


What features would you use to build a recommendation algorithm for users?

595


What is simulated annealing algorithm?

659


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).

567






Which is the most straight forward approach for planning algorithms?

605


Tell us how will you know which machine learning algorithm to choose for your classification problem?

505


What are disadvantages uniform cost search algorithm?

1222


Which algorithm inverts a complete resolution strategy?

583


Which algorithm in ‘unification and lifting’ takes two sentences and returns a unifier?

577


What are the disadvantages of breadth-first search algorithm?

679


what are the minimum requirements for statr testing?

2237


Sorting algorithms and time complexity of various algorithms.

592


list the types of linked list with aid of diagram?

2232


Which search algorithm will use a limited amount of memory in an online search?

804