Skip to content

Instantly share code, notes, and snippets.

// Binay tree by using the Array
package BTree;
public class BTest {
int arr[];
int lastusedindex;
public BTest(int size) {
arr = new int[size+1];
/* 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
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);
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.
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.
*/
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.
*/
import java.util.ArrayList;
import java.util.Iterator;
public class q1 {
}
class CollectionExerciseFour {
public static void main(String[] args) {
// TODO Auto-generated method stub
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());
package StackImplementation;
import nodes.Nodes;
import java.util.InputMismatchException;
import java.util.Scanner;
public class StackByLinkedList {
Nodes top;
public StackByLinkedList()
/*
Implementation of stack by using the linked list
*/
import java.util.InputMismatchException;
import java.util.Scanner;
// the node class