A class has 12 students. At the beginning of class, each student shakes hands wi
ID: 3764608 • Letter: A
Question
A class has 12 students. At the beginning of class, each student shakes hands with each of the other students. How many handshakes take place?
Thinking of this discretely, let’s go and simplify this problem. When there is one person, (n=1), how many handshakes are there? None. 0. However, where there are two people (n=2), then there is one handshake. If a third person enters the room, it’s a sum of 2+1+0 = 3 handshakes.
A general formula for this is:
sum = n * (n+1)
2
So, for example, if there are 12 students, n= 11 (not 12), so we have (11 * 12)/2 = 66 handshakes.
Let’s now adapt our handshaking theory to networking. One of the more recent network topologies is the “full mesh” topology. Full mesh simply means everything is connected to each other to enable the ultimate ‘fault tolerance.’ Although the downside is cost, network stability is increased if one or more devices goes down.
Write a program which asks the user to select a number of devices, and it will yield the amount of network patch cables to enable a ‘full mesh.'
**Please use C++ or Python
Explanation / Answer
Here is the code for you. If you need any further clarifications, just get back to me.
#include <iostream>
using namespace std;
int main()
{
int num, cables;
cout<<"Enter the number of devices: ";
cin>>num;
cables = (num-1) * num / 2;
cout<<"The number of network patch cables to enable a full mesh is: "<<cables<<endl;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.