Question: Q2) Copy node1.cpp to node2.cpp. For node2.cpp: - remove overwriteNeighborNode, getNeighborAtIndex functions. - Set max edge count to 1000, i.e., array size. a) Implement a

 Q2) Copy node1.cpp to node2.cpp. For node2.cpp: - remove overwriteNeighborNode, getNeighborAtIndex

Q2) Copy node1.cpp to node2.cpp. For node2.cpp: - remove overwriteNeighborNode, getNeighborAtIndex functions. - Set max edge count to 1000, i.e., array size. a) Implement a constructor with which you can instantiate a node, assign an id directly. b) Implement addNeighbor(Node n) member function. You will need to do some assumptions, put them in your source code as comments. Hint: You may traverse through the node array, find the first empty(i.e. NULL) spot and add the neighbor's pointer there. c) Would using a friend function help us in this case? Given that our graph is non-directional you need to add nodes to each other, a two step process. Can you write a single friend function which sets both nodes as neighbors(no implementation, just explain) d) Implement bool removeNeighbor(Node n) function which returns false if the neighbor cannot be found. Describe your logic in the comments. e) What are the limitations of having a constant array size? Advantages, Disadvantages? How can we improve the design? Q2) Copy node1.cpp to node2.cpp. For node2.cpp: - remove overwriteNeighborNode, getNeighborAtIndex functions. - Set max edge count to 1000, i.e., array size. a) Implement a constructor with which you can instantiate a node, assign an id directly. b) Implement addNeighbor(Node n) member function. You will need to do some assumptions, put them in your source code as comments. Hint: You may traverse through the node array, find the first empty(i.e. NULL) spot and add the neighbor's pointer there. c) Would using a friend function help us in this case? Given that our graph is non-directional you need to add nodes to each other, a two step process. Can you write a single friend function which sets both nodes as neighbors(no implementation, just explain) d) Implement bool removeNeighbor(Node n) function which returns false if the neighbor cannot be found. Describe your logic in the comments. e) What are the limitations of having a constant array size? Advantages, Disadvantages? How can we improve the design

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!