Question: Given classes neighborhood and edge ( see below ) , what is the big - O cost of generateCombinations? Show and explain the calculations. public

Given classes neighborhood and edge (see below), what is the big-O cost of generateCombinations? Show and explain the calculations.
public long generateCombinations(java.util.ArrayList C,int k){
long cnt =0;
int i =0;
int cmb[]= new int[k];
while(i >-1){
if(i < k){
cmb[i]++;
if(cmb[i]<= C.size()){
if(i == k -1){ cnt++; }
else { cmb[++i]= cmb[i -1]; }
}
else { i--; }
}
else { i--; }
}
return cnt;
}
public class edge {
final private neighborhood vF;
/**
* @param vF neighborhood that influences
*/
public edge(neighborhood vF){
this.vF = vF;
}
/**
* @return neighborhood that influences
*/
final public neighborhood getNeighbor(){ return vF; }
}
public class neighborhood {
final private java.util.Collection I; // neighbors
final private int l[]; // label or location
/**
* @param l label or location of neighborhood
*/
public neighborhood(int l[]){
I = new java.util.ArrayList<>();
this.l = l;
}
/**
* @param e edge or neighborhood to add
* @return true if unique edge is added
*/
final public boolean add(edge e){
if(!I.contains(e)){
return I.add(e);
}
else {
return false;
}
}
/**
* @return label or name or location of vertex
*/
final public int[] getLabel(){
return l;
}
/**
* @return neighbors of vertex
*/
final public java.util.Collection getNeighbors(){
return I;
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!