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 |
What is the uniform cost search algorithm?
Give a general algorithm for converting a m-array tree to a 2-ary tree.
How are the k-nearest neigh-bors (knn) algorithms different from k-means clustering?
Which algorithm is used for solving temporal probabilistic reasoning?
What is greedy best first search algorithm?
Which search algorithm will use a limited amount of memory in online search?
Give an example of an O (n) algorithm and O (n*n) algorithm such that the algorithm is slower.
Which is the most straight forward approach for planning algorithm?
What are the disadvantages of depth-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.
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?
Given a sorted array of n integers that has been rotated i(unknown) number of times, give a (log n) algorithm that finds an element in the array.
AI Algorithms (74)
AI Natural Language Processing (96)
AI Knowledge Representation Reasoning (12)
AI Robotics (183)
AI Computer Vision (13)
AI Neural Networks (66)
AI Fuzzy Logic (31)
AI Games (8)
AI Languages (141)
AI Tools (11)
AI Machine Learning (659)
Data Science (671)
Data Mining (120)
AI Deep Learning (111)
Generative AI (153)
AI Frameworks Libraries (197)
AI Ethics Safety (100)
AI Applications (427)
AI General (197)
AI AllOther (6)