Demo entry 6785754

sadfsadf

   

Submitted by anonymous on Mar 19, 2019 at 18:27
Language: ActionScript 3. Code size: 668 Bytes.

package  {
	public class DisjointSet {
		
		public var count:Number;
		public var parent:Array;
		
		public function DisjointSet(count:int) {
			this.count = count;
			this.parent = new Array(this.count);
			
			for (var i:int = 0; i < this.count; i++){
				this.parent[i] = i;
			}
		}
		
		public function Find(i:int):int{
			if (this.parent[i] == i){
				return i;
			}
			else {
				var result:int = Find(this.parent[i]);
				parent[i] = result;
				return result;
			}
		}
		
		public function Union(i:int, j:int):void{
			var irep:int = this.Find(i);
			var jrep:int = this.Find(j);
			
			this.parent[irep] = jrep;
		}

	}	
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).