src/Recursion_Course/recursion_print.java
public static void coinTossNoConsecutive(int n, String ans, boolean wasHeadIncluded, boolean wasTailIncluded) {
		if (n == 0) {
			System.out.println(ans);
			return;
		}

		if (wasHeadIncluded == false && wasTailIncluded == false) {
			coinTossNoConsecutive(n - 1, ans + "H", true, false);
			coinTossNoConsecutive(n - 1, ans + "T", false, true);
		}

		if (wasHeadIncluded) {
			coinTossNoConsecutive(n - 1, ans + "T", false, true);
		}

		if (wasTailIncluded) {
			coinTossNoConsecutive(n - 1, ans + "H", true, false);
		}

	}
//	coin Toss with no consecutive heads and tails
coin Toss with no consecutive heads and tails
coin Toss with no consecutive heads and tails
public static void coinTossNoConsecutive(int n, String ans, boolean wasHeadIncluded, boolean wasTailIncluded) {
		if (n == 0) {
			System.out.println(ans);
			return;
		}
		if (wasHeadIncluded == false && wasTailIncluded == false) {
			coinTossNoConsecutive(n - 1, ans + "H", true, false);
			coinTossNoConsecutive(n - 1, ans + "T", false, true);
		}
		if (wasHeadIncluded) {
			coinTossNoConsecutive(n - 1, ans + "T", false, true);
		}
		if (wasTailIncluded) {
			coinTossNoConsecutive(n - 1, ans + "H", true, false);
		}
	}
public static void coinTossNoConsecutive ( int n , String ans , boolean wasHeadIncluded , boolean wasTailIncluded ) { if ( n == 0 ) { System . out . println ( ans ) ; return ; } if ( wasHeadIncluded == false && wasTailIncluded == false ) { coinTossNoConsecutive ( n - 1 , ans + "H" , true , false ) ; coinTossNoConsecutive ( n - 1 , ans + "T" , false , true ) ; } if ( wasHeadIncluded ) { coinTossNoConsecutive ( n - 1 , ans + "T" , false , true ) ; } if ( wasTailIncluded ) { coinTossNoConsecutive ( n - 1 , ans + "H" , true , false ) ; } }
coin Toss with no consecutive heads and tails
coin Toss with no consecutive heads and tails