Question: void list_head_insert (node*& head_ptr, cost node::value_type& entry) //Precondition: head_ptr is the head pointer of a linked list. //Postcondition: A new node containing the given entry

void list_head_insert (node*& head_ptr, cost node::value_type& entry)

//Precondition: head_ptr is the head pointer of a linked list. //Postcondition: A new node containing the given entry has been added at the head of the linked list;

//head_ptr now points to the head of the new, longer linked list. NOTE: If there is insufficient dynamic

//memory for a new node, then bad_alloc is thrown before changing the list.

{

head_ptr = new node (entry, head_ptr);

}

2.b Using comments explain each line of the code (before the line of code), THEN

2.c Sketch out the nodes, data and pointers for each line of code (by hand is fine)

2.d In pseudo code explain the pattern for inserting a node into the linked list

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!