15,921,113 members
Home / Discussions / Algorithms

# Algorithms

 Re: Wildcard Matching Routine Richard Andrew x6426-Dec-21 1:32 Richard Andrew x64 26-Dec-21 1:32
 Re: Wildcard Matching Routine englebart8-Feb-22 16:36 englebart 8-Feb-22 16:36
 Re: Wildcard Matching Routine trønderen9-Feb-22 6:35 trønderen 9-Feb-22 6:35
 Re: Wildcard Matching Routine englebart9-Feb-22 15:37 englebart 9-Feb-22 15:37
 Re: Wildcard Matching Routine Eddy Vluggen9-Feb-22 16:10 Eddy Vluggen 9-Feb-22 16:10
 Re: Wildcard Matching Routine trønderen10-Feb-22 6:03 trønderen 10-Feb-22 6:03
 Re: Wildcard Matching Routine englebart10-Feb-22 9:14 englebart 10-Feb-22 9:14
 Time Complexity of following method? Member 1269110623-Nov-21 4:09 Member 12691106 23-Nov-21 4:09
 Here edges is a String array representing a set of space separated integer pair elements e.g. `"e1 e2"` where 0 < e1!=e2 <= n n is an integer, let's say ranging 0 < n <= 100000 ```public int sumSqrtCeil(int n, String[] edges){ ... List> edgeSetList = "converted first edges element to set of Integer" // iterate rest of edges elements -A for(int i=1;i nodeDuo = "converted this edges element to set of Integer" boolean found = false; //search for nodeDuo in set elements of edgeSetList //iterate the nodeDuo 2 element set -B for(Integer e : nodeDuo){ //iterate the edgeSetList containing a linked set collection -C for (Set edgeSet : edgeSetList) { found = edgeSet.contains(e); if (found) { break; } } if(found) break; } if(!found){ //if nodeDuo has no element common to any element of edgeSetList then add a new set indexOfEdgeSetList++; edgeSetList.add(nodeDuo); } else{ //else add nodeDuo to the existing set element of edgeSetList in which any of nodeDuo elements were found. edgeSetList.get(indexOfEdgeSetList).addAll(nodeDuo); } } Set linkedNodes = //identify a set of all nodes which are linked to a different node(s) //Add 1 for each unit nodes (the nodes which are no linked to any other nodes) -D for(int i=1;i<=n;i++){ if(!linkedNodes.contains(i)) output+=1; } // Add ceil of square root of 'node count' of each linked set in linked nodes set collection -E output += edgeSetList.stream().mapToInt(integers -> (int) Math.ceil(Math.sqrt(integers.size()))).sum(); return output; }``` As per my understanding (updated) complexity should be- O( O(A) * O(B) * O(C) + O(D) + O(E) ) O( O(edges.length) * O(2) * O(n/2) + O(n) + O(edges.length) ) O( O(edges.length) * O(n) + O(n) + O(edges.length) ) //constant removed O( O(n*edges.length) + O(n) + O(edges.length) ) //evaluate O( O(n^3) + O(n) + O(n^2) ) //evaluate O( O(n^3) ) //taking biggest factor O(n^3) - Final Time Complexity. where, O(edges.length) = O( n! / 2! * (n-2)! ) = O( ( n * (n-1)) / 2 ) = O( n^2 - n / 2) ==> O(n^2) Please feel free to share also consider me a complete noob for Algorithm. Just started learning formally.modified 24-Nov-21 1:01am.
 Re: Time Complexity of following method? Greg Utas23-Nov-21 5:17 Greg Utas 23-Nov-21 5:17
 Re: Time Complexity of following method? Member 1269110623-Nov-21 18:22 Member 12691106 23-Nov-21 18:22
 Re: Time Complexity of following method? Member 1269110623-Nov-21 19:05 Member 12691106 23-Nov-21 19:05
 Re: Time Complexity of following method? Member 1546299610-Dec-21 5:08 Member 15462996 10-Dec-21 5:08
 NUMBER OF COMBINATIONS OF THE ARRANGEMENT OF CAPS Member 1543482417-Nov-21 13:48 Member 15434824 17-Nov-21 13:48
 Re: NUMBER OF COMBINATIONS OF THE ARRANGEMENT OF CAPS Greg Utas23-Nov-21 5:14 Greg Utas 23-Nov-21 5:14
 C# Member 153810723-Oct-21 21:36 Member 15381072 3-Oct-21 21:36
 Re: C# Richard MacCutchan3-Oct-21 21:49 Richard MacCutchan 3-Oct-21 21:49
 Function of algorithm danindya1-Sep-21 15:52 danindya 1-Sep-21 15:52
 Re: Function of algorithm - Spammer Dave Kreskowiak1-Sep-21 16:23 Dave Kreskowiak 1-Sep-21 16:23
 Help with allocation algorithm Cynthia Moore24-Aug-21 19:43 Cynthia Moore 24-Aug-21 19:43
 Re: Help with allocation algorithm Gerry Schmitz25-Aug-21 18:49 Gerry Schmitz 25-Aug-21 18:49
 Re: Help with allocation algorithm Cynthia Moore25-Aug-21 19:42 Cynthia Moore 25-Aug-21 19:42
 Re: Help with allocation algorithm Gerry Schmitz26-Aug-21 4:37 Gerry Schmitz 26-Aug-21 4:37
 Re: Help with allocation algorithm Cynthia Moore26-Aug-21 7:16 Cynthia Moore 26-Aug-21 7:16
 Re: Help with allocation algorithm BillWoodruff28-Aug-21 16:09 BillWoodruff 28-Aug-21 16:09
 Which is the more preferred approach for novice coders, depth first search, or, breadth first search? the prestige city23-Jul-21 1:23 the prestige city 23-Jul-21 1:23
 Last Visit: 31-Dec-99 18:00     Last Update: 21-Jun-24 11:08 Refresh ᐊ Prev1...567891011121314 Next ᐅ