Data structures for linked lists must contain at least one member that is a(n) i
ID: 673826 • Letter: D
Question
Data structures for linked lists must contain at least one member that is a(n) integer string pointer null Revise this structure to make it work as a linked list. Write your answer below. The assembly code below is for a kill system call. Translate this to a command line that could be used in a terminal. Using the structure that you revised above, write the code that would declare an instance of one link, then using malloc(), allocate memory for another link and attach the second link to the first. THIS DOESN'T HAVE TO BE A WHOLE PROGRAM, JUST THE NECESSARY CODE TO ANSWER THE QUESTION, (partial credit will be given for this question)Explanation / Answer
25. Data Structure for linked list must contains at least one member is : Pointer
struct potenial_list{
int grade;
float rawgrade;
char lettergrade;
struct potenial_list *next;
}
Ans: To make linked list it must be have pointer to point the another node in a list
Dont have the idea baout assembly language code
Insert Node in List is below code:
/* Given a reference (pointer to pointer) to the head of a list and an int,
inserts a new node on the front of the list. */
void push(struct node** head_ref, int grade, float rawgrade, char lettergrade)
{
/* 1. allocate node */
struct node* new_node = (struct node*) malloc(sizeof(struct node));
/* 2. put in the data */
new_node->grade = grade;
new_node->rawgrade = rawgrade;
new_node->lettergrade = lettergrade;
/* 3. Make next of new node as head */
new_node->next = (*head_ref);
/* 4. move the head to point to the new node */
(*head_ref) = new_node;
}
Code spinet for Insert Node after the first node is below:
/* Given a node prev_node, insert a new node after the given prev_node */
void insertAfter(struct node* prev_node, int grade, float rawgrade, char lettergrade)
{
/*1. check if the given prev_node is NULL */
if (prev_node == NULL)
{
printf("the given previous node cannot be NULL");
return;
}
/* 2. allocate new node */
struct node* new_node =(struct node*) malloc(sizeof(struct node));
/* 3. put in the data */
new_node->grade = grade;
new_node->rawgrade = rawgrade;
new_node->lettergrade = lettergrade;
/* 4. Make next of new node as next of prev_node */
new_node->next = prev_node->next;
/* 5. move the next of prev_node as new_node */
prev_node->next = new_node;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.