dfsfinals

5
Linear Data Structure: Queues Problem: Dancing Partners The annual Single’s Night dance at Runeterra’s Lodge is just around the corner. Men and women enter the lodge and stand in line. The dance floor is quite small and there is room for only three couples at a time. As there is room on the dance floor, dance partners are chosen by taking the first man and woman in line. These couples are taken out of the line and the next set of men and women are moved to the front of the line. As this action takes place, the program announces the first set of dance partners and who the next people are in line. If there is not a complete couple, the next person in line is announced. If no one is left in line, this fact is displayed. The program accepts values from a text file. Sample data would be like: F KatnissEverdeen M PeetaMellark M Gale Hawthorne M Tobias Eaton F Beatrice Prior F Hazel Lancaster . . .

Upload: mohammad-usman

Post on 24-Apr-2017

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: dfsFinals

Linear Data Structure: Queues

Problem: Dancing PartnersThe annual Single’s Night dance at Runeterra’s Lodge is just around the corner. Men and women enter the lodge and stand in line. The dance floor is quite small and there is room for only three couples at a time. As there is room on the dance floor, dance partners are chosen by taking the first man and woman in line. These couples are taken out of the line and the next set of men and women are moved to the front of the line.

As this action takes place, the program announces the first set of dance partners and who the next people are in line. If there is not a complete couple, the next person in line is announced. If no one is left in line, this fact is displayed. The program accepts values from a text file. Sample data would be like:

F KatnissEverdeenM PeetaMellarkM Gale HawthorneM Tobias EatonF Beatrice PriorF Hazel Lancaster...

Page 2: dfsFinals

Hierarchical Data Structure: Binary Search Tree

Problem: City DatabaseImplement a city database using BST to store the database records. Each database record contains the name of the city (a string of arbitrary length) and the coordinates of the city expressed as integer x- and y- coordinates. The BST should be organized by city name. Your database should allow records to be inserted, deleted by name or coordinate, update name or coordinate, and searched by name or coordinate. Another operation that should be supported is to print all records within a given distance of a specified point. The files can be saved/read from a text file.

Page 3: dfsFinals

Graphical Data Structure: Undirected Graphs

Problem: City Tour

Note: Thomas’ Farm is connected to the Dry Cleaner and the City Hall.

Using the graph above, ask the user for the distances or weight of every vertex. After placing all the weights ask the user for start point and end point. Using the shortest path algorithm discussed in class find the shortest path from the start point up to the end point. You need to show the path and the total distance covered.

Page 4: dfsFinals

Hashing: Any Collision Resolution

Problem: Telephone DirectoryHashing is a very common technique for storing data in such a way the data can be inserted and retrieved very quickly. Hashing uses a data structure called a hash table. A telephone company needs to have a quick access over the large database of their customer. Create a program that utilizes Hashing. Your program must allow records to be inserted, updated, deleted, searched and retrieved. Your telephone directory program uses the telephone number as key. A sample data would be:

Natsu Dragneel M Magnolia 123-4567Erza Scarlet F Magnolia 987-1234Gray Fullbuster M Townsville 445-7891Lucy Heartfilia F Punk Hazard 123-5577

Your data must be saved on a text file.