Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A distributed caching service wants to build an algorithm to measure the efficiency of its network. The network is represented as a number of nodes

A distributed caching service wants to build an algorithm to measure the efficiency of its network. The network is represented as a number of nodes and a list of connected pairs. The efficiency of this network can be estimated by first summing the cost of each isolated set of nodes where each individual node has a cost of 1.

To account for the increase in efficiency as mode nodes are connected, update the cost of each isolated set to be the ceiling of the square root of the original cost and return the final sum of all costs.

Example

graph_nodes=10

graph_form=[1,1,2,3,7]

graph_to=[2,3,4,5,8]

There are two isolated sets with more than one node, {1,2,3,4,5} and {7,8}. The ceilings of their square roots are 5 ^ 1/2 = 2.236 and ceil(2.236) = 3, 2 ^ 1/2 = 1.414 and ceil (1.414) = 2. The other three isolated nodes

are separate and the square root of their weights is 1 ^ 1/2 = 1 respectively. The sum is 3 + 2 + (3 * 1) = 8.

Input has 3 parameters:

int graph nodes: the number of nodes

int graph from graph edges]: an array of integers that represent one end of an edge

int graph tolgraph edges]: an array of integers that represent the other end of an edge

Returns:int an integer that denotes the sum of the values calculated .

Please answer it quickly.It is urgent

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

Database Application Development And Design

Authors: Michael V. Mannino

1st Edition

0072463678, 978-0072463675

More Books

Students also viewed these Databases questions

Question

a sin(2x) x Let f(x)=2x+1 In(be)

Answered: 1 week ago

Question

1. Describe the types of power that effective leaders employ

Answered: 1 week ago