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

Why size of integer depends on the machine architecture then what the best sorting algorithm and why?

0 Answers   HPCL, Hughes Systique Corporation,


What is iterative deepening depth-first search algorithm?

0 Answers  


Which algorithm inverts a complete resolution strategy?

0 Answers  


A* algorithm is based on which search method?

0 Answers  


What is the iterative deepening depth-first search algorithm?

0 Answers  






list the types of linked list with aid of diagram?

0 Answers  


Which language is used for artificial intelligence?

0 Answers   Flextronics,


Give an algorithm for the following problem. Given a list of n distinct positive integers, partition the list into two sublists, each of size n/2, such that the difference between the sums of the integers in the two sublists is minimized. You may assume that n is a multiple of 2.

0 Answers  


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

0 Answers  


Which algorithm is used for solving temporal probabilistic reasoning?

0 Answers  


What are the disadvantages of breadth-first search algorithm?

0 Answers  


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?

1 Answers   IBM, TCS,


Categories