Problem
Auditions
"Singing Champs" is a famous reality series. The show organizers
have planned to roll out the show's 5th season in the coming
month. The auditions for the show is announced at various Cities
widely and the organizers have inaugurated the first audition
today.
Large mass of people gathered at the venue. Based on the
selection procedure for the first level, all the people are made to
stand in a queue. Participants who are standing in the even
positions of the queue are selected initially. Of the selected
people a queue is formed and again out of these only people on
even position are selected. This continues until we are left with
one person.
To help them in the selection procedure, the organizers
approached you to write a recursive function for determining
the position of that final person in the original queue.
write a python program to solve this question
Answers
Answered by
1
Answer:
problem auditions bhai please listen me
Answered by
1
Program in Python:
def selection(n):
if n == 1:
return 1
return 2*selection((int)(n/2))
n = int(input("Enter the number of people : "))
print("The position of that person who is left :", selection(n))
Output 1:
Enter the number of people : 5
The position of that person who is left : 4
Output 2:
Enter the number of people : 180
The position of that person who is left : 128
Similar questions
History,
29 days ago
Computer Science,
29 days ago
English,
29 days ago
Science,
1 month ago
Math,
9 months ago