Beta
Are these nodes connected?
31SimplGy
Description:
Your goal is to create a data structure that can quickly determine whether nodes are connected.
Nodes are represented as positive integers 0-N
.
You can connect them by saying connect(a,b)
.
You should be able to ask if they are connected by saying isConnected(a,b)
.
Connections are bidirectional, so if a
is connected to b
, b
is also connected to a
.
This connection determination is a classic computer science problem, but is also totally deducible from first princicples. You'll get the most learning value out of this if you to try to solve it yourself first before going to look up solutions.
The API should work like this:
var nodes = Nodes(6); // size 6
nodes.connect(0,1); // node at index 0 is connected with node at index 1
nodes.connect(1,2);
nodes.isConnected(0,2); // true, since 0 -> 1 -> 2
Data Structures
Algorithms
Graph Theory
Similar Kata:
Stats:
Created | Oct 5, 2016 |
Published | Oct 5, 2016 |
Warriors Trained | 108 |
Total Skips | 7 |
Total Code Submissions | 234 |
Total Times Completed | 31 |
JavaScript Completions | 31 |
Total Stars | 4 |
% of votes with a positive feedback rating | 75% of 16 |
Total "Very Satisfied" Votes | 10 |
Total "Somewhat Satisfied" Votes | 4 |
Total "Not Satisfied" Votes | 2 |
Total Rank Assessments | 16 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 6 kyu |