Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1. (30 points) Given the following link that has 3 nodes (Figure ) where each node has two components: an integer variabledata feld and a
1. (30 points) Given the following link that has 3 nodes (Figure ) where each node has two components: an integer variable"data feld" and a pointer lInk_eld" pointing to the next node in the list. We also bave a poirter head_ptr"pointing to the head of the list and a pointer "prevlous_ptr" pointing to the second node. hesd_pt Figure 1 (S points) Write a function a. vold let_head_Insert node & head_ptr, const Int entry) where a new code cortaining the given entry is added at the head of tha ist. You can write either Ccode or pseudo code. (8points) Write a function b. vold llet_Insert node prevlous_ptr, const Int entry where a new code cortaining the given entry is added after the node that prevlous_ptr points to. You can write either Ccode or pseudo code (4 points) After (data() and next() are two constant member functions in class node deta() retums the value of date field and next) retuns the value of lIlnk_neld). coutcchesd ptr-dato)ccendl; coutcchesd ptr-next)-dat)ccendl: (10 points) If we pass the first parameter in list head_Insert as a value parameter c. and b, what output is produced by the following? d. vold llet_head_Insert node* head_ptr, conet Int &entry) then what output is produced by the following? couthead ptr-d ta( )
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started