Seating arrangement of N boys sitting around a round table such that two particular boys sit together
There are N boys which are to be seated around a round table. The task is to find the number of ways in which N boys can sit around a round table such that two particular boys sit together.
Input: N = 5
2 boy can be arranged in 2! ways and other boys
can be arranged in (5 – 2)! (2 is subtracted because the
previously selected two boys will be considered as a single boy now and No. of ways to arrange boys around a round table = (n-1)!)
So, total ways are 2! * (n-2)!) = 2! * 3! = 12
Input: N = 9
- First, 2 boys can be arranged in 2! ways.
- No. of ways to arrange remaining boys and the previous two boy pair is (n – 2)!.
- So, Total ways = 2! * (n – 2)!.
Below is the implementation of the above approach:
Time Complexity: O(n)
Auxiliary Space: O(1)