Question: Use c++ language We are going to make a graph like structure to calculate the Euclidean distance between trees in a forest and add them
Use c++ language

We are going to make a graph like structure to calculate the Euclidean distance between trees in a forest and add them to clusters. d(p, q) 3 (1: - p.) Euclidean distance: i=1 Example: trees_height = {16.3, 12.5 ....} where each values corresponds to each tree height trees_width = {4.5, 5.3... } such that; tree 3 -- > trees_height [2], trees_width[2] would show the height and width value of tree# 3 Euclidean distance d(treel, tree2) = [ (tree1_height - tree2_height)2 + (tree2_width - tree2_width) ] 0.5 Tasks: 1. Take number of trees height and width from the user. 2. Create three clusters that will hold three different type of trees based upon distance values stated below. 3. For first tree entered by user. Calculate its Euclidean distance from other trees using both height and width. 4. Add the index of the first tree and the tree with smallest Euclidean distance to it to the first cluster. E-g: Tree 1 and Tree 6 has minimum Euclidean distance so cluster1(1,6); 5. Calculate mean height and mean width of cluster1. 6. Calculate the Euclidean distance for next tree from this cluster1. (Use mean height and mean width value of cluster1 for Euclidean distance calculation to the next tree). 7. If the Euclidean distance calculated in point no 6 is less or equal than mean height and mean width of cluster1 then the new tree will be added in cluster1, otherwise it will become part of cluster2. E.g: cluster1->(1,6) and cluster 2->{4} where 4 is the new tree added in cluster2. Note: Clusters mean will always change when new tree is added to it. 8. For the next tree calculate the Euclidean distance for it from all the clusters (mentioned in point no 6) and add it to cluster having less difference between Euclidean distance and mean values of clusters. Note: Calculate mean values for all the three clusters. 9. Display all the clusters, their means at the end. Eg: Cluster 1 tree1, tree. Cluster 1 mean height = 3.5 Cluster 1 mean width=2.0 Cluster2 tree4 Cluster 2 mean height=3.1 Cluster 2 mean width=3.3 Cluster 3 tree 2, tree 3, tree 5 Cluster mean height=2.2 Cluster mean width=1.3 Note: If the condition for any tree does not satisfy to become part of cluster1 or cluster2 then automatically it will be added to cluster3. We are going to make a graph like structure to calculate the Euclidean distance between trees in a forest and add them to clusters. d(p, q) 3 (1: - p.) Euclidean distance: i=1 Example: trees_height = {16.3, 12.5 ....} where each values corresponds to each tree height trees_width = {4.5, 5.3... } such that; tree 3 -- > trees_height [2], trees_width[2] would show the height and width value of tree# 3 Euclidean distance d(treel, tree2) = [ (tree1_height - tree2_height)2 + (tree2_width - tree2_width) ] 0.5 Tasks: 1. Take number of trees height and width from the user. 2. Create three clusters that will hold three different type of trees based upon distance values stated below. 3. For first tree entered by user. Calculate its Euclidean distance from other trees using both height and width. 4. Add the index of the first tree and the tree with smallest Euclidean distance to it to the first cluster. E-g: Tree 1 and Tree 6 has minimum Euclidean distance so cluster1(1,6); 5. Calculate mean height and mean width of cluster1. 6. Calculate the Euclidean distance for next tree from this cluster1. (Use mean height and mean width value of cluster1 for Euclidean distance calculation to the next tree). 7. If the Euclidean distance calculated in point no 6 is less or equal than mean height and mean width of cluster1 then the new tree will be added in cluster1, otherwise it will become part of cluster2. E.g: cluster1->(1,6) and cluster 2->{4} where 4 is the new tree added in cluster2. Note: Clusters mean will always change when new tree is added to it. 8. For the next tree calculate the Euclidean distance for it from all the clusters (mentioned in point no 6) and add it to cluster having less difference between Euclidean distance and mean values of clusters. Note: Calculate mean values for all the three clusters. 9. Display all the clusters, their means at the end. Eg: Cluster 1 tree1, tree. Cluster 1 mean height = 3.5 Cluster 1 mean width=2.0 Cluster2 tree4 Cluster 2 mean height=3.1 Cluster 2 mean width=3.3 Cluster 3 tree 2, tree 3, tree 5 Cluster mean height=2.2 Cluster mean width=1.3 Note: If the condition for any tree does not satisfy to become part of cluster1 or cluster2 then automatically it will be added to cluster3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
