Answered step by step
Verified Expert Solution
Question
1 Approved Answer
A restaurant chain has N restaurants. Each restaurant is given a unique ID from 0 to N - 1 . To establish connectivity among all
A restaurant chain has N restaurants. Each restaurant is given a unique ID from to N To establish connectivity among all the restaurants, the head office maintains a hierarchy with N connections. The restaurant with head office is given an ID A restaurant is further connected to a maximum of two restaurants. For every restaurant, a new restaurant A is always added to the left of it and if its left connection is occupied then a restaurant A is added to the right of it The system maintains the count of permanent customers of every restaurant.
An annual festival is being organised in one of the restaurants. To select which restaurant will host the festival, an algorithm is used which generates a number M and makes a sequence of restaurants from traversing the hierarchy so that for every restaurant, the given rule is followed. The rule is: for a restaurant with ID X first the left connected restaurant to X is added, then the restaurant with ID X is added and then the right connected restaurant X is added in the sequence. Then the Mth restaurant from the start of the sequence is selected for the festival. The system must store the count of permanent customers of the selected restaurant.
Write an algorithm to find the count of permanent customers of the selected restaurant.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started