There are 12 books in a shelf in a particular order.
All books are unique.
I decide to change their order such that no 2 books, adjacent earlier, are now adjacent.
For Example- Let the books be A,B,C,D.
A cannot come next to B, B cannot come next to A and C....and so on.
In how many ways can I arrange them?
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Excellent solution
Why cant we use derangement technique....please explain
Log in to reply
How do you plan on using Derangements ? Maybe then I'll be able to help you out
As expected from the Annihilator ! Just when I think that no one's able to provide a solution , a great mind comes forward :D
The recursion that I have used is
[a 0 = a 1 = 1, a 2 = a 3 = 0), and a n = ( n + 1 ) a n − 1 − ( n − 2 ) a n − 2 − ( n − 5 ) a n − 3 + ( n − 3 ) a n − 4 for all (n \geq 4]
If you guys want to check the OEIS listing , try here
Very nice recursion technique
Problem Loading...
Note Loading...
Set Loading...
The idea is to use the Principle of Inclusion-Exclusion , but the solution is somewhat intricate. The best way to understand the solution is to look at a particular example.
More generally, let S be the set of all permutations of the numbers 1, 2, … , n , and for 1 ≤ i ≤ n − 1 , let A i , i + 1 denote the subset of permutations where i and i + 1 are adjacent. We want to count the number of permutations where i and i + 1 are never adjacent, and by PIE, this number is ∣ S ∣ − ∣ A 1 , 2 ∣ − ∣ A 2 , 3 ∣ − ⋯ − ∣ A n − 1 , n ∣ + ∣ A 1 , 2 ∩ A 2 , 3 ∣ + ∣ A 1 , 2 ∩ A 3 , 4 ∣ + ⋯ + ∣ A 1 , 2 ∩ A n − 1 , n ∣ − ∣ A 1 , 2 ∩ A 2 , 3 ∩ A 3 , 4 ∣ − ⋯ . So, we must understand what the intersections of these sets look like.
As an example, let n = 8 . Consider the intersection A 1 , 2 ∩ A 2 , 3 ∩ A 3 , 4 ∩ A 5 , 6 ∩ A 6 , 7 . For a permutation in this intersection, 1 is next to 2, 2 is next to 3, 3 is next to 4, 5 is next to 6, and 6 is next to 7. Thus, the numbers 1, 2, 3, 4 form one chain, and the numbers 5, 6, 7 form another chain. So permutations in this intersection include ( 4 , 3 , 2 , 1 , 8 , 5 , 6 , 7 ) and ( 7 , 6 , 5 , 1 , 2 , 3 , 4 , 8 ) .
More generally, consider an intersection of k of the sets A i , i + 1 . Just as we saw in the example above, there will be a number of chains in this intersection. Let t be the number of such chains. (Note that this number t is not uniquely determined by k .) Then for the PIE calculation, for a fixed value of k , instead of trying to compute the number of elements in each intersection, then summing over all possible intersections of k sets, we will count the number of permutations with t chains (that arise from the intersection of k sets).
Let c 1 , c 2 , … , c t be the number of elements in the first chain, second chain, and so on, up until the t th chain. Then the first chain is determined by c 1 − 1 adjacent pairs, the second chain is determined by c 2 − 1 adjacent pairs, and so on. Hence, i = 1 ∑ t ( c i − 1 ) = i = 1 ∑ t c i − t = k , so i = 1 ∑ t c i = t + k . This says there are t + k elements among all t chains, so there are n − t − k elements that are not included in any chains. Let's call these "single elements".
To construct a permutation with t chains, we start by writing the numbers 1, 2, … , n in a row, and deciding which numbers go in chains, and which numbers become single elements. First, we decide the number of elements in each chain. We use the equation i = 1 ∑ t ( c i − 1 ) = k . Each value c i − 1 is a positive integer. Then by stars and bars, the number of solutions to the equation above is ( t − 1 k − 1 ) .
When we write out the numbers 1, 2, … , n , they will form t chains and n − t − k single elements, in some order. There are ( t n − k ) ways to order them. We then let c 1 be the number of elements in the first chain, c 2 the number of elements in the second chain, and so on. Every number from 1 to n has now been assigned as part of a chain or a single element.
There are now ( n − k ) ! ways to order the t chains and n − t − k single elements. Finally, for each chain, we can order it forwards or backwards, so there are 2 t different ways to order the elements in the t chains. Putting everything together, we get that the number of permutations we seek is n ! + k = 1 ∑ n ( − 1 ) k t = 1 ∑ n ( t − 1 k − 1 ) ( t n − k ) 2 t ( n − k ) ! .