Friday, February 3, 2012

Data Structures and Algorithms?

A dating agency holds the following information about each of its clients:

age: a value in the range 18 to 65,

height: recorded in feet and inches,

hair colour: which can be black, blond, red or grey,

eye colour: which can be green, blue or black,

gender: male or female,

interests: one or more selected from reading, theatre, cinema, walking, gardening

or dining out.

Design suitable abstract data types to enable such information to be held for each client.

Data Structures and Algorithms?
struct Person

{

int PersonID;

int age;

int height; // in inches

int haircolor; // enum

int eyecolor; // enum

int gender; // enum

};



struct Activity

{

int ActivityID;

string ActivityName;

};



struct Interest

{

int PersonID;

int ActivityID;

};



For each person, there is one record in the Interest table for each of their interests. This allows additions to the Activity table without changeing the structure of the Person records.
Reply:The main table:



Clients-with each of the fields above except interests. Each interest needs to be a separate field with either a yes/no entry allowed.



Some other tables:

Hair_Color: with single field. Each color is a record.

Eye_Color: same

Gender: same
Reply:STRUCT CLIENT

{

int age;

struct height

{

int feet;

int inch;

}

int eyecolour;

int gender;

struct interest

{

Boolean reading;

Boolean theater;

Boolean cinema;

Boolean walking;

Boolean dining out;

}

}



Now look at other perspective .





1. Usually male looks at this dating service for female . So Search would be more for female.



2. Search for clients 18 - 30 would be greatest.



3. Search would also be great for cinema and dining out.





Now we should represent our Data structure such that searching could be fast.







Now searching we would make unbalance tree such that depth of girls , people of age ( 18 - 30 ) and certain interes t has low depth so could be easily find in small number of serach attempt.





so we should represesnt them in unbalanced priority tree .



we can also reprsent them using hash table for hashes like age , sex and interest to make searching efficient

my fish

No comments:

Post a Comment