Home / Expert Answers / Computer Science / write-the-member-function-collapse-m-nodes-int-m-which-will-collapse-the-first-m-nodes-into-pa444

(Solved): Write the member function collapse_m_nodes(int m), which will collapse the first \( m \) nodes into ...




Write the member function collapse_m_nodes(int m), which will collapse the first \( m \) nodes into one node that contains th
Ex3. Returning a list before \( a \) certain value (30 points)
Write the member function prior_v \( \mathbf{( T} \mathbf{v} \
Ex4. Main (10 points)
Write a main () function (in main.cpp ) that tests the functions you implemented in exercises 1-3. Your
Ex5. Bonus exercise: Insert at closest match (30 points)
For this exercise, you will need to implement the function insert_at
Write the member function collapse_m_nodes(int m), which will collapse the first \( m \) nodes into one node that contains the average of their values. The function does the same with the next \( \mathrm{m} \) nodes and so on with the remaining nodes in the list. You must remove the nodes that are no longer needed. If there are less than \( \mathrm{m} \) nodes, then all of them should be collapsed into one node. You are allowed to use an extra (temporary) data structure in your implementation, but you will get extra \( 10 \% \) if you do not. Ex3. Returning a list before \( a \) certain value (30 points) Write the member function prior_v \( \mathbf{( T} \mathbf{v} \), int count), which searches for a node with the value \( v \) (first occurrence), and then returns a list with all the nodes (up to nodes) right before that node. If the value \( v \) is not found or the first occurrence of \( v \) is at the head node, the function should return an empty list. Ex4. Main (10 points) Write a main () function (in main.cpp ) that tests the functions you implemented in exercises 1-3. Your main( ) function must do the following: 1. Create a DLList and add some items. 2. Test all the implemented functions properly. Ex5. Bonus exercise: Insert at closest match (30 points) For this exercise, you will need to implement the function insert_at_closest, which receives a value \( v \). The function should insert a new node that contains the value \( \mathbf{v} \) right before the node with the closest match to \( \mathbf{v} \). For numeric values, that node is the one with the closest value from \( v \). For strings, that node would be the one with smallest hamming distance from \( v \). Use the provided function, str_hamming_dist, to compute the distance between any two strings. This function counts the differences between two strings by position. If multiple nodes have values with similar distance from \( v \), then you should insert the new node right before the left most one of them. If the list is empty, add a new node with the value \( v \) to the empty list.


We have an Answer from Expert

View Expert Answer

Expert Answer


From the above question collapse m nodes into one below is the code - void LinkedList::c
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe