java - Compiler Code(s) Errors? -
this question exact duplicate of:
i have still having trouble compiling code(s), since following 4 errors showing up. thus, prevents me being able run code , have desired output.
here 4 errors:
error 1:
solver.java:29: error: method breadthfirstsearch in class searchmethods cannot applied given types; sm.breadthfirstsearch(adjmatrix, 0); ^ required: boolean[][],int,boolean[] found: integer[][],int reason: actual , formal argument lists differ in length
error 2:
solver.java:34: error: method depthfirstsearch in class searchmethods cannot applied given types; sm.depthfirstsearch(adjmatrix, 0); ^ required: int[][],int[],int,int found: integer[][],int reason: actual , formal argument lists differ in length
error 3:
searchmethods.java:64: error: cannot find symbol queued qd = new queued(); ^ symbol: class queued location: class searchmethods
error 4:
searchmethods.java:64: error: cannot find symbol queued qd = new queued(); ^ symbol: class queued location: class searchmethods
also, below have attached code(s).
here 1st/main code: searchmethods.java
public class searchmethods { // initialize adjacent matrix: matrix zeros. public void initmatrix(integer[][] matrix) { for(int i=0; < matrix.length; i++) { for(int j=0; j < matrix[i].length; j++) { matrix[i][j]=0; } } } // disply adjacent matrix: matrix. public void displaymatrix(integer[][] matrix) { for(int i=0; < matrix.length; i++) { for(int j=0; j < matrix[i].length; j++) { system.out.print(" "+matrix[i][j]); } system.out.println(); } } // method should called each time array reached updated. private void displayreached(boolean[] r) { for(int i=0; i< r.length; i++) { if(r[i]== false) { system.out.print(" f"); } else { system.out.print(" t"); } } system.out.println(); } //bfs public void breadthfirstsearch(boolean[][] m, int callvertex, boolean[] reached) { reached = new boolean[m.length]; while(true) { boolean test = false; for(int = 0;i < m.length; i++) { if(reached[i] == false) { test = true; } } if(test == false) break; } queued qd = new queued(); qd.enqueue=new integer[m.length]; qd.offer(callvertex); reached[callvertex]=true; while(!qd.isempty()) { integer temp=(integer)qd.dequeue(); system.out.println(temp); for(int i=0;i<m[0].length;i++) { if(m[temp][i]==true && reached[i]==false) { qd.offer(i); reached[i]=true; } } } } //dfs public static void depthfirstsearch(int minteger[][], int nextarray[], int callvertex, int s) { system.out.println("/r" + (callvertex + 1)); nextarray[callvertex] = 1; for(int k = 0; k < s; k++) { if(minteger[callvertex][k] == 1 && nextarray[k] == 0) { depthfirstsearch(minteger,nextarray,k,s); } } } }
and here 2nd code: solver.java used run in compiler , produce desired output
public class solver { public static void main(string[] args) { integer[][] //adjmatrix adjmatrix = { // a, b, c, d, e, f, g, h, i, j, {0, 1, 1, 1, 0, 0, 0, 0, 0, 0}, //a {0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, //b {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //c {0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, //d {0, 0, 1, 0, 0, 0, 1, 1, 0, 0}, //e {0, 0, 0, 1, 1, 0, 0, 0, 0, 0}, //f {0, 0, 0, 0, 0, 0, 0, 1, 1, 0}, //g {0, 0, 0, 0, 0, 1, 0, 0, 1, 1}, //h {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, //i {0, 0, 0, 0, 0, 1, 0, 0, 1, 0} //j }; searchmethods sm = new searchmethods(); system.out.println("the input graph g in adjacent matrix is:"); system.out.println(); sm.displaymatrix(adjmatrix); system.out.println(); system.out.println("performing bfs on g start vertex a: "); system.out.println(); sm.breadthfirstsearch(adjmatrix, 0); system.out.println(); system.out.println("performing dfs on g start vertex a: "); system.out.println(); sm.depthfirstsearch(adjmatrix, 0); } }
can please provide me "exact solutions" or "detailed steps" can fix them?
if so, please let me know asap today, since need submit code tonight.
thank you!
error 1: aren't supplying right parameters. @ error message. tells gave , it's expecting. looks need remove boolean[] reached
parameter. don't declare method-scoped variables parameters function.
error 2: same thing
error 3: queued isn't class exists anywhere. did mean use queue
? examples of how use this, won't able replace queued
queue
queue
interface.
error 4: same thing.
Comments
Post a Comment