Data Structures: 2. Write the definition for a node that consists of the followi
ID: 638543 • Letter: D
Question
Data Structures:
2. Write the definition for a node that consists of the following: a 25 character name, a 9 character ID, a floating point value for GPA, a 4 character code for major and a pointer to the node for the link. The structure should have a name of StudentNode.
3. Show the process for searching the linked list for a specific name. Use your definition from question 2 for the nodes in the list. Assume that the list is a dynamically allocated linked list and the item that you are searching for exists in the list. Make any declarations necessary to complete the task.
Explanation / Answer
2)
struct StudentNode
{
char name[25],ID[9],major[4];
float GPA;
StudentNode* next;
}
3) To search for a particular name
studentNode* find_from_name(StudentNode* root)
{
while(root!=NULL){
if (strcmp(root->name,name_src)==0){
return root;
}
root=root->next;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.