You are not logged in. Please login at www.codechef.com to post your questions!

×

connecting islands

can anyone please tell me which theorem is to be applied in connecting islands??

asked 05 Feb '15, 23:29

vip_code's gravatar image

2★vip_code
1
accept rate: 0%


The question is basically asking if two vertices belong to the same connected component( edges are added dynamically here though).

Union-Find Disjoint data structure can be used to solve this problem. For each edge to be added between x any y, take the Union of set(x) and set(y) .

For checking if vertices x and y are connected or not, see if they both belong to the same set.

link

answered 05 Feb '15, 23:50

ironmandhruv's gravatar image

4★ironmandhruv
333239
accept rate: 20%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1

question asked: 05 Feb '15, 23:29

question was seen: 513 times

last updated: 05 Feb '15, 23:50

Related questions