Answered step by step
Verified Expert Solution
Link Copied!

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 0 to N-1. To establish connectivity among all the restaurants, the head office maintains a hierarchy with N-1 connections. The restaurant with head office is given an ID 0. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual C# And Databases

Authors: Philip Conrod, Lou Tylee

16th Edition

1951077083, 978-1951077082

More Books

Students also viewed these Databases questions