Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

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

Modern Database Management

Authors: Donald A. Carpenter Fred R. McFadden

1st Edition

8178088045, 978-8178088044

More Books

Students also viewed these Databases questions