Monday, June 17, 2019

Java program to calculate subset in o(n) time complexity using ArratList


  1. Brutforce:

      1. for(int i = 0; i < len; i++) {  
      2.             //This loop adds the next character every iteration for the subset to form and add it to the array  
      3.             for(int j = i; j < len; j++) {  
      4.                 arr[temp] = str.substring(i, j+1);  
      5.                 temp++;  
      6.             }  
      7.         }  


Subset can be implemented with the concept of decision tree:


How we can implement decision tree in code is:





CODE in JAVA:



No comments:

Post a Comment