Question
Assignment: Birthday Bonanza Background: Busy Sally Socialite has trouble remembering people's birthdays, so she has organised her friends into what she calls a Birthday Support
Assignment: Birthday Bonanza
Background: Busy Sally Socialite has trouble remembering people's birthdays, so she has organised her friends into what she calls a Birthday Support Team, or BST. Each friend needs only to keep track of three items of information: their own birthday (which of course they do not need to write down), the name of someone whose birthday comes earlier in the year than their own (which they write on a card and keep in their left pocket), and the name of someone whose birthday comes later in the year (which they write on a card and keep in their right pocket). Whenever Sally makes a new friend, she calls her best friend, who is currently Harry, and initiates an Install New Support Enquiry Response Tag procedure (INSERT for short). If the new friend's birthday is before Harry's own birthday, then he relays the INSERT call to the person whose name is on the card in his left pocket. If the new friend's birthday is instead after Harry's, then he relays the call to the person on the card in his right pocket. However, if the appropriate pocket is currently empty, Harry writes the name on a new card and puts the card in the empty pocket. Of course, the person to whom Harry relays the INSERT does the same thing, which means that collectively the BST ends up remembering the new friend's birthday
For example, if Sally called Harry to say I have found out that John's birthday is next Friday, Harry, who knows that his own Birthday is 15 March and that next Friday is 30 June, would reach into his right pocket, find a card with the name Marge, and call Marge to pass on the news of John's birthday. Marge, whose Birthday is 23 September and who currently has an empty left pocket, would then write John on a new card and put the card into her left pocket.
The first thing Sally needs to do every morning is to find out whose birthday it is that day, and the BST again swings into action. Sally calls Harry and initiates the Sudden Enquiry Activity Requiring Collective Help procedure (SEARCH for short). If the day in question happens to be Harry's own birthday, he tells Sally the happy news and hangs up. Otherwise, he will need to consult with his friends. If Harry has not yet celebrated his own birthday this year, he calls the person on the card in his left pocket to ask whose birthday it is, then relays the answer back to Sally. If Harry's birthday has already passed, he calls his right-pocket friend instead. In either case, if the appropriate pocket is empty, he can tell Sally that it is nobody's birthday. Of course, whoever Harry calls will follow the same procedure so that, collectively, the BST will either provide the name of the birthday celebrant or discover that nobody is celebrating a birthday that day.
For example, if Sally calls Harry on 30 June and asks Whose birthday is it today?, Harry would reach into his right pocket then put Sally on hold and call Marge. Marge would find John's name in her left pocket then put Harry on hold and call John. Finally, John would report that it is his birthday, which Marge would relay back to Harry, who in turn would report to Sally. Of course, Sally would then call John to wish him Happy Birthday
Further explanation: Of course, a Birthday Support Team is really just a thinly disguised Binary Search Tree, when we look at the details of how it works. Each friend in the Team can be represented by a node in a Binary Search Tree, and the left and right pockets correspond to left and right branches from that node to other nodes. The ordering of friends that is imposed by the Binary Search Tree is according to the order of the days of the year, with birthdays that occur earlier in the year going to the left subtree below a particular node, and birthdays that occur later in the year going to the right subtree. All of the questions in this Report pertain to a Binary Search Tree solution for the problem.
TASK
After using the scheme for some time, Sally finds out that it has some problems and has asked for your help. To assist, you will need to prepare answers to the following four questions:
1. The main problem is that as Sally's circle of friends grows, it sometimes takes a long time to get a response to SEARCH calls, which is using up valuable talk-time on Sallys mobile phone plan. Explain the circumstances that would result in unnecessarily long SEARCH calls and what can be done to minimise the problem. If on average a SEARCH call takes one minute deciding who to call, placing the call, and reporting its outcome what is the maximum time that a SEARCH might take if Sally added all 200 of her friends to her BST? If the problem could be fixed, how much time would a typical SEARCH take? Further Explanation: This question has to do with the performance of a binary search tree, i.e. the time that it takes to perform specific operations. Explain under what circumstances the long waiting times for search operations would occur, and how these waiting times can be reduced. Explain the maximum waiting time if the problem has not been fixed, and the typical waiting time if the problem can be fixed in the way you have described. You will receive a better mark if you dont just state the numeric answer, but also explain your reasoning.
ANSWER THIS QUESTION PLEASE.....
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