MCPcopy Create free account
hub / github.com/apna-college/Alpha / printBinStrings

Method printBinStrings

7_RecursionBasics/RecursionBasics.java:149–162  ·  view source on GitHub ↗
(int n, int lastPlace, String str)

Source from the content-addressed store, hash-verified

147 }
148
149 public static void printBinStrings(int n, int lastPlace, String str) {
150 //base case
151 if(n == 0) {
152 System.out.println(str);
153 return;
154 }
155
156 //kaam
157 printBinStrings(n-1, 0, str+"0");
158
159 if(lastPlace == 0) {
160 printBinStrings(n-1, 1, str+"1");
161 }
162 }
163 public static void main(String args[]) {
164 printBinStrings(3, 0, "");
165 }

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected