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?



There are numbers from 1 to n, which are inverted such that it results in numbers from n to 1. If ..

Answer / 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

More AI Algorithms Interview Questions

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

0 Answers   Expedia,


Name search algorithm technology?

0 Answers  


What is meant by uniform cost search algorithm?

0 Answers  


What is local search algorithms?

0 Answers  


What is the breadth-first search algorithm?

0 Answers  






what is software cycle?give a diagramatic representation

0 Answers  


Tell briefly about the Banker's algorithm and what is it used for?

0 Answers   Impetus,


Draw a flowchart to find the average of four number?

0 Answers  


What do you mean by overfitting and underfitting algorithms?

0 Answers  


Tell me how do you choose an algorithm for a classification problem?

0 Answers  


What is the most efficient way to store 1 million phone numbers memory-wise?

0 Answers   Aspire, Infogain,


What is bidirectional search algorithm?

0 Answers  


Categories