This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Q5_6 { | |
public static void main(String[] args){ | |
int test = 73; | |
System.out.println(Integer.toBinaryString(test)); | |
System.out.println(Integer.toBinaryString(SwapEvenOdd(test))); | |
} | |
public static int SwapEvenOdd(int n){ | |
int tempOdd = (n & 0x55555555) << 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Q5_5 { | |
public static void main(String[] args){ | |
int a = 73; | |
int b =834; | |
System.out.println("Binary a is:"+Integer.toBinaryString(a)); | |
System.out.println("Binary b is:"+Integer.toBinaryString(b)); | |
System.out.println(bitDifference(a,b)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Q5_3 { | |
public static void main(String[] args){ | |
int test = 0b11011001111111; | |
System.out.println(Integer.toBinaryString(test)); | |
System.out.println(Integer.toBinaryString(getPrevious(test))); | |
System.out.println(Integer.toBinaryString(getNext(test))); | |
} | |
public static int getPrevious(int n){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Q5_2 { | |
public static void main(String[] args){ | |
System.out.println(ToBinary(0.72,0)); | |
System.out.println(ToBinary(0.87948723,0)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Q5_1 { | |
public static void main(String[] args){ | |
int m =0b10011; | |
int n = 0b10000000001; | |
int i = 2; | |
int j = 6; | |
System.out.println(Integer.toBinaryString(InsertMN(m,n,i,j))); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package cc150_4_8; | |
public class CheckSubtree<Key extends Comparable<Key>> { | |
private Node root; | |
class Node{ | |
private Key key; | |
public Node left; | |
public Node right; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package cc150_4_7; | |
public class CommonAncestor<Key extends Comparable<Key>> { | |
private Node root; | |
class Node{ | |
private Key key; | |
public Node left; | |
public Node right; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package cc150_4_6; | |
public class NodeSuccessor<Key extends Comparable<Key>> { | |
private Node root; | |
class Node{ | |
private Key key; | |
public Node left; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package cc_150_4_5; | |
import java.util.Stack; | |
public class CheckTree<Key extends Comparable<Key>> { | |
private Node root; | |
public class Node{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package cc150_4_4; | |
import java.util.LinkedList; | |
public class ComDepth<Key extends Comparable<Key>> { | |
public Node root; | |
public class Node{ | |
private Key key; |