Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. Multi-threaded Application: The goal in this application is to return the height of a spanning tree in a distributed manner. Consider a spanning tree.

2. Multi-threaded Application: The goal in this application is to return the height of a spanning tree in a distributed manner. Consider a spanning tree. Each node in this tree is represented as a separate thread. Initially, each thread knows which node is its parent and which nodes are its children. The root is the thread with id 0. Thread-0 initiates the following algorithm: It sends height 1 message to its children. The children that receive this message sends height 2 message to their children. The children that receives this message sends height 3 message to their children. This continues until the node (thread) receiving height message is a leaf node, since in this case the node does not have any children. When a leaf node receives the height message, it does the following: It sends height_ack message with the number that it receives previously to its parent. A parent node waits until it receives height_ack message from all its children. When this happens, it finds the maximum value received from its children from the message height_ack. Then, it sends this maximum value its parent. This process continues until the root receives the height_ack message with the actual height of the tree. Then the root prints the height of the tree. You application should also print all message passing between the threads. See an example below.

image text in transcribedthis code must be java

0 Height(1) Height(1) Height(1) 1 3 HEIGHT 2 Height(2) Height(2) Height(2) 5 Height(3) Height(3) 7 8

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

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions