# September 2014

## Utopian Tree

Problem Statement
The Utopian Tree goes through 2 cycles of growth every year. The first growth cycle occurs during the spring, when it doubles in height. The second growth cycle occurs during the summer, when its height increases by 1 meter.
Now, a new Utopian Tree sapling is planted at the onset of spring. Its height is 1 meter. Can you find the height of the tree after N growth cycles?

### SOURCE CODE:

 #include<stdio.h>
void main()
{
int t,test,total;
scanf("%d",&test);
while(test--){
scanf("%d",&t);
total=1;
int flag=1;
while(t--)
{
if(flag){
if(total==1){
total+=1;
}else{
total*=2;
}
flag--;
}
else{
total+=1;
flag++;
}
}
printf("%d\n",total);
}
}


## Unipolar encoding has 2 voltage states with one of the states being 0 volts. Since Unipolar line encoding has one of its states being 0 Volts, it is also called Return to Zero (RTZ). A common example of Unipolar line encoding is the logic levels used in computers and digital logic. A logic High (1) is represented by +5V and a logic Low (0) is represented by 0V.

### SOURCE CODE:

 import java.util.Scanner;
public class Lowhigh {
public static void main(String[] args) {
String input = "";
String line1 = "";
String line2 = "";
String line3 = "";
int flag = 0, i;
Scanner inputs = new Scanner(System.in);
System.out.print("Enter the binary number :");
input = inputs.next();
for (i = 0; i < input.length(); i++) {
if (input.charAt(i) == '1') {
if (flag == 0) {
line1 += " ";
line2 += "|";
line3 += "|";
flag = 1;
}
line1 = line1 + " _ ";
line2 = line2 + "  ";
line3 = line3 + "  ";
} else {
if (flag == 1) {
line1 += " ";
line2 += "|";
line3 += "|";
flag = 0;
}
line1 = line1 + "  ";
line2 = line2 + "  ";
line3 = line3 + " _ ";
}
}
System.out.println(line1);
System.out.println(line2);
System.out.println(line3);
}
}