Question
Write a Java interface source file UnionFind.java to express the API , the union-find interface. Also rewrite just the first line of UF.java to assert
Write a Java interface source file UnionFind.java to express the API , the union-find interface. Also rewrite just the first line of UF.java to assert that class UF implements this interface.
This the API in which I need a java interface for which uses these:
public class UF
UF(int N) initialize N sites with integer names (0 to N-1)
void union(int p, int q) add connection between p and q
int find(int p) component identifier for p (0 to N-1)
boolean connected(int p, int q) return true if p and q are in the same component
int count() number of components
example:
public interface Account {
// withdraw amt from this BA int withdraw(int amount); /
/ deposit amt to this BA void deposit(int amount); //
return balance for this BA int getBalance();
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started