This file contains hidden or 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
| // Binay tree by using the Array | |
| package BTree; | |
| public class BTest { | |
| int arr[]; | |
| int lastusedindex; | |
| public BTest(int size) { | |
| arr = new int[size+1]; |
This file contains hidden or 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
| /* Quick Sort | |
| This algorithm is based on divide and conquer algorithm (We take the bigger problem , break it down to the smaller problem, try to solve the solution to | |
| smaller problem and then join the smaller solutions to get the final result | |
| concept of quick sort algorithm | |
| =============================== | |
| At each step it finds "pivot" (Means point of division)and then make sure that all the smaller elements are at left side of the pivot and all bigger | |
| elements are at right side of pivot. This we will do multiple times(Recursively) so that we get the final answer |
This file contains hidden or 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
| import java.util.HashSet; | |
| import java.util.Iterator; | |
| import java.util.Set; | |
| public class Testing78 { | |
| public static void main(String[] args) { | |
| Set obj = new HashSet(); | |
| obj.add("neeraj"); | |
| obj.add(12); | |
| obj.add(12); |
This file contains hidden or 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 collectionAssignments; | |
| import java.util.Comparator; | |
| import java.util.Iterator; | |
| import java.util.TreeSet; | |
| /* | |
| Create a Collection called TreeSet which is capable of storing String objects. | |
| They try these following operations: | |
| a) Reverse the elements of the Collection. |
This file contains hidden or 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 collectionAssignments; | |
| /* | |
| Develop a java class with a instance variable H1 (HashSet) | |
| add a method saveCountryNames(StringCountryName), the method should add the passed | |
| country to a HashSet (H1) and return the added HashSet (H1). | |
| develop a method getCountry(String CountryName) which iterates through the HashSet and returns the country | |
| if exist else return null. | |
| Note: - you can test the methods using a main method. | |
| */ |
This file contains hidden or 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 collectionAssignments; | |
| /* | |
| Develop a java class with a instance variable H1 (HashSet) | |
| add a method saveCountryNames(StringCountryName), the method should add the passed | |
| country to a HashSet (H1) and return the added HashSet (H1). | |
| develop a method getCountry(String CountryName) which iterates through the HashSet and returns the country | |
| if exist else return null. | |
| Note: - you can test the methods using a main method. | |
| */ |
This file contains hidden or 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
| import java.util.ArrayList; | |
| import java.util.Iterator; | |
| public class q1 { | |
| } | |
| class CollectionExerciseFour { | |
| public static void main(String[] args) { | |
| // TODO Auto-generated method stub |
This file contains hidden or 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 StringAssignments; | |
| public class StringAssign1 { | |
| public static void main(String[] args) | |
| { | |
| String str = "aeea"; | |
| StringBuffer str1 = new StringBuffer(str); | |
| str1.reverse(); | |
| System.out.println(str1); | |
| int ans = str.compareTo(str1.toString()); |
This file contains hidden or 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 StackImplementation; | |
| import nodes.Nodes; | |
| import java.util.InputMismatchException; | |
| import java.util.Scanner; | |
| public class StackByLinkedList { | |
| Nodes top; | |
| public StackByLinkedList() |
This file contains hidden or 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
| /* | |
| Implementation of stack by using the linked list | |
| */ | |
| import java.util.InputMismatchException; | |
| import java.util.Scanner; | |
| // the node class |