Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

the third parameter to DEPARTMENT. Part 3: a) A class node has three public data members: record data, static int counter and node next. b)

image text in transcribed
the third parameter to DEPARTMENT. Part 3: a) A class node has three public data members: record" data, static int counter and node" next. b) There is one and only one empty constructor used to set the next and data pointers to nullptr and increase the static int counter by one unit. c) The destructor releases the memory allocated for the data (if any) and decreases the static int counter by one unit. d) The counter is initialized to 0 before your main function. Part 4: a) Write a function to add a new node. The function receives a reference to the head node, and the new record to be stored as the node's data. The new node is always added at the end of the list. Use the header: void addNode (node* &head, record* nr) b) Write a function to show the record data in all the nodes in the list. The function receives a pointer to the head node and calls the show () function member in record and the current value of the counter. This is, assume the list has 2 nodes, then calling this function will display (1020, John Doe, CS)->2 (1030, Homer Simpson, ECS)->2 Use the header: void show (node * head) c) Write a recursive function to count the number of nodes in the list. Use the header: int getSize(node "head) d) Write a function to remove a node by id, the function receives a reference to the head node, and the id to be removed. Consider the cases when there are: i) no nodes in the list (empty), li) the node to be removed is the head node and iii) the list is not empty and the node to be removed is not the head node. The function returns true if successful and false otherwise. Use the header: bool removeNodeByID(node' & head, int key)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions