By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 884 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

got ex questtion here...

P: 2
guys, this question is easy, but i am new in data structure. got confusion here. need help. and please, reduce my headache..kkk...thanks a lot...
Q=>
Write a statement or set of statements to accomplish each of the following. Assume that all the manipulations occur in main (therefore, no addresses of pointer variables are needed), and assume the following definitions:

struct gradeNode
{
char lastname[20];
double grade;
struct gradeNode *nextPtr;
};
typedef struct gradeNode GradeNode;
typedef GradeNode *GradeNodePtr;

1.Create a pointer of the start of the list called startPtr. The list is empty.
2.Create a new node of type GradeNode that is pointed to by pointer newPtr of type GradeNodePtr. Assign the string “Jones” to member lastName and the value 91.5 to member grade (use strcpy). Provide any necessary declarations and statements.
3.Assume that the list pointed to by startPtr currently consists of 2 nodes - one containing “Jones” and one containing “Smith”. The nodes are in alphabetical order. Provide the statements necessary to insert in order nodes containing the following data for lastName and grade:
“Adams” 85.0
“Thompson” 73.5
“Pritchard” 66.5
4.Use pointers previousPtr, currentPtr and newPtr to perform the insertions. State what previousPtr and currentPtr point to before each insertion. Assume that newPtr always points to the new node, and that the new node has already been assigned the data.
5.Write a while loop that prints the data in each node of the list. Use pointer currentPtr to move along the list.
Aug 4 '07 #1
Share this Question
Share on Google+
2 Replies


Expert 10K+
P: 11,448
guys, this question is easy, but i am new in data structure. got confusion here. need help. and please, reduce my headache..kkk...thanks a lot...
That's a nice homework assignment you've got there. We don't hand out boiler
plate code here, we can help you though when you're stuck with something.
What have you done yourself sofar? You could go to www.rentacoder.com, but
you have to pay for it to get your spoonfed code (quite normal, if you'd ask me,
everybody needs money to live). So what's up?

kind regards,

Jos
Aug 4 '07 #2

P: 2
That's a nice homework assignment you've got there. We don't hand out boiler
plate code here, we can help you though when you're stuck with something.
What have you done yourself sofar? You could go to www.rentacoder.com, but
you have to pay for it to get your spoonfed code (quite normal, if you'd ask me,
everybody needs money to live). So what's up?

kind regards,

Jos

thanks for reply. yup..so far, i got something. i got the idea. i know the linked list concept but the confusion start because my lecturer doesnt want us to use sth like 'newNode.lastname' where she wants us to use 'newNodePtr -> lastname' and use strcpy and strcmp.then typedef thing, i don't really familiar using typedef. so far..i am into something now. using my logic . hope God will help me. hahaha.
anyway, this is my minor course. but kind of like it. hehe..
Aug 5 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.