it says:
1st part:
define a structure that represents family linked list information each family has three components:husband,wife and children.as the number of children varies from family to family,the children are represented by a list that is capable of accomodating any number of items .each person is in turn represented by a structure of four components:name,surname,date of birth,and job.the job information is "unemployed" or it specifies the working organization and salary.
the 2nd part of it
assume that a simple(one way) list is already populated with a set of families,and a global pointer list points to the first node of the list.
write a program to answer the following queries:
1.find the name of all the "unemployed "people.
2.find all the children born in 2000
3.find all names with salary s,where 1000<=s<=2000
4-find whether x is a wife.
5.find whether x is a child.
all i did was writing a node of family and another of family member....couldnt do the job node or the children node
anybody could help pleaaaaaaaaaase um lost

i
dont want the whole problem done......any help would be usefull even
just the begging of the problem cuz um lost and i dunno anything
the only part i did was this(i dont think it's even right
)
insert
and i wrote the whole problem so that people who could help can know what um talking about
the only part i did was this(i dont think it's even right
)insert
record member {
member next
string firstName
string surname
int birthdate
integer age
}
record family {
family next
string husband
string wife
string children
member members /
}
Sam HobbsPosted Dec 11, 2009, 3:57 PM
Sam HobbsPosted Dec 17, 2009, 10:56 PM
Sam HobbsPosted Dec 15, 2009, 9:01 PM
I think it would be easier for me to just write the program for you. I don't want to do that, though; I want you to be able to write programs such as this yourself.
Note that there are many details being overlooked; that is, this is a simplified version of what would be done if this were a real application. For example, a person in real life could be both a child and a father or mother. I suppose that that would not be much different from what you already have; I guess that in a person object, the member linking to the next member would be a link to the next sibling.
For the linked list, I think you will need a reference to the first item in the linked list and that reference will not be part of a family or person structure. Understand? So the first item in the linked list would be referenced differenty than the other items of the list. So then after you get the first structure object, you use the "next" member to get to the next object. Typically something such as a null is used to indicate that last item in the list. So to get to each item, you just get the reference to the first item, then get each item until the next member is null. You could use a for loop for that or a while loop might be more approriate. A for loop is essentially a while loop except in a for loop you include the initialization of the variable used to reference items and a for loop also does the iteration (such as ++i).
I am sorry that I don't understand your childlist structure.
I think the family structure is a good start. You don't show any children for the family structure in your last reply, but that is good for now. Get the family working without the children. That is a reasonable thing to do; that is, do just the families without children. Then when you have that working, add the children.
So you will create a family structure and then fill in the person structures (with names and such) for the father and mother. Then for the first family, save the reference to the first family in a special variable for that purpose. Then for all family members except the first, get the last family in the list and then set the next member to a refernce to the new family object. For efficiency, you could keep a reference to the last family object so you can get to it quicker, but you could just go therough each family object from beginning to end to get to the last family object in the list. After writing the code to do that, I would write code that prints the data out, so I could be sure it is working and so I new I understood how it works. You could probably even do items 1, 3 and 4 of the second part. And then I think you will feel better about what to do and how to do it.
yara takishiPosted Dec 15, 2009, 11:30 AM
this is how far i have done
struct person
{person next;
string firstname;
strinf surname;
int birthdate;
boolean emp;
string org;
int salary;
}
struct family
{
family next;
person father=new person();
person mother=new person();
}
in the family struct i had to declare a list called childlist
i dunno how it should be done but i tried this way
public class childlist
{
private node start;
private string name; // string like "list" to display
// construct empty List with specified name
public childlist(string listName)
{
name = listName;
start = null;
} // end constructor
public list()
: this("list")
{
} // end default constructorpublic void create_list(int data)
{
node q, tmp;
tmp = new node(data);
if (start == null) /* if List is empty */
start = tmp;
else
{ /* Element inserted at the end */
q = start;
while (q.Next != null)
q = q.Next;
q.Next = tmp;
}
}/*End of create_list *is it right to make the child list this way??
that way i can end the 1st part right??
and also for the 2nd part of the program.........
should i use for loop to go through the family struct and check each member???i dunno how to make the loop goes through the entire struct
should i use the for loop for the 5 requirments in the 2nd part of the program??
"1.find the name of all the "unemployed "people.
2.find all the children born in 2000
3.find all names with salary s,where 1000<=s<=2000
4-find whether x is a wife.
5.find whether x is a child."
Sam HobbsPosted Dec 13, 2009, 12:36 PM
Sorry that I did not get back to you sooner. Most forums notify people when someone replies to a thread, but these forums do not. I will try to check here more often.
Also, I am not accustomed to using linked lists. So my instructions are a little inaccurate because I was thinking of lists and arrays but not linked lists.
Also, I don't understand what you mean by node. The term probably has a more specific meaning to you that I am not familiar with. So I don't understand what the difference is between a member and a linked list of nodes. Probably the husband, wife and children members should all be member types, not strings. For the husband and wife members the next member will always be null. The children member could be null if there are no children or the next member could be null depending on how many members there are.
Note that the tem member is confusing for this, since the term applies both to a member of the family and a member of the class.
Also not that C# does not have "records"; you probably want to use "class" instead of record.
yara takishiPosted Dec 12, 2009, 1:32 AM
Sam HobbsPosted Dec 12, 2009, 12:09 AM
By doing things this way, you make the project less complicated since you can work on each peice separately and then things are not so overwhelming.
Sam HobbsPosted Dec 12, 2009, 12:00 AM
Note that their are zero to many children for each family. I doubt that a string is what you need. Probably you need a member for each child.
Also note that your member record does not have job information.
yara takishiPosted Dec 11, 2009, 2:16 PM
Hiren SoniPosted Dec 11, 2009, 12:35 PM
yara takishiPosted Dec 11, 2009, 12:03 PM
Kirtan PatelPosted Dec 11, 2009, 11:38 AM