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 / 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 |
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).
What are disadvantages uniform cost search algorithm?
When an algorithm is considered completed?
what is software cycle?give a diagramatic representation
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.
Explain the Canny's Algorithm.
What features would you use to build a recommendation algorithm for users?
Which search algorithm will use a limited amount of memory in online search?
Tell me how do you choose an algorithm for a classification problem?
What is greedy best first search algorithm?
A lot of questions were asked on sorting for eg. Best algorithm on the basis of number of swaps, number of comparisons etc.
What is breadth-first search algorithm?