From ed0ef1ccb0d9d36a0d8905dc05ef13da359e06f2 Mon Sep 17 00:00:00 2001 From: gitaman8481 <65482419+gitaman8481@users.noreply.github.com> Date: Tue, 18 Aug 2020 17:32:12 +0530 Subject: [PATCH 01/56] new folders added for program --- CollectionFramework/List.java | 14 ++++++ arrays/BasicArrays.java | 33 ++++++++++++++ arrays/FIndDublicate.java | 32 ++++++++++++++ arrays/package-info.java | 1 + basics/ControlStatements.java | 31 +++++++++++++ basics/DoWhileLoop.java | 15 +++++++ basics/Operators.java | 17 ++++++++ basics/Treedatastructure.java | 65 ++++++++++++++++++++++++++++ basics/VariablesandDataTypes.java | 15 +++++++ basics/WhileLoop.java | 16 +++++++ dataStructure/ArrayDequeDemo.java | 24 ++++++++++ dataStructure/ArrayListDemo.java | 33 ++++++++++++++ dataStructure/HashMapIntro.java | 28 ++++++++++++ dataStructure/LinkedListDemo.java | 35 +++++++++++++++ dataStructure/MyHashSet.java | 10 +++++ oops/A.java | 10 +++++ oops/Mor.java | 13 ++++++ oops/MyConstructor.java | 12 +++++ oops/Person.java | 7 +++ oops/RepairShop.java | 20 +++++++++ oops/Sonata.java | 12 +++++ oops/StaticKeyword.java | 15 +++++++ oops/Vehicle.java | 19 ++++++++ oops/Watches.java | 8 ++++ oopsEncapsulation/EncapIntro.java | 17 ++++++++ oopsEncapsulation/S.java | 30 +++++++++++++ oopsinheritance/MainClass.java | 20 +++++++++ oopsinheritance/Person.java | 15 +++++++ oopsinheritance/Singer.java | 9 ++++ oopsinheritance/Teacher.java | 9 ++++ patternsByloops/Pattern1.java | 18 ++++++++ patternsByloops/Pattern2.java | 17 ++++++++ patternsByloops/Pattern3.java | 18 ++++++++ patternsByloops/Pattern4.java | 20 +++++++++ patternsByloops/Pattern5.java | 30 +++++++++++++ patternsByloops/Pattern5_2.java | 24 ++++++++++ patternsByloops/Pattern6.java | 21 +++++++++ patternsByloops/Pattern7.java | 18 ++++++++ patternsByloops/Pattern8.java | 21 +++++++++ patternsByloops/Pattern9.java | 19 ++++++++ sdeProblems/FindDuplicate.java | 32 ++++++++++++++ sdeProblems/RotateArray.java | 38 ++++++++++++++++ sdeProblems/Test.java | 37 ++++++++++++++++ sortingAlgorithms/BubbleSort.java | 30 +++++++++++++ sortingAlgorithms/InsertionSort.java | 42 ++++++++++++++++++ sortingAlgorithms/SelectionSort.java | 42 ++++++++++++++++++ 46 files changed, 1012 insertions(+) create mode 100644 CollectionFramework/List.java create mode 100644 arrays/BasicArrays.java create mode 100644 arrays/FIndDublicate.java create mode 100644 arrays/package-info.java create mode 100644 basics/ControlStatements.java create mode 100644 basics/DoWhileLoop.java create mode 100644 basics/Operators.java create mode 100644 basics/Treedatastructure.java create mode 100644 basics/VariablesandDataTypes.java create mode 100644 basics/WhileLoop.java create mode 100644 dataStructure/ArrayDequeDemo.java create mode 100644 dataStructure/ArrayListDemo.java create mode 100644 dataStructure/HashMapIntro.java create mode 100644 dataStructure/LinkedListDemo.java create mode 100644 dataStructure/MyHashSet.java create mode 100644 oops/A.java create mode 100644 oops/Mor.java create mode 100644 oops/MyConstructor.java create mode 100644 oops/Person.java create mode 100644 oops/RepairShop.java create mode 100644 oops/Sonata.java create mode 100644 oops/StaticKeyword.java create mode 100644 oops/Vehicle.java create mode 100644 oops/Watches.java create mode 100644 oopsEncapsulation/EncapIntro.java create mode 100644 oopsEncapsulation/S.java create mode 100644 oopsinheritance/MainClass.java create mode 100644 oopsinheritance/Person.java create mode 100644 oopsinheritance/Singer.java create mode 100644 oopsinheritance/Teacher.java create mode 100644 patternsByloops/Pattern1.java create mode 100644 patternsByloops/Pattern2.java create mode 100644 patternsByloops/Pattern3.java create mode 100644 patternsByloops/Pattern4.java create mode 100644 patternsByloops/Pattern5.java create mode 100644 patternsByloops/Pattern5_2.java create mode 100644 patternsByloops/Pattern6.java create mode 100644 patternsByloops/Pattern7.java create mode 100644 patternsByloops/Pattern8.java create mode 100644 patternsByloops/Pattern9.java create mode 100644 sdeProblems/FindDuplicate.java create mode 100644 sdeProblems/RotateArray.java create mode 100644 sdeProblems/Test.java create mode 100644 sortingAlgorithms/BubbleSort.java create mode 100644 sortingAlgorithms/InsertionSort.java create mode 100644 sortingAlgorithms/SelectionSort.java diff --git a/CollectionFramework/List.java b/CollectionFramework/List.java new file mode 100644 index 0000000..689e035 --- /dev/null +++ b/CollectionFramework/List.java @@ -0,0 +1,14 @@ +package CollectionFramework; + +import java.util.LinkedList; +public class List{ + public static void main(String[] args) { + + LinkedList ll = new LinkedList<>(); + + ll.add("Aman"); + ll.add("Soni"); + ll.add(1, "Kumar"); + System.out.println(ll); + } +} diff --git a/arrays/BasicArrays.java b/arrays/BasicArrays.java new file mode 100644 index 0000000..2421967 --- /dev/null +++ b/arrays/BasicArrays.java @@ -0,0 +1,33 @@ +package arrays; + +import java.io.*; + +public class BasicArrays { + + public static void main(String[] args) { + + int a[]; + a = new int[5]; + + try { + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + for(int i=0;i<5;i++) { + int j=i+1; + System.out.println(" Enter element no." +j); + String s = br.readLine(); + a[i] = Integer.parseInt(s); + } + for(int i=0;i<5;i++) { + System.out.println("arr["+i+"]="+a[i]); + } + } + + catch(Exception e) { + System.out.println(""+e); + } + } +} + + + + diff --git a/arrays/FIndDublicate.java b/arrays/FIndDublicate.java new file mode 100644 index 0000000..a96cce0 --- /dev/null +++ b/arrays/FIndDublicate.java @@ -0,0 +1,32 @@ +package arrays; + +public class FIndDublicate { + // Implementing an array as a HashMap for finding duplicate elements + void printRepeating(int m[],int size) { + + int i; + System.out.print("The repeating elements are:"); + + for(i=0;i=0) m[Math.abs(m[i])] = -m[Math.abs(m[i])]; + else System.out.print(Math.abs(m[i]) + " "); + } + } + + //Driver Method + public static void main(String[] args) { + + FIndDublicate dublicate= new FIndDublicate(); // Making an object of FindDuplicate class + + int m[] = {1,2,3,1,3,6,6}; // Putting or declare values in or to array + int m_size = m.length; // variables which store size or length of array + + dublicate.printRepeating(m,m_size); // calling above function to pass value in it to print repeating elements + + } + +} + diff --git a/arrays/package-info.java b/arrays/package-info.java new file mode 100644 index 0000000..7fae96a --- /dev/null +++ b/arrays/package-info.java @@ -0,0 +1 @@ +package arrays; \ No newline at end of file diff --git a/basics/ControlStatements.java b/basics/ControlStatements.java new file mode 100644 index 0000000..2962c5f --- /dev/null +++ b/basics/ControlStatements.java @@ -0,0 +1,31 @@ +package basics; +// public class to implement or for run the code +public class ControlStatements { + + public static void main(String[] args) { + // for loop to implement switch case statement + for(int i =0;i<9;i++){ + // switch controle statement + switch(i) { + // case1 + case 1: + System.out.println(" i is zero."); + break; //break statement + //case2 + case 2: + System.out.println(" i is one."); + break; + //case3 + case 3: + System.out.println(" i is zero."); + break; + default: //default statement + System.out.println(" i is greater than 3."); + + } + + } + } +} + + diff --git a/basics/DoWhileLoop.java b/basics/DoWhileLoop.java new file mode 100644 index 0000000..a13f4c4 --- /dev/null +++ b/basics/DoWhileLoop.java @@ -0,0 +1,15 @@ +package basics; + +public class DoWhileLoop { + //method inside which do while loop will occur + public static void main(String[] args) { + + int n = 10; + //do while loop's do block + // must executes atleast once + do { + System.out.println(" tick " +n); + n--; + }while(n>0);// do while loop's while block + } // end of main method +}// end of class diff --git a/basics/Operators.java b/basics/Operators.java new file mode 100644 index 0000000..1d06969 --- /dev/null +++ b/basics/Operators.java @@ -0,0 +1,17 @@ +package basics; + +public class Operators { + + public static void main(String[] args) { + int a = 7,b= 6; + int c = a*b; //* (multiplication) operator + int d = a+b; // + addition operator + int e = a/b; // - substration operator + int f = a%b; // % modulus operator + int g = a^b; // ^ power operator + long h = b^a; + System.out.println(c + " " + d + " " + e + " " + f + " " + g + " " + h); + + } + +} diff --git a/basics/Treedatastructure.java b/basics/Treedatastructure.java new file mode 100644 index 0000000..cbdbe60 --- /dev/null +++ b/basics/Treedatastructure.java @@ -0,0 +1,65 @@ +package basics; + +// a node class +class Node{ + int key ; + Node left,right; + public Node(int item) { + key = item; + left = right = null; + } +} + +class Treedatastructure{ + // Root of Binary Tree + Node root; + + // Constructors + Treedatastructure(int key) + { + root = new Node(key); + } + + Treedatastructure() + { + root = null; + } + + public static void main(String[] args) + { + Treedatastructure tree = new Treedatastructure(); + + /*create root*/ + tree.root = new Node(1); + + /* following is the tree after above statement + + 1 + / \ + null null */ + + tree.root.left = new Node(2); + tree.root.right = new Node(3); + + /* 2 and 3 become left and right children of 1 + 1 + / \ + 2 3 + / \ / \ + null null null null */ + + + tree.root.left.left = new Node(4); + /* 4 becomes left child of 2 + 1 + / \ + 2 3 + / \ / \ + 4 null null null + / \ + null null + */ + + }} + + diff --git a/basics/VariablesandDataTypes.java b/basics/VariablesandDataTypes.java new file mode 100644 index 0000000..111d443 --- /dev/null +++ b/basics/VariablesandDataTypes.java @@ -0,0 +1,15 @@ +package basics; + +public class VariablesandDataTypes { + + public static void main(String[] args) { + + int age = 18; // integer data type + String name = "Aman"; // String data type + long number = 7023; // long data type + String address ="Behind Fort"; + System.out.println(age + " " + name + " " + number + " " + address); + + } + +} diff --git a/basics/WhileLoop.java b/basics/WhileLoop.java new file mode 100644 index 0000000..6c0195a --- /dev/null +++ b/basics/WhileLoop.java @@ -0,0 +1,16 @@ +package basics; + +public class WhileLoop { + + public static void main(String[] args) { + + int n = 5; + // while loop block + while(n>0) { + System.out.println(" tick " + n); + n--; // post substraction operator + } + + } + + } diff --git a/dataStructure/ArrayDequeDemo.java b/dataStructure/ArrayDequeDemo.java new file mode 100644 index 0000000..15aaa23 --- /dev/null +++ b/dataStructure/ArrayDequeDemo.java @@ -0,0 +1,24 @@ +package dataStructure; +import java.util.*; +public class ArrayDequeDemo { + + public static void main(String[] args) { + + ArrayDeque adq = new ArrayDeque(); + + adq.push("A"); + adq.push("B"); + adq.push("C"); + adq.push("D"); + adq.push("E"); + + System.out.print("Popping the stack:"); + + while(adq.peek()!=null) + System.out.print(adq.pop()+" "); + + System.out.println(); + + } + +} diff --git a/dataStructure/ArrayListDemo.java b/dataStructure/ArrayListDemo.java new file mode 100644 index 0000000..f0aae7e --- /dev/null +++ b/dataStructure/ArrayListDemo.java @@ -0,0 +1,33 @@ +package dataStructure; +import java.util.ArrayList; + +public class ArrayListDemo { + + public static void main(String[] args) { + + //Create an array list + ArrayList al = new ArrayList(); + System.out.println("Initial size of al:" + al.size()); + + //Add elements to array list + al.add("A"); + al.add("M"); + al.add("A"); + al.add("N"); + al.add("S"); + al.add("s1"); + System.out.println("Size of al after additions:" + al.size()); + + //Display the array list + System.out.println("Contents of al:" + al); + + //Remove elements from the array + al.remove("s1"); + + System.out.println("Size of al after deletions:"+ al.size()); + System.out.println("Contents of al:" + al); + + + } + +} diff --git a/dataStructure/HashMapIntro.java b/dataStructure/HashMapIntro.java new file mode 100644 index 0000000..bebd6c3 --- /dev/null +++ b/dataStructure/HashMapIntro.java @@ -0,0 +1,28 @@ +package dataStructure; +import java.util.HashMap; +public class HashMapIntro +{ + + public static void main(String[] args) + { + // Create an empty hash map + HashMap map = new HashMap<>(); + + // Add elements to the map + map.put("vishal", 10); + map.put("sachin", 30); + map.put("vaibhav", 20); + + // Print size and content + System.out.println("Size of map is:- " + map.size()); + System.out.println(map); + + // Check if a key is present and if present, print value + if ( map.containsKey("vishal")) + { + Integer a = map.get("vishal"); + System.out.println("value for key vishal is:- "+ a); + } + } + +} diff --git a/dataStructure/LinkedListDemo.java b/dataStructure/LinkedListDemo.java new file mode 100644 index 0000000..994ff70 --- /dev/null +++ b/dataStructure/LinkedListDemo.java @@ -0,0 +1,35 @@ +package dataStructure; +import java.util.LinkedList; +public class LinkedListDemo { + + public static void main(String[] args) { + // Create a linked list + LinkedList ll = new LinkedList<>(); + + // Add elements to the linked list + ll.add("A"); + ll.add("M"); + ll.add("M"); + ll.add("N"); + ll.add("S"); + ll.addFirst("S1"); + ll.addLast("S2"); + ll.add(1,"A1"); + System.out.println("Original contents of ll:"+ll); + + //Remove elements from the linked list + ll.remove("A1"); + System.out.println("Content of ll after deletion:"+ll); + + //Remove first & last elements + ll.removeFirst(); + ll.removeLast(); + System.out.println("ll after deleting first & last:" + ll); + + //Get & set value + String val = ll.get(2); + ll.set(2, val + "Changed"); + System.out.println("ll after change:"+ll); + } + +} diff --git a/dataStructure/MyHashSet.java b/dataStructure/MyHashSet.java new file mode 100644 index 0000000..e0b82f4 --- /dev/null +++ b/dataStructure/MyHashSet.java @@ -0,0 +1,10 @@ +package dataStructure; + +public class MyHashSet { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/oops/A.java b/oops/A.java new file mode 100644 index 0000000..face387 --- /dev/null +++ b/oops/A.java @@ -0,0 +1,10 @@ +package oops; + +public class A { +class B{ + int age; +} +static class C{ + String name; +} +} diff --git a/oops/Mor.java b/oops/Mor.java new file mode 100644 index 0000000..263c1c7 --- /dev/null +++ b/oops/Mor.java @@ -0,0 +1,13 @@ +package oops; + +public class Mor extends Watches { + + @Override + public void Digital() { + System.out.println("Method_overriding is digital"); + } + public void Royal() { + System.out.println("Method_overriding is royal"); + } + +} diff --git a/oops/MyConstructor.java b/oops/MyConstructor.java new file mode 100644 index 0000000..eadde6c --- /dev/null +++ b/oops/MyConstructor.java @@ -0,0 +1,12 @@ +package oops; + +public class MyConstructor { + + MyConstructor(){ + System.out.println("Obj is now created"); + } + public static void main(String[] args) { + MyConstructor obj = new MyConstructor(); + } + +} diff --git a/oops/Person.java b/oops/Person.java new file mode 100644 index 0000000..d17564a --- /dev/null +++ b/oops/Person.java @@ -0,0 +1,7 @@ +package oops; + +public class Person { +int age; +String name; +final static String breed = "HomoSapiens"; +} diff --git a/oops/RepairShop.java b/oops/RepairShop.java new file mode 100644 index 0000000..f119ee3 --- /dev/null +++ b/oops/RepairShop.java @@ -0,0 +1,20 @@ +package oops; + +public class RepairShop { + + + public static void repair (Watches ws) { + System.out.println("watch is repaired"); + } + public static void repair(Sonata sn) { + System.out.println("watch is repaired"); + } + public static void main(String[] args) { + Mor Mo = new Mor(); + Sonata sn = new Sonata(); + + repair(Mo); + repair(sn); + } + +} diff --git a/oops/Sonata.java b/oops/Sonata.java new file mode 100644 index 0000000..7d8972d --- /dev/null +++ b/oops/Sonata.java @@ -0,0 +1,12 @@ +package oops; + +public class Sonata extends Watches{ + + @Override + public void Digital() { + System.out.println("Sonata is digital"); + } + public void Royal() { + System.out.println("Sonata is royal"); + } +} diff --git a/oops/StaticKeyword.java b/oops/StaticKeyword.java new file mode 100644 index 0000000..ce2e6d9 --- /dev/null +++ b/oops/StaticKeyword.java @@ -0,0 +1,15 @@ +package oops; + +public class StaticKeyword { + public static void main(String[] args) { + Person obj = new Person(); + obj.name ="Aman"; + obj.age = 19; + System.out.println(obj.name); + System.out.println(obj.age + " age"); + System.out.println(obj.breed); + + + } + +} diff --git a/oops/Vehicle.java b/oops/Vehicle.java new file mode 100644 index 0000000..b6058cb --- /dev/null +++ b/oops/Vehicle.java @@ -0,0 +1,19 @@ +package oops; + +class transport{ + int wheels; + transport(){ + wheels = 4; + } +} + +public class Vehicle { + + public static void main(String[] args) { + + transport car = new transport(); + System.out.println(car.wheels + " wheels"); + + } + +} diff --git a/oops/Watches.java b/oops/Watches.java new file mode 100644 index 0000000..863a6d9 --- /dev/null +++ b/oops/Watches.java @@ -0,0 +1,8 @@ +package oops; + +public abstract class Watches { + + public abstract void Digital(); + public abstract void Royal(); + +} diff --git a/oopsEncapsulation/EncapIntro.java b/oopsEncapsulation/EncapIntro.java new file mode 100644 index 0000000..e069086 --- /dev/null +++ b/oopsEncapsulation/EncapIntro.java @@ -0,0 +1,17 @@ +package oopsEncapsulation; + +public class EncapIntro { + + public static void main(String[] args) { + + S obj = new S(); + + obj.setName("Milan"); + obj.setAge(16); + System.out.println(obj.getName()); + System.out.println(obj.getAge()); + + + } + +} diff --git a/oopsEncapsulation/S.java b/oopsEncapsulation/S.java new file mode 100644 index 0000000..f8de03c --- /dev/null +++ b/oopsEncapsulation/S.java @@ -0,0 +1,30 @@ +package oopsEncapsulation; + +public class S { + + /*we have to put the variables private to achieve encapsulation*/ + private int age; + + private String name; + + //setter methods + public void setAge(int age) { + if(age>20) System.out.println(" You are to old:"); + else this.age = age; + } + + public void setName(String name) { + this.name = name; + } + + //getter methods + public int getAge() { + return age; + } + + public String getName() { + return name; + } + + +} diff --git a/oopsinheritance/MainClass.java b/oopsinheritance/MainClass.java new file mode 100644 index 0000000..c4c5dd6 --- /dev/null +++ b/oopsinheritance/MainClass.java @@ -0,0 +1,20 @@ +package oopsinheritance; + +public class MainClass { + + public static void main(String[] args) { + + Teacher T = new Teacher(); + T.name = "Mr Harry "; + T.eat(); + T.walk(); + T.teach(); + + Singer s = new Singer(); + s.name = "Justin B "; + s.sing(); + s.eat(); + + } + +} diff --git a/oopsinheritance/Person.java b/oopsinheritance/Person.java new file mode 100644 index 0000000..d4c4805 --- /dev/null +++ b/oopsinheritance/Person.java @@ -0,0 +1,15 @@ +package oopsinheritance; + +public class Person { + + protected String name; + + public void walk() { + System.out.println(name + "is walking"); + } + + public void eat() { + System.out.println(name + "is eating"); + } + +} diff --git a/oopsinheritance/Singer.java b/oopsinheritance/Singer.java new file mode 100644 index 0000000..0d39ff4 --- /dev/null +++ b/oopsinheritance/Singer.java @@ -0,0 +1,9 @@ +package oopsinheritance; + +public class Singer extends Person { + + public void sing() { + System.out.println(name + "is singing"); + } + +} diff --git a/oopsinheritance/Teacher.java b/oopsinheritance/Teacher.java new file mode 100644 index 0000000..71e38d8 --- /dev/null +++ b/oopsinheritance/Teacher.java @@ -0,0 +1,9 @@ +package oopsinheritance; + +public class Teacher extends Person { + + public void teach() { + System.out.println(name + "is teaching"); + } + +} diff --git a/patternsByloops/Pattern1.java b/patternsByloops/Pattern1.java new file mode 100644 index 0000000..4546ec7 --- /dev/null +++ b/patternsByloops/Pattern1.java @@ -0,0 +1,18 @@ +package patternsByloops; + +public class Pattern1 { + + public static void main(String[] args) { + + int n = 6; + + for(int i= 0;i=i;j--) //j for horizontal stars + System.out.print("* "); //printing the stars + + System.out.println(); + } + } + +} diff --git a/patternsByloops/Pattern3.java b/patternsByloops/Pattern3.java new file mode 100644 index 0000000..d2a20ca --- /dev/null +++ b/patternsByloops/Pattern3.java @@ -0,0 +1,18 @@ +package patternsByloops; + +public class Pattern3 { + + public static void main(String[] args) { + + int n = 6; //size of the pattern + + for(int i=1;i<=n;i++) { //i for horizontal stars operation + + for(int j=n-1;j>=i;j--) //j for vertical stars operation + System.out.print("* "); //printing the stars + + System.out.println(); // for new line + } + } + +} diff --git a/patternsByloops/Pattern4.java b/patternsByloops/Pattern4.java new file mode 100644 index 0000000..3635f7e --- /dev/null +++ b/patternsByloops/Pattern4.java @@ -0,0 +1,20 @@ +package patternsByloops; + +public class Pattern4 { + public static void main(String[] args) { + + int n=6; //size of the pattern + + for(int i=n;i>=1;i--){ //i for horizontal stars + + for(int j=n-1;j>=i;j--) //j for vertical and for print & handling the spaces + System.out.print(" "); + + for(int k=1;k<=i;k++) //k variable for print the values + System.out.print("* "); //printing the stars + + System.out.println(); + } + } + +} diff --git a/patternsByloops/Pattern5.java b/patternsByloops/Pattern5.java new file mode 100644 index 0000000..a93e554 --- /dev/null +++ b/patternsByloops/Pattern5.java @@ -0,0 +1,30 @@ +package patternsByloops; + +public class Pattern5 { + + public static void main(String[] args) { + + int min_stars =0; /*change value to set minimum no. of stars in pyramid + take odd no.for odd no. of stars in each row 1-3-5 + etc + take even no. for even no. stars in each row,2-4-6 etc */ + + int p_height=6; //change value to increase or decrease the size of pyramid + + int p_space = p_height - 1; + + for(int i= 1;ii;j--) + System.out.print(" "); + + for(int k=0;k<=min_stars;k++) + System.out.print("* "); + + min_stars+=2; + System.out.println(); + } + + }//end of main +}//end of class diff --git a/patternsByloops/Pattern5_2.java b/patternsByloops/Pattern5_2.java new file mode 100644 index 0000000..3728cec --- /dev/null +++ b/patternsByloops/Pattern5_2.java @@ -0,0 +1,24 @@ +package patternsByloops; + +public class Pattern5_2 { + + public static void main(String[] args) { + + int n = 5; //size of pattern + + int px =n; //left print control + int py =n; //right print control + + for(int i=1;i<=n;i++) //i for horizontal stars + { + for(int j=1;j=px && j<=py) System.out.print("* "); //if condition is true then print the stars + else System.out.print(" "); //else print the spaces + + px--; //post decrementing the left print control + py++; //post incrementing the right print control + System.out.println(); + } + + } +} diff --git a/patternsByloops/Pattern6.java b/patternsByloops/Pattern6.java new file mode 100644 index 0000000..efb017c --- /dev/null +++ b/patternsByloops/Pattern6.java @@ -0,0 +1,21 @@ +package patternsByloops; + +public class Pattern6 { + + public static void main(String[] args) + { + int n=5; + //size of pattern + for(int i= n;i>=1;i--) + { + for(int j=n-1;j>=i;j--) // loop for print the spaces + System.out.print(" "); //printing the spaces + + for(int k =1;k<=i;k++) // loop for print the stars + System.out.print("*"); //printing the stars + + System.out.println(); //for new line + }//end of loop + + }//end of main +}//end of class diff --git a/patternsByloops/Pattern7.java b/patternsByloops/Pattern7.java new file mode 100644 index 0000000..4365cb5 --- /dev/null +++ b/patternsByloops/Pattern7.java @@ -0,0 +1,18 @@ +package patternsByloops; + +public class Pattern7 +{ + public static void main(String[] args) + { + + int size = 3; //size of the pattern + + for(int i=size;i>=-size;i--) //loop to print the stars + { + for( int j=size;j>=Math.abs(i);j--) //inner or nested loop for print the stars + System.out.print("* "); + + System.out.println(); //for new line + }//end of loop + }//end of main +}//end of class diff --git a/patternsByloops/Pattern8.java b/patternsByloops/Pattern8.java new file mode 100644 index 0000000..8ef97cb --- /dev/null +++ b/patternsByloops/Pattern8.java @@ -0,0 +1,21 @@ +package patternsByloops; + +public class Pattern8 +{ + public static void main(String[] args) + { + int size = 3; //size of pattern + + for(int i=size;i>=-size;i--) { //loop for handling spaces & stars + + for(int j=1;j<=Math.abs(i);j++) //inner or nested loop to handle or print spaces + System.out.print(" "); //printing the spaces + + for(int k=size;k>=Math.abs(i);k--) //inner or nested loop to handle or print stars + System.out.print("*"); //printing the stars + + System.out.println(); //for new line + }//end of loop + + }//end of main +}//end of class diff --git a/patternsByloops/Pattern9.java b/patternsByloops/Pattern9.java new file mode 100644 index 0000000..d9ea106 --- /dev/null +++ b/patternsByloops/Pattern9.java @@ -0,0 +1,19 @@ +package patternsByloops; + +public class Pattern9 { + + public static void main(String[] args) { + + int size = 3; //size of pattern + for(int i=size;i>=-size;i--) //loop for handle stars & spaces + { + for(int j=1;j<=Math.abs(i);j++) //inner or nested loop for spaces + System.out.print(" "); //printing the spaces + + for(int k=size;k>=Math.abs(i);k--) //inner or nested loop for stars + System.out.print("* "); //printing the stars + + System.out.println(); //new line + } + }//end of main +}//end of class diff --git a/sdeProblems/FindDuplicate.java b/sdeProblems/FindDuplicate.java new file mode 100644 index 0000000..df101dc --- /dev/null +++ b/sdeProblems/FindDuplicate.java @@ -0,0 +1,32 @@ +package sdeProblems; + +public class FindDuplicate { + + // Implementing an array as a HashMap for finding duplicate elements + void printRepeating(int m[],int size) { + + int i; + System.out.print("The repeating elements are:"); + + for(i=0;i=0) m[Math.abs(m[i])] = -m[Math.abs(m[i])]; + else System.out.print(Math.abs(m[i]) + " "); + } + } + + //Driver Method + public static void main(String[] args) { + + FindDuplicate duplicate = new FindDuplicate(); // Making an object of FindDuplicate class + + int m[] = {1,2,3,1,3,6,6}; // Putting or declare values in or to array + int m_size = m.length; // variables which store size or length of array + + duplicate.printRepeating(m,m_size); // calling above function to pass value in it to print repeating elements + + } + + } diff --git a/sdeProblems/RotateArray.java b/sdeProblems/RotateArray.java new file mode 100644 index 0000000..69b6ef1 --- /dev/null +++ b/sdeProblems/RotateArray.java @@ -0,0 +1,38 @@ +package sdeProblems; + +public class RotateArray { + + //function to rotate the elements of an array + + void rotateL(int a[], int d, int n) { + for(int i= 0;i=0; i--) + { + /* Find the smallest element greater than ar2[i]. Move all elements one position ahead till the smallest greater + element is not found */ + int j, last = arr1[m-1]; + + for (j=m-2; j >= 0 && arr1[j] > arr2[i]; j--) + arr1[j+1] = arr1[j]; + + // If there was a greater element + if (j != m-2 || last > arr2[i]) { + arr1[j+1] = arr2[i]; + arr2[i] = last; } + } + } + + // Driver method to test the above function + public static void main1(String[] args) + { + merge(arr1.length,arr2.length); + System.out.print("After Merging nFirst Array: "); + System.out.println(Arrays.toString(arr1)); + System.out.print("Second Array: "); + System.out.println(Arrays.toString(arr2)); + } +} diff --git a/sortingAlgorithms/BubbleSort.java b/sortingAlgorithms/BubbleSort.java new file mode 100644 index 0000000..4bd2323 --- /dev/null +++ b/sortingAlgorithms/BubbleSort.java @@ -0,0 +1,30 @@ +package sortingAlgorithms; + +public class BubbleSort { + + public static void main(String[] args) { + + int a[] = {7,9,-4,6,8,5}; + int n = a.length; + + for(int i=0;i<=n-1-i;i++) { + for(int j=0;j<=n-1-i;j++) { + + boolean sorted = true; + + if(a[j+1] < a[j]){ + int temp = a[j+1]; + a[j+1] = a[j]; + a[j]= temp; + sorted = false; + } + + if(sorted) break; + } + } + + for(int item:a) + System.out.print(item+" "); + + }//end of main +}//end of class diff --git a/sortingAlgorithms/InsertionSort.java b/sortingAlgorithms/InsertionSort.java new file mode 100644 index 0000000..2efb58c --- /dev/null +++ b/sortingAlgorithms/InsertionSort.java @@ -0,0 +1,42 @@ +package sortingAlgorithms; + +public class InsertionSort { + + /*Function to sort array using insertion sort*/ + void sort(int arr[]) + { + int n = arr.length; + for (int i = 1; i < n; ++i) { + int key = arr[i]; + int j = i - 1; + + while (j >= 0 && arr[j] > key) { + arr[j + 1] = arr[j]; + j = j - 1; + } + arr[j + 1] = key; + } + } + + /* A utility function to print array of size n*/ + static void printArray(int arr[]) + { + int n = arr.length; + for (int i = 0; i < n; ++i) + System.out.print(arr[i] + " "); + + System.out.println(); + } + + // Driver method + public static void main(String args[]) + { + int arr[] = { 12, 11, 13, 5, 6 }; + + InsertionSort ob = new InsertionSort(); + ob.sort(arr); + + printArray(arr); + } +} + diff --git a/sortingAlgorithms/SelectionSort.java b/sortingAlgorithms/SelectionSort.java new file mode 100644 index 0000000..a517475 --- /dev/null +++ b/sortingAlgorithms/SelectionSort.java @@ -0,0 +1,42 @@ +package sortingAlgorithms; + +public class SelectionSort { + + void sort(int arr[]) + { + int n = arr.length; + + // One by one move boundary of unsorted sub-array + for (int i = 0; i < n-1; i++) { + // Find the minimum element in unsorted array + int min_idx = i; + for (int j = i+1; j < n; j++) + if (arr[j] < arr[min_idx]) + min_idx = j; + + // Swap the found minimum element with the first + // element + int temp = arr[min_idx]; + arr[min_idx] = arr[i]; + arr[i] = temp; + } + } + + // Prints the array + void printArray(int arr[]) { + int n = arr.length; + for (int i=0; i Date: Thu, 20 Aug 2020 11:38:27 +0530 Subject: [PATCH 02/56] Create README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..a93624f --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Java-Programs +This is a repository where, I will upload and keep up to date my Java, DataStructure and algorithms code and question regarding to them,which i practiced on eclipse with help of Books. +The books i refer and use for learning java and algorithms are 1. Java for Dummies. 2. Java The Complete Reference by Herberth Schildt. 3. Algorithms by Sedwig. 4. Algorithms by Cormen. From 877cdc3a6a199f2da1cf0bad6c565f51f310f6c1 Mon Sep 17 00:00:00 2001 From: gitaman8481 <65482419+gitaman8481@users.noreply.github.com> Date: Tue, 25 Aug 2020 11:56:53 +0530 Subject: [PATCH 03/56] JAva program update --- dataStructure/MYStackByList.java | 121 +++++++++++++++++++++++++++++++ dataStructure/MyQueue.java | 82 +++++++++++++++++++++ dataStructure/MyStack.java | 58 +++++++++++++++ 3 files changed, 261 insertions(+) create mode 100644 dataStructure/MYStackByList.java create mode 100644 dataStructure/MyQueue.java create mode 100644 dataStructure/MyStack.java diff --git a/dataStructure/MYStackByList.java b/dataStructure/MYStackByList.java new file mode 100644 index 0000000..01fea0f --- /dev/null +++ b/dataStructure/MYStackByList.java @@ -0,0 +1,121 @@ +package dataStructure; + +//Java program to Implement a stack +//using singly linked list +//import package +import static java.lang.System.exit; + +//Create Stack Using Linked list +class StackUsingLinkedlist { + + // A linked list node + private class Node { + + int data; // integer data + Node link; // reference variable Node type + } + // create global top reference variable global + Node top; + // Constructor + StackUsingLinkedlist() + { + this.top = null; + } + + // Utility function to add an element x in the stack + public void push(int x) // insert at the beginning + { + // create new node temp and allocate memory + Node temp = new Node(); + + // initialize data into data field + temp.data = x; + + // put top reference into link + temp.link = top; + + // update top reference + top = temp; + } + + // Utility function to check if the stack is empty or not + public boolean isEmpty() + { + return top == null; + } + + // Utility function to return top element in a stack + public int peek() + { + // check for empty stack + if (!isEmpty()) { + return top.data; + } + else { + System.out.println("Stack is empty"); + return -1; + } + } + + // Utility function to pop top element from the stack + public void pop() // remove at the beginning + { + // check for stack underflow + if (top == null) { + System.out.print("\nStack Underflow"); + return; + } + + // update the top pointer to point to the next node + top = (top).link; + } + + public void display() + { + // check for stack underflow + if (top == null) { + System.out.printf("\nStack Underflow"); + exit(1); + } + else { + Node temp = top; + while (temp != null) { + + // print node data + System.out.printf("%d->", temp.data); + + // assign temp link to temp + temp = temp.link; + } + } + } +} +//main class +public class MYStackByList { + public static void main(String[] args) + { + // create Object of Implementing class + StackUsingLinkedlist obj = new StackUsingLinkedlist(); + // insert Stack value + obj.push(11); + obj.push(22); + obj.push(33); + obj.push(44); + + // print Stack elements + obj.display(); + + // print Top element of Stack + System.out.printf("\nTop element is %d\n", obj.peek()); + + // Delete top element of Stack + obj.pop(); + obj.pop(); + + // print Stack elements + obj.display(); + + // print Top element of Stack + System.out.printf("\nTop element is %d\n", obj.peek()); + } +} diff --git a/dataStructure/MyQueue.java b/dataStructure/MyQueue.java new file mode 100644 index 0000000..0cb291e --- /dev/null +++ b/dataStructure/MyQueue.java @@ -0,0 +1,82 @@ +//Java program for array implementation of queue +package dataStructure; +//A class to represent a queue +class Queue{ + int front, rear, size; + int capacity; + int array[]; + + public Queue(int capacity) { + this.capacity = capacity; + front = this.size = 0; + rear = capacity - 1; + array = new int[this.capacity]; + } + + //Queue is full when size becomes equal to capacity + boolean isFull(Queue queue) { + return(queue.size == queue.capacity); + } + + //Queue is Empty when size is 0 + boolean isEmpty(Queue queue){ + return(queue.size == 0); + } + + //Method to add an item to the queue + //It changes rear and size + void enqueue(int item) { + if(isFull(this)) + return; + this.rear = (this.rear+1)%this.capacity; + this.array[this.rear] = item; + this.size = this.size+1; + System.out.println(item + " enqueud to queue"); + } + + //Method to remove an item from queue + //It changes front and size + int dequeue() { + if(isEmpty(this)) + return Integer.MIN_VALUE; + + int item = this.array[this.front]; + this.front = (this.front + 1) % this.capacity; + this.size = this.size-1; + return item; + + } + + //Method to get front of queue + int front() { + if(isEmpty(this)) + return Integer.MIN_VALUE; + + return this.array[this.front]; + } + + //Method to get rear of queue + int rear() { + if(isEmpty(this)) + return Integer.MIN_VALUE; + + return this.array[this.rear]; + } +} + +//Driver Class +public class MyQueue{ + public static void main(String[] args){ + + Queue queue = new Queue(1000); + + queue.enqueue(10); + queue.enqueue(20); + queue.enqueue(30); + queue.enqueue(40); + + System.out.println(queue.dequeue()+(" dequeued from queue")); + System.out.println("Front item is " + queue.front()); + System.out.println("Rear item is "+ queue.rear()); + } +} diff --git a/dataStructure/MyStack.java b/dataStructure/MyStack.java new file mode 100644 index 0000000..0c45b42 --- /dev/null +++ b/dataStructure/MyStack.java @@ -0,0 +1,58 @@ +package dataStructure; + + class Stack { + static final int MAX = 1000; + int top; + int a[] = new int[MAX]; + + boolean isEmpty() { + return (top<0); + } + + Stack(){ + top = -1; + } + + boolean push(int x) { + if(top>= (MAX-1)) { + System.out.println(x+"pushed into stack"); + return false; + } + else { + a[++top] = x; + System.out.println(x+"pushed into stack"); + return true; + } + } + + int pop() { + if(top<0) { + System.out.println("Stack underflow"); + return 0; + } + else { + int x = a[top--]; + return x; + } + } + + int peek() { + if(top<0) { + System.out.println("Stack underflow"); + return 0; + } + else { + int x = a[top]; return x; + } + } + + class MyStack{ + public void main (String[] args) { + Stack s = new Stack(); + s.push(10); + s.push(20); + s.push(30); + System.out.println(s.pop() + " Popped from stack"); + } + } +} From 26d2d577f3d9fe69db155171c374a6391232703f Mon Sep 17 00:00:00 2001 From: gitaman8481 <65482419+gitaman8481@users.noreply.github.com> Date: Sat, 12 Sep 2020 14:30:30 +0530 Subject: [PATCH 04/56] this is repo to be commited --- arrays/Maximum_subarray_problem.java | 44 +++++++ arrays/RotateArray.java | 38 ++++++ ...out_using_extra_space_or_sorting_algo.java | 38 ++++++ basicProblems/Factorial.java | 19 +++ basicProblems/Fibonacci_Series.java | 24 ++++ .../Multiplicative_Table_till_20.java | 20 +++ basicProblems/Palindrome_Number.java | 13 ++ basicProblems/Prime_Number_Or_Not.java | 21 +++ basicProblems/Series_Sum_1.java | 20 +++ basicProblems/Series_Sum_2.java | 32 +++++ basicProblems/Swap_two_numbers.java | 22 ++++ basicProblems/X_raisedTo_power_Y.java | 18 +++ .../List.java | 2 +- dataStructure/MyArrayList.java | 33 +++++ dataStructure/MyHashMap.java | 28 ++++ dataStructure/MyHashSet.java | 15 ++- dataStructure/MyLinkedList.java | 35 +++++ dataStructure/SetExample.java | 34 +++++ dataStructure/Tree.java | 52 ++++++++ oops/A.java | 12 +- oops/MYStaticKeyword.java | 22 ++++ oops/MyConstructor.java | 1 + oops/StaticKeyword.java | 4 +- oopsabstraction/Audi.java | 14 ++ oopsabstraction/Car.java | 8 ++ oopsabstraction/RepairShop.java | 21 +++ oopsabstraction/WagonR.java | 20 +++ oopspolymorphism/Animal.java | 5 + oopspolymorphism/Dog.java | 10 ++ oopspolymorphism/MainClass.java | 29 +++++ oopspolymorphism/Pet.java | 9 ++ queues/ArrayDequeDemo.java | 24 ++++ recursion/Factorial_using_Recursion.java | 21 +++ searchingAlgorithms/BinarySearch.java | 46 +++++++ searchingAlgorithms/LinearSearch.java | 28 ++++ searchingAlgorithms/package-info.java | 1 + sortingAlgorithms/BubbleSort.java | 58 +++++---- sortingAlgorithms/HeapSort.java | 77 +++++++++++ sortingAlgorithms/MergeSort.java | 98 ++++++++++++++ sortingAlgorithms/QuickSort.java | 80 ++++++++++++ sortingAlgorithms/RadixSort.java | 73 +++++++++++ stack/MYStackByList.java | 121 ++++++++++++++++++ trees/FindFullNodesInABinaryTree.java | 47 +++++++ trees/Insertion_In_BinaryTree.java | 78 +++++++++++ 44 files changed, 1380 insertions(+), 35 deletions(-) create mode 100644 arrays/Maximum_subarray_problem.java create mode 100644 arrays/RotateArray.java create mode 100644 arrays/Sort_an_array_of_0s_1s_2s_without_using_extra_space_or_sorting_algo.java create mode 100644 basicProblems/Factorial.java create mode 100644 basicProblems/Fibonacci_Series.java create mode 100644 basicProblems/Multiplicative_Table_till_20.java create mode 100644 basicProblems/Palindrome_Number.java create mode 100644 basicProblems/Prime_Number_Or_Not.java create mode 100644 basicProblems/Series_Sum_1.java create mode 100644 basicProblems/Series_Sum_2.java create mode 100644 basicProblems/Swap_two_numbers.java create mode 100644 basicProblems/X_raisedTo_power_Y.java rename {CollectionFramework => dataStructure}/List.java (89%) create mode 100644 dataStructure/MyArrayList.java create mode 100644 dataStructure/MyHashMap.java create mode 100644 dataStructure/MyLinkedList.java create mode 100644 dataStructure/SetExample.java create mode 100644 dataStructure/Tree.java create mode 100644 oops/MYStaticKeyword.java create mode 100644 oopsabstraction/Audi.java create mode 100644 oopsabstraction/Car.java create mode 100644 oopsabstraction/RepairShop.java create mode 100644 oopsabstraction/WagonR.java create mode 100644 oopspolymorphism/Animal.java create mode 100644 oopspolymorphism/Dog.java create mode 100644 oopspolymorphism/MainClass.java create mode 100644 oopspolymorphism/Pet.java create mode 100644 queues/ArrayDequeDemo.java create mode 100644 recursion/Factorial_using_Recursion.java create mode 100644 searchingAlgorithms/BinarySearch.java create mode 100644 searchingAlgorithms/LinearSearch.java create mode 100644 searchingAlgorithms/package-info.java create mode 100644 sortingAlgorithms/HeapSort.java create mode 100644 sortingAlgorithms/MergeSort.java create mode 100644 sortingAlgorithms/QuickSort.java create mode 100644 sortingAlgorithms/RadixSort.java create mode 100644 stack/MYStackByList.java create mode 100644 trees/FindFullNodesInABinaryTree.java create mode 100644 trees/Insertion_In_BinaryTree.java diff --git a/arrays/Maximum_subarray_problem.java b/arrays/Maximum_subarray_problem.java new file mode 100644 index 0000000..724dcf7 --- /dev/null +++ b/arrays/Maximum_subarray_problem.java @@ -0,0 +1,44 @@ +package arrays; + +public class Maximum_subarray_problem { + // Java program to print largest + // contiguous array sum + + static void maxSubArraySum(int a[], int size) + { + int max_so_far = Integer.MIN_VALUE, + max_ending_here = 0,start = 0, + end = 0, s = 0; + + for (int i = 0; i < size; i++) + { + max_ending_here += a[i]; + + if (max_so_far < max_ending_here) + { + max_so_far = max_ending_here; + start = s; + end = i; + } + + if (max_ending_here < 0) + { + max_ending_here = 0; + s = i + 1; + } + } + System.out.println("Maximum contiguous sum is " + + max_so_far); + System.out.println("Starting index " + start); + System.out.println("Ending index " + end); + } + + // Driver code + public static void main(String[] args) + { + int a[] = { -2, -3, 4, -1, -2, 1, 5, -3 }; + int n = a.length; + maxSubArraySum(a, n); + } + } + diff --git a/arrays/RotateArray.java b/arrays/RotateArray.java new file mode 100644 index 0000000..00691e4 --- /dev/null +++ b/arrays/RotateArray.java @@ -0,0 +1,38 @@ +package arrays; + +public class RotateArray { + + //function to rotate the elements of an array + + void rotateL(int a[], int d, int n) { + for(int i= 0;i=0; i--) + { + /* Find the smallest element greater than ar2[i]. Move all elements one position ahead till the smallest greater + element is not found */ + int j, last = arr1[m-1]; + + for (j=m-2; j >= 0 && arr1[j] > arr2[i]; j--) + arr1[j+1] = arr1[j]; + + // If there was a greater element + if (j != m-2 || last > arr2[i]) { + arr1[j+1] = arr2[i]; + arr2[i] = last; + + } + } + } + + // Driver method to test the above function + public static void main1(String[] args) + { + merge(arr1.length,arr2.length); + System.out.print("After Merging nFirst Array: "); + System.out.println(Arrays.toString(arr1)); + System.out.print("Second Array: "); + System.out.println(Arrays.toString(arr2)); + } +} diff --git a/basicProblems/Factorial.java b/basicProblems/Factorial.java new file mode 100644 index 0000000..f4a4355 --- /dev/null +++ b/basicProblems/Factorial.java @@ -0,0 +1,19 @@ +package basicProblems; +import java.util.*; +public class Factorial { + + public static void main(String[] args) { + int fact=1; + @SuppressWarnings("resource") + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + + for(int i = n ; i>=1;i--) { + fact = fact*i; + } + + System.out.println("fact of " + n + " is " + fact ); + } +} + + diff --git a/basicProblems/Fibonacci_Series.java b/basicProblems/Fibonacci_Series.java new file mode 100644 index 0000000..2772bc1 --- /dev/null +++ b/basicProblems/Fibonacci_Series.java @@ -0,0 +1,24 @@ +package basicProblems; +import java.util.*; +public class Fibonacci_Series { + + public static void main(String[] args) { + + @SuppressWarnings("resource") + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int a=0,b=1; + + System.out.println(a + " "); + System.out.println(b + " "); + + for(int i=0;i al = new ArrayList(); + System.out.println("Initial size of al:" + al.size()); + + //Add elements to array list + al.add("A"); + al.add("M"); + al.add("A"); + al.add("N"); + al.add("S"); + al.add("s1"); + System.out.println("Size of al after additions:" + al.size()); + + //Display the array list + System.out.println("Contents of al:" + al); + + //Remove elements from the array + al.remove("s1"); + + System.out.println("Size of al after deletions:"+ al.size()); + System.out.println("Contents of al:" + al); + + + } + +} diff --git a/dataStructure/MyHashMap.java b/dataStructure/MyHashMap.java new file mode 100644 index 0000000..3d7cc2f --- /dev/null +++ b/dataStructure/MyHashMap.java @@ -0,0 +1,28 @@ +package dataStructure; +import java.util.HashMap; +public class MyHashMap +{ + + public static void main(String[] args) + { + // Create an empty hash map + HashMap map = new HashMap<>(); + + // Add elements to the map + map.put("vishal", 10); + map.put("sachin", 30); + map.put("vaibhav", 20); + + // Print size and content + System.out.println("Size of map is:- " + map.size()); + System.out.println(map); + + // Check if a key is present and if present, print value + if ( map.containsKey("vishal")) + { + Integer a = map.get("vishal"); + System.out.println("value for key vishal is:- "+ a); + } + } + +} diff --git a/dataStructure/MyHashSet.java b/dataStructure/MyHashSet.java index e0b82f4..7537ba5 100644 --- a/dataStructure/MyHashSet.java +++ b/dataStructure/MyHashSet.java @@ -1,10 +1,21 @@ package dataStructure; +import java.util.HashSet; + public class MyHashSet { public static void main(String[] args) { - // TODO Auto-generated method stub - + + HashSet hs = new HashSet<>(); + + hs.add("Beta"); + hs.add("Alpha"); + hs.add("Gama"); + hs.add("Eplision"); + hs.add("Omega"); + + System.out.println(hs); + } } diff --git a/dataStructure/MyLinkedList.java b/dataStructure/MyLinkedList.java new file mode 100644 index 0000000..977d3e9 --- /dev/null +++ b/dataStructure/MyLinkedList.java @@ -0,0 +1,35 @@ +package dataStructure; +import java.util.LinkedList; +public class MyLinkedList { + + public static void main(String[] args) { + // Create a linked list + LinkedList ll = new LinkedList<>(); + + // Add elements to the linked list + ll.add("A"); + ll.add("M"); + ll.add("M"); + ll.add("N"); + ll.add("S"); + ll.addFirst("S1"); + ll.addLast("S2"); + ll.add(1,"A1"); + System.out.println("Original contents of ll:"+ll); + + //Remove elements from the linked list + ll.remove("A1"); + System.out.println("Content of ll after deletion:"+ll); + + //Remove first & last elements + ll.removeFirst(); + ll.removeLast(); + System.out.println("ll after deleting first & last:" + ll); + + //Get & set value + String val = ll.get(2); + ll.set(2, val + "Changed"); + System.out.println("ll after change:"+ll); + } + +} diff --git a/dataStructure/SetExample.java b/dataStructure/SetExample.java new file mode 100644 index 0000000..ad4bb39 --- /dev/null +++ b/dataStructure/SetExample.java @@ -0,0 +1,34 @@ +package dataStructure; +// Java program to demonstrate the +// union, intersection and difference +// operations on sets +import java.util.*; +public class SetExample +{ + public static void main(String args[]) + { + Set a = new HashSet(); + a.addAll(Arrays.asList(new Integer[] {1, 3, 2, 4, 8, 9, 0})); + Set b = new HashSet(); + b.addAll(Arrays.asList(new Integer[] {1, 3, 7, 5, 4, 0, 7, 5})); + + // To find union + Set union = new HashSet(a); + union.addAll(b); + System.out.print("Union of the two Set"); + System.out.println(union); + + // To find intersection + Set intersection = new HashSet(a); + + intersection.retainAll(b); + System.out.print("Intersection of the two Set"); + System.out.println(intersection); + + // To find the symmetric difference + Set difference = new HashSet(a); + difference.removeAll(b); + System.out.print("Difference of the two Set"); + System.out.println(difference); + } +} diff --git a/dataStructure/Tree.java b/dataStructure/Tree.java new file mode 100644 index 0000000..8581c0a --- /dev/null +++ b/dataStructure/Tree.java @@ -0,0 +1,52 @@ +package dataStructure; + +//class containing left & right child of current node & key value +class Node{ + int key; + Node left,right; + public Node(int item) { + key = item; + left = right = null; + } +} + +// A java program to introduce Binary Tree +public class Tree { + + //Root node of binary tree + Node root; + + //Constructors + Tree(int key){ + root = new Node(key); + } + + Tree(){ + root = null; + } + public static void main(String[] args) { + Tree t = new Tree(); + //create root + t.root = new Node(1); + + /* following is the tree after above statement + 1 + / \ + null null*/ + + t.root.left = new Node(2); + t.root.right = new Node(3); + /* 2 & 3 become left & right children of 1 + * 1 + * / \ + * 2 3 + * / \ | \ + * null null null null + */ + t.root.left.left = new Node(4); + t.root.right.right = new Node(5); + t.root.right.left = new Node(6); + t.root.left.right = new Node(7); + + } +} diff --git a/oops/A.java b/oops/A.java index face387..aec9a69 100644 --- a/oops/A.java +++ b/oops/A.java @@ -1,10 +1,10 @@ package oops; public class A { -class B{ - int age; -} -static class C{ - String name; -} + class B{ + int age; + } + static class C{ + String name; + } } diff --git a/oops/MYStaticKeyword.java b/oops/MYStaticKeyword.java new file mode 100644 index 0000000..181746e --- /dev/null +++ b/oops/MYStaticKeyword.java @@ -0,0 +1,22 @@ +package oops; +import oops.A.C; +public class MYStaticKeyword { + + static { + System.out.println("in block 1"); + } + static { + System.out.println("in block 2"); + } + + public static void main(String[] args) { + + A objA = new A(); + @SuppressWarnings("unused") + A.B objB = objA.new B(); + @SuppressWarnings("unused") + C objC = new A.C(); + System.out.println("inside main"); + } + +} diff --git a/oops/MyConstructor.java b/oops/MyConstructor.java index eadde6c..d5ebf6b 100644 --- a/oops/MyConstructor.java +++ b/oops/MyConstructor.java @@ -6,6 +6,7 @@ public class MyConstructor { System.out.println("Obj is now created"); } public static void main(String[] args) { + @SuppressWarnings("unused") MyConstructor obj = new MyConstructor(); } diff --git a/oops/StaticKeyword.java b/oops/StaticKeyword.java index ce2e6d9..7ae5504 100644 --- a/oops/StaticKeyword.java +++ b/oops/StaticKeyword.java @@ -7,9 +7,7 @@ public static void main(String[] args) { obj.age = 19; System.out.println(obj.name); System.out.println(obj.age + " age"); - System.out.println(obj.breed); - - + System.out.println(Person.breed); } } diff --git a/oopsabstraction/Audi.java b/oopsabstraction/Audi.java new file mode 100644 index 0000000..26d5ed8 --- /dev/null +++ b/oopsabstraction/Audi.java @@ -0,0 +1,14 @@ +package oopsabstraction; + +public class Audi extends Car{ + + public void accelerate() { + System.out.println("Audi is accelerating"); + } + @Override + public void apply_break() { + System.out.println("Audi is breaking"); + + } + +} diff --git a/oopsabstraction/Car.java b/oopsabstraction/Car.java new file mode 100644 index 0000000..dceb3b5 --- /dev/null +++ b/oopsabstraction/Car.java @@ -0,0 +1,8 @@ +package oopsabstraction; + +public abstract class Car { + + public abstract void accelerate(); + public abstract void apply_break(); + +} diff --git a/oopsabstraction/RepairShop.java b/oopsabstraction/RepairShop.java new file mode 100644 index 0000000..6a09ac2 --- /dev/null +++ b/oopsabstraction/RepairShop.java @@ -0,0 +1,21 @@ +package oopsabstraction; + +public class RepairShop { + + public static void repairCar(Car car) { + System.out.println("car is repaired"); + } + + public static void repairCar(Car...Audi) { + System.out.println("car is repaired"); + } + + public static void main(String[] args) { + WagonR wagonR = new WagonR(); + Audi audi = new Audi(); + + repairCar(wagonR); + repairCar(audi); + } + +} diff --git a/oopsabstraction/WagonR.java b/oopsabstraction/WagonR.java new file mode 100644 index 0000000..8f8425b --- /dev/null +++ b/oopsabstraction/WagonR.java @@ -0,0 +1,20 @@ +package oopsabstraction; + +public class WagonR extends Car{ + + public static void main(String[] args) { + + } + @Override + public void accelerate() { + + System.out.println("WagonR is accelerating"); + } + + @Override + public void apply_break() { + + System.out.println("break is applied in WagonR"); + } + +} diff --git a/oopspolymorphism/Animal.java b/oopspolymorphism/Animal.java new file mode 100644 index 0000000..d46eeb4 --- /dev/null +++ b/oopspolymorphism/Animal.java @@ -0,0 +1,5 @@ +package oopspolymorphism; + +public class Animal { + +} diff --git a/oopspolymorphism/Dog.java b/oopspolymorphism/Dog.java new file mode 100644 index 0000000..995b0d6 --- /dev/null +++ b/oopspolymorphism/Dog.java @@ -0,0 +1,10 @@ +package oopspolymorphism; + +public class Dog extends Pet { + + public void walk() { + System.out.println("dog is walking"); + } + + +} diff --git a/oopspolymorphism/MainClass.java b/oopspolymorphism/MainClass.java new file mode 100644 index 0000000..112fc11 --- /dev/null +++ b/oopspolymorphism/MainClass.java @@ -0,0 +1,29 @@ +package oopspolymorphism; + +public class MainClass { + + + public static void greetings() { + System.out.println("Hi,there"); + } + public static void greetings(String s) { + System.out.println(s); + } + public static void greetings(String s, int count) { + for(int i=0;i adq = new ArrayDeque(); + + adq.push("A"); + adq.push("B"); + adq.push("C"); + adq.push("D"); + adq.push("E"); + + System.out.print("Popping the stack:"); + + while(adq.peek()!=null) + System.out.print(adq.pop()+" "); + + System.out.println(); + + } + +} diff --git a/recursion/Factorial_using_Recursion.java b/recursion/Factorial_using_Recursion.java new file mode 100644 index 0000000..f31d5d1 --- /dev/null +++ b/recursion/Factorial_using_Recursion.java @@ -0,0 +1,21 @@ +package recursion; +import java.util.Scanner; + +public class Factorial_using_Recursion { + public static long multiplyNumbers(int num) + { + if (num >= 1) + return num * multiplyNumbers(num - 1); + else + return 1; + } + public static void main(String[] args) { + + @SuppressWarnings("resource") + Scanner sc = new Scanner(System.in); + int num = sc.nextInt(); + long factorial = multiplyNumbers(num); + System.out.println("Factorial of " + num + " = " + factorial); + } + +} diff --git a/searchingAlgorithms/BinarySearch.java b/searchingAlgorithms/BinarySearch.java new file mode 100644 index 0000000..d331720 --- /dev/null +++ b/searchingAlgorithms/BinarySearch.java @@ -0,0 +1,46 @@ +package searchingAlgorithms; + +public class BinarySearch { + + // Returns index of x if it is present in arr[l.. + // r], else return -1 + int binarySearch(int arr[], int l, int r, int x) + { + if (r >= l) { + int mid = l + (r - l) / 2; + + // If the element is present at the + // middle itself + if (arr[mid] == x) + return mid; + + // If element is smaller than mid, then + // it can only be present in left subarray + if (arr[mid] > x) + return binarySearch(arr, l, mid - 1, x); + + // Else the element can only be present + // in right subarray + return binarySearch(arr, mid + 1, r, x); + } + + // We reach here when element is not present + // in array + return -1; + } + + // Driver method to test above + public static void main(String args[]) + { + BinarySearch ob = new BinarySearch(); + int arr[] = { 2, 3, 4, 10, 40, 50, 90, 130, 230, 740}; + int n = arr.length; + int x = 130; + int result = ob.binarySearch(arr, 0, n - 1, x); + if (result == -1) + System.out.println("Element not present"); + else + System.out.println("Element found at index " + result); + } +} + diff --git a/searchingAlgorithms/LinearSearch.java b/searchingAlgorithms/LinearSearch.java new file mode 100644 index 0000000..ff4718c --- /dev/null +++ b/searchingAlgorithms/LinearSearch.java @@ -0,0 +1,28 @@ +package searchingAlgorithms; + +public class LinearSearch { + + public static int search(int arr[], int x) + { + int n = arr.length; + for(int i = 0; i < n; i++) + { + if(arr[i] == x) + return i; + } + return -1; + } + + public static void main(String args[]) + { + int arr[] = { 1, 2, 3, 4, 10, 40, 50, 60, 90, 80, 70}; + int x = 90; + + int result = search(arr, x); + if(result == -1) + System.out.print("Element is not present in array"); + else + System.out.print("Element is present at index " + result); + } + +} diff --git a/searchingAlgorithms/package-info.java b/searchingAlgorithms/package-info.java new file mode 100644 index 0000000..9d8805d --- /dev/null +++ b/searchingAlgorithms/package-info.java @@ -0,0 +1 @@ +package searchingAlgorithms; diff --git a/sortingAlgorithms/BubbleSort.java b/sortingAlgorithms/BubbleSort.java index 4bd2323..56ae59c 100644 --- a/sortingAlgorithms/BubbleSort.java +++ b/sortingAlgorithms/BubbleSort.java @@ -1,30 +1,42 @@ package sortingAlgorithms; public class BubbleSort { - - public static void main(String[] args) { - - int a[] = {7,9,-4,6,8,5}; + + void bubbleSort(int a[]) { + int n = a.length; - - for(int i=0;i<=n-1-i;i++) { - for(int j=0;j<=n-1-i;j++) { - - boolean sorted = true; - - if(a[j+1] < a[j]){ - int temp = a[j+1]; - a[j+1] = a[j]; - a[j]= temp; - sorted = false; + for(int i=0;ia[j+1]) { + //swap a[j+1] and a[i] + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; } - - if(sorted) break; - } + } } + } + + //function to print the array + void printArray(int a[]) { + + int n = a.length; + for(int i=0;i= 0; i--) + heapify(A, n, i); + + // One by one extract an element from heap + for (int i=n-1; i>0; i--) + { + // Move current root to end + int temp = A[0]; + A[0] = A[i]; + A[i] = temp; + + // call max heapify on the reduced heap + heapify(A, i, 0); + } + } + + // To heapify a subtree rooted with node i which is + // an index in arr[]. n is size of heap + void heapify(int A[], int n, int i) + { + int largest = i; // Initialize largest as root + int l = 2*i + 1; // left = 2*i + 1 + int r = 2*i + 2; // right = 2*i + 2 + + // If left child is larger than root + if (l < n && A[l] > A[largest]) + largest = l; + + // If right child is larger than largest so far + if (r < n && A[r] > A[largest]) + largest = r; + + // If largest is not root + if (largest != i) + { + int swap = A[i]; + A[i] = A[largest]; + A[largest] = swap; + + // Recursively heapify the affected sub-tree + heapify(A, n, largest); + } + } + + /* A utility function to print array of size n */ + static void printArray(int A[]) + { + int n = A.length; + for (int i=0; i Array to be sorted, + low --> Starting index, + high --> Ending index */ + void sort(int arr[], int low, int high) + { + if (low < high) + { + /* pi is partitioning index, arr[pi] is + now at right place */ + int pi = partition(arr, low, high); + + // Recursively sort elements before + // partition and after partition + sort(arr, low, pi-1); + sort(arr, pi+1, high); + } + } + + /* A utility function to print array of size n */ + static void printArray(int arr[]) + { + int n = arr.length; + for (int i=0; i mx) + mx = arr[i]; + return mx; + } + + // A function to do counting sort of arr[] according to + // the digit represented by exp. + static void countSort(int arr[], int n, int exp) { + int output[] = new int[n]; // output array + int i; + int count[] = new int[10]; + Arrays.fill(count,0); + + // Store count of occurrences in count[] + for (i = 0; i < n; i++) + count[ (arr[i]/exp)%10 ]++; + + // Change count[i] so that count[i] now contains + // actual position of this digit in output[] + for (i = 1; i < 10; i++) + count[i] += count[i - 1]; + + // Build the output array + for (i = n - 1; i >= 0; i--) + { + output[count[ (arr[i]/exp)%10 ] - 1] = arr[i]; + count[ (arr[i]/exp)%10 ]--; + } + + // Copy the output array to arr[], so that arr[] now + // contains sorted numbers according to curent digit + for (i = 0; i < n; i++) + arr[i] = output[i]; + } + + // The main function to that sorts arr[] of size n using + // Radix Sort + static void radixsort(int arr[], int n) { + // Find the maximum number to know number of digits + int m = getMax(arr, n); + + // Do counting sort for every digit. Note that instead + // of passing digit number, exp is passed. exp is 10^i + // where i is current digit number + for (int exp = 1; m/exp > 0; exp *= 10) + countSort(arr, n, exp); + } + + // A utility function to print an array + static void print(int arr[], int n) { + for (int i=0; i", temp.data); + + // assign temp link to temp + temp = temp.link; + } + } + } +} +//main class +public class MYStackByList { + public static void main(String[] args) + { + // create Object of Implementing class + StackUsingLinkedlist obj = new StackUsingLinkedlist(); + // insert Stack value + obj.push(11); + obj.push(22); + obj.push(33); + obj.push(44); + + // print Stack elements + obj.display(); + + // print Top element of Stack + System.out.printf("\nTop element is %d\n", obj.peek()); + + // Delete top element of Stack + obj.pop(); + obj.pop(); + + // print Stack elements + obj.display(); + + // print Top element of Stack + System.out.printf("\nTop element is %d\n", obj.peek()); + } +} diff --git a/trees/FindFullNodesInABinaryTree.java b/trees/FindFullNodesInABinaryTree.java new file mode 100644 index 0000000..9ef37e1 --- /dev/null +++ b/trees/FindFullNodesInABinaryTree.java @@ -0,0 +1,47 @@ +package trees; + +//A Binary Tree Node +class Node{ + int data; + Node left , right; + Node(int data) { + this.data = data; + left = right = null ; + + } +} + +public class FindFullNodesInABinaryTree { + + //Traverse given tree in In-order fashion & prints all nodes that have both children as non-empty + public static void findFullNode(Node root) { + if (root!=null) { + findFullNode(root.left); + if(root.left != null && root.right != null) + System.out.println(root.data +" "); + findFullNode(root.right); + } + } + + //Driver method + public static void main(String[] args) { + Node root = new Node(1); + root.left = new Node(2); + root.right = new Node(3); + root.left.left = new Node(4); + root.left.right = new Node(5); + root.right.left = new Node(6); + root.right.right = new Node(7); + root.right.right.right = new Node(8); + root.right.left.right = new Node(9); + root.right.left.left = new Node(10); + root.left.left.left= new Node(11); + root.left.left.right = new Node(12); + root.left.right.left = new Node(13); + root.left.right.right = new Node(14); + + findFullNode(root); + + } + +} diff --git a/trees/Insertion_In_BinaryTree.java b/trees/Insertion_In_BinaryTree.java new file mode 100644 index 0000000..98e45ad --- /dev/null +++ b/trees/Insertion_In_BinaryTree.java @@ -0,0 +1,78 @@ +package trees; + + // Java program to insert element in binary tree +import java.util.LinkedList; +import java.util.Queue; +public class Insertion_In_BinaryTree { + /* A binary tree node has key, pointer to + left child and a pointer to right child */ + static class Node { + int key; + Node left, right; + + // constructor + Node(int key){ + this.key = key; + left = right = null; + } + } + static Node root; + static Node temp = root; + + //Inorder traversal of a binary tree + static void inorder(Node temp) + { + if (temp == null) + return; + + inorder(temp.left); + System.out.print(temp.key+" "); + inorder(temp.right); + } + + //function to insert element in binary tree + static void insert(Node temp, int key) + { + Queue q = new LinkedList(); + q.add(temp); + + // Do level order traversal until we find + // an empty place. + while (!q.isEmpty()) { + temp = q.peek(); + q.remove(); + + if (temp.left == null) { + temp.left = new Node(key); + break; + } else + q.add(temp.left); + + if (temp.right == null) { + temp.right = new Node(key); + break; + } else + q.add(temp.right); + } + } + + // Driver code + public static void main(String args[]) + { + root = new Node(10); + root.left = new Node(11); + root.left.left = new Node(7); + root.right = new Node(9); + root.right.left = new Node(15); + root.right.right = new Node(8); + + System.out.print( "Inorder traversal before insertion:"); + inorder(root); + + int key = 12; + insert(root, key); + + System.out.print("\nInorder traversal after insertion:"); + inorder(root); + } +} From 5c169a01a359a49a0967fd852255d3726c2e809d Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Sun, 15 Nov 2020 22:18:03 +0530 Subject: [PATCH 05/56] #Modification 08 --- array/Candy_Distribution_Problem.java | 49 ++++++ array/KadanesAlgorithm.java | 31 ++++ arrays/ArrayLevel1.java | 17 ++ arrays/{BasicArrays.java => ArrayLevel2.java} | 3 +- arrays/Array_Problem_1.java | 41 +++++ arrays/Array_Problem_10.java | 51 ++++++ arrays/Array_Problem_11.java | 33 ++++ arrays/Array_Problem_12.java | 69 ++++++++ arrays/Array_Problem_18.java | 29 ++++ arrays/Array_Problem_2.java | 55 ++++++ ...ray_problem.java => Array_Problem_23.java} | 13 +- arrays/Array_Problem_3.java | 122 ++++++++++++++ arrays/Array_Problem_32.java | 35 ++++ arrays/Array_Problem_4_Approach1.java | 63 +++++++ ...go.java => Array_Problem_4_Approach2.java} | 17 +- arrays/Array_Problem_5.java | 41 +++++ arrays/Array_Problem_6.java | 118 +++++++++++++ ...{RotateArray.java => Array_Problem_7.java} | 8 +- arrays/Array_Problem_8.java | 32 ++++ arrays/Array_Problem_9.java | 65 +++++++ arrays/Array_of_objects.java | 44 +++++ arrays/FIndDublicate.java | 32 ---- arrays/KadanesAlgorithm.java | 31 ++++ arrays/MultiDArray.java | 16 ++ arrays/package-info.java | 1 - backtracking/Rat_In_A_Maze.java | 90 ++++++++++ basicProblems/Armstrong_Number.java | 26 +++ basicProblems/Factorial.class | Bin 0 -> 1124 bytes basicProblems/Factorial.java | 9 +- basicProblems/Fibonacci_Series.java | 8 +- .../Multiplicative_Table_till_20.java | 15 +- basicProblems/Palindrome_Number.java | 4 - basicProblems/Prime_Number_Or_Not.java | 15 +- ...ive_decimal_number_from_right_to_left.java | 19 +++ basicProblems/Reverse_Given_number.java | 22 +++ basicProblems/Series_Sum_1.java | 6 +- basicProblems/Swap_two_numbers.java | 15 +- basicProblems/Swapping_2.java | 24 +++ .../ArrayDequeDemo.java | 2 +- .../ArrayListDemo.java | 2 +- basic_idea_of_DS/Graph.java | 41 +++++ .../HashMapIntro.java | 2 +- .../LinkedListDemo.java | 2 +- {dataStructure => basic_idea_of_DS}/List.java | 2 +- .../MYStackByList.java | 2 +- .../MyArrayList.java | 2 +- .../MyHashMap.java | 2 +- .../MyHashSet.java | 2 +- .../MyLinkedList.java | 2 +- .../MyQueue.java | 2 +- .../MyStack.java | 2 +- .../SetExample.java | 2 +- {dataStructure => basic_idea_of_DS}/Tree.java | 2 +- basics/ControlStatements.java | 38 ++--- basics/Fast_Inputs_Main.java | 63 +++++++ basics/Treedatastructure.java | 65 ------- basics/WhileLoop.java | 8 +- bit_manupulation/Bitmain.java | 13 ++ dataStructures/Info.java | 10 ++ dataStructures/graphs/Graph.java | 41 +++++ exercise_and_practice_Problems/Cylinder.java | 26 +++ exercise_and_practice_Problems/Exercise1.java | 33 ++++ exercise_and_practice_Problems/Exercise2.java | 34 ++++ .../Getters_Setters_For_Cylinder.java | 44 +++++ list/Deletion_in_Linked_List.java | 100 +++++++++++ list/Insertion_in_Linked_List.java | 99 +++++++++++ list/MainList.java | 18 ++ list/MyLL.java | 53 ++++++ list/Problem_1_1.java | 63 +++++++ list/Problem_1_2.java | 67 ++++++++ list/Queue.java | 157 +++++++++++++++++ recursion/Problem_01.java | 20 +++ sdeProblems/FindDuplicate.java | 32 ---- sdeProblems/RotateArray.java | 38 ----- sdeProblems/Test.java | 37 ---- sortingAlgorithms/BubbleSort.java | 3 +- sortingAlgorithms/HeapSort.java | 129 +++++++------- sortingAlgorithms/RadixSort.java | 14 +- stack/Parenthesis_Checker_Problem.java | 75 +++++++++ stack/Tower_Of_Hanoi.java | 29 ++++ trees/BST_Deletion.java | 158 ++++++++++++++++++ trees/BinarySearchTree.java | 83 +++++++++ trees/BinaryTreeNode.java | 13 ++ trees/BinaryTreeUse.java | 51 ++++++ ...struct_Tree_from_Preorder_and_Inorder.java | 69 ++++++++ trees/Count_leaf_nodes.java | 44 +++++ trees/FindFullNodesInABinaryTree.java | 28 ++-- trees/Insertion_In_BinaryTree.java | 14 +- trees/Problem_01.java | 85 ++++++++++ 89 files changed, 2815 insertions(+), 377 deletions(-) create mode 100644 array/Candy_Distribution_Problem.java create mode 100644 array/KadanesAlgorithm.java create mode 100644 arrays/ArrayLevel1.java rename arrays/{BasicArrays.java => ArrayLevel2.java} (86%) create mode 100644 arrays/Array_Problem_1.java create mode 100644 arrays/Array_Problem_10.java create mode 100644 arrays/Array_Problem_11.java create mode 100644 arrays/Array_Problem_12.java create mode 100644 arrays/Array_Problem_18.java create mode 100644 arrays/Array_Problem_2.java rename arrays/{Maximum_subarray_problem.java => Array_Problem_23.java} (82%) create mode 100644 arrays/Array_Problem_3.java create mode 100644 arrays/Array_Problem_32.java create mode 100644 arrays/Array_Problem_4_Approach1.java rename arrays/{Sort_an_array_of_0s_1s_2s_without_using_extra_space_or_sorting_algo.java => Array_Problem_4_Approach2.java} (76%) create mode 100644 arrays/Array_Problem_5.java create mode 100644 arrays/Array_Problem_6.java rename arrays/{RotateArray.java => Array_Problem_7.java} (82%) create mode 100644 arrays/Array_Problem_8.java create mode 100644 arrays/Array_Problem_9.java create mode 100644 arrays/Array_of_objects.java delete mode 100644 arrays/FIndDublicate.java create mode 100644 arrays/KadanesAlgorithm.java create mode 100644 arrays/MultiDArray.java delete mode 100644 arrays/package-info.java create mode 100644 backtracking/Rat_In_A_Maze.java create mode 100644 basicProblems/Armstrong_Number.java create mode 100644 basicProblems/Factorial.class create mode 100644 basicProblems/Print_all_digits_of_positive_decimal_number_from_right_to_left.java create mode 100644 basicProblems/Reverse_Given_number.java create mode 100644 basicProblems/Swapping_2.java rename {dataStructure => basic_idea_of_DS}/ArrayDequeDemo.java (93%) rename {dataStructure => basic_idea_of_DS}/ArrayListDemo.java (96%) create mode 100644 basic_idea_of_DS/Graph.java rename {dataStructure => basic_idea_of_DS}/HashMapIntro.java (96%) rename {dataStructure => basic_idea_of_DS}/LinkedListDemo.java (96%) rename {dataStructure => basic_idea_of_DS}/List.java (90%) rename {dataStructure => basic_idea_of_DS}/MYStackByList.java (99%) rename {dataStructure => basic_idea_of_DS}/MyArrayList.java (96%) rename {dataStructure => basic_idea_of_DS}/MyHashMap.java (96%) rename {dataStructure => basic_idea_of_DS}/MyHashSet.java (91%) rename {dataStructure => basic_idea_of_DS}/MyLinkedList.java (96%) rename {dataStructure => basic_idea_of_DS}/MyQueue.java (98%) rename {dataStructure => basic_idea_of_DS}/MyStack.java (96%) rename {dataStructure => basic_idea_of_DS}/SetExample.java (97%) rename {dataStructure => basic_idea_of_DS}/Tree.java (97%) create mode 100644 basics/Fast_Inputs_Main.java delete mode 100644 basics/Treedatastructure.java create mode 100644 bit_manupulation/Bitmain.java create mode 100644 dataStructures/Info.java create mode 100644 dataStructures/graphs/Graph.java create mode 100644 exercise_and_practice_Problems/Cylinder.java create mode 100644 exercise_and_practice_Problems/Exercise1.java create mode 100644 exercise_and_practice_Problems/Exercise2.java create mode 100644 exercise_and_practice_Problems/Getters_Setters_For_Cylinder.java create mode 100644 list/Deletion_in_Linked_List.java create mode 100644 list/Insertion_in_Linked_List.java create mode 100644 list/MainList.java create mode 100644 list/MyLL.java create mode 100644 list/Problem_1_1.java create mode 100644 list/Problem_1_2.java create mode 100644 list/Queue.java create mode 100644 recursion/Problem_01.java delete mode 100644 sdeProblems/FindDuplicate.java delete mode 100644 sdeProblems/RotateArray.java delete mode 100644 sdeProblems/Test.java create mode 100644 stack/Parenthesis_Checker_Problem.java create mode 100644 stack/Tower_Of_Hanoi.java create mode 100644 trees/BST_Deletion.java create mode 100644 trees/BinarySearchTree.java create mode 100644 trees/BinaryTreeNode.java create mode 100644 trees/BinaryTreeUse.java create mode 100644 trees/Construct_Tree_from_Preorder_and_Inorder.java create mode 100644 trees/Count_leaf_nodes.java create mode 100644 trees/Problem_01.java diff --git a/array/Candy_Distribution_Problem.java b/array/Candy_Distribution_Problem.java new file mode 100644 index 0000000..8a56be7 --- /dev/null +++ b/array/Candy_Distribution_Problem.java @@ -0,0 +1,49 @@ +package array; +import java.util.*; + +//Language: Java +//Time Complexity: O(n) 3 Linear traversals. +//Space Complexity: O(n) Array of candies. + +public class Candy_Distribution_Problem{ + + public int candy(int[] ratings) { + if (ratings.length < 2) + return ratings.length; + + + int[] candies = new int[ratings.length]; + Arrays.fill(candies, 1); + + // ** Step 1: Forward ** + for (int i=0; i= ratings[i+1]) { + continue; + } + candies[i+1] = candies[i] + 1; + } + + // ** Step 2: Backward ** + for (int i=ratings.length-1; i>0; i--) { + if (ratings[i] >= ratings[i-1]) { + continue; + } + candies[i-1] = Math.max(candies[i] + 1, candies[i-1]); + } + + // ** Step 3: Count Candies ** + int count = 0; + for (int i=0; i=0) m[Math.abs(m[i])] = -m[Math.abs(m[i])]; + else System.out.print(Math.abs(m[i]) + " "); + } + } + + //Driver Method + public static void main(String[] args) { + + Array_Problem_11 dublicate= new Array_Problem_11(); + + int m[] = {1,2,3,1,3,6,6}; + int m_size = m.length; + + dublicate.printRepeating(m,m_size); + + } + +} + diff --git a/arrays/Array_Problem_12.java b/arrays/Array_Problem_12.java new file mode 100644 index 0000000..e878764 --- /dev/null +++ b/arrays/Array_Problem_12.java @@ -0,0 +1,69 @@ +package arrays; + +import java.util.Arrays; + +/* + * Problem :- + * Merge two sorted array without using extra space + */ + +/* + * Understanding of the Problem :- + * + * We are given two sorted array. + * We need to merge these two arrays, + * such that the initial numbers(after complete sorting) are in the first array , + * and the remaining numbers are in the second array. + * Extra space allowed in O(1). + */ + +/* + * Simple Discussion : + * This task is simple and O(m+n) if we are allowed to use extra space. + * But it becomes really complicated when extra space is not allowed, + * and doesn't look possible in less than O(m*n) worst case time. + */ + +/* + * Idea or Approach of Solution :- + * The idea is to begin from last element of ar2[] and search it in ar1[]. + * If there is a greater element in ae1[], then we moe lastt element of ar2[] at correct place in ar1[]. + * + * We can use INSERTION Sort type of insertion for this. + */ + +public class Array_Problem_12 { + + static int arr1[] = new int[] {1, 5 , 9, 10, 15, 20}; + static int arr2[] = new int[] {2, 3, 8, 13}; + + static void merge(int m , int n) { + + //Iterate through all elements of the last element + for(int i = n-1; i >= 0; i--) { + + /* + * FInd the smallest element greater than ar2[i]. + * Move all elements one position ahead till the smallest greater element is not found. + */ + int j , last = arr1[m -1]; + for( j = m-2 ; j>= 0 && arr1[j] > arr2[i] ; j--) + arr1[j+1] = arr1[j]; + + //if there was a greater element + if(j != m-2 || last > arr2[i]) { + arr1[j+1] = arr2[i]; + arr2[i] = last; + } + } + } + + public static void main(String[] args) { + merge(arr1.length, arr2.length); + System.out.println("After Merging nFirst Array: "); + System.out.println(Arrays.toString(arr1)); + System.out.println("Second Array: "); + System.out.println(Arrays.toString(arr2)); + } + +} diff --git a/arrays/Array_Problem_18.java b/arrays/Array_Problem_18.java new file mode 100644 index 0000000..709bf09 --- /dev/null +++ b/arrays/Array_Problem_18.java @@ -0,0 +1,29 @@ +package arrays; + +/* + * find all pairs on integer array whose sum is equal to given number + * OR + * Equal_Sum_Pairs_of_Array + */ + +public class Array_Problem_18 { + + //function to find & print the sum & elements + static void pairs_value(int iA[], int iN) { + System.out.println("Pairs of elements & their sum : "); + + //loop to iterate & find the pair of elements whose sum is equal + for(int i = 0 ; i < iA.length ; i++) { + for(int j = i + 1 ; j < iA.length ; j++) + //check if the sum of pair is equal, if equal then print the pair of elements & their sum + if(iA[i]+iA[j] == iN) System.out.println(iA[i] + " + " + iA[j] + " = " + iN); + } + } + + //Driver Method + public static void main(String[] args) { + pairs_value(new int[] {2,7,4,-5,11,5,20}, 15); + pairs_value(new int[] {14,-15,9,16,25,45,12,8},30); + } + +} diff --git a/arrays/Array_Problem_2.java b/arrays/Array_Problem_2.java new file mode 100644 index 0000000..63dc567 --- /dev/null +++ b/arrays/Array_Problem_2.java @@ -0,0 +1,55 @@ +package arrays; + +//Java program to find the maximum & minimum element in given or array as user input +public class Array_Problem_2 { +/* Class Pair is used to return two values from getMinMax() */ + static class Pair { + + int min; + int max; + } + + static Pair getMinMax(int arr[], int n) { + Pair minmax = new Pair(); + int i; + + /*If there is only one element then return it as min and max both*/ + if (n == 1) { + minmax.max = arr[0]; + minmax.min = arr[0]; + return minmax; + } + + /* If there are more than one elements, then initialize min + and max*/ + if (arr[0] > arr[1]) { + minmax.max = arr[0]; + minmax.min = arr[1]; + } else { + minmax.max = arr[1]; + minmax.min = arr[0]; + } + + for (i = 2; i < n; i++) { + if (arr[i] > minmax.max) { + minmax.max = arr[i]; + } else if (arr[i] < minmax.min) { + minmax.min = arr[i]; + } + } + + return minmax; + } + + /* Driver program to test above function */ + public static void main(String args[]) { + int arr[] = {1000, 11, 445, 1, 330, 3000}; + int arr_size = 6; + Pair minmax = getMinMax(arr, arr_size); + System.out.printf("\nMinimum element is %d", minmax.min); + System.out.printf("\nMaximum element is %d", minmax.max); + + } + +} + diff --git a/arrays/Maximum_subarray_problem.java b/arrays/Array_Problem_23.java similarity index 82% rename from arrays/Maximum_subarray_problem.java rename to arrays/Array_Problem_23.java index 724dcf7..9aedc89 100644 --- a/arrays/Maximum_subarray_problem.java +++ b/arrays/Array_Problem_23.java @@ -1,9 +1,11 @@ package arrays; -public class Maximum_subarray_problem { - // Java program to print largest - // contiguous array sum - +/* + * Java program for maximum product sub-array problem + */ + +public class Array_Problem_23 { + static void maxSubArraySum(int a[], int size) { int max_so_far = Integer.MIN_VALUE, @@ -27,8 +29,7 @@ static void maxSubArraySum(int a[], int size) s = i + 1; } } - System.out.println("Maximum contiguous sum is " - + max_so_far); + System.out.println("Maximum contiguous sum is " + max_so_far); System.out.println("Starting index " + start); System.out.println("Ending index " + end); } diff --git a/arrays/Array_Problem_3.java b/arrays/Array_Problem_3.java new file mode 100644 index 0000000..0a9c3ad --- /dev/null +++ b/arrays/Array_Problem_3.java @@ -0,0 +1,122 @@ +package arrays; + +import java.util.Arrays; + +/* + * (Find K^the smallest element) + * Given an array array[] and a number K where K is smaller than size of array, + * the task is to find the K^the smallest element in the given array. + * It is given that all array elements are distinct. + */ +public class Array_Problem_3 { + + // int partition(int array[], int l, int r, int k); + + // A simple function to find median of arr[]. This is called + // only for an array of size 5 in this program. + static int findMedian(int arr[], int i,int n) + { + if(i <= n) + Arrays.sort(arr, i, n); // Sort the array + else + Arrays.sort(arr, n, i); + return arr[n/2]; // Return middle element + } + + // Returns k'th smallest element + // in arr[l..r] in worst case + // linear time. ASSUMPTION: ALL + // ELEMENTS IN ARR[] ARE DISTINCT + static int kthSmallest(int arr[], int l, int r, int k) + { + // If k is smaller than + // number of elements in array + if (k > 0 && k <= r - l + 1) + { + int n = r - l + 1 ; // Number of elements in arr[l..r] + + // Divide arr[] in groups of size 5, + // calculate median of every group + // and store it in median[] array. + int i; + + // There will be floor((n+4)/5) groups; + int []median = new int[(n + 4) / 5]; + for (i = 0; i < n/5; i++) + median[i] = findMedian(arr,l + i * 5, 5); + + // For last group with less than 5 elements + if (i*5 < n) + { + median[i] = findMedian(arr,l + i * 5, n % 5); + i++; + } + + // Find median of all medians using recursive call. + // If median[] has only one element, then no need + // of recursive call + int medOfMed = (i == 1)? median[i - 1]: + kthSmallest(median, 0, i - 1, i / 2); + + // Partition the array around a random element and + // get position of pivot element in sorted array + int pos = partition(arr, l, r, medOfMed); + + // If position is same as k + if (pos-l == k - 1) + return arr[pos]; + if (pos-l > k - 1) // If position is more, recur for left + return kthSmallest(arr, l, pos - 1, k); + + // Else recur for right subarray + return kthSmallest(arr, pos + 1, r, k - pos + l - 1); + } + + // If k is more than number of elements in array + return Integer.MAX_VALUE; + } + + static int[] swap(int []arr, int i, int j) + { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + return arr; + } + + // It searches for x in arr[l..r], and + // partitions the array around x. + static int partition(int arr[], int l, + int r, int x) + { + // Search for x in arr[l..r] and move it to end + int i; + for (i = l; i < r; i++) + if (arr[i] == x) + break; + swap(arr, i, r); + + // Standard partition algorithm + i = l; + for (int j = l; j <= r - 1; j++) + { + if (arr[j] <= x) + { + swap(arr, i, j); + i++; + } + } + swap(arr, i, r); + return i; + } + + // Driver code + public static void main(String[] args) + { + int arr[] = {12, 3, 5, 7, 4, 19, 26}; + int n = arr.length, k = 3; + System.out.println("K'th smallest element is " + + kthSmallest(arr, 0, n - 1, k)); + } + +} diff --git a/arrays/Array_Problem_32.java b/arrays/Array_Problem_32.java new file mode 100644 index 0000000..7f50762 --- /dev/null +++ b/arrays/Array_Problem_32.java @@ -0,0 +1,35 @@ +package arrays; + +//Java program to find minimum number of operations to make an array palindrome +public class Array_Problem_32 { + + static int findMinOps(int[] a, int n) { + + //Initialize result + int ans = 0; + + //Start from two corners + for(int i=0,j=n-1;i<=j;) { + + if(a[i] == a[j]) { + i++; + j--; + }else if(a[i] > a[j]) { + j--; + a[j] += a[j+1]; + ans++; + }else { + i++; + a[i] += a[i-1]; + ans++; + } + } + return ans; + } + + public static void main(String[] args) { + int a[] = new int[] {1,2,3,4,5,6,7,8,9,10}; + System.out.println("Count of minimum operations is " + findMinOps(a , a.length)); + } + +} diff --git a/arrays/Array_Problem_4_Approach1.java b/arrays/Array_Problem_4_Approach1.java new file mode 100644 index 0000000..b1e4e48 --- /dev/null +++ b/arrays/Array_Problem_4_Approach1.java @@ -0,0 +1,63 @@ +package arrays; +import java.io.*; + +/* + * Java program to solve that, + * Given an array A of size N containing 0s, 1s, and 2s; + * you need to sort the array in ascending order without using any sorting algorithm + */ + +@SuppressWarnings("unused") +public class Array_Problem_4_Approach1 { + + // Sort the input array, the array is assumed to + // have values in {0, 1, 2} + static void sort012(int a[], int arr_size) + { + int lo = 0; + int hi = arr_size - 1; + int mid = 0, temp = 0; + while (mid <= hi) { + switch (a[mid]) { + case 0: { + temp = a[lo]; + a[lo] = a[mid]; + a[mid] = temp; + lo++; + mid++; + break; + } + case 1: + mid++; + break; + case 2: { + temp = a[mid]; + a[mid] = a[hi]; + a[hi] = temp; + hi--; + break; + } + } + } + } + + /* Utility function to print array arr[] */ + static void printArray(int arr[], int arr_size) + { + int i; + for (i = 0; i < arr_size; i++) + System.out.print(arr[i] + " "); + System.out.println(""); + } + + /*Driver function to check for above functions*/ + public static void main(String[] args) + { + int arr[] = { 0, 1, 1, 0, 1, 2, 1, 2, 0, 0, 0, 1 }; + int arr_size = arr.length; + sort012(arr, arr_size); + System.out.println("Array after seggregation "); + printArray(arr, arr_size); + } + +} diff --git a/arrays/Sort_an_array_of_0s_1s_2s_without_using_extra_space_or_sorting_algo.java b/arrays/Array_Problem_4_Approach2.java similarity index 76% rename from arrays/Sort_an_array_of_0s_1s_2s_without_using_extra_space_or_sorting_algo.java rename to arrays/Array_Problem_4_Approach2.java index 4e47013..1116d1d 100644 --- a/arrays/Sort_an_array_of_0s_1s_2s_without_using_extra_space_or_sorting_algo.java +++ b/arrays/Array_Problem_4_Approach2.java @@ -1,7 +1,12 @@ package arrays; import java.util.Arrays; -public class Sort_an_array_of_0s_1s_2s_without_using_extra_space_or_sorting_algo { +/* + * Sort_an_array_of_0s_1s_2s_without_using_extra_space_or_sorting_algo + */ + +public class Array_Problem_4_Approach2 { + static int arr1[] = new int[]{1, 5, 9, 10, 15, 20}; static int arr2[] = new int[]{2, 3, 8, 13}; @@ -10,8 +15,11 @@ static void merge(int m, int n) // Iterate through all elements of ar2[] starting from to the last element for (int i=n-1; i>=0; i--) { - /* Find the smallest element greater than ar2[i]. Move all elements one position ahead till the smallest greater - element is not found */ + + /* Find the smallest element greater than ar2[i]. + * Move all elements one position ahead, + * till the smallest greater element is not found + */ int j, last = arr1[m-1]; for (j=m-2; j >= 0 && arr1[j] > arr2[i]; j--) @@ -21,7 +29,6 @@ static void merge(int m, int n) if (j != m-2 || last > arr2[i]) { arr1[j+1] = arr2[i]; arr2[i] = last; - } } } @@ -30,8 +37,10 @@ static void merge(int m, int n) public static void main1(String[] args) { merge(arr1.length,arr2.length); + System.out.print("After Merging nFirst Array: "); System.out.println(Arrays.toString(arr1)); + System.out.print("Second Array: "); System.out.println(Arrays.toString(arr2)); } diff --git a/arrays/Array_Problem_5.java b/arrays/Array_Problem_5.java new file mode 100644 index 0000000..d2a4008 --- /dev/null +++ b/arrays/Array_Problem_5.java @@ -0,0 +1,41 @@ +package arrays; + +/* + * Move all the negative elements to one side of the array + */ + +public class Array_Problem_5 { + + static void rearrange(int arr[], int n) + { + int j = 0, temp; + for (int i = 0; i < n; i++) { + if (arr[i] < 0) { + if (i != j) { + temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + j++; + } + } + } + + // A utility function to print an array + static void printArray(int arr[], int n) + { + for (int i = 0; i < n; i++) + System.out.print(arr[i] + " "); + } + + //Driver Method + public static void main(String[] args) { + int arr[] = { -1, 2, -3, 4, 5, 6, -7, 8, 9 , -47}; + int n = arr.length; + + rearrange(arr, n); + printArray(arr, n); + + } + +} diff --git a/arrays/Array_Problem_6.java b/arrays/Array_Problem_6.java new file mode 100644 index 0000000..5552ee1 --- /dev/null +++ b/arrays/Array_Problem_6.java @@ -0,0 +1,118 @@ +package arrays; + +// A Java program to print union and intersection of two unsorted arrays +import java.util.Arrays; + +/* + * Find the Union and Intersection of the two sorted arrays. + */ + +public class Array_Problem_6 { + + + void printUnion(int arr1[], int arr2[], int m, int n) + { + // Before finding union, make sure arr1[0..m-1] + // is smaller + if (m > n) { + int tempp[] = arr1; + arr1 = arr2; + arr2 = tempp; + + int temp = m; + m = n; + n = temp; + } + + // Now arr1[] is smaller + // Sort the first array and print its elements + // (these two steps can be swapped as order in + // output is not important) + Arrays.sort(arr1); + for (int i = 0; i < m; i++) + System.out.print(arr1[i] + " "); + + // Search every element of bigger array in smaller + // array and print the element if not found + for (int i = 0; i < n; i++) { + if (binarySearch(arr1, 0, m - 1, arr2[i]) == -1) + System.out.print(arr2[i] + " "); + } + } + + // Prints intersection of arr1[0..m-1] and arr2[0..n-1] + void printIntersection(int arr1[], int arr2[], int m, + int n) + { + // Before finding intersection, make sure + // arr1[0..m-1] is smaller + if (m > n) { + int tempp[] = arr1; + arr1 = arr2; + arr2 = tempp; + + int temp = m; + m = n; + n = temp; + } + + // Now arr1[] is smaller + // Sort smaller array arr1[0..m-1] + Arrays.sort(arr1); + + // Search every element of bigger array in smaller + // array and print the element if found + for (int i = 0; i < n; i++) { + if (binarySearch(arr1, 0, m - 1, arr2[i]) != -1) + System.out.print(arr2[i] + " "); + } + } + + // A recursive binary search function. It returns + // location of x in given array arr[l..r] is present, + // otherwise -1 + int binarySearch(int arr[], int l, int r, int x) + { + if (r >= l) { + int mid = l + (r - l) / 2; + + // If the element is present at the middle + // itself + if (arr[mid] == x) + return mid; + + // If element is smaller than mid, then it can + // only be present in left subarray + if (arr[mid] > x) + return binarySearch(arr, l, mid - 1, x); + + // Else the element can only be present in right + // subarray + return binarySearch(arr, mid + 1, r, x); + } + + // We reach here when element is not present in + // array + return -1; + } + + // Driver code + public static void main(String[] args) + { + Array_Problem_6 u_i= new Array_Problem_6(); + + int arr1[] = { 7, 1, 5, 2, 3, 6 }; + int arr2[] = { 3, 8, 6, 20, 7 }; + int m = arr1.length; + int n = arr2.length; + + // Function call + System.out.println("Union of two arrays is "); + u_i.printUnion(arr1, arr2, m, n); + System.out.println(""); + System.out.println( + "Intersection of two arrays is "); + u_i.printIntersection(arr1, arr2, m, n); + } + } + diff --git a/arrays/RotateArray.java b/arrays/Array_Problem_7.java similarity index 82% rename from arrays/RotateArray.java rename to arrays/Array_Problem_7.java index 00691e4..948018d 100644 --- a/arrays/RotateArray.java +++ b/arrays/Array_Problem_7.java @@ -1,6 +1,10 @@ package arrays; -public class RotateArray { +/* + * Write a program to cyclically rotate an array by one. + */ + +public class Array_Problem_7 { //function to rotate the elements of an array @@ -29,7 +33,7 @@ void printArray(int a[],int n) { // driver method of the program public static void main(String[] args) { - RotateArray rotate = new RotateArray(); + Array_Problem_7 rotate = new Array_Problem_7(); int a[] = {2,4,6,8,10,12,14,16,18,20}; rotate.rotateL(a, 3, 10); diff --git a/arrays/Array_Problem_8.java b/arrays/Array_Problem_8.java new file mode 100644 index 0000000..eaf505d --- /dev/null +++ b/arrays/Array_Problem_8.java @@ -0,0 +1,32 @@ +package arrays; + +/* + * find Largest sum contiguous Sub-array + */ + +public class Array_Problem_8 { + + public static void main (String[] args) + { + int [] a = {-2, -3, 4, -1, -2, 1, 5, -3}; + System.out.println("Maximum contiguous sum is " + maxSubArraySum(a)); + } + + static int maxSubArraySum(int a[]) + { + int size = a.length; + int max_so_far = Integer.MIN_VALUE, max_ending_here = 0; + + for (int i = 0; i < size; i++) + { + max_ending_here = max_ending_here + a[i]; + if (max_so_far < max_ending_here) + max_so_far = max_ending_here; + + if (max_ending_here < 0) + max_ending_here = 0; + } + return max_so_far; + } + +} diff --git a/arrays/Array_Problem_9.java b/arrays/Array_Problem_9.java new file mode 100644 index 0000000..f1f646f --- /dev/null +++ b/arrays/Array_Problem_9.java @@ -0,0 +1,65 @@ +package arrays; +import java.util.*; + +//Minimize the maximum difference between heights [V.IMP] +public class Array_Problem_9 { + + // Modifies the array by subtracting/adding k to every element such that the difference + // between maximum and minimum is minimized + static int getMinDiff(int arr[], int n, int k) + { + if (n == 1) + return 0; + + // Sort all elements + Arrays.sort(arr); + + // Initialize result + int ans = arr[n-1] - arr[0]; + + // Handle corner elements + int small = arr[0] + k; + int big = arr[n-1] - k; + int temp = 0; + + if (small > big) + { + temp = small; + small = big; + big = temp; + } + + // Traverse middle elements + for (int i = 1; i < n-1; i ++) + { + int subtract = arr[i] - k; + int add = arr[i] + k; + + // If both subtraction and addition + // do not change diff + if (subtract >= small || add <= big) + continue; + + // Either subtraction causes a smaller number or addition causes a greater number. + // Update small or big using greedy approach (If big - subtract causes smaller difference , + // update small Else update big) + if (big - subtract <= add - small) + small = subtract; + else + big = add; + } + + return Math.min(ans, big - small); + } + + // Driver function to test the above function + public static void main(String[] args) + { + int arr[] = {4, 6}; + int n = arr.length; + int k = 10; + System.out.println("Maximum difference is "+ + getMinDiff(arr, n, k)); + } + +} diff --git a/arrays/Array_of_objects.java b/arrays/Array_of_objects.java new file mode 100644 index 0000000..adb9674 --- /dev/null +++ b/arrays/Array_of_objects.java @@ -0,0 +1,44 @@ +package arrays; + +//Program to demonstrate the array of objects + +//Cricketer class +class Cricketer{ + public int batting_position; + public String name; + + Cricketer(int batting_position, String name) + { + this.batting_position = batting_position; + this.name = name; + } +} + +//Driver Class +public class Array_of_objects { + + //Driver Method + public static void main(String[] args) { + + // Declaring or making the array of type Cricketer , which is known as Array of Objects + Cricketer[] arr; + // array capacity is of storing 5 elements in it. + arr = new Cricketer[11]; + + arr[0 ] = new Cricketer(1, "Rohit Sharma(W.C)"); + arr[1 ] = new Cricketer(2, "Shikhar Dhawan"); + arr[2 ] = new Cricketer(3, "Virat Kohli(C.)"); + arr[3 ] = new Cricketer(4, "K.L Rahul"); + arr[4 ] = new Cricketer(5, "Rishabh Pant(W.K)"); + arr[5 ] = new Cricketer(6, "Hardik Pandaya"); + arr[6 ] = new Cricketer(7, "Bhuvaneshwar Kumar"); + arr[7 ] = new Cricketer(8, "Mohammed Shami"); + arr[8 ] = new Cricketer(9, "Jaspreet Bumrah"); + arr[9 ] = new Cricketer(10, "Yuzvendre Chahal"); + arr[10] = new Cricketer(11, "Kuldeep Yadav"); + + + for(int i = 0 ; i < arr.length ; i++) + System.out.println("Element at index " + i + " : " + "Batting Position: " + arr[i].batting_position + " " + "Player Name: " + arr[i].name); + } +} diff --git a/arrays/FIndDublicate.java b/arrays/FIndDublicate.java deleted file mode 100644 index a96cce0..0000000 --- a/arrays/FIndDublicate.java +++ /dev/null @@ -1,32 +0,0 @@ -package arrays; - -public class FIndDublicate { - // Implementing an array as a HashMap for finding duplicate elements - void printRepeating(int m[],int size) { - - int i; - System.out.print("The repeating elements are:"); - - for(i=0;i=0) m[Math.abs(m[i])] = -m[Math.abs(m[i])]; - else System.out.print(Math.abs(m[i]) + " "); - } - } - - //Driver Method - public static void main(String[] args) { - - FIndDublicate dublicate= new FIndDublicate(); // Making an object of FindDuplicate class - - int m[] = {1,2,3,1,3,6,6}; // Putting or declare values in or to array - int m_size = m.length; // variables which store size or length of array - - dublicate.printRepeating(m,m_size); // calling above function to pass value in it to print repeating elements - - } - -} - diff --git a/arrays/KadanesAlgorithm.java b/arrays/KadanesAlgorithm.java new file mode 100644 index 0000000..de15f21 --- /dev/null +++ b/arrays/KadanesAlgorithm.java @@ -0,0 +1,31 @@ +package arrays; +import java.util.*; + +/* + * Kadane's Algorithm to find the maxSubarray Sum in O(n)[Linear Time Complexity] + */ +public class KadanesAlgorithm { + + public static void main(String[] args) { + @SuppressWarnings("resource") + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int a[]=new int[n]; + + for(int i=0;i= 0 && x < N && y >= 0 + && y < N && maze[x][y] == 1); + } + + /* + * This function solves the Maze problem using Backtracking. + * It mainly uses solvemazeUtil() function to solve the problem. + * It returns false if no path is possible, otherwise return true & + * prints the path in the form of 1s. + * Please note :-> that there may be more than one solutions, + * this function prints one of the feasible solutions. + */ + boolean solveMaze(int maze[][]){ + int sol[][] = new int[N][N]; + + if(solveMazeUtil(maze, 0, 0, sol) == false) { + System.out.print("Solution doesn't exist"); + return false; + } + printSolution(sol); + return true; + } + + /* + * A recursive utility function to solve Maze problem + */ + boolean solveMazeUtil( int maze[][] , int x , int y , int sol[][]) { + + //if (x , y is goal) than return true + if(x == N - 1 && y == N-1 && maze[x][y] == 1) { + sol[x][y] = 1; + return true; + } + + //Check if maze[x][y] is valid + if(isSafe(maze, x, y) == true) { + //mark x, y as part of solution path + sol[x][y] = 1; + + //if moving in x direction doesn't give solution then Move down in y direction + if(solveMazeUtil(maze , x+1 , y , sol)) + return true; + /* + * If none of the above movements works then BACKTRACK: remove mark of x, y as part of solution path + */ + if(solveMazeUtil(maze , x , y+1 , sol)) + return true; + + sol[x][y] = 0; + return false; + } + + return false; + } + + //Driver Method + public static void main(String[] args) { + + Rat_In_A_Maze rat = new Rat_In_A_Maze(); + int maze[][] = {{ 1, 1, 1, 0 }, + { 1, 1, 1, 1 }, + { 1, 1, 1, 1 }, + { 1, 1, 1, 1 } }; + + N = maze.length; + rat.solveMaze(maze); + } //end of main +} //end of class diff --git a/basicProblems/Armstrong_Number.java b/basicProblems/Armstrong_Number.java new file mode 100644 index 0000000..5230826 --- /dev/null +++ b/basicProblems/Armstrong_Number.java @@ -0,0 +1,26 @@ +package basicProblems; +import java.util.*; + +public class Armstrong_Number { + + @SuppressWarnings("resource") + public static void main(String[] args) { + + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + + int sum = 0; + int original_no = n; + + while(n>0) { + int last_digit = n % 10; + sum += Math.pow(last_digit,3); + n=n/10; + } + + if(sum == original_no) System.out.println("Armstrong number"); + else System.out.println("Not Armstrong"); + + } + +} diff --git a/basicProblems/Factorial.class b/basicProblems/Factorial.class new file mode 100644 index 0000000000000000000000000000000000000000..89634d6bd6e83a204a8e7d37834186fbd03e9f1a GIT binary patch literal 1124 zcmaJ=O-~b16g_V`?UZr&wtQH@f`A2)svxMXENnt-0!mV%F|J;R2MnFgG&8S6*7_sd zx^gWGNHFmS_;Xyk5bv8-DQV*@?tLHko_o%{Z+`qf{|;ac>n2R342<+(6k{edj4N|P zZPP;(a?3;pQwF9D+-67=9M6&K46*F|YX-gO?+S+gO~(^28?}lEc6i056TQYAk6|SH zZu5{I@tn)O{ajfFj<=sziM?gX?dle7Vct^Vc@y%%TNZqz9r;=zZ>=^a4(4^3pw03 z@W8@DEHjK&c<9*MflsV!VeVg50=VS;s&Xi7$uQhS%$30MaVSNNK~vgOP34ZCD|z*X zB=LgR@(g3yt{18+h9}<3l1HVey(O}KgVvWo+tk0mKqgl3h#Iv=jmr3Y8J2Ov3?oG~ zUKK^(v$=fZ$OBr1l6x{#!zh*JJI6t~BB?~Q4WG!=RW(;BX)(S!L<6g;nNJyJE?ebz zM}AebCf#Jw?CG(A0zIEi->)|63|2`^ujukH6h!S)dxaK8b8auVx9f^qXY{30 z`a$8Ne(~kv=Lr%M>2nysDUu3Vi;$<0jPNz`y@WqRWYR<@Lw=5`EmOTgibz4bAQLw* k#0+Tky6}sxVi=B~uHy-Llc=pBkH;9tP1+}EuM|!G0c+YBD*ylh literal 0 HcmV?d00001 diff --git a/basicProblems/Factorial.java b/basicProblems/Factorial.java index f4a4355..c73f54c 100644 --- a/basicProblems/Factorial.java +++ b/basicProblems/Factorial.java @@ -1,17 +1,18 @@ package basicProblems; import java.util.*; + public class Factorial { public static void main(String[] args) { + int fact=1; - @SuppressWarnings("resource") - Scanner sc = new Scanner(System.in); + @SuppressWarnings("resource") + Scanner sc = new Scanner(System.in); int n = sc.nextInt(); - for(int i = n ; i>=1;i--) { + for(int i = n ; i >= 1 ; i--) { fact = fact*i; } - System.out.println("fact of " + n + " is " + fact ); } } diff --git a/basicProblems/Fibonacci_Series.java b/basicProblems/Fibonacci_Series.java index 2772bc1..f1fb26d 100644 --- a/basicProblems/Fibonacci_Series.java +++ b/basicProblems/Fibonacci_Series.java @@ -1,5 +1,6 @@ package basicProblems; import java.util.*; + public class Fibonacci_Series { public static void main(String[] args) { @@ -9,12 +10,13 @@ public static void main(String[] args) { int n = sc.nextInt(); int a=0,b=1; - System.out.println(a + " "); - System.out.println(b + " "); + System.out.println("a = " + a + " "); + System.out.println("b = " + b + " "); + System.out.println("Fibonacci Series:"); for(int i=0;i 0) { + int rem = n % 10; + System.out.print(rem); + n = n/10; + } + + } + +} diff --git a/basicProblems/Reverse_Given_number.java b/basicProblems/Reverse_Given_number.java new file mode 100644 index 0000000..f3c5371 --- /dev/null +++ b/basicProblems/Reverse_Given_number.java @@ -0,0 +1,22 @@ +package basicProblems; + +import java.util.*; +public class Reverse_Given_number { + + @SuppressWarnings("resource") + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + + int reverse=0; + + while(n>0) { + int last_digit = n % 10; + reverse = reverse*10 + last_digit; + n = n/10; + } + + System.out.println(reverse); + } + +} diff --git a/basicProblems/Series_Sum_1.java b/basicProblems/Series_Sum_1.java index ed57857..8d0b704 100644 --- a/basicProblems/Series_Sum_1.java +++ b/basicProblems/Series_Sum_1.java @@ -1,18 +1,20 @@ package basicProblems; import java.util.*; + public class Series_Sum_1 { public static void main(String[] args) { + //taking user input @SuppressWarnings("resource") Scanner sc = new Scanner(System.in); int n = sc.nextInt(); float result = 0; - for(float i=1;i<=n;i++) { + for(float i=1;i<=n;i++) result +=1/i; - } + System.out.println(result); } diff --git a/basicProblems/Swap_two_numbers.java b/basicProblems/Swap_two_numbers.java index 90bebb2..066a354 100644 --- a/basicProblems/Swap_two_numbers.java +++ b/basicProblems/Swap_two_numbers.java @@ -6,17 +6,12 @@ public static void main(String[] args) { @SuppressWarnings("resource") Scanner sc = new Scanner(System.in); - int a = sc.nextInt(); - int b = sc.nextInt(); - int swap; + int a = sc.nextInt() , b = sc.nextInt() , swap; + System.out.println( " elements before swapping " + a + " " + b ); - - swap = a; - a = b; - b= swap; - + swap = a; + a = b; + b = swap; System.out.println( " elements after swapping " + a + " " + b ); - - } } diff --git a/basicProblems/Swapping_2.java b/basicProblems/Swapping_2.java new file mode 100644 index 0000000..dd56abc --- /dev/null +++ b/basicProblems/Swapping_2.java @@ -0,0 +1,24 @@ +package basicProblems; + +/* + * swap two given numbers without using third variable + */ + +public class Swapping_2 { + + public static void main(String[] args) { + + int a = 20; + int b = 40; + + System.out.println("Number's before swapping: " + "a = " + a + "," + " b =" + " " + b); + + a = a + b; + b = a - b; + a = a - b; + + System.out.println("Number's after swapping: " + "a = " + a + "," + " b =" + " " + b); + + } + +} diff --git a/dataStructure/ArrayDequeDemo.java b/basic_idea_of_DS/ArrayDequeDemo.java similarity index 93% rename from dataStructure/ArrayDequeDemo.java rename to basic_idea_of_DS/ArrayDequeDemo.java index 15aaa23..91718cb 100644 --- a/dataStructure/ArrayDequeDemo.java +++ b/basic_idea_of_DS/ArrayDequeDemo.java @@ -1,4 +1,4 @@ -package dataStructure; +package basic_idea_of_DS; import java.util.*; public class ArrayDequeDemo { diff --git a/dataStructure/ArrayListDemo.java b/basic_idea_of_DS/ArrayListDemo.java similarity index 96% rename from dataStructure/ArrayListDemo.java rename to basic_idea_of_DS/ArrayListDemo.java index f0aae7e..eaa79d5 100644 --- a/dataStructure/ArrayListDemo.java +++ b/basic_idea_of_DS/ArrayListDemo.java @@ -1,4 +1,4 @@ -package dataStructure; +package basic_idea_of_DS; import java.util.ArrayList; public class ArrayListDemo { diff --git a/basic_idea_of_DS/Graph.java b/basic_idea_of_DS/Graph.java new file mode 100644 index 0000000..91bd1e8 --- /dev/null +++ b/basic_idea_of_DS/Graph.java @@ -0,0 +1,41 @@ +package basic_idea_of_DS; +import java.util.*; + +public class Graph { + + private LinkedList adj[]; + + @SuppressWarnings("unchecked") + public Graph(int v) { + //array of Linked List + adj = new LinkedList[v]; + + for(int i=0;i(); + } + } + + public void addEdge(int source, int destination) { + adj[source].add(destination); + adj[destination].add(source); + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + + System.out.println("Enter number of vertices and edges"); + int v = sc.nextInt(); + int e = sc.nextInt(); + + Graph graph = new Graph(v); + System.out.println("Enter " + e + " edges"); + + for(int i=0;i0) { System.out.println(" tick " + n); - n--; // post substraction operator - } - + // post subtraction operator + n--; + } } - } diff --git a/bit_manupulation/Bitmain.java b/bit_manupulation/Bitmain.java new file mode 100644 index 0000000..6a7de81 --- /dev/null +++ b/bit_manupulation/Bitmain.java @@ -0,0 +1,13 @@ +package bit_manupulation; + +public class Bitmain { + + static boolean getBit(int n , int pos) { + return ((n & (1 << pos))!=0); + } + + public static int main(String[] args) { + System.out.println(getBit(5,2)); + return 0; + } +} diff --git a/dataStructures/Info.java b/dataStructures/Info.java new file mode 100644 index 0000000..6f332ad --- /dev/null +++ b/dataStructures/Info.java @@ -0,0 +1,10 @@ +package dataStructures; + +public class Info { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/dataStructures/graphs/Graph.java b/dataStructures/graphs/Graph.java new file mode 100644 index 0000000..2ff08b8 --- /dev/null +++ b/dataStructures/graphs/Graph.java @@ -0,0 +1,41 @@ +package dataStructures.graphs; +import java.util.*; + +public class Graph { + + private LinkedList adj[]; + + @SuppressWarnings("unchecked") + public Graph(int v) { + //array of Linked List + adj = new LinkedList[v]; + + for(int i=0;i(); + } + } + + public void addEdge(int source, int destination) { + adj[source].add(destination); + adj[destination].add(source); + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + + System.out.println("Enter number of vertices and edges"); + int v = sc.nextInt(); + int e = sc.nextInt(); + + Graph graph = new Graph(v); + System.out.println("Enter " + e + " edges"); + + for(int i=0;i (V = 3.14*(r)^2*h) + double V = sg.getPie()*(sg.getRadius()*sg.getRadius())*sg.getHeight(); + System.out.println("The volume of the cylinder is: " + V + " cm^3"); + + } + +} diff --git a/exercise_and_practice_Problems/Exercise1.java b/exercise_and_practice_Problems/Exercise1.java new file mode 100644 index 0000000..b2aca46 --- /dev/null +++ b/exercise_and_practice_Problems/Exercise1.java @@ -0,0 +1,33 @@ +package exercise_and_practice_Problems; +import java.util.*; + +/* To calculate percentage of a given student in CBSE Board exam. + * His marks from 5 subjects must be taken as input from the keyboard + * (Marks are out of 100) + * */ + +public class Exercise1 { + + static Scanner sc = new Scanner(System.in); + + static int subject_1_marks = sc.nextInt(); + static int subject_2_marks = sc.nextInt(); + static int subject_3_marks = sc.nextInt(); + static int subject_4_marks = sc.nextInt(); + static int subject_5_marks = sc.nextInt(); + + public static void main(String[] args) { + + int total = (subject_1_marks + subject_2_marks + subject_3_marks + subject_4_marks + subject_5_marks); + float percentage = (total)/5; + + System.out.println("The marks of the subject's are: \n " + "\n" + "subject_1_marks:- " + subject_1_marks + "\n" + + "subject_2_marks:- " + subject_2_marks + "\n" + "subject_3_marks:- " + subject_3_marks + "\n" + + "subject_4_marks:- " + subject_4_marks + "\n" + "subject_5_marks:- " + subject_5_marks + "\n"); + + System.out.println("The total no. of marks are: " + total); + System.out.println("Total percentage is: " + percentage); + + } + +} diff --git a/exercise_and_practice_Problems/Exercise2.java b/exercise_and_practice_Problems/Exercise2.java new file mode 100644 index 0000000..a395797 --- /dev/null +++ b/exercise_and_practice_Problems/Exercise2.java @@ -0,0 +1,34 @@ +package exercise_and_practice_Problems; +import java.util.Scanner; + +/* + * Take an array as input & print all of its content at particular index wise + */ + +public class Exercise2 { + + public static void main(String[] args) { + try (Scanner sc = new Scanner(System.in)) { + int n,sum =0; + + System.out.println("Enter no. of elements you want in array:"); + n = sc.nextInt(); + + int A[] = new int[n]; + System.out.println("Enter all the elements: "); + + for(int i=0;i 40) System.out.println(" The height of cylender is to high to to find vol & surface area: "); + else this.height = height; + } + + //setter method to set radius of cylinder + public void setRadius(double radius) { + this.radius = radius; + } + + //setter method to set the value of pie + public void setPie(double pie) { + this.pie = pie; + } + + //getter method to get the height of cylinder + public int getHeight() { + return height; + } + + //getter method to get the radius of cylinder + public double getRadius() { + return radius; + } + + //getter method to get the value of pie + public double getPie() { + return pie; + } + + + +} diff --git a/list/Deletion_in_Linked_List.java b/list/Deletion_in_Linked_List.java new file mode 100644 index 0000000..98076d0 --- /dev/null +++ b/list/Deletion_in_Linked_List.java @@ -0,0 +1,100 @@ +package list; + +class LinkedList +{ + Node head; // head of list + + /* Linked list Node*/ + class Node + { + int data; + Node next; + Node(int d) + { + data = d; + next = null; + } + } + + /* Inserts a new Node at front of the list. */ + public void push(int new_data) + { + /* 1 & 2: Allocate the Node & + Put in the data*/ + Node new_node = new Node(new_data); + + /* 3. Make next of new Node as head */ + new_node.next = head; + + /* 4. Move the head to point to new Node */ + head = new_node; + } + + /* Given a reference (pointer to pointer) to the head of a list + and a position, deletes the node at the given position */ + void deleteNode(int position) + { + // If linked list is empty + if (head == null) + return; + + // Store head node + Node temp = head; + + // If head needs to be removed + if (position == 0) + { + head = temp.next; // Change head + return; + } + + // Find previous node of the node to be deleted + for (int i=0; temp!=null && inext is the node to be deleted + // Store pointer to the next of node to be deleted + Node next = temp.next.next; + + temp.next = next; // Unlink the deleted node from list + } + + /* This function prints contents of linked list starting from + the given node */ + public void printList() + { + Node tnode = head; + while (tnode != null) + { + System.out.print(tnode.data+" "); + tnode = tnode.next; + } + } + + /* Driver program to test above functions. Ideally this function + should be in a separate user class. It is kept here to keep + code compact */ + public static void main(String[] args) + { + /* Start with the empty list */ + LinkedList llist = new LinkedList(); + + llist.push(7); + llist.push(1); + llist.push(3); + llist.push(2); + llist.push(8); + + System.out.println("\nCreated Linked list is: "); + llist.printList(); + + llist.deleteNode(4); // Delete node at position 4 + + System.out.println("\nLinked List after Deletion at position 4: "); + llist.printList(); + } +} \ No newline at end of file diff --git a/list/Insertion_in_Linked_List.java b/list/Insertion_in_Linked_List.java new file mode 100644 index 0000000..f395e1a --- /dev/null +++ b/list/Insertion_in_Linked_List.java @@ -0,0 +1,99 @@ +package list; + +public class Insertion_in_Linked_List { + + class Node{ + int data; + Node next; + + Node(int d){ + data = d; + next = null; + } + } + + Node head; + + public void push(int new_data ) { + Node new_node = new Node(new_data); + new_node.next = head; + head = new_node; + } + + public void insertAfter(Node prev_node, int new_data) + { + /* 1. Check if the given Node is null */ + if (prev_node == null) + { + System.out.println("The given previous node cannot be null"); + return; + } + + /* 2 & 3: Allocate the Node & Put in the data*/ + Node new_node = new Node(new_data); + + /* 4. Make next of new Node as next of prev_node */ + new_node.next = prev_node.next; + + /* 5. make next of prev_node as new_node */ + prev_node.next = new_node; + } + + public void append(int new_data) { + + //make an object of above mentioned Node class + Node new_node = new Node(new_data); + + if(head == null) { + head = new_node; + return; + } + + new_node.next = null; + + Node last = head; + while (last.next != null) + last = last.next; + + last.next = new_node; + return; + } + + public void printList() + { + Node tnode = head; + while (tnode != null) + { + System.out.print(tnode.data+" "); + tnode = tnode.next; + } + } + + public static void main(String[] args) { + Insertion_in_Linked_List llist = new Insertion_in_Linked_List(); + /* Start with the empty list */ + + // Insert 6. So linked list becomes 6->NUllist + llist.append(6); + + // Insert 7 at the beginning. So linked list becomes + // 7->6->NUllist + llist.push(7); + + // Insert 1 at the beginning. So linked list becomes + // 1->7->6->NUllist + llist.push(1); + + // Insert 4 at the end. So linked list becomes + // 1->7->6->4->NUllist + llist.append(4); + + // Insert 8, after 7. So linked list becomes + // 1->7->8->6->4->NUllist + llist.insertAfter(llist.head.next, 8); + + System.out.println("\nCreated Linked list is: "); + llist.printList(); + } + +} diff --git a/list/MainList.java b/list/MainList.java new file mode 100644 index 0000000..62e39df --- /dev/null +++ b/list/MainList.java @@ -0,0 +1,18 @@ +package list; +public class MainList { + + public static void main(String[] args) { + + MyLL myll = new MyLL(); + + + myll.add(0); + myll.add(1); + myll.add(2); + myll.add(3); + myll.add(4); + + myll.print(); + } + +} diff --git a/list/MyLL.java b/list/MyLL.java new file mode 100644 index 0000000..478b1da --- /dev/null +++ b/list/MyLL.java @@ -0,0 +1,53 @@ +package list; + +public class MyLL { + + static class Node{ + int data; + Node next; + + public Node(int data) { + this.data = data; + next = null; + } + } + + Node head; + Node position; + + void add(int data) { + Node toAdd = new Node(data); + + if(isEmpty()) { + head = toAdd; + return; + } + + Node temp = head; + while(temp.next != null) { + temp = temp.next; + } + temp.next = toAdd; + } + + void print() { + Node temp = head; + while(temp != null) { + System.out.println(temp.data + " "); + temp = temp.next; + } + + } + + boolean isEmpty() { + return head == null; + } + + void remove(int data) { + head = null; + } + + boolean isValue() { + return head == position; + } +} diff --git a/list/Problem_1_1.java b/list/Problem_1_1.java new file mode 100644 index 0000000..0247116 --- /dev/null +++ b/list/Problem_1_1.java @@ -0,0 +1,63 @@ +package list; + +/* + * Write a Program to Reverse the Linked List Iteratively + */ + +public class Problem_1_1 { + + static Node head; + + static class Node{ + int data; + Node next; + Node(int d){ + data = d; + next = null; + } + } + + Node reverse (Node node) { + + Node prev = null; + Node current = node; + Node next = null; + + while(current != null) { + next = current.next; + current.next = prev; + prev = current; + current = next; + } + + node = prev; + return node; + } + + void printList(Node node) { + while(node != null) { + System.out.println(node.data + " "); + node = node.next; + } + } + + @SuppressWarnings("static-access") + public static void main(String[] args) { + + Problem_1_1 list = new Problem_1_1(); + + list.head = new Node(85); + list.head.next = new Node(15); + list.head.next.next = new Node(4); + list.head.next.next.next = new Node(20); + + System.out.println("Given Linked list"); + list.printList(head); + head = list.reverse(head); + System.out.println(" "); + System.out.println("Reversed linked list "); + list.printList(head); + + } + +} diff --git a/list/Problem_1_2.java b/list/Problem_1_2.java new file mode 100644 index 0000000..f7bd1de --- /dev/null +++ b/list/Problem_1_2.java @@ -0,0 +1,67 @@ +package list; + +/* + * Write a Program to Reverse the LinkedList Recursively + */ + +public class Problem_1_2 { + + static Node head; + + static class Node{ + int data; + Node next; + Node(int d){ + data = d; + next = null; + } + } + + static Node reverse(Node head) { + if(head == null || head.next == null) { + return head; + } + + Node rest = reverse(head.next); + head.next.next = head; + + + head.next = null; + + return rest; + } + + + static void print() { + Node temp = head; + while(temp != null) { + System.out.print(temp.data + " "); + temp = temp.next; + } + System.out.println(); + } + + static void push(int data) { + Node temp = new Node(data); + temp.next = head; + head = temp; + } + + public static void main(String[] args) { + + push(20); + push(4); + push(15); + push(85); + + System.out.println("Given linked list"); + print(); + + head = reverse(head); + + System.out.println("Reversed Linked list"); + print(); + + } + +} diff --git a/list/Queue.java b/list/Queue.java new file mode 100644 index 0000000..41008f2 --- /dev/null +++ b/list/Queue.java @@ -0,0 +1,157 @@ +package list; +import java.util.*; + +/* + * Code: Queue Using LL + * + * Send Feedback: + * You need to implement a Queue class using linked list. + * All the required data members should be private. + * + * Implement the following public functions: + * 1. Constructor - Initialise's the data members. + * 2. enqueue - This function should take one argument of type T and has return type void. + * This function should insert an element in the queue. + * Time complexity should be O(1). + * 3. dequeue - This function takes no arguments and has return type T. + * This should removes the first element which is entered and return that element as an answer. + * Time complexity should be O(1). + * 4. front - This function takes no input arguments and has return type T. + * This should return the first element which is entered and return that element as an answer. + * Time complexity should be O(1). + * 5. size - Return the size of stack i.e. count of elements which are present ins stack right now. + * Time complexity should be O(1). + * 6. isEmpty - Checks if the queue is empty or not. + * Return true or false + * + */ + +class QueueEmptyException extends Exception { + + private static final long serialVersionUID = 7243921724361015813L; + + public static void main(String[] args) { + + @SuppressWarnings("resource") + Scanner s = new Scanner(System.in); + + Queue st = new Queue(); + + int choice = s.nextInt(); + int input; + + while (choice !=-1) { + + if(choice == 1) { + input = s.nextInt(); + st.enqueue(input); + } + + else if(choice == 2) { + + try { + System.out.println(st.dequeue()); + }catch (QueueEmptyException e) { + System.out.println(-1); + } + } + + else if(choice == 3) { + + try { + System.out.println(st.front()); + } catch (QueueEmptyException e) { + System.out.println(-1); + } + } + + else if(choice == 4) + System.out.println(st.size()); + + else if(choice == 5) + System.out.println(st.isEmpty()); + + choice = s.nextInt(); + } + } +} + +class Node { + T data; + Node next; + + public Node(T data) { + this.data = data; + } +} + +public class Queue { + + private Node front; + private Node rear; + private int size; + + + public Queue() { + front=null; + rear=null; + size=0; + + } + + public int size() { + return size; + } + + public boolean isEmpty() { + return (size==0); + } + + public T front() throws QueueEmptyException { + + if(size==0) + throw new QueueEmptyException(); + + return front.data; + } + + public void enqueue(T data) { + + if(size==0){ + Node newnode=new Node(data); + front=newnode; + rear=newnode; + size++; + } + + else{ + Node newnode=new Node(data); + rear.next=newnode; + rear=rear.next; + size++; + } + } + + + public T dequeue() throws QueueEmptyException { + + if(size==0) + throw new QueueEmptyException(); + + if(size==1){ + T temp=front.data; + front=null; + rear=null; + size=0; + return temp; + } + + else{ + T temp = front.data; + front = front.next; + size--; + return temp; + } + } + +} \ No newline at end of file diff --git a/recursion/Problem_01.java b/recursion/Problem_01.java new file mode 100644 index 0000000..b5a8998 --- /dev/null +++ b/recursion/Problem_01.java @@ -0,0 +1,20 @@ +package recursion; + +/* + * Find sum of first N natural numbers using recursion + */ +public class Problem_01 { + + public static void main(String[] args) { + System.out.println(sum(5)); + } + + static int sum(int N) { + //Base case + if(N == 1) return 1; + + //Recursive call + return N+sum(N-1) ; + } + +} diff --git a/sdeProblems/FindDuplicate.java b/sdeProblems/FindDuplicate.java deleted file mode 100644 index df101dc..0000000 --- a/sdeProblems/FindDuplicate.java +++ /dev/null @@ -1,32 +0,0 @@ -package sdeProblems; - -public class FindDuplicate { - - // Implementing an array as a HashMap for finding duplicate elements - void printRepeating(int m[],int size) { - - int i; - System.out.print("The repeating elements are:"); - - for(i=0;i=0) m[Math.abs(m[i])] = -m[Math.abs(m[i])]; - else System.out.print(Math.abs(m[i]) + " "); - } - } - - //Driver Method - public static void main(String[] args) { - - FindDuplicate duplicate = new FindDuplicate(); // Making an object of FindDuplicate class - - int m[] = {1,2,3,1,3,6,6}; // Putting or declare values in or to array - int m_size = m.length; // variables which store size or length of array - - duplicate.printRepeating(m,m_size); // calling above function to pass value in it to print repeating elements - - } - - } diff --git a/sdeProblems/RotateArray.java b/sdeProblems/RotateArray.java deleted file mode 100644 index 69b6ef1..0000000 --- a/sdeProblems/RotateArray.java +++ /dev/null @@ -1,38 +0,0 @@ -package sdeProblems; - -public class RotateArray { - - //function to rotate the elements of an array - - void rotateL(int a[], int d, int n) { - for(int i= 0;i=0; i--) - { - /* Find the smallest element greater than ar2[i]. Move all elements one position ahead till the smallest greater - element is not found */ - int j, last = arr1[m-1]; - - for (j=m-2; j >= 0 && arr1[j] > arr2[i]; j--) - arr1[j+1] = arr1[j]; - - // If there was a greater element - if (j != m-2 || last > arr2[i]) { - arr1[j+1] = arr2[i]; - arr2[i] = last; } - } - } - - // Driver method to test the above function - public static void main1(String[] args) - { - merge(arr1.length,arr2.length); - System.out.print("After Merging nFirst Array: "); - System.out.println(Arrays.toString(arr1)); - System.out.print("Second Array: "); - System.out.println(Arrays.toString(arr2)); - } -} diff --git a/sortingAlgorithms/BubbleSort.java b/sortingAlgorithms/BubbleSort.java index 56ae59c..cc52dc0 100644 --- a/sortingAlgorithms/BubbleSort.java +++ b/sortingAlgorithms/BubbleSort.java @@ -1,5 +1,6 @@ package sortingAlgorithms; +//Program to demonstrate the bubble sort algorithm public class BubbleSort { void bubbleSort(int a[]) { @@ -9,7 +10,7 @@ void bubbleSort(int a[]) { { for(int j=0;ja[j+1]) { + if(a[j] > a[j+1]) { //swap a[j+1] and a[i] int temp = a[j]; a[j] = a[j+1]; diff --git a/sortingAlgorithms/HeapSort.java b/sortingAlgorithms/HeapSort.java index 62ba46d..2f8dfdd 100644 --- a/sortingAlgorithms/HeapSort.java +++ b/sortingAlgorithms/HeapSort.java @@ -1,77 +1,76 @@ package sortingAlgorithms; +import java.util.*; //Java program for implementation of Heap Sort -public class HeapSort -{ - public void sort(int A[]) - { - int n = A.length; +public class HeapSort { + + public void sort(int A[]) { + + int n = A.length; + + for(int i=n/2;i>=0;i--) + heapify(A,n,i); + + for(int i = n-1;i>0;i--) { + int temp = A[0]; + A[0] = A[i]; + A[i] = temp; + + heapify(A,i,0); + } + } + + void heapify(int A[], int n, int i) { - // Build heap (rearrange array) - for (int i = n / 2 - 1; i >= 0; i--) - heapify(A, n, i); + int largest = i; // Initialize largest as root + int l = 2*i + 1; // left = 2*i + 1 + int r = 2*i + 2; // right = 2*i + 2 - // One by one extract an element from heap - for (int i=n-1; i>0; i--) - { - // Move current root to end - int temp = A[0]; - A[0] = A[i]; - A[i] = temp; + // If left child is larger than root + if (l < n && A[l] > A[largest]) + largest = l; - // call max heapify on the reduced heap - heapify(A, i, 0); - } - } + // If right child is larger than largest so far + if (r < n && A[r] > A[largest]) + largest = r; - // To heapify a subtree rooted with node i which is - // an index in arr[]. n is size of heap - void heapify(int A[], int n, int i) - { - int largest = i; // Initialize largest as root - int l = 2*i + 1; // left = 2*i + 1 - int r = 2*i + 2; // right = 2*i + 2 + // If largest is not root + if (largest != i) + { + int swap = A[i]; + A[i] = A[largest]; + A[largest] = swap; - // If left child is larger than root - if (l < n && A[l] > A[largest]) - largest = l; + // Recursively heapify the affected sub-tree + heapify(A, n, largest); + } + } - // If right child is larger than largest so far - if (r < n && A[r] > A[largest]) - largest = r; + /* A utility function to print array of size n */ + static void printArray(int A[]) + { + int n = A.length; + for (int i=0; i 0; exp *= 10) countSort(arr, n, exp); } diff --git a/stack/Parenthesis_Checker_Problem.java b/stack/Parenthesis_Checker_Problem.java new file mode 100644 index 0000000..c602cad --- /dev/null +++ b/stack/Parenthesis_Checker_Problem.java @@ -0,0 +1,75 @@ +package stack; +import java.util.Scanner; +import java.util.Stack; + +public class Parenthesis_Checker_Problem { + + @SuppressWarnings("resource") + public static void main(String[] args) { + + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-- != 0) { + + String s = sc.nextLine(); + Stack stack = new Stack<>(); + + boolean isBalanced = true; + + for(int i = 0 ; i < s.length() ; i++) { + + char ch = s.charAt(i); + if(ch == '(' || ch == '{' || ch == '[') { + stack.push(ch); + continue; + } + + if(stack.isEmpty()) { + isBalanced = false; + break; + } + + if(ch == ')') { + if(stack.peek() == '(') { + stack.pop(); + }else { + isBalanced = false; + break; + } + } + + if(ch == '}') { + if(stack.peek() == '{') { + stack.pop(); + }else { + isBalanced = false; + break; + } + } + + if(ch == ']') { + if(stack.peek() == '[') { + stack.pop(); + }else { + isBalanced = false; + break; + } + } + + } + + if(!stack.isEmpty()) { + isBalanced = false; + } + + if(isBalanced) { + System.out.println("isBalanced"); + }else { + System.out.println("not balanced"); + } + + } + + } + +} diff --git a/stack/Tower_Of_Hanoi.java b/stack/Tower_Of_Hanoi.java new file mode 100644 index 0000000..4f2e26f --- /dev/null +++ b/stack/Tower_Of_Hanoi.java @@ -0,0 +1,29 @@ +package stack; + +/* + * Stack Application :- Tower of Hanoi Problem(Puzzle 1) + */ +public class Tower_Of_Hanoi { + + //function to solve the tower of hanoi proble + static void towerOfHanoi(int n, char from_rod, char to_rod, char aux_rod) { + + if(n == 1) { + System.out.println("Move disk 1 from rod " + from_rod + " to_rod " + to_rod); + return; + } + + towerOfHanoi(n-1, from_rod, to_rod, aux_rod); + System.out.println("Move disk "+ n +" from_rod "+from_rod+" to rod "+to_rod); + + } + + //Driver Method + public static void main(String[] args) { + + int n =4; + towerOfHanoi(n,'A','C','B'); + + } + +} diff --git a/trees/BST_Deletion.java b/trees/BST_Deletion.java new file mode 100644 index 0000000..6d6d3ce --- /dev/null +++ b/trees/BST_Deletion.java @@ -0,0 +1,158 @@ +package trees; + +//Java program to demonstrate delete operation in binary search tree +class BST_Deletion{ + + // Class to make a Node + class Node { + int key; + Node left, right; + + public Node(int item) { + key = item; + left = right = null; + } + } + + // Root of BST + Node root; + + // Constructor + BST_Deletion() { + root = null; + } + + // This method mainly calls deleteRec() + void deleteKey(int key) { + root = deleteRec(root, key); + } + + /* A recursive function to insert a new key in BST */ + Node deleteRec(Node root, int key) { + /* Base Case: If the tree is empty */ + if (root == null) return root; + + /* Otherwise, recur down the tree */ + if (key < root.key) + root.left = deleteRec(root.left, key); + else if (key > root.key) + root.right = deleteRec(root.right, key); + + // if key is same as root's key, then This is the node + // to be deleted + else + { + // node with only one child or no child + if (root.left == null) + return root.right; + else if (root.right == null) + return root.left; + + // node with two children: Get the inorder successor (smallest + // in the right subtree) + root.key = minValue(root.right); + + // Delete the inorder successor + root.right = deleteRec(root.right, root.key); + } + + return root; + } + + int minValue(Node root) + { + int minv = root.key; + while (root.left != null) + { + minv = root.left.key; + root = root.left; + } + return minv; + } + + // This method mainly calls insertRec() + void insert(int key) + { + root = insertRec(root, key); + } + + /* A recursive function to insert a new key in BST */ + Node insertRec(Node root, int key) + { + + /* If the tree is empty, return a new node */ + if (root == null) + { + root = new Node(key); + return root; + } + + /* Otherwise, recur down the tree */ + if (key < root.key) + root.left = insertRec(root.left, key); + else if (key > root.key) + root.right = insertRec(root.right, key); + + /* return the (unchanged) node pointer */ + return root; + } + + // This method mainly calls InorderRec() + void inorder() + { + inorderRec(root); + } + + // A utility function to do inorder traversal of BST + void inorderRec(Node root) + { + if (root != null) + { + inorderRec(root.left); + System.out.print(root.key + " "); + inorderRec(root.right); + } + } + + // Driver Program to test above functions + public static void main(String[] args) + { + BST_Deletion tree = new BST_Deletion(); + + /* Let us create following BST + 50 + / \ + 30 70 + / \ / \ + 20 40 60 80 */ + + tree.insert(50); + tree.insert(30); + tree.insert(20); + tree.insert(40); + tree.insert(70); + tree.insert(60); + tree.insert(80); + + System.out.println("Inorder traversal of the given tree"); + tree.inorder(); + + System.out.println("\nDelete 20"); + tree.deleteKey(20); + + System.out.println("Inorder traversal of the modified tree"); + tree.inorder(); + + System.out.println("\nDelete 30"); + tree.deleteKey(30); + + System.out.println("Inorder traversal of the modified tree"); + tree.inorder(); + + System.out.println("\nDelete 50"); + tree.deleteKey(50); + + System.out.println("Inorder traversal of the modified tree"); + tree.inorder(); + } +} \ No newline at end of file diff --git a/trees/BinarySearchTree.java b/trees/BinarySearchTree.java new file mode 100644 index 0000000..5bf25b3 --- /dev/null +++ b/trees/BinarySearchTree.java @@ -0,0 +1,83 @@ +package trees; + +class BinarySearchTree { + + /* Class containing left and right child of current node and key value*/ + class Node { + int key; + Node left, right; + + public Node(int item) { + key = item; + left = right = null; + } + } + + // Root of BST + Node root; + + // Constructor + BinarySearchTree() { + root = null; + } + + // This method mainly calls insertRec() + void insert(int key) { + root = insertRec(root, key); + } + + /* A recursive function to insert a new key in BST */ + Node insertRec(Node root, int key) { + + /* If the tree is empty, return a new node */ + if (root == null) { + root = new Node(key); + return root; + } + + /* Otherwise, recur down the tree */ + if (key < root.key) + root.left = insertRec(root.left, key); + else if (key > root.key) + root.right = insertRec(root.right, key); + + /* return the (unchanged) node pointer */ + return root; + } + + // This method mainly calls InorderRec() + void inorder() { + inorderRec(root); + } + + // A utility function to do inorder traversal of BST + void inorderRec(Node root) { + if (root != null) { + inorderRec(root.left); + System.out.println(root.key); + inorderRec(root.right); + } + } + + // Driver Program to test above functions + public static void main(String[] args) { + BinarySearchTree tree = new BinarySearchTree(); + + /* Let us create following BST + 50 + / \ + 30 70 + / \ / \ + 20 40 60 80 */ + tree.insert(50); + tree.insert(30); + tree.insert(20); + tree.insert(40); + tree.insert(70); + tree.insert(60); + tree.insert(80); + + // print inorder traversal of the BST + tree.inorder(); + } +} diff --git a/trees/BinaryTreeNode.java b/trees/BinaryTreeNode.java new file mode 100644 index 0000000..fe8e3f1 --- /dev/null +++ b/trees/BinaryTreeNode.java @@ -0,0 +1,13 @@ +package trees; + +public class BinaryTreeNode { + + public T data; + public BinaryTreeNode left; + public BinaryTreeNode right; + + BinaryTreeNode(T data){ + this.data = data; + } + +} diff --git a/trees/BinaryTreeUse.java b/trees/BinaryTreeUse.java new file mode 100644 index 0000000..f28e6a3 --- /dev/null +++ b/trees/BinaryTreeUse.java @@ -0,0 +1,51 @@ +package trees; +import java.util.*; + +public class BinaryTreeUse { + + public static BinaryTreeNode takeInput(Scanner s){ + int rootdata; + System.out.println("Enter root data: "); + rootdata = s.nextInt(); + + if(rootdata == -1) return null; + + + BinaryTreeNode root = new BinaryTreeNode<>(rootdata); + root.left = takeInput(s); + root.right = takeInput(s); + return root; + + } + + public static void printTree(BinaryTreeNode root) { + if(root == null) return; + String s = root.data+" "; + + if(root.left!=null) + s+="L. "+root.left.data+" ,"; + + if(root.right!=null) + s+="R. "+root.right.data; + + System.out.println(s); + printTree(root.left); + printTree(root.right); + } + + public static void main(String[] args) { + +// BinaryTreeNode root= new BinaryTreeNode(1); +// BinaryTreeNode node1=new BinaryTreeNode(2); +// root.left=node1; +// BinaryTreeNode node2=new BinaryTreeNode(3); +// root.left=node2; + + Scanner s = new Scanner(System.in); + BinaryTreeNode root = takeInput(s); + printTree(root); + s.close(); + + } + +} diff --git a/trees/Construct_Tree_from_Preorder_and_Inorder.java b/trees/Construct_Tree_from_Preorder_and_Inorder.java new file mode 100644 index 0000000..0531425 --- /dev/null +++ b/trees/Construct_Tree_from_Preorder_and_Inorder.java @@ -0,0 +1,69 @@ +package trees; + + +/* + * Code: Construct Tree from Preorder and Inorder + * + * + *Given Pre-order and In-order traversal of a binary tree, + *create the binary tree associated with the traversals. + *You just need to construct the tree and return the root. + * + *Note: Assume binary tree contains only unique elements. + * + * Input format : + * + * Line 1 : n (Total number of nodes in binary tree) + * Line 2 : Pre order traversal + * Line 3 : Inorder Traversal + * + * Output Format : + * + * Elements are printed level wise, each level in new line (separated by space). + * + * Sample Input : + * 12 + * 1 2 3 4 15 5 6 7 8 10 9 12 + * 4 15 3 2 5 1 6 10 8 7 9 12 + * + * Sample Output : + * 1 + * 2 6 + * 3 5 7 + * 4 8 9 + * 15 10 12 + */ +public class Construct_Tree_from_Preorder_and_Inorder { + + public static BinaryTreeNode getTreeFromPreorderAndInorder(int[] pre , int[] in){ + return helper (0, 0, in.length - 1, pre, in); + } + + private static BinaryTreeNode helper(int preStart , int inStart , int inEnd , int[] preorder , int[] inorder){ + + //Base Case + if(preStart > preorder.length || inStart > inEnd) + return null; + + + //get the root node with current pre-order element + BinaryTreeNode root = new BinaryTreeNode(preorder[preStart]); + + //get inIndex; finding preorder's element's index in in-order + int inIndex = 0; + + for(int i = inStart ; i<= inEnd ; i++) { + if(inorder[i] == root.data) + inIndex = i; + } + + //(next, left of inIndex is the end for left subtree) + root.left = helper(preStart + 1, inStart, inIndex - 1, preorder, inorder); + + //(prestart + length of left subtree + 1) + root.right = helper(preStart + inIndex - inStart + 1, inIndex + 1, inEnd, preorder, inorder); + + return root; + } + +} diff --git a/trees/Count_leaf_nodes.java b/trees/Count_leaf_nodes.java new file mode 100644 index 0000000..dca7876 --- /dev/null +++ b/trees/Count_leaf_nodes.java @@ -0,0 +1,44 @@ +package trees; +import java.util.*; + + /*Code : Count leaf nodes + * Send Feedback + * Given a generic tree, count and return the number of leaf nodes present in the given tree. + * Input format : + * Elements in level order form separated by space (as per done in class). Order is - + * Root_data, n (No_Of_Child_Of_Root), n children, and so on for every element + * Output Format : + * Count of leaf nodes + * Sample Input 1 : + * 10 3 20 30 40 2 40 50 0 0 0 0 + * Sample Output 1 : + * 4 */ + +public class Count_leaf_nodes { + + class TreeNode { + T data; + ArrayList> children; + + TreeNode(T data){ + this.data = data; + children = new ArrayList>(); + } + + public int countLeafNodes(TreeNode root){ + + int leaf = 0; + + if (root == null ) + return 0; + + if (root.children.size() == 0) + return 1; + + for (TreeNode child : root.children) + leaf += countLeafNodes(child); + + return leaf ; + } + } +} diff --git a/trees/FindFullNodesInABinaryTree.java b/trees/FindFullNodesInABinaryTree.java index 9ef37e1..cde6448 100644 --- a/trees/FindFullNodesInABinaryTree.java +++ b/trees/FindFullNodesInABinaryTree.java @@ -2,12 +2,14 @@ //A Binary Tree Node class Node{ + int data; Node left , right; + + //Constructor of Node Class Node(int data) { this.data = data; left = right = null ; - } } @@ -15,31 +17,37 @@ public class FindFullNodesInABinaryTree { //Traverse given tree in In-order fashion & prints all nodes that have both children as non-empty public static void findFullNode(Node root) { - if (root!=null) { + if (root != null) { findFullNode(root.left); + if(root.left != null && root.right != null) System.out.println(root.data +" "); + findFullNode(root.right); } } //Driver method public static void main(String[] args) { - Node root = new Node(1); + + //Calling Node class by making an object of it (means by making a root node) + Node root = new Node(1); + root.left = new Node(2); root.right = new Node(3); root.left.left = new Node(4); root.left.right = new Node(5); root.right.left = new Node(6); root.right.right = new Node(7); - root.right.right.right = new Node(8); - root.right.left.right = new Node(9); - root.right.left.left = new Node(10); - root.left.left.left= new Node(11); - root.left.left.right = new Node(12); - root.left.right.left = new Node(13); - root.left.right.right = new Node(14); + root.left.left.left= new Node(8); + root.right.left.left = new Node(9); + root.left.left.right = new Node(10); + root.left.right.left = new Node(11); + root.right.left.right = new Node(12); + root.left.right.right = new Node(13); + root.right.right.right = new Node(14); + //calling the find full nodes by passing values of or as root or root valuess in it findFullNode(root); } diff --git a/trees/Insertion_In_BinaryTree.java b/trees/Insertion_In_BinaryTree.java index 98e45ad..efdb19a 100644 --- a/trees/Insertion_In_BinaryTree.java +++ b/trees/Insertion_In_BinaryTree.java @@ -1,9 +1,9 @@ package trees; +import java.util.*; - // Java program to insert element in binary tree -import java.util.LinkedList; -import java.util.Queue; +//Java program to insert element in binary tree public class Insertion_In_BinaryTree { + /* A binary tree node has key, pointer to left child and a pointer to right child */ static class Node { @@ -19,13 +19,14 @@ static class Node { static Node root; static Node temp = root; - //Inorder traversal of a binary tree + //In-order traversal of a binary tree static void inorder(Node temp) { if (temp == null) return; inorder(temp.left); + System.out.print(temp.key+" "); inorder(temp.right); } @@ -51,7 +52,8 @@ static void insert(Node temp, int key) if (temp.right == null) { temp.right = new Node(key); break; - } else + } + else q.add(temp.right); } } @@ -61,8 +63,8 @@ public static void main(String args[]) { root = new Node(10); root.left = new Node(11); - root.left.left = new Node(7); root.right = new Node(9); + root.left.left = new Node(7); root.right.left = new Node(15); root.right.right = new Node(8); diff --git a/trees/Problem_01.java b/trees/Problem_01.java new file mode 100644 index 0000000..c7bf03c --- /dev/null +++ b/trees/Problem_01.java @@ -0,0 +1,85 @@ +/* + * Check if generic tree contain element x + * + * Send Feedback + * Given a generic tree and an integer x, check if x is present in the given tree or not. + * Return : true :- if x is present, + * Return : false :- otherwise. + * + * Input format : + * Line 1 : Integer x + * Line 2 : Elements in level order form separated by space (as per done in class). + * + * Order is - + * Root_data , n (No_Of_Child_Of_Root) , n children , and so on for every element. + * + * Output format : true or false + * Sample Input 1 : + * 40 + * 10 3 20 30 40 2 40 50 0 0 0 0 + * + * Sample Output 1 : + * true + * + * Sample Input 2 : + * 4 + * 10 3 20 30 40 2 40 50 0 0 0 0 + * + * Sample Output 2: + * false + */ + +package trees; +import java.util.*; + +public class Problem_01 { + // TreeNode class + class TreeNode { + T data; + ArrayList> children; + + TreeNode(T data){ + this.data = data; + children = new ArrayList>(); + } + } + + public static boolean checkIfContainsX(TreeNode root, int x){ + + // Write your code here + if(root==null) + return false; + + // Write your code here + Queue> queue = new LinkedList<>(); + + //added 1st level here + queue.add(root); + queue.add(null); + @SuppressWarnings("unused") + int ans=0; + + // if(x frontNode = queue.remove(); + if(frontNode == null) + { + if(queue.isEmpty()) + break; + + queue.add(null); + } + else{ + if(frontNode.data==x) + return true; + System.out.print(frontNode.data+" "); + + for(int i=0;i Date: Sun, 15 Nov 2020 22:21:02 +0530 Subject: [PATCH 06/56] Adding Readme --- README_2.md | 1102 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1102 insertions(+) create mode 100644 README_2.md diff --git a/README_2.md b/README_2.md new file mode 100644 index 0000000..8147bcf --- /dev/null +++ b/README_2.md @@ -0,0 +1,1102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Java-Programs/README.md at master-1 Β· gitaman8481/Java-Programs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Skip to content + + + + + + + + + +
+ +
+ + + + + +
+ + + +
+ + + + + + + + + +
+
+
+ + + + + + + + + + + + +
+ +
+ +
+

+ + + / + + Java-Programs + + Template +

+ + +
+ +
    + +
  • +
    + +
    + + + Unwatch + + + +
    + Notifications +
    +
    + + + + + + + +
    +
    +
    + +
    +
  • + +
  • +
    +
    + + +
    +
    + + +
    + +
  • + +
  • +
    +
    + + + Fork + + + +
    + +

    Fork Java-Programs

    +
    + +
    + +
    +

    If this dialog fails to load, you can visit the fork page directly.

    +
    +
    + +
    +
    +
    + + +
  • +
+ +
+ + +
+ + +
+
+ + + + + + + Permalink + + + + +
+ +
+
+ + + master-1 + + + + +
+ + + +
+
+
+ +
+ + + + Go to file + + +
+ + +
+ +
+ + + +
+ +
+
+
 
+
+ +
+
 
+ Cannot retrieve contributors at this time +
+
+ + + + + + +
+ +
+
+ + 7 lines (7 sloc) + + 417 Bytes +
+ +
+ +
+ Raw + Blame +
+ +
+ + + + +
+ +
+
+ +
+
+
+ + +
+

Java-Programs

+

This is a repository where, I will upload and keep up to date my Java, DataStructure and algorithms code and question regarding to them,which i practiced on eclipse with help of Books and programming websites. +The books I prefer and use for learning java and algorithms are:

+
    +
  1. Java for Dummies.
  2. +
  3. Java The Complete Reference by Herberth Schildt.
  4. +
  5. Algorithms by Sedwig.
  6. +
  7. Algorithms by Cormen.
  8. +
+
+
+ +
+ + + + +
+ + +
+ + +
+
+ + + + + + +
+
+ +
+
+ +
+ + + + + + +
+ + + You can’t perform that action at this time. +
+ + + + + + + + + + + + + From 3d0f65bfda2253494615b2d8b47b23eda3a38091 Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Sun, 15 Nov 2020 22:23:25 +0530 Subject: [PATCH 07/56] Adding Readme --- README_2.md => README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename README_2.md => README.md (100%) diff --git a/README_2.md b/README.md similarity index 100% rename from README_2.md rename to README.md From c101c27e3b323cd8baf95d36bd8ac1365890e844 Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Sun, 15 Nov 2020 22:25:00 +0530 Subject: [PATCH 08/56] Delete Readme --- README.md | 1102 ----------------------------------------------------- 1 file changed, 1102 deletions(-) delete mode 100644 README.md diff --git a/README.md b/README.md deleted file mode 100644 index 8147bcf..0000000 --- a/README.md +++ /dev/null @@ -1,1102 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Java-Programs/README.md at master-1 Β· gitaman8481/Java-Programs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Skip to content - - - - - - - - - -
- -
- - - - - -
- - - -
- - - - - - - - - -
-
-
- - - - - - - - - - - - -
- -
- -
-

- - - / - - Java-Programs - - Template -

- - -
- -
    - -
  • -
    - -
    - - - Unwatch - - - -
    - Notifications -
    -
    - - - - - - - -
    -
    -
    - -
    -
  • - -
  • -
    -
    - - -
    -
    - - -
    - -
  • - -
  • -
    -
    - - - Fork - - - -
    - -

    Fork Java-Programs

    -
    - -
    - -
    -

    If this dialog fails to load, you can visit the fork page directly.

    -
    -
    - -
    -
    -
    - - -
  • -
- -
- - -
- - -
-
- - - - - - - Permalink - - - - -
- -
-
- - - master-1 - - - - -
- - - -
-
-
- -
- - - - Go to file - - -
- - -
- -
- - - -
- -
-
-
 
-
- -
-
 
- Cannot retrieve contributors at this time -
-
- - - - - - -
- -
-
- - 7 lines (7 sloc) - - 417 Bytes -
- -
- -
- Raw - Blame -
- -
- - - - -
- -
-
- -
-
-
- - -
-

Java-Programs

-

This is a repository where, I will upload and keep up to date my Java, DataStructure and algorithms code and question regarding to them,which i practiced on eclipse with help of Books and programming websites. -The books I prefer and use for learning java and algorithms are:

-
    -
  1. Java for Dummies.
  2. -
  3. Java The Complete Reference by Herberth Schildt.
  4. -
  5. Algorithms by Sedwig.
  6. -
  7. Algorithms by Cormen.
  8. -
-
-
- -
- - - - -
- - -
- - -
-
- - - - - - -
-
- -
-
- -
- - - - - - -
- - - You can’t perform that action at this time. -
- - - - - - - - - - - - - From db9134bdbda1185e97dc6907802accfa6f2d6388 Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Sun, 15 Nov 2020 22:26:57 +0530 Subject: [PATCH 09/56] Create README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..5c22bcf --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# Java-ProgramsThis is a repository where, I will upload and keep up to date my Java, DataStructure and algorithms code and question regarding to them,which i practiced on eclipse & IntelliJ with help of Books and programming websites. The books I prefer and use for learning java and algorithms are: + +1. Java for Dummies. +2. Java The Complete Reference by Herberth Schildt. +3. Algorithms by Sedwig. +4. Algorithms by Cormen. From d7742f27fa4502b10028745af632cfbc60113673 Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Sun, 15 Nov 2020 22:27:18 +0530 Subject: [PATCH 10/56] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5c22bcf..64f387a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -# Java-ProgramsThis is a repository where, I will upload and keep up to date my Java, DataStructure and algorithms code and question regarding to them,which i practiced on eclipse & IntelliJ with help of Books and programming websites. The books I prefer and use for learning java and algorithms are: +# Java-Programs +This is a repository where, I will upload and keep up to date my Java, DataStructure and algorithms code and question regarding to them,which i practiced on eclipse & IntelliJ with help of Books and programming websites. The books I prefer and use for learning java and algorithms are: 1. Java for Dummies. 2. Java The Complete Reference by Herberth Schildt. From e2bfecb328148f3896a896c2e08fad08e8bf716d Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Wed, 9 Dec 2020 11:40:35 +0530 Subject: [PATCH 11/56] #Modification 10 --- .vscode/settings.json | 5 + arrays/Candy_Distribution_Problem.java | 49 +++++++ basics/Operators.java | 2 +- dp/CoinChoiseProblem.java | 51 ++++++++ graphs/Graph.java | 41 ++++++ graphs/Graph_Traversal_DFS.java | 57 ++++++++ matrix/Matrix_Problem_01.java | 87 +++++++++++++ matrix/Matrix_Problem_02.java | 123 ++++++++++++++++++ oops/Mor.java | 2 + oopsEncapsulation/S.java | 1 + oopsinheritance/MainClass.java | 4 +- oopspolymorphism/Animal.java | 2 +- patternsByloops/Pattern1.java | 1 + practiceProblems/Cylinder.java | 26 ++++ practiceProblems/Exercise1.java | 33 +++++ practiceProblems/Exercise2.java | 34 +++++ .../Getters_Setters_For_Cylinder.java | 44 +++++++ queues/ArrayDequeDemo.java | 1 + recursion/Factorial.java | 21 +++ recursion/NRaiseP.java | 15 +++ recursion/NaturalNoSum.java | 20 +++ recursion/Subsequences.java | 50 +++++++ recursion/Tower_Of_Hanoi.java | 29 +++++ searchingAlgorithms/BinarySearch.java | 1 + sortingAlgorithms/BubbleSort.java | 2 +- ...java_cfba17b398252ca38e082cac809277ad.prob | 1 + stack/Infix_To_Postfix.java | 76 +++++++++++ stack/Postfix.java | 75 +++++++++++ stack/stack/Postfix.class | Bin 0 -> 2162 bytes trees/BT_Traversal.java | 82 ++++++++++++ trees/BinaryTree_LOT.java | 99 ++++++++++++++ trees/BinaryTree_Traversal.java | 95 ++++++++++++++ trees/Binary_Tree_01.java | 97 ++++++++++++++ trees/Count_leaf_nodes.java | 12 +- trees/Problem_01.java | 9 +- 35 files changed, 1233 insertions(+), 14 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 arrays/Candy_Distribution_Problem.java create mode 100644 dp/CoinChoiseProblem.java create mode 100644 graphs/Graph.java create mode 100644 graphs/Graph_Traversal_DFS.java create mode 100644 matrix/Matrix_Problem_01.java create mode 100644 matrix/Matrix_Problem_02.java create mode 100644 practiceProblems/Cylinder.java create mode 100644 practiceProblems/Exercise1.java create mode 100644 practiceProblems/Exercise2.java create mode 100644 practiceProblems/Getters_Setters_For_Cylinder.java create mode 100644 recursion/Factorial.java create mode 100644 recursion/NRaiseP.java create mode 100644 recursion/NaturalNoSum.java create mode 100644 recursion/Subsequences.java create mode 100644 recursion/Tower_Of_Hanoi.java create mode 100644 stack/.cph/.Postfix.java_cfba17b398252ca38e082cac809277ad.prob create mode 100644 stack/Infix_To_Postfix.java create mode 100644 stack/Postfix.java create mode 100644 stack/stack/Postfix.class create mode 100644 trees/BT_Traversal.java create mode 100644 trees/BinaryTree_LOT.java create mode 100644 trees/BinaryTree_Traversal.java create mode 100644 trees/Binary_Tree_01.java diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..07bcd3c --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "POSTFIX.C": "cpp" + } +} \ No newline at end of file diff --git a/arrays/Candy_Distribution_Problem.java b/arrays/Candy_Distribution_Problem.java new file mode 100644 index 0000000..806cd6d --- /dev/null +++ b/arrays/Candy_Distribution_Problem.java @@ -0,0 +1,49 @@ +package arrays; +import java.util.*; + +//Language: Java +//Time Complexity: O(n) 3 Linear traversals. +//Space Complexity: O(n) Array of candies. + +public class Candy_Distribution_Problem{ + + public int candy(int[] ratings) { + if (ratings.length < 2) + return ratings.length; + + + int[] candies = new int[ratings.length]; + Arrays.fill(candies, 1); + + // ** Step 1: Forward ** + for (int i=0; i= ratings[i+1]) { + continue; + } + candies[i+1] = candies[i] + 1; + } + + // ** Step 2: Backward ** + for (int i=ratings.length-1; i>0; i--) { + if (ratings[i] >= ratings[i-1]) { + continue; + } + candies[i-1] = Math.max(candies[i] + 1, candies[i-1]); + } + + // ** Step 3: Count Candies ** + int count = 0; + for (int i=0; i= 0) { + + int subAns = 0; + + if(dp[n-a[i]] != -1) + subAns = dp[n-a[i]]; + + else + subAns = minCoins(n-a[i],a, dp); + + if(subAns != Integer.MAX_VALUE && subAns + 1 < ans) + ans = subAns + 1; + } + } + + return dp[n] = ans; + + } +} diff --git a/graphs/Graph.java b/graphs/Graph.java new file mode 100644 index 0000000..6bf1150 --- /dev/null +++ b/graphs/Graph.java @@ -0,0 +1,41 @@ +package graphs; +import java.util.*; + +public class Graph { + + private LinkedList adj[]; + + @SuppressWarnings("unchecked") + public Graph(int v) { + //array of Linked List + adj = new LinkedList[v]; + + for(int i=0;i(); + } + } + + public void addEdge(int source, int destination) { + adj[source].add(destination); + adj[destination].add(source); + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + + System.out.println("Enter number of vertices and edges"); + int v = sc.nextInt(); + int e = sc.nextInt(); + + Graph graph = new Graph(v); + System.out.println("Enter " + e + " edges"); + + for(int i=0;i adj[]; + + @SuppressWarnings("unchecked") + public Graph_Traversal_DFS(int v){ + adj = new LinkedList[v]; + for(int i = 0 ; i < v ; ++i) + adj[i] = new LinkedList(); + } + + void addEdge(int v, int w) { + adj[v].add(w); + } + + void DFSUtil(int v, boolean visited[]) { + visited[v] = true; + System.out.println(v + " "); + + Iterator i = adj[v].listIterator(); + while(i.hasNext()) { + int n = i.next(); + if(!visited[n]) + DFSUtil(n,visited); + } + } + + void DFS(int v) { + boolean visited[] = new boolean[v]; + DFSUtil(v,visited); + } + + public static void main(String[] args) { + + Graph_Traversal_DFS d = new Graph_Traversal_DFS(4); + + d.addEdge(0, 1); + d.addEdge(0, 2); + d.addEdge(1, 2); + d.addEdge(2, 0); + d.addEdge(2, 3); + d.addEdge(3, 3); + + System.out.println( + "Following is Depth First Traversal " + + "(starting from vertex 2)"); + + d.DFS(2); + + } + +} diff --git a/matrix/Matrix_Problem_01.java b/matrix/Matrix_Problem_01.java new file mode 100644 index 0000000..5b34422 --- /dev/null +++ b/matrix/Matrix_Problem_01.java @@ -0,0 +1,87 @@ +package matrix; +import java.io.*; + +/* + * Spiral traversal on a Matrix + */ + +/* + * GIven an 2D array, print it in spiral form. + * See the following examples. + * + * Inputs: + * 01 02 03 04 + * 05 06 07 08 + * 09 10 11 12 + * 13 14 15 16 + * + * Output: + * 1 2 3 4 8 12 16 15 14 13 9 5 6 7 11 10 + * + * Explanation: + * The output is matrix in spiral format. + */ + +/* Graphical Try: + * + * 01-- 02-- 03-- 04 + * | + * 05-- 06-- 07 08 + * | | | + * 09 10 11 12 + * | | + * 13-- 14-- 15 --16 + * + * Output: + * 1, 2, 3, 4, 8, 12, 16, 15, 14, 13, 9, 5, 6, 7, 11, 10 + */ + +@SuppressWarnings("unused") +public class Matrix_Problem_01 { + + static void spiralPrint(int m, int n, int[][] a) { + + System.out.println("Spiral Traversal of given matrix is: "); + int i, k = 0, l = 0; + + /* + * k - starting row index + * m - ending row index + * l - starting column index + * n - ending column index + * i - iterator + */ + + while(k < m && l < n) { + + + for( i = l ; i < n ; ++i) + System.out.print(a[k][i] + " "); + k++; + + for(i = k ; i < m ; ++i) + System.out.print(a[i][n - 1] + " "); + n--; + + if(l < n) { + for(i = m - 1 ; i >= k ; --i) + System.out.print(a[i][l] + " "); + l++; + } + } + + } + + public static void main(String[] args) { + + int R = 3; + int C = 6; + int a[][] = { { 1 , 2 , 3 , 4 , 5 , 6 }, + { 7 , 8 , 9 , 10 , 11 , 12 }, + { 13 , 14 , 15 , 16 , 17 , 18 } + }; + + spiralPrint(R,C,a); + } + +} diff --git a/matrix/Matrix_Problem_02.java b/matrix/Matrix_Problem_02.java new file mode 100644 index 0000000..1de28d7 --- /dev/null +++ b/matrix/Matrix_Problem_02.java @@ -0,0 +1,123 @@ +package matrix; + +//Search an element in a matrix + +/* + * Example; + * Consider: | 1 2 3 4| + * x = 3, + * mat = | 5 6 7 8| Middle column: + * | 9 10 11 12| = {2, 6, 10, 14} + * |13 14 15 16| + * perform binary search on them + * since, x < 6, + * discard the last 2 rows as 'a' will not lie in them(sorted matrix) + * Now, only two rows are left + * | 1 2 3 4| + * x = 3, mat = | 5 6 7 8| + * + * Check whether element is present on the middle elements of these rows = {2, 6} + * + * If x != 2 or 6 + * + * If not, consider the four sub-parts + * 1st half of 1st row = {1}, 2nd half of 1st row = {3, 4} + * 1st half of 2nd row = {5}, 2nd half of 2nd row = {7, 8} + * + * According the value of 'x' it will be searched in the + * 2nd half of 1st row = {3, 4} and found at (i, j): (0, 2) + */ +public class Matrix_Problem_02 { + + static int MAX = 100; + + static void binarySearch(int mat[][], int i, int j_low, int j_high, int x) { + + while(j_low <= j_high) { + + int j_mid = (j_low + j_high)/2; + + if(mat[i][j_mid] == x) { + System.out.println("Found at (" + i + "," + j_mid + ")"); + return; + } + + else if(mat[i][j_mid] < x) + j_high = j_mid - 1; + + else + j_low = j_mid + 1; + } + + System.out.println("Element Not Found: "); + } + + static void sortedMatrixSearch(int mat[][], int n, int m, int x) { + + + // Single row matrix + if (n == 1) + { + binarySearch(mat, 0, 0, m - 1, x); + return; + } + + // Do binary search in middle column. + // Condition to terminate the loop when the 2 desired rows are found + int i_low = 0; + int i_high = n - 1; + int j_mid = m / 2; + + while ((i_low + 1) < i_high) + { + int i_mid = (i_low + i_high) / 2; + + // element found + if (mat[i_mid][j_mid] == x) + { + System.out.println ( "Found at (" + i_mid +", " + j_mid +")"); + return; + } + + else if (mat[i_mid][j_mid] > x) + i_high = i_mid; + + else + i_low = i_mid; + } + + // If element is present on the mid of the two rows + if (mat[i_low][j_mid] == x) + System.out.println ( "Found at (" + i_low + "," + j_mid +")"); + + else if (mat[i_low + 1][j_mid] == x) + System.out.println ( "Found at (" + (i_low + 1) + ", " + j_mid +")"); + + // Search element on 1st half of 1st row + else if (x <= mat[i_low][j_mid - 1]) + binarySearch(mat, i_low, 0, j_mid - 1, x); + + // Search element on 2nd half of 1st row + else if (x >= mat[i_low][j_mid + 1] && x <= mat[i_low][m - 1]) + binarySearch(mat, i_low, j_mid + 1, m - 1, x); + + // Search element on 1st half of 2nd row + else if (x <= mat[i_low + 1][j_mid - 1]) + binarySearch(mat, i_low + 1, 0, j_mid - 1, x); + + // search element on 2nd half of 2nd row + else + binarySearch(mat, i_low + 1, j_mid + 1, m - 1, x); + } + + public static void main(String[] args) { + int n = 4, m = 5, x = 8; + int mat[][] = {{0, 6, 8, 9, 11}, + {20, 22, 28, 29, 31}, + {36, 38, 50, 61, 63}, + {64, 66, 100, 122, 128}}; + + sortedMatrixSearch(mat, n, m, x); + } + +} diff --git a/oops/Mor.java b/oops/Mor.java index 263c1c7..31ccaa6 100644 --- a/oops/Mor.java +++ b/oops/Mor.java @@ -2,10 +2,12 @@ public class Mor extends Watches { + //overrided function @Override public void Digital() { System.out.println("Method_overriding is digital"); } + //second function public void Royal() { System.out.println("Method_overriding is royal"); } diff --git a/oopsEncapsulation/S.java b/oopsEncapsulation/S.java index f8de03c..bb69bb6 100644 --- a/oopsEncapsulation/S.java +++ b/oopsEncapsulation/S.java @@ -1,5 +1,6 @@ package oopsEncapsulation; +//Student class short name as S public class S { /*we have to put the variables private to achieve encapsulation*/ diff --git a/oopsinheritance/MainClass.java b/oopsinheritance/MainClass.java index c4c5dd6..8332e70 100644 --- a/oopsinheritance/MainClass.java +++ b/oopsinheritance/MainClass.java @@ -3,13 +3,13 @@ public class MainClass { public static void main(String[] args) { - + //Object of teacher class Teacher T = new Teacher(); T.name = "Mr Harry "; T.eat(); T.walk(); T.teach(); - + //Object of singer class Singer s = new Singer(); s.name = "Justin B "; s.sing(); diff --git a/oopspolymorphism/Animal.java b/oopspolymorphism/Animal.java index d46eeb4..99bbd6b 100644 --- a/oopspolymorphism/Animal.java +++ b/oopspolymorphism/Animal.java @@ -1,5 +1,5 @@ package oopspolymorphism; - +//An empty Animal class public class Animal { } diff --git a/patternsByloops/Pattern1.java b/patternsByloops/Pattern1.java index 4546ec7..a4ad1d9 100644 --- a/patternsByloops/Pattern1.java +++ b/patternsByloops/Pattern1.java @@ -1,5 +1,6 @@ package patternsByloops; +//Program for pattern 1 public class Pattern1 { public static void main(String[] args) { diff --git a/practiceProblems/Cylinder.java b/practiceProblems/Cylinder.java new file mode 100644 index 0000000..72c0b2f --- /dev/null +++ b/practiceProblems/Cylinder.java @@ -0,0 +1,26 @@ +package practiceProblems; + +public class Cylinder { + + public static void main(String[] args) { + + //The below line represent's the , Object of the Setter_Getters class + Getters_Setters_For_Cylinder sg = new Getters_Setters_For_Cylinder(); + + //setting values of pie, height & radius by using setter method with use of other class & by calling it + sg.setHeight(35); + sg.setRadius(3.0); + sg.setPie(3.14); + + //getting values of pie, radius & height + System.out.println("The value of the Pie is: " + sg.getPie()); + System.out.println("The height of the cylinder is: " + sg.getHeight() + " cm"); + System.out.println("The radius of the cylinder is: " + sg.getRadius() + " cm"); + + // volume of cylinder => (V = 3.14*(r)^2*h) + double V = sg.getPie()*(sg.getRadius()*sg.getRadius())*sg.getHeight(); + System.out.println("The volume of the cylinder is: " + V + " cm^3"); + + } + +} diff --git a/practiceProblems/Exercise1.java b/practiceProblems/Exercise1.java new file mode 100644 index 0000000..a62e265 --- /dev/null +++ b/practiceProblems/Exercise1.java @@ -0,0 +1,33 @@ +package practiceProblems; +import java.util.*; + +/* To calculate percentage of a given student in CBSE Board exam. + * His marks from 5 subjects must be taken as input from the keyboard + * (Marks are out of 100) + * */ + +public class Exercise1 { + + static Scanner sc = new Scanner(System.in); + + static int subject_1_marks = sc.nextInt(); + static int subject_2_marks = sc.nextInt(); + static int subject_3_marks = sc.nextInt(); + static int subject_4_marks = sc.nextInt(); + static int subject_5_marks = sc.nextInt(); + + public static void main(String[] args) { + + int total = (subject_1_marks + subject_2_marks + subject_3_marks + subject_4_marks + subject_5_marks); + float percentage = (total)/5; + + System.out.println("The marks of the subject's are: \n " + "\n" + "subject_1_marks:- " + subject_1_marks + "\n" + + "subject_2_marks:- " + subject_2_marks + "\n" + "subject_3_marks:- " + subject_3_marks + "\n" + + "subject_4_marks:- " + subject_4_marks + "\n" + "subject_5_marks:- " + subject_5_marks + "\n"); + + System.out.println("The total no. of marks are: " + total); + System.out.println("Total percentage is: " + percentage); + + } + +} diff --git a/practiceProblems/Exercise2.java b/practiceProblems/Exercise2.java new file mode 100644 index 0000000..794539d --- /dev/null +++ b/practiceProblems/Exercise2.java @@ -0,0 +1,34 @@ +package practiceProblems; +import java.util.Scanner; + +/* + * Take an array as input & print all of its content at particular index wise + */ + +public class Exercise2 { + + public static void main(String[] args) { + try (Scanner sc = new Scanner(System.in)) { + int n,sum =0; + + System.out.println("Enter no. of elements you want in array:"); + n = sc.nextInt(); + + int A[] = new int[n]; + System.out.println("Enter all the elements: "); + + for(int i=0;i 40) System.out.println(" The height of cylender is to high to to find vol & surface area: "); + else this.height = height; + } + + //setter method to set radius of cylinder + public void setRadius(double radius) { + this.radius = radius; + } + + //setter method to set the value of pie + public void setPie(double pie) { + this.pie = pie; + } + + //getter method to get the height of cylinder + public int getHeight() { + return height; + } + + //getter method to get the radius of cylinder + public double getRadius() { + return radius; + } + + //getter method to get the value of pie + public double getPie() { + return pie; + } + + + +} diff --git a/queues/ArrayDequeDemo.java b/queues/ArrayDequeDemo.java index 4443dd3..675d25d 100644 --- a/queues/ArrayDequeDemo.java +++ b/queues/ArrayDequeDemo.java @@ -1,5 +1,6 @@ package queues; import java.util.*; +//program inside queue package public class ArrayDequeDemo { public static void main(String[] args) { diff --git a/recursion/Factorial.java b/recursion/Factorial.java new file mode 100644 index 0000000..6091555 --- /dev/null +++ b/recursion/Factorial.java @@ -0,0 +1,21 @@ +package recursion; +import java.util.Scanner; + +public class Factorial { + public static long multiplyNumbers(int num) + { + if (num >= 1) + return num * multiplyNumbers(num - 1); + else + return 1; + } + public static void main(String[] args) { + + @SuppressWarnings("resource") + Scanner sc = new Scanner(System.in); + int num = sc.nextInt(); + long factorial = multiplyNumbers(num); + System.out.println("Factorial of " + num + " = " + factorial); + } + +} diff --git a/recursion/NRaiseP.java b/recursion/NRaiseP.java new file mode 100644 index 0000000..1aff02b --- /dev/null +++ b/recursion/NRaiseP.java @@ -0,0 +1,15 @@ +package recursion; + +public class NRaiseP { + + public static int nRaisep(int n, int p) { + if(p == 0) + return 1; + return n*nRaisep(n,p-1); + } + + public static void main(String[] args) { + System.out.println(nRaisep(3,4)); + } + +} diff --git a/recursion/NaturalNoSum.java b/recursion/NaturalNoSum.java new file mode 100644 index 0000000..6c52af4 --- /dev/null +++ b/recursion/NaturalNoSum.java @@ -0,0 +1,20 @@ +package recursion; + +/* + * Find sum of first N natural numbers using recursion + */ +public class NaturalNoSum { + + public static void main(String[] args) { + System.out.println(sum(5)); + } + + static int sum(int N) { + //Base case + if(N == 1) return 1; + + //Recursive call + return N+sum(N-1) ; + } + +} diff --git a/recursion/Subsequences.java b/recursion/Subsequences.java new file mode 100644 index 0000000..87719e9 --- /dev/null +++ b/recursion/Subsequences.java @@ -0,0 +1,50 @@ +package recursion; + +//Program to Find the Subsequences of Given String by using RECURSION +public class Subsequences { + + public static String[] findSubsequences(String str) { + + if(str.length() == 0) { + String ans[] = {""}; + return ans; + } + + String smallAns[] = findSubsequences(str.substring(1)); + String ans[] = new String[2 * smallAns.length]; + + /* + * Otherwise: + * int k = 0; + */ + for(int i = 0 ; i < smallAns.length ; i++) { + ans[i] = smallAns[i]; + /* + * Otherwise: + * ans[k] = smallAns[i]; + * k++; + */ + } + + for(int i = 0 ; i< smallAns.length ; i++) { + /* + * otherwise: ans[k] in place of ans[i + smallAns] and + * k++; + */ + ans[i + smallAns.length] = str.charAt(0) + smallAns[i]; + } + + return ans; + } + + public static void main(String[] args) { + + String str = "xyz"; + String ans[] = findSubsequences(str); + for(int i = 0 ; i < ans.length; i++) { + System.out.println(ans[i]); + } + + } + +} diff --git a/recursion/Tower_Of_Hanoi.java b/recursion/Tower_Of_Hanoi.java new file mode 100644 index 0000000..567e397 --- /dev/null +++ b/recursion/Tower_Of_Hanoi.java @@ -0,0 +1,29 @@ +package recursion; + +/* + * Stack Application :- Tower of Hanoi Problem(Puzzle 1) + */ +public class Tower_Of_Hanoi { + + //function to solve the tower of hanoi proble + static void towerOfHanoi(int n, char from_rod, char to_rod, char aux_rod) { + + if(n == 1) { + System.out.println("Move disk 1 from rod " + from_rod + " to_rod " + to_rod); + return; + } + + towerOfHanoi(n-1, from_rod, to_rod, aux_rod); + System.out.println("Move disk "+ n +" from_rod "+from_rod+" to rod "+to_rod); + + } + + //Driver Method + public static void main(String[] args) { + + int n =4; + towerOfHanoi(n,'A','C','B'); + + } + +} diff --git a/searchingAlgorithms/BinarySearch.java b/searchingAlgorithms/BinarySearch.java index d331720..3eda77a 100644 --- a/searchingAlgorithms/BinarySearch.java +++ b/searchingAlgorithms/BinarySearch.java @@ -1,5 +1,6 @@ package searchingAlgorithms; +//Binary Search Algorithm public class BinarySearch { // Returns index of x if it is present in arr[l.. diff --git a/sortingAlgorithms/BubbleSort.java b/sortingAlgorithms/BubbleSort.java index cc52dc0..f22a31c 100644 --- a/sortingAlgorithms/BubbleSort.java +++ b/sortingAlgorithms/BubbleSort.java @@ -1,6 +1,6 @@ package sortingAlgorithms; -//Program to demonstrate the bubble sort algorithm +//Program to demonstrate the bubble sort algorithm... public class BubbleSort { void bubbleSort(int a[]) { diff --git a/stack/.cph/.Postfix.java_cfba17b398252ca38e082cac809277ad.prob b/stack/.cph/.Postfix.java_cfba17b398252ca38e082cac809277ad.prob new file mode 100644 index 0000000..4be9537 --- /dev/null +++ b/stack/.cph/.Postfix.java_cfba17b398252ca38e082cac809277ad.prob @@ -0,0 +1 @@ +{"name":"Local: Postfix","url":"c:\\Users\\AmanSoni\\Desktop\\Java Program's\\Java-Eclipse\\Placement Prepration\\src\\stack\\Postfix.java","tests":[{"id":1606658519851,"input":"a+b*(c^d-e)^(f+g*h)-i","output":""}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"c:\\Users\\AmanSoni\\Desktop\\Java Program's\\Java-Eclipse\\Placement Prepration\\src\\stack\\Postfix.java","group":"local","local":true} \ No newline at end of file diff --git a/stack/Infix_To_Postfix.java b/stack/Infix_To_Postfix.java new file mode 100644 index 0000000..d8548c5 --- /dev/null +++ b/stack/Infix_To_Postfix.java @@ -0,0 +1,76 @@ +package stack; +import java.util.*; + +public class Infix_To_Postfix { + + static int Prec(char ch){ + switch(ch){ + case '+': + case '-': + return 1; + + case '*': + case '/': + return 2; + + case '^': + return 3; + } + + return -1; + } + + static String infixToPostfix(String exp){ + + String result = new String(" "); + Stack stack = new Stack<>(); + + for(int i = 0 ; i < exp.length() ; ++i){ + char c = exp.charAt(i); + + if(Character.isLetterOrDigit(c)) + result += c; + + else if(c == '(') + stack.push(c); + + else if (c == ')'){ + while (!stack.isEmpty() && stack.peek() != '(') + result += stack.pop(); + + stack.pop(); + } + + else{ + while(!stack.isEmpty() && Prec(c) <= Prec(stack.peek())){ + result += stack.pop(); + } + } + + stack.push(c); + } + + while (!stack.isEmpty()) { + + if(stack.peek() == '(') + return "Invalid Expression"; + + result += stack.pop(); + } + + return result; + } + + public static void main(String[] args) { + + Scanner sc = new Scanner(System.in); + String exp = sc.nextLine(); + + @SuppressWarnings("unused") + Infix_To_Postfix post = new Infix_To_Postfix(); + + System.out.println(infixToPostfix(exp)); + sc.close(); + } + +} diff --git a/stack/Postfix.java b/stack/Postfix.java new file mode 100644 index 0000000..2b38b93 --- /dev/null +++ b/stack/Postfix.java @@ -0,0 +1,75 @@ +package stack; +import java.util.*; +//Program to convert infix to postfix +public class Postfix{ + + static int Prec(char ch){ + switch(ch){ + case '+': + case '-': + return 1; + + case '*': + case '/': + return 2; + + case '^': + return 3; + } + + return -1; + } + + static String infixToPostfix(String exp){ + + String result = new String(" "); + Stack stack = new Stack<>(); + + for(int i = 0 ; i < exp.length() ; ++i){ + char c = exp.charAt(i); + + if(Character.isLetterOrDigit(c)) + result += c; + + else if(c == '(') + stack.push(c); + + else if (c == ')'){ + while (!stack.isEmpty() && stack.peek() != '(') + result += stack.pop(); + + stack.pop(); + } + + else{ + while(!stack.isEmpty() && Prec(c) <= Prec(stack.peek())){ + result += stack.pop(); + } + } + + stack.push(c); + } + + while (!stack.isEmpty()) { + + if(stack.peek() == '(') + return "Invalid Expression"; + + result += stack.pop(); + } + + return result; + } + + public static void main(String[] args) { + + Scanner sc = new Scanner(System.in); + String exp = sc.nextLine(); + sc.close(); + + Postfix p = new Postfix(); + + p = infixToPostfix(exp); + System.out.println(p); + } +} \ No newline at end of file diff --git a/stack/stack/Postfix.class b/stack/stack/Postfix.class new file mode 100644 index 0000000000000000000000000000000000000000..826a0d3a74d50f8338451e0b936b5342a268cce3 GIT binary patch literal 2162 zcmaJ?OHUhD6#lL~_84ct=3zo;2m}b&yxb-fNFcPqf#AkG8Yl$PCK=2H4~%DA&zM3h zb=4oyWRs{}P^m0Z76yUTcHKp#E-O`v`ZFq3Nzb({Y{06l`#SeLzVn?k*T20v`We6= zzVf0Oy)ybd2z%kcyE5MM!i8ROxGts}Uii>oL)t@PcT?Qn64S7lMr7O;;!$zITtPdoG1NqjEmhZ6TgJCjX>M7X zNr_gMK#Hq|!P7F<6s#j5Fl!1nuu1${0&cjFt^yrN1)T`WFcg@WQII;5`^?G)kJ}7^ za>NslZk-$Jb|P12Dxf<~*zb_O6pV%<#FS>mxJ{|dr0;6$TJ9neTK3{|q!}EHF=C~an)Yb>;&xyq+weOon>N1%2rz@LNa`2jiG@Wsifj3R1OoQRK_Bpr&=hV-l-NU zh!|we8c(L|om_6q!k%;Dur62{;6%GZWWFF^OkIJGs96Mm9a^mt4T_*p%CiKg=lw=!MAPk@twtg63l64M43-q&(gP5be-=` za$F)NhEhUFCrGZiZdzQ1B^vb$hW27NYsQwj$qOHAzRnZW-DY}6265|-ndWAOh*F}W zYa_a9S)7XhZ7FXBANh}IQZ-g}ZnftPhfByTBvT?eWjMc+;$_rJUx+g0D7c8Ix<04b zd|1Yp4A;)(R}LG)mH*enReCy`>8S-IF!Auv+)Ae=S{bdbt^=^2Xv5G(vpXl0;1MqY z?S*QJR-ro5_#@50O&Ts5T{PaO(M{t9jo!ip&-oClC%$8aqjz&+(0ZR*NG{thp? znzHZ=NCD{(70=-74oFAj9sZyKFM3Q6^#TQcTL@^ zQ-S{Kesx080{zK>>gGiw!MIGnCZevHh;E_3;Z}^&={}X`0g;v rheight) + return(lheight + 1); + + //else return r-height + 1; + else return(rheight + 1); + } + } + + //function to print the given level of tree + void printGivenLevel(Node root, int level) { + + //if their is no value at root node or node is empty then simply return; + if(root == null) + return; + + //if level is equal to 1 then print the data of root node + if(level == 1) + System.out.print(root.data + " "); + + //else if level is greater then 1, then call the function "RECUSIVELY" for left node & -1th level + else if(level > 1) { + //recursive call for left node at level-1 level + printGivenLevel(root.left, level-1); + + //recursive call for right node at level-1 level + printGivenLevel(root.right, level-1); + } + } + + //main or driver method + public static void main(String[] args) { + + //Making an object of BinaryTree_LOT class + BinaryTree_LOT tree = new BinaryTree_LOT(); + + //setting values of the different nodes of tree with use of tree object of tree classs + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + + System.out.println("Level order traversal of binary tree is "); + + //calling printLevelOrder() function + tree.printLevelOrder(); + + } + +} diff --git a/trees/BinaryTree_Traversal.java b/trees/BinaryTree_Traversal.java new file mode 100644 index 0000000..8d491ba --- /dev/null +++ b/trees/BinaryTree_Traversal.java @@ -0,0 +1,95 @@ +package trees; + +//java program for different tree traversals +/* + * Class containing left and right child of current node and key value + */ +//class Node{ +// int key; +// Node left, right; +// +// public Node(int item) { +// key = item; +// left = right = null; +// } +//} + +public class BinaryTree_Traversal { + + //root of binary Tree + Node root; + + BinaryTree_Traversal(){ + root = null; + } + + void printPostorder(Node node) { + + if(node == null) + return; + + printPostorder(node.left); + + printPostorder(node.right); + + System.out.print(node.key + " "); + } + + void printInorder(Node node) { + + if(node == null) + return; + + printInorder(node.left); + + System.out.println(node.key + " "); + + printInorder(node.right); + } + + void printPreorder(Node node) { + + if(node == null) + return; + + System.out.println(node.key + " "); + + printPreorder(node.left); + + printPreorder(node.right); + } + + void printPostorder() { + printPostorder(root); + } + + void printInorder() { + printInorder(root); + } + + void printPreorder() { + printPreorder(root); + } + + public static void main(String[] args) { + + BinaryTree_Traversal tree = new BinaryTree_Traversal(); + + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + + System.out.println("Preorder traversal of binary tree is "); + tree.printPreorder(); + + System.out.println("\n Inorder traversal of bianry tree is "); + tree.printInorder(); + + System.out.println("\n Postorder traversal of bianry tree is "); + tree.printPostorder(); + + } + +} diff --git a/trees/Binary_Tree_01.java b/trees/Binary_Tree_01.java new file mode 100644 index 0000000..aa50fbd --- /dev/null +++ b/trees/Binary_Tree_01.java @@ -0,0 +1,97 @@ +package trees; + +/* + * Level Order Traversal + */ + +/* + * Algorithm: + * There are basically two functions in this method. + * One is to print all node at a given level(printGIvenLevel), + * and other is to print level order traversal of the tree(printLevelorder). + * printLevelorder makes use of printGivenLevel to print nodes at all levels one by one starting from root. + */ + + +//Recursive Java program for level +//order traversal of Binary Tree + +/* Class containing left and right child of current +node and key value*/ +class Node +{ + int data; + Node left, right; + public Node(int item) + { + data = item; + left = right = null; + } +} + +class Binary_Tree_01{ + // Root of the Binary Tree + Node root; + + public Binary_Tree_01(){ + root = null; + } + + /* function to print level order traversal of tree*/ + void printLevelOrder() + { + int h = height(root); + int i; + for (i=1; i<=h; i++) + printGivenLevel(root, i); + } + + /* Compute the "height" of a tree -- the number of + nodes along the longest path from the root node + down to the farthest leaf node.*/ + int height(Node root) + { + if (root == null) + return 0; + else + { + /* compute height of each subtree */ + int lheight = height(root.left); + int rheight = height(root.right); + + /* use the larger one */ + if (lheight > rheight) + return(lheight+1); + else return(rheight+1); + } + } + + /* Print nodes at the given level */ + void printGivenLevel (Node root ,int level) + { + if (root == null) + return; + if (level == 1) + System.out.print(root.data + " "); + else if (level > 1) + { + printGivenLevel(root.left, level-1); + printGivenLevel(root.right, level-1); + } + } + + /* Driver program to test above functions */ + public static void main(String args[]) + { + Binary_Tree_01 tree = new Binary_Tree_01(); + tree.root= new Node(1); + tree.root.left= new Node(2); + tree.root.right= new Node(3); + tree.root.left.left= new Node(4); + tree.root.left.right= new Node(5); + + System.out.println("Level order traversal of binary tree is "); + tree.printLevelOrder(); + } +} + diff --git a/trees/Count_leaf_nodes.java b/trees/Count_leaf_nodes.java index dca7876..d618bf7 100644 --- a/trees/Count_leaf_nodes.java +++ b/trees/Count_leaf_nodes.java @@ -16,16 +16,16 @@ public class Count_leaf_nodes { - class TreeNode { + class BinaryTreeNode { T data; - ArrayList> children; + ArrayList> children; - TreeNode(T data){ + BinaryTreeNode(T data){ this.data = data; - children = new ArrayList>(); + children = new ArrayList>(); } - public int countLeafNodes(TreeNode root){ + public int countLeafNodes(BinaryTreeNode root){ int leaf = 0; @@ -35,7 +35,7 @@ public int countLeafNodes(TreeNode root){ if (root.children.size() == 0) return 1; - for (TreeNode child : root.children) + for (BinaryTreeNode child : root.children) leaf += countLeafNodes(child); return leaf ; diff --git a/trees/Problem_01.java b/trees/Problem_01.java index c7bf03c..c668090 100644 --- a/trees/Problem_01.java +++ b/trees/Problem_01.java @@ -1,3 +1,6 @@ +package trees; +import java.util.*; + /* * Check if generic tree contain element x * @@ -29,8 +32,6 @@ * false */ -package trees; -import java.util.*; public class Problem_01 { // TreeNode class @@ -71,8 +72,10 @@ public static boolean checkIfContainsX(TreeNode root, int x){ queue.add(null); } + else{ - if(frontNode.data==x) + + if(frontNode.data==x) return true; System.out.print(frontNode.data+" "); From 6b75cdfbc5858f21d25476e5fdc65a1599096b56 Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Wed, 9 Dec 2020 11:43:13 +0530 Subject: [PATCH 12/56] #Modification 11 --- oopsabstraction/Audi.java | 1 + 1 file changed, 1 insertion(+) diff --git a/oopsabstraction/Audi.java b/oopsabstraction/Audi.java index 26d5ed8..2475df8 100644 --- a/oopsabstraction/Audi.java +++ b/oopsabstraction/Audi.java @@ -1,4 +1,5 @@ package oopsabstraction; +//Audi Class public class Audi extends Car{ From 10ab7fa7362469ace04f33012c5b4ca6d06b2e9a Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Sat, 19 Dec 2020 10:45:50 +0530 Subject: [PATCH 13/56] #Modification 12 --- array/KadanesAlgorithm.class | Bin 0 -> 812 bytes searchingAlgorithms/BinarySearch.class | Bin 0 -> 1311 bytes stack/Postfix.java | 42 +++++++++--------- stack/stack/Postfix.class | Bin 2162 -> 2162 bytes ...java_99fbe9a6d479d3fea744cafd49bd01c0.prob | 1 + trees/BinaryTree_Traversal.java | 35 ++++++++------- trees/trees/BinaryTree_Traversal$Node.class | Bin 0 -> 554 bytes trees/trees/BinaryTree_Traversal.class | Bin 0 -> 2145 bytes 8 files changed, 41 insertions(+), 37 deletions(-) create mode 100644 array/KadanesAlgorithm.class create mode 100644 searchingAlgorithms/BinarySearch.class create mode 100644 trees/.cph/.BinaryTree_Traversal.java_99fbe9a6d479d3fea744cafd49bd01c0.prob create mode 100644 trees/trees/BinaryTree_Traversal$Node.class create mode 100644 trees/trees/BinaryTree_Traversal.class diff --git a/array/KadanesAlgorithm.class b/array/KadanesAlgorithm.class new file mode 100644 index 0000000000000000000000000000000000000000..3591a6f02c4dddb6c86518d227e298cc8a31e79e GIT binary patch literal 812 zcmZuvT~8B16g{(F1M4C!bqZpORz$bdwtgfv5j9Z~!-fJTB_zs=)3Pax-EFgM4ZQO+ zeDcL-c>trvAK-t`zu-F$;GOzVHSELO*>lg_bMBq_e){U!Fm)#LGpw_cZ(Yg#$tENXBe*sk-ypxn|{15n;k-oPzDi0 z*4?b{$hWfEkx{$aNa7%BFQ|iKjYPKItjOMg&oRq!gTZce`*F*E9;gyxS#HV5-+kI? zcjF-04lAmXg9~sN(u1n~B!65vj*^4hC_AX2%5lfRUECv2 zGLGeb_5bP&siD)g=8oS=7&7PBXV5mif7p%v-NX+GS1pS_4F}z-7xnrH_3X=Vfnmx$ zH=%~XBY!XPBGRL&Qt69BBP%l5CODLP45sUODy?_>L>=n9ps5aZGK0e;{})UWJw@t} zKg0Ek8z^9u?p=Kvm>MaqWAvA&$S9ig$6z06LvCob1|X+H<4Dn7QGY@Qr`Y-e?d2i# zV;J?)5zNQAulA~5GlY?Qk91iW3S2ud*oU)U1nV_ZuUW#P>Nk3(=_9AQKm(FR7Ikvzz+a-1R?m&j0_c5@U7yf#1g&W tWlUq8uvf%vVg_ldP=I+xX_I4uLt`8n>iPtkQ;aaivL__QsJN09zX9w$r4s-E literal 0 HcmV?d00001 diff --git a/searchingAlgorithms/BinarySearch.class b/searchingAlgorithms/BinarySearch.class new file mode 100644 index 0000000000000000000000000000000000000000..2de59790b046aea0f178c4490308021e0fc7b42b GIT binary patch literal 1311 zcmaJ>-EI?C5dMz6yT{(R$vR;ZpmyqzpW1N}7idFU^CMyrH6p>4jA%_H#Ib#vY_i_9 zc8}BMwtWdMsZ^;qxoIyz3Wx`2Ujy+Fr~+nfR~RK?r9CrecIG?t&6(MM-WM^Y}D@jEO9!$I0sg$1H3vZNZ0CxXM86hU*BA(7wSpr^3G@JUUH=KhxG3_P{Aa6E>|{PyOaI1nXQcsr$< z3LI~zT)4+E$1%@f*8FbJl!PXr;E>~M>XJ?0-|u#)4K_Sa1{GI?p`;TY4d*<-=-2i; z;k8^D&h-P!C({_Rd=Pl|up>`#AHInG?UaYP4InDQb!(22WsYwc=1=fDEjNbgkNaVU z<|j!L1CrFa7@;*qyDUjYQeS)u_7^EM473_OqedFFFX@r%Z_vpO+{k8rM>&(tv~>63 zs$R796X>u5hH0`y9`XNhp4qP{jU>_-A0+heAfcb1Azpt9ZPPNJoAtO}t!qZLuJdZ$ zu*_bz6@;#^~SB z$Bif8f5IZw){mpKX&+UqPh_E2+Bve%qk;vj( stack = new Stack<>(); - for(int i = 0 ; i < exp.length() ; ++i){ + for (int i = 0; i < exp.length(); ++i) { + char c = exp.charAt(i); - if(Character.isLetterOrDigit(c)) + if (Character.isLetterOrDigit(c)) result += c; - else if(c == '(') + else if (c == '(') stack.push(c); - else if (c == ')'){ - while (!stack.isEmpty() && stack.peek() != '(') - result += stack.pop(); + else if (c == ')') { + while (!stack.isEmpty() && stack.peek() != '(') + result += stack.pop(); stack.pop(); } - else{ - while(!stack.isEmpty() && Prec(c) <= Prec(stack.peek())){ + else { + while (!stack.isEmpty() && Prec(c) <= Prec(stack.peek())) { result += stack.pop(); - } + } } stack.push(c); @@ -52,10 +55,10 @@ else if (c == ')'){ while (!stack.isEmpty()) { - if(stack.peek() == '(') + if (stack.peek() == '(') return "Invalid Expression"; - result += stack.pop(); + result += stack.pop(); } return result; @@ -63,13 +66,12 @@ else if (c == ')'){ public static void main(String[] args) { + //Taking String "exe" input Scanner sc = new Scanner(System.in); String exp = sc.nextLine(); sc.close(); Postfix p = new Postfix(); - - p = infixToPostfix(exp); - System.out.println(p); + System.out.println(infixToPostfix(exp)); } } \ No newline at end of file diff --git a/stack/stack/Postfix.class b/stack/stack/Postfix.class index 826a0d3a74d50f8338451e0b936b5342a268cce3..9b2d1c0b7e9f6d54e1885e7829b17130e328d262 100644 GIT binary patch delta 288 zcmWlU%Sr-a7>1ueoH3^fCOgq+(t&bHqXTvzNm_*2C|T~>6e3BHHNi-<>IzyIv#T3u zs{(rPO^t<(P5eyQhIs7j^gxTjt=kn!&WDIrYnU0D&T z_oI{tLZr}H!(f9!HW~4&YFHdb(1;QyCON@0QzRtUnIXe0c`QoIamGA1B)MaWN0xbJ zm6p8eNZFf|eUj#jExy_IK7!eFqRrSV=Ftn0{T9(=hw(PCCLp98`JgJ9rH@@XD8~@C M?9a=_f@k+ye~6PdTmS$7 delta 290 zcmWlS%Su9V5Qo2icszDGg-TJ!v@4}y7KmNww&?1OGIwnXk)+5nI1;UTf)>Wv)eE#$ z!GspkvQ5wv^bQiOn;018H_Uur$J_DNj+OOrG8oWF8d$`-*(UWrr42G<4F>A9Clyxo z+SNkwVm?=~tEKZ>lQNekVIn$LCKV1$t{HFUyMC3EbFFz4TCrTQPn-9ygi@CCuEmwh z`OykKodgDp^s$VO75bYcw_hDvvJBuSC>3IoQKF2o!~`3XGE9+Ynln+}FvA@&9+~5r zI1Tw|v%s5Ne+u+Vpx>-JANua473lIei2dIg7^Weup5+e!0gM@<@v)~HFT9VyD!q4*1n0W99 z_@j)kJu4n|W?yz^-n`wf?~hLaXE@40N6CbNafkOjT2JJ51on zs6T%a3|80oh3t4-DWMqZy+8_~+SjhnZ>oCEdxC9Q0u7s>Ufp zWsQjL>ld!?23HKV=DLgB){s(l;#B#b>x=&4btL3~k37n0-p?0uEN9`$xSgxOK+QrPwuMd9Eu@jLkVDpji7Z3)pE()q$gk~jf6~4i&BT}{F8?i}7jCwO zsL`7n^d(7J)R7QTznG~xVB1k9s_8Q*Sb=bhs!LL6#3koA1asbza4I1*$6*g4k|9!W lv1FUD5S!=7JWuo3D3Xna9Xd&17ke=mVG)~TuG9Gj@B=h%cZvW2 literal 0 HcmV?d00001 diff --git a/trees/trees/BinaryTree_Traversal.class b/trees/trees/BinaryTree_Traversal.class new file mode 100644 index 0000000000000000000000000000000000000000..440edb1d157fc0231cea1eac491988f5cc955c97 GIT binary patch literal 2145 zcmah~ZBr9h6n<_9Bw03qC{n0mu)&7J5^W2$f^UG7v>~8DC~CD!xWbxcm+o$8^H2IW z>{#gNOsC&E(;wC8b2mFBfq;|Qd(S=hob#O5n}7a&_a}g_u%+Q65=O?jxR7;^j#^v{H$pkZhe*X%T?Fdm#$}6X{9(V&^2S) zrhiwUBQw56&AGr{Z_%`6skXZ*-Bn}LB0|reYuf&b8}PaTy~zKE@>-i)tCgRUHLfis4%w-=U~u2_=EPS*FeNU1M)a`a8~+ z*V~2VI97B#!s8gqI#%&SM_OsGDQXN?1%^*gvcQ$oFM|riu&(2KY$z9>3XH9UnMl!# zMxj#9tJG#tK=PzanO;f(j|g1TQehsCOB=RZZ<05P{8zj_~#A64>wNBLjgd@U>N zr>G@gaqD!=?H%q-66Lz*%Uw2+Q{%-zqjsi~Ur|lN@=0Ttz1C5cbpcV(@C?rdA|fR) zxNB79oMTrEf8F$VNO`_t`)uNYOkw*7gK`ZFVD6YV_u!VQ*Q|OE)B^PX^t@X;ECQ@5wge&GXhK z-q6IHVOeFDfJ@cjOG4D^i4MR799tOs=br@Z|EWwd#At-kWeNg zfyrTXk-kimBj_Y2NrMBN`ZUMx6W(+{baLY}a2Af%YQH;#)sEwg6DLcY>%^I0@Hc4q zW-|^SnYK7>>@z$)#L&=;4WEW8e=!DC&|lsoxp9b|;(PRN z4^ylb_^%Pi zGMjIOK0d-E9%CM5{+{rGTf<8}?AzEtl_w9+@iSh~{|xma7-!AFli)x6FsXj>dTCQN S@Cz8!9l{r+ Date: Tue, 22 Dec 2020 11:27:38 +0530 Subject: [PATCH 14/56] #Modification 13 --- backtracking/N_Queen.java | 86 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 backtracking/N_Queen.java diff --git a/backtracking/N_Queen.java b/backtracking/N_Queen.java new file mode 100644 index 0000000..696068e --- /dev/null +++ b/backtracking/N_Queen.java @@ -0,0 +1,86 @@ +package backtracking; + +public class N_Queen { + final int N = 4; + + void printSolution(int board[][]) { + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + System.out.print(" " + board[i][j] + " "); + System.out.println(); + } + } + } + + boolean isSafe(int board[][], int row, int col) { + int i, j; + + for (i = 0; i < col; i++) { + if (board[row][i] == 1) + return false; + } + + for (i = row, j = col; i >= 0 && j >= 0; i--, j--) { + if (board[i][j] == 1) { + return false; + } + } + + for (i = row, j = col; j >= 0 && i < N; i++, j--) { + if (board[i][j] == 1) + return false; + } + + return true; + } + + boolean solveNQUtil(int board[][], int col) { + if (col >= N) + return true; + + for (int i = 0; i < N; i++) { + if (isSafe(board, i, col)) { + board[i][col] = 1; + + if (solveNQUtil(board, col + 1) == true) + return true; + + /* + If placing queen in board[i][col] doesn't lead to a solution then rempve queen from board[i][col] + */ + board[i][col] = 0; //"BACKTRACK" + } + } + + /* + * If the queen can not be palced in any row in this col, then return false + */ + return false; + } + + /* + * This function solves the N-Queen problem using "BACKTRACKING". + * It mainly uses solveNQUtil() to solve the problem. + * It return false if queens cannot placed, otherwise, + * return true & prints placement of queens in the form of 1's. + * Please note that there may be more than one solutions, + * this functionprints one of the feasible solutions. + */ + boolean solveNQ() { + int board[][] = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } }; + + if (solveNQUtil(board, 0) == false) { + System.out.println("Solution does not exist"); + return false; + } + + printSolution(board); + return true; + } + + //Driver program to test above functions + public static void main(String[] args) { + N_Queen nq = new N_Queen(); + nq.solveNQ(); + } +} From ec7d68e384d8af1b329b73fbc0d5dd4ee2ae9e80 Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Sun, 27 Dec 2020 21:04:14 +0530 Subject: [PATCH 15/56] #Modification 14 --- arrays/Array_Problem_13.java | 32 ++++ arrays/Array_Problem_14.java | 38 +++++ arrays/KadanesAlgorithm.java | 2 +- backtracking/Sudoku_Solver.java | 72 ++++++++ stack/Postfix.java | 2 +- t/trees/BST_Deletion.java | 158 ++++++++++++++++++ t/trees/BT_Traversal.java | 82 +++++++++ t/trees/BinarySearchTree.java | 88 ++++++++++ t/trees/BinaryTreeNode.java | 13 ++ t/trees/BinaryTreeUse.java | 51 ++++++ t/trees/BinaryTree_LOT.java | 99 +++++++++++ ...struct_Tree_from_Preorder_and_Inorder.java | 69 ++++++++ t/trees/Count_Nodes.java | 63 +++++++ t/trees/Count_leaf_nodes.java | 44 +++++ t/trees/Insertion_In_BinaryTree.java | 80 +++++++++ t/trees/Problem_01.java | 88 ++++++++++ ...java_63c5e7cc4610c2b023e3b74d2ff6f26b.prob | 1 + trees/Binary_Tree_01.java | 90 +++++----- trees/FindFullNodesInABinaryTree.java | 84 +++++----- trees/trees/FindFullNodesInABinaryTree.class | Bin 0 -> 1159 bytes trees/trees/Node.class | Bin 0 -> 339 bytes 21 files changed, 1067 insertions(+), 89 deletions(-) create mode 100644 arrays/Array_Problem_13.java create mode 100644 arrays/Array_Problem_14.java create mode 100644 backtracking/Sudoku_Solver.java create mode 100644 t/trees/BST_Deletion.java create mode 100644 t/trees/BT_Traversal.java create mode 100644 t/trees/BinarySearchTree.java create mode 100644 t/trees/BinaryTreeNode.java create mode 100644 t/trees/BinaryTreeUse.java create mode 100644 t/trees/BinaryTree_LOT.java create mode 100644 t/trees/Construct_Tree_from_Preorder_and_Inorder.java create mode 100644 t/trees/Count_Nodes.java create mode 100644 t/trees/Count_leaf_nodes.java create mode 100644 t/trees/Insertion_In_BinaryTree.java create mode 100644 t/trees/Problem_01.java create mode 100644 trees/.cph/.FindFullNodesInABinaryTree.java_63c5e7cc4610c2b023e3b74d2ff6f26b.prob create mode 100644 trees/trees/FindFullNodesInABinaryTree.class create mode 100644 trees/trees/Node.class diff --git a/arrays/Array_Problem_13.java b/arrays/Array_Problem_13.java new file mode 100644 index 0000000..05d3dd9 --- /dev/null +++ b/arrays/Array_Problem_13.java @@ -0,0 +1,32 @@ +package arrays; +import java.util.*; + +/* + * Kadane's Algorithm to find the maxSubarray Sum in O(n)[Linear Time Complexity] + */ +public class Array_Problem_13 { + public static void main(String[] args) { + @SuppressWarnings("resource") + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int a[] = new int[n]; + + for(int i=0;i stack = new Stack<>(); + Arrays.sort(a.new Comparator() { + public int compare(Interval i1, Interval i2) { + return i1.start - i2.start; + } + }); + + stack.push(a[0]); + } + + public static void main(String[] args) { + Interval a[] = new Interval[4]; + + } +} + +/** + * Interval + */ +class Interval { + + int start, end; + + Interval(int start, int end) { + this.start = start; + this.end = end; + } +} diff --git a/arrays/KadanesAlgorithm.java b/arrays/KadanesAlgorithm.java index de15f21..089335a 100644 --- a/arrays/KadanesAlgorithm.java +++ b/arrays/KadanesAlgorithm.java @@ -10,7 +10,7 @@ public static void main(String[] args) { @SuppressWarnings("resource") Scanner sc = new Scanner(System.in); int n = sc.nextInt(); - int a[]=new int[n]; + int a[] = new int[n]; for(int i=0;i root.key) + root.right = deleteRec(root.right, key); + + // if key is same as root's key, then This is the node + // to be deleted + else + { + // node with only one child or no child + if (root.left == null) + return root.right; + else if (root.right == null) + return root.left; + + // node with two children: Get the inorder successor (smallest + // in the right subtree) + root.key = minValue(root.right); + + // Delete the inorder successor + root.right = deleteRec(root.right, root.key); + } + + return root; + } + + int minValue(Node root) + { + int minv = root.key; + while (root.left != null) + { + minv = root.left.key; + root = root.left; + } + return minv; + } + + // This method mainly calls insertRec() + void insert(int key) + { + root = insertRec(root, key); + } + + /* A recursive function to insert a new key in BST */ + Node insertRec(Node root, int key) + { + + /* If the tree is empty, return a new node */ + if (root == null) + { + root = new Node(key); + return root; + } + + /* Otherwise, recur down the tree */ + if (key < root.key) + root.left = insertRec(root.left, key); + else if (key > root.key) + root.right = insertRec(root.right, key); + + /* return the (unchanged) node pointer */ + return root; + } + + // This method mainly calls InorderRec() + void inorder() + { + inorderRec(root); + } + + // A utility function to do inorder traversal of BST + void inorderRec(Node root) + { + if (root != null) + { + inorderRec(root.left); + System.out.print(root.key + " "); + inorderRec(root.right); + } + } + + // Driver Program to test above functions + public static void main(String[] args) + { + BST_Deletion tree = new BST_Deletion(); + + /* Let us create following BST + 50 + / \ + 30 70 + / \ / \ + 20 40 60 80 */ + + tree.insert(50); + tree.insert(30); + tree.insert(20); + tree.insert(40); + tree.insert(70); + tree.insert(60); + tree.insert(80); + + System.out.println("Inorder traversal of the given tree"); + tree.inorder(); + + System.out.println("\nDelete 20"); + tree.deleteKey(20); + + System.out.println("Inorder traversal of the modified tree"); + tree.inorder(); + + System.out.println("\nDelete 30"); + tree.deleteKey(30); + + System.out.println("Inorder traversal of the modified tree"); + tree.inorder(); + + System.out.println("\nDelete 50"); + tree.deleteKey(50); + + System.out.println("Inorder traversal of the modified tree"); + tree.inorder(); + } +} \ No newline at end of file diff --git a/t/trees/BT_Traversal.java b/t/trees/BT_Traversal.java new file mode 100644 index 0000000..3ed9851 --- /dev/null +++ b/t/trees/BT_Traversal.java @@ -0,0 +1,82 @@ +package trees; + +public class BT_Traversal { + + static class Node{ + int key; + Node left,right; + public Node(int item) { + key = item; + left = right = null; + } + } + + static Node root; + BT_Traversal(){ + root = null; + } + + static void printPostorder(Node node) { + if(node == null) { + return; + } + printPostorder(node.left); + System.out.print(node.key + " "); + printPostorder(node.right); + } + + static void printInorder(Node node) { + if(node == null) { + return; + } + printInorder(node.left); + System.out.print(node.key + " "); + printInorder(node.right); + } + + static void printPreorder(Node node) { + if(node == null) { + return; + } + printPreorder(node.left); + System.out.print(node.key + " "); + printPreorder(node.right); + } + + static void printPostorder() { + printPostorder(root); + } + + static void printInorder() { + printInorder(root); + } + + static void printPreorder() { + printPreorder(root); + } + + + public static void main(String[] args) { + @SuppressWarnings("unused") + BT_Traversal tree = new BT_Traversal(); + + root = new Node(1); + root.left = new Node(11); + root.right = new Node(9); + root.left.left = new Node(7); + root.right.left = new Node(15); + root.right.right = new Node(8); + + System.out.println( "Inorder traversal of given tree is:"); + BT_Traversal.printInorder(); + System.out.println(); + + System.out.println( "Postorder traversal of given tree is:"); + BT_Traversal.printPostorder(); + System.out.println(); + + System.out.println( "Preorder traversal of given tree is:"); + BT_Traversal.printPreorder(); + } + +} diff --git a/t/trees/BinarySearchTree.java b/t/trees/BinarySearchTree.java new file mode 100644 index 0000000..5da44fb --- /dev/null +++ b/t/trees/BinarySearchTree.java @@ -0,0 +1,88 @@ +package trees; + +class BinarySearchTree { + + /* Class containing left and right child of current node and key value*/ + class Node { + int key; + Node left, right; + + public Node(int item) { + key = item; + left = right = null; + } + } + + // Root of BST + Node root; + + // Constructor + BinarySearchTree() { + root = null; + } + + // This method mainly calls insertRec() + void insert(int key) { + root = insertRec(root, key); + } + + /* A recursive function to insert a new key in BST */ + Node insertRec(Node root, int key) { + + /* If the tree is empty, return a new node */ + if (root == null) { + root = new Node(key); + return root; + } + + /* Otherwise, recur down the tree */ + if (key < root.key) + root.left = insertRec(root.left, key); + else if (key > root.key) + root.right = insertRec(root.right, key); + + /* return the (unchanged) node pointer */ + return root; + } + + // This method mainly calls InorderRec() + void inorder() { + inorderRec(root); + } + + // A utility function to do inorder traversal of BST + void inorderRec(Node root) { + if (root != null) { + inorderRec(root.left); + System.out.println(root.key); + inorderRec(root.right); + } + } + + // Driver Program to test above functions + public static void main(String[] args) { + BinarySearchTree tree = new BinarySearchTree(); + + /* + * Let us create following BST + * |50| + * / \ + * / \ + * 30 70 + * / \ / \ + * 20 40 60 80 + * + */ + + tree.insert(50); + tree.insert(30); + tree.insert(20); + tree.insert(40); + tree.insert(70); + tree.insert(60); + tree.insert(80); + + // print in-order traversal of the BST + tree.inorder(); + } +} diff --git a/t/trees/BinaryTreeNode.java b/t/trees/BinaryTreeNode.java new file mode 100644 index 0000000..fe8e3f1 --- /dev/null +++ b/t/trees/BinaryTreeNode.java @@ -0,0 +1,13 @@ +package trees; + +public class BinaryTreeNode { + + public T data; + public BinaryTreeNode left; + public BinaryTreeNode right; + + BinaryTreeNode(T data){ + this.data = data; + } + +} diff --git a/t/trees/BinaryTreeUse.java b/t/trees/BinaryTreeUse.java new file mode 100644 index 0000000..f28e6a3 --- /dev/null +++ b/t/trees/BinaryTreeUse.java @@ -0,0 +1,51 @@ +package trees; +import java.util.*; + +public class BinaryTreeUse { + + public static BinaryTreeNode takeInput(Scanner s){ + int rootdata; + System.out.println("Enter root data: "); + rootdata = s.nextInt(); + + if(rootdata == -1) return null; + + + BinaryTreeNode root = new BinaryTreeNode<>(rootdata); + root.left = takeInput(s); + root.right = takeInput(s); + return root; + + } + + public static void printTree(BinaryTreeNode root) { + if(root == null) return; + String s = root.data+" "; + + if(root.left!=null) + s+="L. "+root.left.data+" ,"; + + if(root.right!=null) + s+="R. "+root.right.data; + + System.out.println(s); + printTree(root.left); + printTree(root.right); + } + + public static void main(String[] args) { + +// BinaryTreeNode root= new BinaryTreeNode(1); +// BinaryTreeNode node1=new BinaryTreeNode(2); +// root.left=node1; +// BinaryTreeNode node2=new BinaryTreeNode(3); +// root.left=node2; + + Scanner s = new Scanner(System.in); + BinaryTreeNode root = takeInput(s); + printTree(root); + s.close(); + + } + +} diff --git a/t/trees/BinaryTree_LOT.java b/t/trees/BinaryTree_LOT.java new file mode 100644 index 0000000..43777cd --- /dev/null +++ b/t/trees/BinaryTree_LOT.java @@ -0,0 +1,99 @@ +package trees; + +//Node of tree +class Node{ + int data; + Node left,right; + + //making public constructor of Node class + public Node(int item) { + data = item; + left = right = null; + } +} + +//main class to find linear order traversal +public class BinaryTree_LOT { + + //root node + Node root; + + //making an constructor + public BinaryTree_LOT() { + root = null; + } + + //function to print level order + void printLevelOrder() { + + //variable to store height which will be received from height function + int h = height(root), i; + + //loop for calculating given level + for(i = 1 ; i<= h ; i++) + printGivenLevel(root, i); + } + + //function to find the height of tree + int height(Node root) { + + //if their is no value at root node or node is empty then simply return 0; + if(root == null) + return 0; + + else { + //declare l-height for height of left & r-height variables for height of right, by using recursive call + int lheight = height(root.left); + int rheight = height(root.right); + + //if(l-height is greater then r-height then return(l-height + 1); + if(lheight > rheight) + return(lheight + 1); + + //else return r-height + 1; + else return(rheight + 1); + } + } + + //function to print the given level of tree + void printGivenLevel(Node root, int level) { + + //if their is no value at root node or node is empty then simply return; + if(root == null) + return; + + //if level is equal to 1 then print the data of root node + if(level == 1) + System.out.print(root.data + " "); + + //else if level is greater then 1, then call the function "RECUSIVELY" for left node & -1th level + else if(level > 1) { + //recursive call for left node at level-1 level + printGivenLevel(root.left, level-1); + + //recursive call for right node at level-1 level + printGivenLevel(root.right, level-1); + } + } + + //main or driver method + public static void main(String[] args) { + + //Making an object of BinaryTree_LOT class + BinaryTree_LOT tree = new BinaryTree_LOT(); + + //setting values of the different nodes of tree with use of tree object of tree classs + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + + System.out.println("Level order traversal of binary tree is "); + + //calling printLevelOrder() function + tree.printLevelOrder(); + + } + +} diff --git a/t/trees/Construct_Tree_from_Preorder_and_Inorder.java b/t/trees/Construct_Tree_from_Preorder_and_Inorder.java new file mode 100644 index 0000000..0531425 --- /dev/null +++ b/t/trees/Construct_Tree_from_Preorder_and_Inorder.java @@ -0,0 +1,69 @@ +package trees; + + +/* + * Code: Construct Tree from Preorder and Inorder + * + * + *Given Pre-order and In-order traversal of a binary tree, + *create the binary tree associated with the traversals. + *You just need to construct the tree and return the root. + * + *Note: Assume binary tree contains only unique elements. + * + * Input format : + * + * Line 1 : n (Total number of nodes in binary tree) + * Line 2 : Pre order traversal + * Line 3 : Inorder Traversal + * + * Output Format : + * + * Elements are printed level wise, each level in new line (separated by space). + * + * Sample Input : + * 12 + * 1 2 3 4 15 5 6 7 8 10 9 12 + * 4 15 3 2 5 1 6 10 8 7 9 12 + * + * Sample Output : + * 1 + * 2 6 + * 3 5 7 + * 4 8 9 + * 15 10 12 + */ +public class Construct_Tree_from_Preorder_and_Inorder { + + public static BinaryTreeNode getTreeFromPreorderAndInorder(int[] pre , int[] in){ + return helper (0, 0, in.length - 1, pre, in); + } + + private static BinaryTreeNode helper(int preStart , int inStart , int inEnd , int[] preorder , int[] inorder){ + + //Base Case + if(preStart > preorder.length || inStart > inEnd) + return null; + + + //get the root node with current pre-order element + BinaryTreeNode root = new BinaryTreeNode(preorder[preStart]); + + //get inIndex; finding preorder's element's index in in-order + int inIndex = 0; + + for(int i = inStart ; i<= inEnd ; i++) { + if(inorder[i] == root.data) + inIndex = i; + } + + //(next, left of inIndex is the end for left subtree) + root.left = helper(preStart + 1, inStart, inIndex - 1, preorder, inorder); + + //(prestart + length of left subtree + 1) + root.right = helper(preStart + inIndex - inStart + 1, inIndex + 1, inEnd, preorder, inorder); + + return root; + } + +} diff --git a/t/trees/Count_Nodes.java b/t/trees/Count_Nodes.java new file mode 100644 index 0000000..b288091 --- /dev/null +++ b/t/trees/Count_Nodes.java @@ -0,0 +1,63 @@ +package trees; + +import java.util.*; + +//A Binary Tree Node +class Node { + + int data; + Node left, right; + + // Constructor of Node Class + Node(int data) { + this.data = data; + left = right = null; + } +} + +public class Count_Nodes { + + Node root; + + // Traverse given tree in In-order fashion & prints all nodes that have both + // children as non-empty + int getFullCount() { + if (root == null) + return 0; + + Queue queue = new LinkedList<>(); + + queue.add(root); + int count = 0; + + while (!queue.isEmpty()) { + Node temp = queue.poll(); + if (temp.left != null && temp.right != null) + count++; + + if (temp.left != null) + queue.add(temp.left); + + if (temp.right != null) + queue.add(temp.right); + + } + + return count; + } + + public static void main(String[] args) { + Count_Nodes tree_level = new Count_Nodes(); + tree_level.root = new Node(2); + tree_level.root.left = new Node(7); + tree_level.root.right = new Node(5); + tree_level.root.left.right = new Node(6); + tree_level.root.left.right.left = new Node(1); + tree_level.root.left.right.right = new Node(11); + tree_level.root.right.right = new Node(9); + tree_level.root.right.right.left = new Node(4); + + System.out.println(tree_level.getFullCount()); + } + +} diff --git a/t/trees/Count_leaf_nodes.java b/t/trees/Count_leaf_nodes.java new file mode 100644 index 0000000..d618bf7 --- /dev/null +++ b/t/trees/Count_leaf_nodes.java @@ -0,0 +1,44 @@ +package trees; +import java.util.*; + + /*Code : Count leaf nodes + * Send Feedback + * Given a generic tree, count and return the number of leaf nodes present in the given tree. + * Input format : + * Elements in level order form separated by space (as per done in class). Order is - + * Root_data, n (No_Of_Child_Of_Root), n children, and so on for every element + * Output Format : + * Count of leaf nodes + * Sample Input 1 : + * 10 3 20 30 40 2 40 50 0 0 0 0 + * Sample Output 1 : + * 4 */ + +public class Count_leaf_nodes { + + class BinaryTreeNode { + T data; + ArrayList> children; + + BinaryTreeNode(T data){ + this.data = data; + children = new ArrayList>(); + } + + public int countLeafNodes(BinaryTreeNode root){ + + int leaf = 0; + + if (root == null ) + return 0; + + if (root.children.size() == 0) + return 1; + + for (BinaryTreeNode child : root.children) + leaf += countLeafNodes(child); + + return leaf ; + } + } +} diff --git a/t/trees/Insertion_In_BinaryTree.java b/t/trees/Insertion_In_BinaryTree.java new file mode 100644 index 0000000..efdb19a --- /dev/null +++ b/t/trees/Insertion_In_BinaryTree.java @@ -0,0 +1,80 @@ +package trees; +import java.util.*; + +//Java program to insert element in binary tree +public class Insertion_In_BinaryTree { + + /* A binary tree node has key, pointer to + left child and a pointer to right child */ + static class Node { + int key; + Node left, right; + + // constructor + Node(int key){ + this.key = key; + left = right = null; + } + } + static Node root; + static Node temp = root; + + //In-order traversal of a binary tree + static void inorder(Node temp) + { + if (temp == null) + return; + + inorder(temp.left); + + System.out.print(temp.key+" "); + inorder(temp.right); + } + + //function to insert element in binary tree + static void insert(Node temp, int key) + { + Queue q = new LinkedList(); + q.add(temp); + + // Do level order traversal until we find + // an empty place. + while (!q.isEmpty()) { + temp = q.peek(); + q.remove(); + + if (temp.left == null) { + temp.left = new Node(key); + break; + } else + q.add(temp.left); + + if (temp.right == null) { + temp.right = new Node(key); + break; + } + else + q.add(temp.right); + } + } + + // Driver code + public static void main(String args[]) + { + root = new Node(10); + root.left = new Node(11); + root.right = new Node(9); + root.left.left = new Node(7); + root.right.left = new Node(15); + root.right.right = new Node(8); + + System.out.print( "Inorder traversal before insertion:"); + inorder(root); + + int key = 12; + insert(root, key); + + System.out.print("\nInorder traversal after insertion:"); + inorder(root); + } +} diff --git a/t/trees/Problem_01.java b/t/trees/Problem_01.java new file mode 100644 index 0000000..c668090 --- /dev/null +++ b/t/trees/Problem_01.java @@ -0,0 +1,88 @@ +package trees; +import java.util.*; + +/* + * Check if generic tree contain element x + * + * Send Feedback + * Given a generic tree and an integer x, check if x is present in the given tree or not. + * Return : true :- if x is present, + * Return : false :- otherwise. + * + * Input format : + * Line 1 : Integer x + * Line 2 : Elements in level order form separated by space (as per done in class). + * + * Order is - + * Root_data , n (No_Of_Child_Of_Root) , n children , and so on for every element. + * + * Output format : true or false + * Sample Input 1 : + * 40 + * 10 3 20 30 40 2 40 50 0 0 0 0 + * + * Sample Output 1 : + * true + * + * Sample Input 2 : + * 4 + * 10 3 20 30 40 2 40 50 0 0 0 0 + * + * Sample Output 2: + * false + */ + + +public class Problem_01 { + // TreeNode class + class TreeNode { + T data; + ArrayList> children; + + TreeNode(T data){ + this.data = data; + children = new ArrayList>(); + } + } + + public static boolean checkIfContainsX(TreeNode root, int x){ + + // Write your code here + if(root==null) + return false; + + // Write your code here + Queue> queue = new LinkedList<>(); + + //added 1st level here + queue.add(root); + queue.add(null); + @SuppressWarnings("unused") + int ans=0; + + // if(x frontNode = queue.remove(); + if(frontNode == null) + { + if(queue.isEmpty()) + break; + + queue.add(null); + } + + else{ + + if(frontNode.data==x) + return true; + System.out.print(frontNode.data+" "); + + for(int i=0;i rheight) - return(lheight+1); - else return(rheight+1); + return (lheight + 1); + else + return (rheight + 1); } } /* Print nodes at the given level */ - void printGivenLevel (Node root ,int level) - { + void printGivenLevel(Node root, int level) { if (root == null) return; if (level == 1) System.out.print(root.data + " "); - else if (level > 1) - { - printGivenLevel(root.left, level-1); - printGivenLevel(root.right, level-1); + else if (level > 1) { + printGivenLevel(root.left, level - 1); + printGivenLevel(root.right, level - 1); } } - + /* Driver program to test above functions */ - public static void main(String args[]) - { - Binary_Tree_01 tree = new Binary_Tree_01(); - tree.root= new Node(1); - tree.root.left= new Node(2); - tree.root.right= new Node(3); - tree.root.left.left= new Node(4); - tree.root.left.right= new Node(5); - - System.out.println("Level order traversal of binary tree is "); - tree.printLevelOrder(); + public static void main(String args[]) { + Binary_Tree_01 tree = new Binary_Tree_01(); + tree.new Node(1); + tree.new Node(2); + tree.new Node(3); + tree.new Node(4); + tree.new Node(5); + + System.out.println("Level order traversal of binary tree is "); + tree.printLevelOrder(); } } - diff --git a/trees/FindFullNodesInABinaryTree.java b/trees/FindFullNodesInABinaryTree.java index cde6448..e25fb09 100644 --- a/trees/FindFullNodesInABinaryTree.java +++ b/trees/FindFullNodesInABinaryTree.java @@ -1,55 +1,63 @@ package trees; +import java.util.*; + //A Binary Tree Node -class Node{ - +class Node { + int data; - Node left , right; - - //Constructor of Node Class + Node left, right; + + // Constructor of Node Class Node(int data) { this.data = data; - left = right = null ; + left = right = null; } } public class FindFullNodesInABinaryTree { - - //Traverse given tree in In-order fashion & prints all nodes that have both children as non-empty - public static void findFullNode(Node root) { - if (root != null) { - findFullNode(root.left); - - if(root.left != null && root.right != null) - System.out.println(root.data +" "); - - findFullNode(root.right); + + Node root; + + // Traverse given tree in In-order fashion & prints all nodes that have both + // children as non-empty + int getFullCount() { + if (root == null) + return 0; + + Queue queue = new LinkedList<>(); + + queue.add(root); + int count = 0; + + while (!queue.isEmpty()) { + Node temp = queue.poll(); + if (temp.left != null && temp.right != null) + count++; + + if (temp.left != null) + queue.add(temp.left); + + if (temp.right != null) + queue.add(temp.right); + } + + return count; } - - //Driver method + public static void main(String[] args) { - - //Calling Node class by making an object of it (means by making a root node) - Node root = new Node(1); - - root.left = new Node(2); - root.right = new Node(3); - root.left.left = new Node(4); - root.left.right = new Node(5); - root.right.left = new Node(6); - root.right.right = new Node(7); - root.left.left.left= new Node(8); - root.right.left.left = new Node(9); - root.left.left.right = new Node(10); - root.left.right.left = new Node(11); - root.right.left.right = new Node(12); - root.left.right.right = new Node(13); - root.right.right.right = new Node(14); - - //calling the find full nodes by passing values of or as root or root valuess in it - findFullNode(root); + FindFullNodesInABinaryTree tree_level = new FindFullNodesInABinaryTree(); + tree_level.root = new Node(2); + tree_level.root.left = new Node(7); + tree_level.root.right = new Node(5); + tree_level.root.left.right = new Node(6); + tree_level.root.left.right.left = new Node(1); + tree_level.root.left.right.right = new Node(11); + tree_level.root.right.right = new Node(9); + tree_level.root.right.right.left = new Node(4); + System.out.println(tree_level.getFullCount()); } } diff --git a/trees/trees/FindFullNodesInABinaryTree.class b/trees/trees/FindFullNodesInABinaryTree.class new file mode 100644 index 0000000000000000000000000000000000000000..a7b1356bf97ae4bb1cc2b2d4019ca5460cf5c5ae GIT binary patch literal 1159 zcmZ`(+fEZv6kTU}nRXbU<)&QZF0>S=$W6Ja5J*TWY9JcqX`n+Lm`<^sn()p~=&L5a z@S;HwNsLdJ_yK-_UtzqhGsP5QeCR%Vud~kHd+jr)Uw(b~2w)tyHAK-KMg=-lbZYRS zy#meXlBQdlt15cJ2%%S+n2NYYZo9^yFN_5GWjLT=5J?r+1pN72&K1y8Zr(Ht$)#M{ zoD>L7S&rq-2>4?0ha}Ar7N|~Hj=5CKuABK4W8EgAXH0jYXxnqSqQfj?FA7vHyT-=$ zU1P^1sTg8{tYJ9<4Y9Sju9e39o9Ap1Z&bFy37XO#eUEADbkwD(cJmKn(Ey~HAYh!u0;F?(` z%N4m_U&>+SlJ_}gm%}!VEU&iKYw{w@R(2%GcF@7kBg!vL@W%<$`sj1uv<-}|aFu(3 zz9Wb?bObKZ20gHb9*0CRYI<%bEQ2G(Mrhc-|t)YSx)g9nn5-FMyO~)7%kM) zO4~-;fnIcC2wl9#Zp@+wi$qos#~S*uiGEmo9Zfu4k6`#G>Qpp~ALvpMihf5_@zTjL zNR8j9P~rOO1QnE~rxGU!tp<)z`3_2gDrFc^y*T_g4tb#_L+bGu!3z*|OVnRJM&211 zsW?ydc#-f0=!|$)^ew6qhp0Y8q5XB5e=uu&AW!)|_Ar6x P{O(_3np#`QSJ3tch#2l{ literal 0 HcmV?d00001 diff --git a/trees/trees/Node.class b/trees/trees/Node.class new file mode 100644 index 0000000000000000000000000000000000000000..306771cee78f9af2cb76992fbfd929b6870d5b3d GIT binary patch literal 339 zcmYLEO-sW-6r63+#>UmuwtnG3k8KX-sGtZc6au9lEIoMJG;7@wQ%DoRpXDJ49{d6R zC~>wI4{zq}+nM+A^ZWG;-~z`!TIjaXM9)Is!oG(C4~GJ7s!AmwVy2mXE(PScEVN!n zlU1s(1e%3eys+H5Hn}NpC>zAX8R?$?0>RkidQ!b6x|pgYW5s`5RmEJ7jD4JrOrDOa zEVJF#aejMea#g%fIpKV%-jsyIk%WgWiEa22ZTM{Qzkxu<>Y_~Li|8R)>N$6D2E!T7 zct(o{It==WucJFP7U{CqYj8&s;tYUuT5VM L0sS4;8rb^-@TxjV literal 0 HcmV?d00001 From c83e9d3a77c074adb5fdb9db43a5c1475ddf8fcf Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Sun, 27 Dec 2020 21:09:13 +0530 Subject: [PATCH 16/56] #Modification 15 --- src | 1 + 1 file changed, 1 insertion(+) create mode 160000 src diff --git a/src b/src new file mode 160000 index 0000000..26d2d57 --- /dev/null +++ b/src @@ -0,0 +1 @@ +Subproject commit 26d2d577f3d9fe69db155171c374a6391232703f From 4e69287067e971bdbda41adca54f1fbce1f69ec8 Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Sun, 27 Dec 2020 21:13:47 +0530 Subject: [PATCH 17/56] #Modification 16 --- data_from_eclipse_ide/arrays/ArrayLevel1.java | 17 ++ data_from_eclipse_ide/arrays/ArrayLevel2.java | 34 ++++ .../arrays/Array_Problem_1.java | 41 +++++ .../arrays/Array_Problem_10.java | 51 ++++++ .../arrays/Array_Problem_11.java | 33 ++++ .../arrays/Array_Problem_12.java | 69 ++++++++ .../arrays/Array_Problem_18.java | 29 ++++ .../arrays/Array_Problem_2.java | 55 ++++++ .../arrays/Array_Problem_23.java | 45 +++++ .../arrays/Array_Problem_3.java | 122 ++++++++++++++ .../arrays/Array_Problem_32.java | 35 ++++ .../arrays/Array_Problem_4_Approach1.java | 63 +++++++ .../arrays/Array_Problem_4_Approach2.java | 47 ++++++ .../arrays/Array_Problem_5.java | 41 +++++ .../arrays/Array_Problem_6.java | 118 +++++++++++++ .../arrays/Array_Problem_7.java | 42 +++++ .../arrays/Array_Problem_8.java | 32 ++++ .../arrays/Array_Problem_9.java | 65 ++++++++ .../arrays/Array_of_objects.java | 44 +++++ .../arrays/Candy_Distribution_Problem.java | 49 ++++++ data_from_eclipse_ide/arrays/FRE.java | 40 +++++ .../arrays/KadanesAlgorithm.java | 31 ++++ data_from_eclipse_ide/arrays/MultiDArray.java | 16 ++ .../backtracking/Rat_In_A_Maze.java | 90 ++++++++++ .../basicProblems/Armstrong_Number.java | 26 +++ .../basicProblems/Factorial.class | Bin 0 -> 1124 bytes .../basicProblems/Factorial.java | 20 +++ .../basicProblems/Fibonacci_Series.java | 26 +++ .../Multiplicative_Table_till_20.java | 27 +++ .../basicProblems/Palindrome_Number.java | 9 + .../basicProblems/Prime_Number_Or_Not.java | 28 ++++ ...ive_decimal_number_from_right_to_left.java | 19 +++ .../basicProblems/Reverse_Given_number.java | 22 +++ .../basicProblems/Series_Sum_1.java | 22 +++ .../basicProblems/Series_Sum_2.java | 32 ++++ .../basicProblems/Swap_two_numbers.java | 17 ++ .../basicProblems/Swapping_2.java | 24 +++ .../basicProblems/X_raisedTo_power_Y.java | 18 ++ .../basic_idea_of_DS/ArrayDequeDemo.java | 24 +++ .../basic_idea_of_DS/ArrayListDemo.java | 33 ++++ .../basic_idea_of_DS/Graph.java | 41 +++++ .../basic_idea_of_DS/HashMapIntro.java | 28 ++++ .../basic_idea_of_DS/LinkedListDemo.java | 35 ++++ .../basic_idea_of_DS/List.java | 14 ++ .../basic_idea_of_DS/MYStackByList.java | 121 ++++++++++++++ .../basic_idea_of_DS/MyArrayList.java | 33 ++++ .../basic_idea_of_DS/MyHashMap.java | 28 ++++ .../basic_idea_of_DS/MyHashSet.java | 21 +++ .../basic_idea_of_DS/MyLinkedList.java | 35 ++++ .../basic_idea_of_DS/MyQueue.java | 82 +++++++++ .../basic_idea_of_DS/MyStack.java | 58 +++++++ .../basic_idea_of_DS/SetExample.java | 34 ++++ .../basic_idea_of_DS/Tree.java | 52 ++++++ .../basics/ControlStatements.java | 29 ++++ data_from_eclipse_ide/basics/DoWhileLoop.java | 15 ++ .../basics/Fast_Inputs_Main.java | 63 +++++++ data_from_eclipse_ide/basics/Operators.java | 17 ++ .../basics/VariablesandDataTypes.java | 15 ++ data_from_eclipse_ide/basics/WhileLoop.java | 14 ++ .../binaryTree/BT_Problem_01.java | 49 ++++++ .../binaryTree/BT_Problem_02.java | 10 ++ .../dp/CoinChoiseProblem.java | 51 ++++++ data_from_eclipse_ide/graphs/Graph.java | 41 +++++ .../graphs/Graph_Traversal_DFS.java | 57 +++++++ .../linkedList/Deletion_in_Linked_List.java | 100 +++++++++++ .../linkedList/Insertion_in_Linked_List.java | 99 +++++++++++ .../linkedList/MainList.java | 18 ++ data_from_eclipse_ide/linkedList/MyLL.java | 53 ++++++ .../linkedList/Problem_1_1.java | 63 +++++++ .../linkedList/Problem_1_2.java | 67 ++++++++ data_from_eclipse_ide/linkedList/Queue.java | 157 ++++++++++++++++++ .../matrix/Matrix_Problem_01.java | 87 ++++++++++ .../matrix/Matrix_Problem_02.java | 123 ++++++++++++++ data_from_eclipse_ide/oops/A.java | 10 ++ .../oops/MYStaticKeyword.java | 22 +++ data_from_eclipse_ide/oops/Mor.java | 15 ++ data_from_eclipse_ide/oops/MyConstructor.java | 13 ++ data_from_eclipse_ide/oops/Person.java | 7 + data_from_eclipse_ide/oops/RepairShop.java | 20 +++ data_from_eclipse_ide/oops/Sonata.java | 12 ++ data_from_eclipse_ide/oops/StaticKeyword.java | 13 ++ data_from_eclipse_ide/oops/Vehicle.java | 19 +++ data_from_eclipse_ide/oops/Watches.java | 8 + .../oopsEncapsulation/EncapIntro.java | 17 ++ .../oopsEncapsulation/S.java | 31 ++++ .../oopsabstraction/Audi.java | 15 ++ .../oopsabstraction/Car.java | 8 + .../oopsabstraction/RepairShop.java | 21 +++ .../oopsabstraction/WagonR.java | 20 +++ .../oopsinheritance/MainClass.java | 20 +++ .../oopsinheritance/Person.java | 15 ++ .../oopsinheritance/Singer.java | 9 + .../oopsinheritance/Teacher.java | 9 + .../oopspolymorphism/Animal.java | 5 + .../oopspolymorphism/Dog.java | 10 ++ .../oopspolymorphism/MainClass.java | 29 ++++ .../oopspolymorphism/Pet.java | 9 + .../patternsByloops/Pattern1.java | 19 +++ .../patternsByloops/Pattern2.java | 17 ++ .../patternsByloops/Pattern3.java | 18 ++ .../patternsByloops/Pattern4.java | 20 +++ .../patternsByloops/Pattern5.java | 30 ++++ .../patternsByloops/Pattern5_2.java | 24 +++ .../patternsByloops/Pattern6.java | 21 +++ .../patternsByloops/Pattern7.java | 18 ++ .../patternsByloops/Pattern8.java | 21 +++ .../patternsByloops/Pattern9.java | 19 +++ .../practiceProblems/Cylinder.java | 26 +++ .../practiceProblems/Exercise1.java | 33 ++++ .../practiceProblems/Exercise2.java | 34 ++++ .../Getters_Setters_For_Cylinder.java | 44 +++++ .../recursion/Factorial.java | 21 +++ data_from_eclipse_ide/recursion/NRaiseP.java | 15 ++ .../recursion/NaturalNoSum.java | 20 +++ .../recursion/Subsequences.java | 50 ++++++ .../recursion/Tower_Of_Hanoi.java | 29 ++++ .../searchingAlgorithms/BinarySearch.java | 47 ++++++ .../searchingAlgorithms/LinearSearch.java | 28 ++++ .../sortingAlgorithms/BubbleSort.java | 43 +++++ .../sortingAlgorithms/HeapSort.java | 76 +++++++++ .../sortingAlgorithms/InsertionSort.java | 42 +++++ .../sortingAlgorithms/MergeSort.java | 98 +++++++++++ .../sortingAlgorithms/QuickSort.java | 80 +++++++++ .../sortingAlgorithms/RadixSort.java | 73 ++++++++ .../sortingAlgorithms/SelectionSort.java | 42 +++++ .../stack_and_queue/Infix_To_Postfix.java | 76 +++++++++ .../Parenthesis_Checker_Problem.java | 75 +++++++++ .../Stack_Queue_Problem_01_i.java | 69 ++++++++ .../Stack_Queue_Problem_01_ii.java | 115 +++++++++++++ .../Stack_Queue_Problem_02_i.java | 67 ++++++++ .../Stack_Queue_Problem_02_ii.java | 10 ++ src | 1 - 132 files changed, 5043 insertions(+), 1 deletion(-) create mode 100644 data_from_eclipse_ide/arrays/ArrayLevel1.java create mode 100644 data_from_eclipse_ide/arrays/ArrayLevel2.java create mode 100644 data_from_eclipse_ide/arrays/Array_Problem_1.java create mode 100644 data_from_eclipse_ide/arrays/Array_Problem_10.java create mode 100644 data_from_eclipse_ide/arrays/Array_Problem_11.java create mode 100644 data_from_eclipse_ide/arrays/Array_Problem_12.java create mode 100644 data_from_eclipse_ide/arrays/Array_Problem_18.java create mode 100644 data_from_eclipse_ide/arrays/Array_Problem_2.java create mode 100644 data_from_eclipse_ide/arrays/Array_Problem_23.java create mode 100644 data_from_eclipse_ide/arrays/Array_Problem_3.java create mode 100644 data_from_eclipse_ide/arrays/Array_Problem_32.java create mode 100644 data_from_eclipse_ide/arrays/Array_Problem_4_Approach1.java create mode 100644 data_from_eclipse_ide/arrays/Array_Problem_4_Approach2.java create mode 100644 data_from_eclipse_ide/arrays/Array_Problem_5.java create mode 100644 data_from_eclipse_ide/arrays/Array_Problem_6.java create mode 100644 data_from_eclipse_ide/arrays/Array_Problem_7.java create mode 100644 data_from_eclipse_ide/arrays/Array_Problem_8.java create mode 100644 data_from_eclipse_ide/arrays/Array_Problem_9.java create mode 100644 data_from_eclipse_ide/arrays/Array_of_objects.java create mode 100644 data_from_eclipse_ide/arrays/Candy_Distribution_Problem.java create mode 100644 data_from_eclipse_ide/arrays/FRE.java create mode 100644 data_from_eclipse_ide/arrays/KadanesAlgorithm.java create mode 100644 data_from_eclipse_ide/arrays/MultiDArray.java create mode 100644 data_from_eclipse_ide/backtracking/Rat_In_A_Maze.java create mode 100644 data_from_eclipse_ide/basicProblems/Armstrong_Number.java create mode 100644 data_from_eclipse_ide/basicProblems/Factorial.class create mode 100644 data_from_eclipse_ide/basicProblems/Factorial.java create mode 100644 data_from_eclipse_ide/basicProblems/Fibonacci_Series.java create mode 100644 data_from_eclipse_ide/basicProblems/Multiplicative_Table_till_20.java create mode 100644 data_from_eclipse_ide/basicProblems/Palindrome_Number.java create mode 100644 data_from_eclipse_ide/basicProblems/Prime_Number_Or_Not.java create mode 100644 data_from_eclipse_ide/basicProblems/Print_all_digits_of_positive_decimal_number_from_right_to_left.java create mode 100644 data_from_eclipse_ide/basicProblems/Reverse_Given_number.java create mode 100644 data_from_eclipse_ide/basicProblems/Series_Sum_1.java create mode 100644 data_from_eclipse_ide/basicProblems/Series_Sum_2.java create mode 100644 data_from_eclipse_ide/basicProblems/Swap_two_numbers.java create mode 100644 data_from_eclipse_ide/basicProblems/Swapping_2.java create mode 100644 data_from_eclipse_ide/basicProblems/X_raisedTo_power_Y.java create mode 100644 data_from_eclipse_ide/basic_idea_of_DS/ArrayDequeDemo.java create mode 100644 data_from_eclipse_ide/basic_idea_of_DS/ArrayListDemo.java create mode 100644 data_from_eclipse_ide/basic_idea_of_DS/Graph.java create mode 100644 data_from_eclipse_ide/basic_idea_of_DS/HashMapIntro.java create mode 100644 data_from_eclipse_ide/basic_idea_of_DS/LinkedListDemo.java create mode 100644 data_from_eclipse_ide/basic_idea_of_DS/List.java create mode 100644 data_from_eclipse_ide/basic_idea_of_DS/MYStackByList.java create mode 100644 data_from_eclipse_ide/basic_idea_of_DS/MyArrayList.java create mode 100644 data_from_eclipse_ide/basic_idea_of_DS/MyHashMap.java create mode 100644 data_from_eclipse_ide/basic_idea_of_DS/MyHashSet.java create mode 100644 data_from_eclipse_ide/basic_idea_of_DS/MyLinkedList.java create mode 100644 data_from_eclipse_ide/basic_idea_of_DS/MyQueue.java create mode 100644 data_from_eclipse_ide/basic_idea_of_DS/MyStack.java create mode 100644 data_from_eclipse_ide/basic_idea_of_DS/SetExample.java create mode 100644 data_from_eclipse_ide/basic_idea_of_DS/Tree.java create mode 100644 data_from_eclipse_ide/basics/ControlStatements.java create mode 100644 data_from_eclipse_ide/basics/DoWhileLoop.java create mode 100644 data_from_eclipse_ide/basics/Fast_Inputs_Main.java create mode 100644 data_from_eclipse_ide/basics/Operators.java create mode 100644 data_from_eclipse_ide/basics/VariablesandDataTypes.java create mode 100644 data_from_eclipse_ide/basics/WhileLoop.java create mode 100644 data_from_eclipse_ide/binaryTree/BT_Problem_01.java create mode 100644 data_from_eclipse_ide/binaryTree/BT_Problem_02.java create mode 100644 data_from_eclipse_ide/dp/CoinChoiseProblem.java create mode 100644 data_from_eclipse_ide/graphs/Graph.java create mode 100644 data_from_eclipse_ide/graphs/Graph_Traversal_DFS.java create mode 100644 data_from_eclipse_ide/linkedList/Deletion_in_Linked_List.java create mode 100644 data_from_eclipse_ide/linkedList/Insertion_in_Linked_List.java create mode 100644 data_from_eclipse_ide/linkedList/MainList.java create mode 100644 data_from_eclipse_ide/linkedList/MyLL.java create mode 100644 data_from_eclipse_ide/linkedList/Problem_1_1.java create mode 100644 data_from_eclipse_ide/linkedList/Problem_1_2.java create mode 100644 data_from_eclipse_ide/linkedList/Queue.java create mode 100644 data_from_eclipse_ide/matrix/Matrix_Problem_01.java create mode 100644 data_from_eclipse_ide/matrix/Matrix_Problem_02.java create mode 100644 data_from_eclipse_ide/oops/A.java create mode 100644 data_from_eclipse_ide/oops/MYStaticKeyword.java create mode 100644 data_from_eclipse_ide/oops/Mor.java create mode 100644 data_from_eclipse_ide/oops/MyConstructor.java create mode 100644 data_from_eclipse_ide/oops/Person.java create mode 100644 data_from_eclipse_ide/oops/RepairShop.java create mode 100644 data_from_eclipse_ide/oops/Sonata.java create mode 100644 data_from_eclipse_ide/oops/StaticKeyword.java create mode 100644 data_from_eclipse_ide/oops/Vehicle.java create mode 100644 data_from_eclipse_ide/oops/Watches.java create mode 100644 data_from_eclipse_ide/oopsEncapsulation/EncapIntro.java create mode 100644 data_from_eclipse_ide/oopsEncapsulation/S.java create mode 100644 data_from_eclipse_ide/oopsabstraction/Audi.java create mode 100644 data_from_eclipse_ide/oopsabstraction/Car.java create mode 100644 data_from_eclipse_ide/oopsabstraction/RepairShop.java create mode 100644 data_from_eclipse_ide/oopsabstraction/WagonR.java create mode 100644 data_from_eclipse_ide/oopsinheritance/MainClass.java create mode 100644 data_from_eclipse_ide/oopsinheritance/Person.java create mode 100644 data_from_eclipse_ide/oopsinheritance/Singer.java create mode 100644 data_from_eclipse_ide/oopsinheritance/Teacher.java create mode 100644 data_from_eclipse_ide/oopspolymorphism/Animal.java create mode 100644 data_from_eclipse_ide/oopspolymorphism/Dog.java create mode 100644 data_from_eclipse_ide/oopspolymorphism/MainClass.java create mode 100644 data_from_eclipse_ide/oopspolymorphism/Pet.java create mode 100644 data_from_eclipse_ide/patternsByloops/Pattern1.java create mode 100644 data_from_eclipse_ide/patternsByloops/Pattern2.java create mode 100644 data_from_eclipse_ide/patternsByloops/Pattern3.java create mode 100644 data_from_eclipse_ide/patternsByloops/Pattern4.java create mode 100644 data_from_eclipse_ide/patternsByloops/Pattern5.java create mode 100644 data_from_eclipse_ide/patternsByloops/Pattern5_2.java create mode 100644 data_from_eclipse_ide/patternsByloops/Pattern6.java create mode 100644 data_from_eclipse_ide/patternsByloops/Pattern7.java create mode 100644 data_from_eclipse_ide/patternsByloops/Pattern8.java create mode 100644 data_from_eclipse_ide/patternsByloops/Pattern9.java create mode 100644 data_from_eclipse_ide/practiceProblems/Cylinder.java create mode 100644 data_from_eclipse_ide/practiceProblems/Exercise1.java create mode 100644 data_from_eclipse_ide/practiceProblems/Exercise2.java create mode 100644 data_from_eclipse_ide/practiceProblems/Getters_Setters_For_Cylinder.java create mode 100644 data_from_eclipse_ide/recursion/Factorial.java create mode 100644 data_from_eclipse_ide/recursion/NRaiseP.java create mode 100644 data_from_eclipse_ide/recursion/NaturalNoSum.java create mode 100644 data_from_eclipse_ide/recursion/Subsequences.java create mode 100644 data_from_eclipse_ide/recursion/Tower_Of_Hanoi.java create mode 100644 data_from_eclipse_ide/searchingAlgorithms/BinarySearch.java create mode 100644 data_from_eclipse_ide/searchingAlgorithms/LinearSearch.java create mode 100644 data_from_eclipse_ide/sortingAlgorithms/BubbleSort.java create mode 100644 data_from_eclipse_ide/sortingAlgorithms/HeapSort.java create mode 100644 data_from_eclipse_ide/sortingAlgorithms/InsertionSort.java create mode 100644 data_from_eclipse_ide/sortingAlgorithms/MergeSort.java create mode 100644 data_from_eclipse_ide/sortingAlgorithms/QuickSort.java create mode 100644 data_from_eclipse_ide/sortingAlgorithms/RadixSort.java create mode 100644 data_from_eclipse_ide/sortingAlgorithms/SelectionSort.java create mode 100644 data_from_eclipse_ide/stack_and_queue/Infix_To_Postfix.java create mode 100644 data_from_eclipse_ide/stack_and_queue/Parenthesis_Checker_Problem.java create mode 100644 data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_01_i.java create mode 100644 data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_01_ii.java create mode 100644 data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_02_i.java create mode 100644 data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_02_ii.java delete mode 160000 src diff --git a/data_from_eclipse_ide/arrays/ArrayLevel1.java b/data_from_eclipse_ide/arrays/ArrayLevel1.java new file mode 100644 index 0000000..c065dd2 --- /dev/null +++ b/data_from_eclipse_ide/arrays/ArrayLevel1.java @@ -0,0 +1,17 @@ +package arrays; + +public class ArrayLevel1 { + + public static void main(String[] args) { + int[] arr; + arr = new int[5]; + + arr[0] = 10; + arr[1] = 20; + arr[2] = 30; + arr[3] = 40; + arr[4] = 50; + + for(int i = 0 ; i =0) m[Math.abs(m[i])] = -m[Math.abs(m[i])]; + else System.out.print(Math.abs(m[i]) + " "); + } + } + + //Driver Method + public static void main(String[] args) { + + Array_Problem_11 dublicate= new Array_Problem_11(); + + int m[] = {1,2,3,1,3,6,6}; + int m_size = m.length; + + dublicate.printRepeating(m,m_size); + + } + +} + diff --git a/data_from_eclipse_ide/arrays/Array_Problem_12.java b/data_from_eclipse_ide/arrays/Array_Problem_12.java new file mode 100644 index 0000000..e878764 --- /dev/null +++ b/data_from_eclipse_ide/arrays/Array_Problem_12.java @@ -0,0 +1,69 @@ +package arrays; + +import java.util.Arrays; + +/* + * Problem :- + * Merge two sorted array without using extra space + */ + +/* + * Understanding of the Problem :- + * + * We are given two sorted array. + * We need to merge these two arrays, + * such that the initial numbers(after complete sorting) are in the first array , + * and the remaining numbers are in the second array. + * Extra space allowed in O(1). + */ + +/* + * Simple Discussion : + * This task is simple and O(m+n) if we are allowed to use extra space. + * But it becomes really complicated when extra space is not allowed, + * and doesn't look possible in less than O(m*n) worst case time. + */ + +/* + * Idea or Approach of Solution :- + * The idea is to begin from last element of ar2[] and search it in ar1[]. + * If there is a greater element in ae1[], then we moe lastt element of ar2[] at correct place in ar1[]. + * + * We can use INSERTION Sort type of insertion for this. + */ + +public class Array_Problem_12 { + + static int arr1[] = new int[] {1, 5 , 9, 10, 15, 20}; + static int arr2[] = new int[] {2, 3, 8, 13}; + + static void merge(int m , int n) { + + //Iterate through all elements of the last element + for(int i = n-1; i >= 0; i--) { + + /* + * FInd the smallest element greater than ar2[i]. + * Move all elements one position ahead till the smallest greater element is not found. + */ + int j , last = arr1[m -1]; + for( j = m-2 ; j>= 0 && arr1[j] > arr2[i] ; j--) + arr1[j+1] = arr1[j]; + + //if there was a greater element + if(j != m-2 || last > arr2[i]) { + arr1[j+1] = arr2[i]; + arr2[i] = last; + } + } + } + + public static void main(String[] args) { + merge(arr1.length, arr2.length); + System.out.println("After Merging nFirst Array: "); + System.out.println(Arrays.toString(arr1)); + System.out.println("Second Array: "); + System.out.println(Arrays.toString(arr2)); + } + +} diff --git a/data_from_eclipse_ide/arrays/Array_Problem_18.java b/data_from_eclipse_ide/arrays/Array_Problem_18.java new file mode 100644 index 0000000..709bf09 --- /dev/null +++ b/data_from_eclipse_ide/arrays/Array_Problem_18.java @@ -0,0 +1,29 @@ +package arrays; + +/* + * find all pairs on integer array whose sum is equal to given number + * OR + * Equal_Sum_Pairs_of_Array + */ + +public class Array_Problem_18 { + + //function to find & print the sum & elements + static void pairs_value(int iA[], int iN) { + System.out.println("Pairs of elements & their sum : "); + + //loop to iterate & find the pair of elements whose sum is equal + for(int i = 0 ; i < iA.length ; i++) { + for(int j = i + 1 ; j < iA.length ; j++) + //check if the sum of pair is equal, if equal then print the pair of elements & their sum + if(iA[i]+iA[j] == iN) System.out.println(iA[i] + " + " + iA[j] + " = " + iN); + } + } + + //Driver Method + public static void main(String[] args) { + pairs_value(new int[] {2,7,4,-5,11,5,20}, 15); + pairs_value(new int[] {14,-15,9,16,25,45,12,8},30); + } + +} diff --git a/data_from_eclipse_ide/arrays/Array_Problem_2.java b/data_from_eclipse_ide/arrays/Array_Problem_2.java new file mode 100644 index 0000000..63dc567 --- /dev/null +++ b/data_from_eclipse_ide/arrays/Array_Problem_2.java @@ -0,0 +1,55 @@ +package arrays; + +//Java program to find the maximum & minimum element in given or array as user input +public class Array_Problem_2 { +/* Class Pair is used to return two values from getMinMax() */ + static class Pair { + + int min; + int max; + } + + static Pair getMinMax(int arr[], int n) { + Pair minmax = new Pair(); + int i; + + /*If there is only one element then return it as min and max both*/ + if (n == 1) { + minmax.max = arr[0]; + minmax.min = arr[0]; + return minmax; + } + + /* If there are more than one elements, then initialize min + and max*/ + if (arr[0] > arr[1]) { + minmax.max = arr[0]; + minmax.min = arr[1]; + } else { + minmax.max = arr[1]; + minmax.min = arr[0]; + } + + for (i = 2; i < n; i++) { + if (arr[i] > minmax.max) { + minmax.max = arr[i]; + } else if (arr[i] < minmax.min) { + minmax.min = arr[i]; + } + } + + return minmax; + } + + /* Driver program to test above function */ + public static void main(String args[]) { + int arr[] = {1000, 11, 445, 1, 330, 3000}; + int arr_size = 6; + Pair minmax = getMinMax(arr, arr_size); + System.out.printf("\nMinimum element is %d", minmax.min); + System.out.printf("\nMaximum element is %d", minmax.max); + + } + +} + diff --git a/data_from_eclipse_ide/arrays/Array_Problem_23.java b/data_from_eclipse_ide/arrays/Array_Problem_23.java new file mode 100644 index 0000000..9aedc89 --- /dev/null +++ b/data_from_eclipse_ide/arrays/Array_Problem_23.java @@ -0,0 +1,45 @@ +package arrays; + +/* + * Java program for maximum product sub-array problem + */ + +public class Array_Problem_23 { + + static void maxSubArraySum(int a[], int size) + { + int max_so_far = Integer.MIN_VALUE, + max_ending_here = 0,start = 0, + end = 0, s = 0; + + for (int i = 0; i < size; i++) + { + max_ending_here += a[i]; + + if (max_so_far < max_ending_here) + { + max_so_far = max_ending_here; + start = s; + end = i; + } + + if (max_ending_here < 0) + { + max_ending_here = 0; + s = i + 1; + } + } + System.out.println("Maximum contiguous sum is " + max_so_far); + System.out.println("Starting index " + start); + System.out.println("Ending index " + end); + } + + // Driver code + public static void main(String[] args) + { + int a[] = { -2, -3, 4, -1, -2, 1, 5, -3 }; + int n = a.length; + maxSubArraySum(a, n); + } + } + diff --git a/data_from_eclipse_ide/arrays/Array_Problem_3.java b/data_from_eclipse_ide/arrays/Array_Problem_3.java new file mode 100644 index 0000000..0a9c3ad --- /dev/null +++ b/data_from_eclipse_ide/arrays/Array_Problem_3.java @@ -0,0 +1,122 @@ +package arrays; + +import java.util.Arrays; + +/* + * (Find K^the smallest element) + * Given an array array[] and a number K where K is smaller than size of array, + * the task is to find the K^the smallest element in the given array. + * It is given that all array elements are distinct. + */ +public class Array_Problem_3 { + + // int partition(int array[], int l, int r, int k); + + // A simple function to find median of arr[]. This is called + // only for an array of size 5 in this program. + static int findMedian(int arr[], int i,int n) + { + if(i <= n) + Arrays.sort(arr, i, n); // Sort the array + else + Arrays.sort(arr, n, i); + return arr[n/2]; // Return middle element + } + + // Returns k'th smallest element + // in arr[l..r] in worst case + // linear time. ASSUMPTION: ALL + // ELEMENTS IN ARR[] ARE DISTINCT + static int kthSmallest(int arr[], int l, int r, int k) + { + // If k is smaller than + // number of elements in array + if (k > 0 && k <= r - l + 1) + { + int n = r - l + 1 ; // Number of elements in arr[l..r] + + // Divide arr[] in groups of size 5, + // calculate median of every group + // and store it in median[] array. + int i; + + // There will be floor((n+4)/5) groups; + int []median = new int[(n + 4) / 5]; + for (i = 0; i < n/5; i++) + median[i] = findMedian(arr,l + i * 5, 5); + + // For last group with less than 5 elements + if (i*5 < n) + { + median[i] = findMedian(arr,l + i * 5, n % 5); + i++; + } + + // Find median of all medians using recursive call. + // If median[] has only one element, then no need + // of recursive call + int medOfMed = (i == 1)? median[i - 1]: + kthSmallest(median, 0, i - 1, i / 2); + + // Partition the array around a random element and + // get position of pivot element in sorted array + int pos = partition(arr, l, r, medOfMed); + + // If position is same as k + if (pos-l == k - 1) + return arr[pos]; + if (pos-l > k - 1) // If position is more, recur for left + return kthSmallest(arr, l, pos - 1, k); + + // Else recur for right subarray + return kthSmallest(arr, pos + 1, r, k - pos + l - 1); + } + + // If k is more than number of elements in array + return Integer.MAX_VALUE; + } + + static int[] swap(int []arr, int i, int j) + { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + return arr; + } + + // It searches for x in arr[l..r], and + // partitions the array around x. + static int partition(int arr[], int l, + int r, int x) + { + // Search for x in arr[l..r] and move it to end + int i; + for (i = l; i < r; i++) + if (arr[i] == x) + break; + swap(arr, i, r); + + // Standard partition algorithm + i = l; + for (int j = l; j <= r - 1; j++) + { + if (arr[j] <= x) + { + swap(arr, i, j); + i++; + } + } + swap(arr, i, r); + return i; + } + + // Driver code + public static void main(String[] args) + { + int arr[] = {12, 3, 5, 7, 4, 19, 26}; + int n = arr.length, k = 3; + System.out.println("K'th smallest element is " + + kthSmallest(arr, 0, n - 1, k)); + } + +} diff --git a/data_from_eclipse_ide/arrays/Array_Problem_32.java b/data_from_eclipse_ide/arrays/Array_Problem_32.java new file mode 100644 index 0000000..7f50762 --- /dev/null +++ b/data_from_eclipse_ide/arrays/Array_Problem_32.java @@ -0,0 +1,35 @@ +package arrays; + +//Java program to find minimum number of operations to make an array palindrome +public class Array_Problem_32 { + + static int findMinOps(int[] a, int n) { + + //Initialize result + int ans = 0; + + //Start from two corners + for(int i=0,j=n-1;i<=j;) { + + if(a[i] == a[j]) { + i++; + j--; + }else if(a[i] > a[j]) { + j--; + a[j] += a[j+1]; + ans++; + }else { + i++; + a[i] += a[i-1]; + ans++; + } + } + return ans; + } + + public static void main(String[] args) { + int a[] = new int[] {1,2,3,4,5,6,7,8,9,10}; + System.out.println("Count of minimum operations is " + findMinOps(a , a.length)); + } + +} diff --git a/data_from_eclipse_ide/arrays/Array_Problem_4_Approach1.java b/data_from_eclipse_ide/arrays/Array_Problem_4_Approach1.java new file mode 100644 index 0000000..b1e4e48 --- /dev/null +++ b/data_from_eclipse_ide/arrays/Array_Problem_4_Approach1.java @@ -0,0 +1,63 @@ +package arrays; +import java.io.*; + +/* + * Java program to solve that, + * Given an array A of size N containing 0s, 1s, and 2s; + * you need to sort the array in ascending order without using any sorting algorithm + */ + +@SuppressWarnings("unused") +public class Array_Problem_4_Approach1 { + + // Sort the input array, the array is assumed to + // have values in {0, 1, 2} + static void sort012(int a[], int arr_size) + { + int lo = 0; + int hi = arr_size - 1; + int mid = 0, temp = 0; + while (mid <= hi) { + switch (a[mid]) { + case 0: { + temp = a[lo]; + a[lo] = a[mid]; + a[mid] = temp; + lo++; + mid++; + break; + } + case 1: + mid++; + break; + case 2: { + temp = a[mid]; + a[mid] = a[hi]; + a[hi] = temp; + hi--; + break; + } + } + } + } + + /* Utility function to print array arr[] */ + static void printArray(int arr[], int arr_size) + { + int i; + for (i = 0; i < arr_size; i++) + System.out.print(arr[i] + " "); + System.out.println(""); + } + + /*Driver function to check for above functions*/ + public static void main(String[] args) + { + int arr[] = { 0, 1, 1, 0, 1, 2, 1, 2, 0, 0, 0, 1 }; + int arr_size = arr.length; + sort012(arr, arr_size); + System.out.println("Array after seggregation "); + printArray(arr, arr_size); + } + +} diff --git a/data_from_eclipse_ide/arrays/Array_Problem_4_Approach2.java b/data_from_eclipse_ide/arrays/Array_Problem_4_Approach2.java new file mode 100644 index 0000000..1116d1d --- /dev/null +++ b/data_from_eclipse_ide/arrays/Array_Problem_4_Approach2.java @@ -0,0 +1,47 @@ +package arrays; +import java.util.Arrays; + +/* + * Sort_an_array_of_0s_1s_2s_without_using_extra_space_or_sorting_algo + */ + +public class Array_Problem_4_Approach2 { + + static int arr1[] = new int[]{1, 5, 9, 10, 15, 20}; + static int arr2[] = new int[]{2, 3, 8, 13}; + + static void merge(int m, int n) + { + // Iterate through all elements of ar2[] starting from to the last element + for (int i=n-1; i>=0; i--) + { + + /* Find the smallest element greater than ar2[i]. + * Move all elements one position ahead, + * till the smallest greater element is not found + */ + int j, last = arr1[m-1]; + + for (j=m-2; j >= 0 && arr1[j] > arr2[i]; j--) + arr1[j+1] = arr1[j]; + + // If there was a greater element + if (j != m-2 || last > arr2[i]) { + arr1[j+1] = arr2[i]; + arr2[i] = last; + } + } + } + + // Driver method to test the above function + public static void main1(String[] args) + { + merge(arr1.length,arr2.length); + + System.out.print("After Merging nFirst Array: "); + System.out.println(Arrays.toString(arr1)); + + System.out.print("Second Array: "); + System.out.println(Arrays.toString(arr2)); + } +} diff --git a/data_from_eclipse_ide/arrays/Array_Problem_5.java b/data_from_eclipse_ide/arrays/Array_Problem_5.java new file mode 100644 index 0000000..d2a4008 --- /dev/null +++ b/data_from_eclipse_ide/arrays/Array_Problem_5.java @@ -0,0 +1,41 @@ +package arrays; + +/* + * Move all the negative elements to one side of the array + */ + +public class Array_Problem_5 { + + static void rearrange(int arr[], int n) + { + int j = 0, temp; + for (int i = 0; i < n; i++) { + if (arr[i] < 0) { + if (i != j) { + temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + j++; + } + } + } + + // A utility function to print an array + static void printArray(int arr[], int n) + { + for (int i = 0; i < n; i++) + System.out.print(arr[i] + " "); + } + + //Driver Method + public static void main(String[] args) { + int arr[] = { -1, 2, -3, 4, 5, 6, -7, 8, 9 , -47}; + int n = arr.length; + + rearrange(arr, n); + printArray(arr, n); + + } + +} diff --git a/data_from_eclipse_ide/arrays/Array_Problem_6.java b/data_from_eclipse_ide/arrays/Array_Problem_6.java new file mode 100644 index 0000000..5552ee1 --- /dev/null +++ b/data_from_eclipse_ide/arrays/Array_Problem_6.java @@ -0,0 +1,118 @@ +package arrays; + +// A Java program to print union and intersection of two unsorted arrays +import java.util.Arrays; + +/* + * Find the Union and Intersection of the two sorted arrays. + */ + +public class Array_Problem_6 { + + + void printUnion(int arr1[], int arr2[], int m, int n) + { + // Before finding union, make sure arr1[0..m-1] + // is smaller + if (m > n) { + int tempp[] = arr1; + arr1 = arr2; + arr2 = tempp; + + int temp = m; + m = n; + n = temp; + } + + // Now arr1[] is smaller + // Sort the first array and print its elements + // (these two steps can be swapped as order in + // output is not important) + Arrays.sort(arr1); + for (int i = 0; i < m; i++) + System.out.print(arr1[i] + " "); + + // Search every element of bigger array in smaller + // array and print the element if not found + for (int i = 0; i < n; i++) { + if (binarySearch(arr1, 0, m - 1, arr2[i]) == -1) + System.out.print(arr2[i] + " "); + } + } + + // Prints intersection of arr1[0..m-1] and arr2[0..n-1] + void printIntersection(int arr1[], int arr2[], int m, + int n) + { + // Before finding intersection, make sure + // arr1[0..m-1] is smaller + if (m > n) { + int tempp[] = arr1; + arr1 = arr2; + arr2 = tempp; + + int temp = m; + m = n; + n = temp; + } + + // Now arr1[] is smaller + // Sort smaller array arr1[0..m-1] + Arrays.sort(arr1); + + // Search every element of bigger array in smaller + // array and print the element if found + for (int i = 0; i < n; i++) { + if (binarySearch(arr1, 0, m - 1, arr2[i]) != -1) + System.out.print(arr2[i] + " "); + } + } + + // A recursive binary search function. It returns + // location of x in given array arr[l..r] is present, + // otherwise -1 + int binarySearch(int arr[], int l, int r, int x) + { + if (r >= l) { + int mid = l + (r - l) / 2; + + // If the element is present at the middle + // itself + if (arr[mid] == x) + return mid; + + // If element is smaller than mid, then it can + // only be present in left subarray + if (arr[mid] > x) + return binarySearch(arr, l, mid - 1, x); + + // Else the element can only be present in right + // subarray + return binarySearch(arr, mid + 1, r, x); + } + + // We reach here when element is not present in + // array + return -1; + } + + // Driver code + public static void main(String[] args) + { + Array_Problem_6 u_i= new Array_Problem_6(); + + int arr1[] = { 7, 1, 5, 2, 3, 6 }; + int arr2[] = { 3, 8, 6, 20, 7 }; + int m = arr1.length; + int n = arr2.length; + + // Function call + System.out.println("Union of two arrays is "); + u_i.printUnion(arr1, arr2, m, n); + System.out.println(""); + System.out.println( + "Intersection of two arrays is "); + u_i.printIntersection(arr1, arr2, m, n); + } + } + diff --git a/data_from_eclipse_ide/arrays/Array_Problem_7.java b/data_from_eclipse_ide/arrays/Array_Problem_7.java new file mode 100644 index 0000000..948018d --- /dev/null +++ b/data_from_eclipse_ide/arrays/Array_Problem_7.java @@ -0,0 +1,42 @@ +package arrays; + +/* + * Write a program to cyclically rotate an array by one. + */ + +public class Array_Problem_7 { + + //function to rotate the elements of an array + + void rotateL(int a[], int d, int n) { + for(int i= 0;i big) + { + temp = small; + small = big; + big = temp; + } + + // Traverse middle elements + for (int i = 1; i < n-1; i ++) + { + int subtract = arr[i] - k; + int add = arr[i] + k; + + // If both subtraction and addition + // do not change diff + if (subtract >= small || add <= big) + continue; + + // Either subtraction causes a smaller number or addition causes a greater number. + // Update small or big using greedy approach (If big - subtract causes smaller difference , + // update small Else update big) + if (big - subtract <= add - small) + small = subtract; + else + big = add; + } + + return Math.min(ans, big - small); + } + + // Driver function to test the above function + public static void main(String[] args) + { + int arr[] = {4, 6}; + int n = arr.length; + int k = 10; + System.out.println("Maximum difference is "+ + getMinDiff(arr, n, k)); + } + +} diff --git a/data_from_eclipse_ide/arrays/Array_of_objects.java b/data_from_eclipse_ide/arrays/Array_of_objects.java new file mode 100644 index 0000000..adb9674 --- /dev/null +++ b/data_from_eclipse_ide/arrays/Array_of_objects.java @@ -0,0 +1,44 @@ +package arrays; + +//Program to demonstrate the array of objects + +//Cricketer class +class Cricketer{ + public int batting_position; + public String name; + + Cricketer(int batting_position, String name) + { + this.batting_position = batting_position; + this.name = name; + } +} + +//Driver Class +public class Array_of_objects { + + //Driver Method + public static void main(String[] args) { + + // Declaring or making the array of type Cricketer , which is known as Array of Objects + Cricketer[] arr; + // array capacity is of storing 5 elements in it. + arr = new Cricketer[11]; + + arr[0 ] = new Cricketer(1, "Rohit Sharma(W.C)"); + arr[1 ] = new Cricketer(2, "Shikhar Dhawan"); + arr[2 ] = new Cricketer(3, "Virat Kohli(C.)"); + arr[3 ] = new Cricketer(4, "K.L Rahul"); + arr[4 ] = new Cricketer(5, "Rishabh Pant(W.K)"); + arr[5 ] = new Cricketer(6, "Hardik Pandaya"); + arr[6 ] = new Cricketer(7, "Bhuvaneshwar Kumar"); + arr[7 ] = new Cricketer(8, "Mohammed Shami"); + arr[8 ] = new Cricketer(9, "Jaspreet Bumrah"); + arr[9 ] = new Cricketer(10, "Yuzvendre Chahal"); + arr[10] = new Cricketer(11, "Kuldeep Yadav"); + + + for(int i = 0 ; i < arr.length ; i++) + System.out.println("Element at index " + i + " : " + "Batting Position: " + arr[i].batting_position + " " + "Player Name: " + arr[i].name); + } +} diff --git a/data_from_eclipse_ide/arrays/Candy_Distribution_Problem.java b/data_from_eclipse_ide/arrays/Candy_Distribution_Problem.java new file mode 100644 index 0000000..806cd6d --- /dev/null +++ b/data_from_eclipse_ide/arrays/Candy_Distribution_Problem.java @@ -0,0 +1,49 @@ +package arrays; +import java.util.*; + +//Language: Java +//Time Complexity: O(n) 3 Linear traversals. +//Space Complexity: O(n) Array of candies. + +public class Candy_Distribution_Problem{ + + public int candy(int[] ratings) { + if (ratings.length < 2) + return ratings.length; + + + int[] candies = new int[ratings.length]; + Arrays.fill(candies, 1); + + // ** Step 1: Forward ** + for (int i=0; i= ratings[i+1]) { + continue; + } + candies[i+1] = candies[i] + 1; + } + + // ** Step 2: Backward ** + for (int i=ratings.length-1; i>0; i--) { + if (ratings[i] >= ratings[i-1]) { + continue; + } + candies[i-1] = Math.max(candies[i] + 1, candies[i-1]); + } + + // ** Step 3: Count Candies ** + int count = 0; + for (int i=0; i= 0 && x < N && y >= 0 + && y < N && maze[x][y] == 1); + } + + /* + * This function solves the Maze problem using Backtracking. + * It mainly uses solvemazeUtil() function to solve the problem. + * It returns false if no path is possible, otherwise return true & + * prints the path in the form of 1s. + * Please note :-> that there may be more than one solutions, + * this function prints one of the feasible solutions. + */ + boolean solveMaze(int maze[][]){ + int sol[][] = new int[N][N]; + + if(solveMazeUtil(maze, 0, 0, sol) == false) { + System.out.print("Solution doesn't exist"); + return false; + } + printSolution(sol); + return true; + } + + /* + * A recursive utility function to solve Maze problem + */ + boolean solveMazeUtil( int maze[][] , int x , int y , int sol[][]) { + + //if (x , y is goal) than return true + if(x == N - 1 && y == N-1 && maze[x][y] == 1) { + sol[x][y] = 1; + return true; + } + + //Check if maze[x][y] is valid + if(isSafe(maze, x, y) == true) { + //mark x, y as part of solution path + sol[x][y] = 1; + + //if moving in x direction doesn't give solution then Move down in y direction + if(solveMazeUtil(maze , x+1 , y , sol)) + return true; + /* + * If none of the above movements works then BACKTRACK: remove mark of x, y as part of solution path + */ + if(solveMazeUtil(maze , x , y+1 , sol)) + return true; + + sol[x][y] = 0; + return false; + } + + return false; + } + + //Driver Method + public static void main(String[] args) { + + Rat_In_A_Maze rat = new Rat_In_A_Maze(); + int maze[][] = {{ 1, 1, 1, 0 }, + { 1, 1, 1, 1 }, + { 1, 1, 1, 1 }, + { 1, 1, 1, 1 } }; + + N = maze.length; + rat.solveMaze(maze); + } //end of main +} //end of class diff --git a/data_from_eclipse_ide/basicProblems/Armstrong_Number.java b/data_from_eclipse_ide/basicProblems/Armstrong_Number.java new file mode 100644 index 0000000..5230826 --- /dev/null +++ b/data_from_eclipse_ide/basicProblems/Armstrong_Number.java @@ -0,0 +1,26 @@ +package basicProblems; +import java.util.*; + +public class Armstrong_Number { + + @SuppressWarnings("resource") + public static void main(String[] args) { + + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + + int sum = 0; + int original_no = n; + + while(n>0) { + int last_digit = n % 10; + sum += Math.pow(last_digit,3); + n=n/10; + } + + if(sum == original_no) System.out.println("Armstrong number"); + else System.out.println("Not Armstrong"); + + } + +} diff --git a/data_from_eclipse_ide/basicProblems/Factorial.class b/data_from_eclipse_ide/basicProblems/Factorial.class new file mode 100644 index 0000000000000000000000000000000000000000..89634d6bd6e83a204a8e7d37834186fbd03e9f1a GIT binary patch literal 1124 zcmaJ=O-~b16g_V`?UZr&wtQH@f`A2)svxMXENnt-0!mV%F|J;R2MnFgG&8S6*7_sd zx^gWGNHFmS_;Xyk5bv8-DQV*@?tLHko_o%{Z+`qf{|;ac>n2R342<+(6k{edj4N|P zZPP;(a?3;pQwF9D+-67=9M6&K46*F|YX-gO?+S+gO~(^28?}lEc6i056TQYAk6|SH zZu5{I@tn)O{ajfFj<=sziM?gX?dle7Vct^Vc@y%%TNZqz9r;=zZ>=^a4(4^3pw03 z@W8@DEHjK&c<9*MflsV!VeVg50=VS;s&Xi7$uQhS%$30MaVSNNK~vgOP34ZCD|z*X zB=LgR@(g3yt{18+h9}<3l1HVey(O}KgVvWo+tk0mKqgl3h#Iv=jmr3Y8J2Ov3?oG~ zUKK^(v$=fZ$OBr1l6x{#!zh*JJI6t~BB?~Q4WG!=RW(;BX)(S!L<6g;nNJyJE?ebz zM}AebCf#Jw?CG(A0zIEi->)|63|2`^ujukH6h!S)dxaK8b8auVx9f^qXY{30 z`a$8Ne(~kv=Lr%M>2nysDUu3Vi;$<0jPNz`y@WqRWYR<@Lw=5`EmOTgibz4bAQLw* k#0+Tky6}sxVi=B~uHy-Llc=pBkH;9tP1+}EuM|!G0c+YBD*ylh literal 0 HcmV?d00001 diff --git a/data_from_eclipse_ide/basicProblems/Factorial.java b/data_from_eclipse_ide/basicProblems/Factorial.java new file mode 100644 index 0000000..c73f54c --- /dev/null +++ b/data_from_eclipse_ide/basicProblems/Factorial.java @@ -0,0 +1,20 @@ +package basicProblems; +import java.util.*; + +public class Factorial { + + public static void main(String[] args) { + + int fact=1; + @SuppressWarnings("resource") + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + + for(int i = n ; i >= 1 ; i--) { + fact = fact*i; + } + System.out.println("fact of " + n + " is " + fact ); + } +} + + diff --git a/data_from_eclipse_ide/basicProblems/Fibonacci_Series.java b/data_from_eclipse_ide/basicProblems/Fibonacci_Series.java new file mode 100644 index 0000000..f1fb26d --- /dev/null +++ b/data_from_eclipse_ide/basicProblems/Fibonacci_Series.java @@ -0,0 +1,26 @@ +package basicProblems; +import java.util.*; + +public class Fibonacci_Series { + + public static void main(String[] args) { + + @SuppressWarnings("resource") + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int a=0,b=1; + + System.out.println("a = " + a + " "); + System.out.println("b = " + b + " "); + System.out.println("Fibonacci Series:"); + + for(int i=0;i 0) { + int rem = n % 10; + System.out.print(rem); + n = n/10; + } + + } + +} diff --git a/data_from_eclipse_ide/basicProblems/Reverse_Given_number.java b/data_from_eclipse_ide/basicProblems/Reverse_Given_number.java new file mode 100644 index 0000000..f3c5371 --- /dev/null +++ b/data_from_eclipse_ide/basicProblems/Reverse_Given_number.java @@ -0,0 +1,22 @@ +package basicProblems; + +import java.util.*; +public class Reverse_Given_number { + + @SuppressWarnings("resource") + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + + int reverse=0; + + while(n>0) { + int last_digit = n % 10; + reverse = reverse*10 + last_digit; + n = n/10; + } + + System.out.println(reverse); + } + +} diff --git a/data_from_eclipse_ide/basicProblems/Series_Sum_1.java b/data_from_eclipse_ide/basicProblems/Series_Sum_1.java new file mode 100644 index 0000000..8d0b704 --- /dev/null +++ b/data_from_eclipse_ide/basicProblems/Series_Sum_1.java @@ -0,0 +1,22 @@ +package basicProblems; +import java.util.*; + +public class Series_Sum_1 { + + public static void main(String[] args) { + + //taking user input + @SuppressWarnings("resource") + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + + float result = 0; + + for(float i=1;i<=n;i++) + result +=1/i; + + System.out.println(result); + + } + +} diff --git a/data_from_eclipse_ide/basicProblems/Series_Sum_2.java b/data_from_eclipse_ide/basicProblems/Series_Sum_2.java new file mode 100644 index 0000000..bb798c9 --- /dev/null +++ b/data_from_eclipse_ide/basicProblems/Series_Sum_2.java @@ -0,0 +1,32 @@ +package basicProblems; +import java.util.Scanner; + +/* This series is also known as TAYLOR series*/ +// program to demonstrate series sum of "1 + 1/2 + 1/3 + 1/4 + 1/5 + ...1 /n" this before mentioned series + +public class Series_Sum_2 { + + public static void main(String[] args) { + + @SuppressWarnings("resource") + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + + float result = 0; + + for(float i=1;i<=n;i++) { + + if(i%2==0) { + result -= 1/i; + } + + else { + result += 1/i; + } + + System.out.println(result); + } + + } + +} diff --git a/data_from_eclipse_ide/basicProblems/Swap_two_numbers.java b/data_from_eclipse_ide/basicProblems/Swap_two_numbers.java new file mode 100644 index 0000000..066a354 --- /dev/null +++ b/data_from_eclipse_ide/basicProblems/Swap_two_numbers.java @@ -0,0 +1,17 @@ +package basicProblems; +import java.util.*; +public class Swap_two_numbers { + + public static void main(String[] args) { + + @SuppressWarnings("resource") + Scanner sc = new Scanner(System.in); + int a = sc.nextInt() , b = sc.nextInt() , swap; + + System.out.println( " elements before swapping " + a + " " + b ); + swap = a; + a = b; + b = swap; + System.out.println( " elements after swapping " + a + " " + b ); + } +} diff --git a/data_from_eclipse_ide/basicProblems/Swapping_2.java b/data_from_eclipse_ide/basicProblems/Swapping_2.java new file mode 100644 index 0000000..dd56abc --- /dev/null +++ b/data_from_eclipse_ide/basicProblems/Swapping_2.java @@ -0,0 +1,24 @@ +package basicProblems; + +/* + * swap two given numbers without using third variable + */ + +public class Swapping_2 { + + public static void main(String[] args) { + + int a = 20; + int b = 40; + + System.out.println("Number's before swapping: " + "a = " + a + "," + " b =" + " " + b); + + a = a + b; + b = a - b; + a = a - b; + + System.out.println("Number's after swapping: " + "a = " + a + "," + " b =" + " " + b); + + } + +} diff --git a/data_from_eclipse_ide/basicProblems/X_raisedTo_power_Y.java b/data_from_eclipse_ide/basicProblems/X_raisedTo_power_Y.java new file mode 100644 index 0000000..36ade66 --- /dev/null +++ b/data_from_eclipse_ide/basicProblems/X_raisedTo_power_Y.java @@ -0,0 +1,18 @@ +package basicProblems; +import java.util.*; +public class X_raisedTo_power_Y { + + public static void main(String[] args) { + + @SuppressWarnings("resource") + Scanner sc= new Scanner(System.in); + int a = sc.nextInt(); + int b = sc.nextInt(); + int result = 1; + for(int i=0;i adq = new ArrayDeque(); + + adq.push("A"); + adq.push("B"); + adq.push("C"); + adq.push("D"); + adq.push("E"); + + System.out.print("Popping the stack:"); + + while(adq.peek()!=null) + System.out.print(adq.pop()+" "); + + System.out.println(); + + } + +} diff --git a/data_from_eclipse_ide/basic_idea_of_DS/ArrayListDemo.java b/data_from_eclipse_ide/basic_idea_of_DS/ArrayListDemo.java new file mode 100644 index 0000000..eaa79d5 --- /dev/null +++ b/data_from_eclipse_ide/basic_idea_of_DS/ArrayListDemo.java @@ -0,0 +1,33 @@ +package basic_idea_of_DS; +import java.util.ArrayList; + +public class ArrayListDemo { + + public static void main(String[] args) { + + //Create an array list + ArrayList al = new ArrayList(); + System.out.println("Initial size of al:" + al.size()); + + //Add elements to array list + al.add("A"); + al.add("M"); + al.add("A"); + al.add("N"); + al.add("S"); + al.add("s1"); + System.out.println("Size of al after additions:" + al.size()); + + //Display the array list + System.out.println("Contents of al:" + al); + + //Remove elements from the array + al.remove("s1"); + + System.out.println("Size of al after deletions:"+ al.size()); + System.out.println("Contents of al:" + al); + + + } + +} diff --git a/data_from_eclipse_ide/basic_idea_of_DS/Graph.java b/data_from_eclipse_ide/basic_idea_of_DS/Graph.java new file mode 100644 index 0000000..91bd1e8 --- /dev/null +++ b/data_from_eclipse_ide/basic_idea_of_DS/Graph.java @@ -0,0 +1,41 @@ +package basic_idea_of_DS; +import java.util.*; + +public class Graph { + + private LinkedList adj[]; + + @SuppressWarnings("unchecked") + public Graph(int v) { + //array of Linked List + adj = new LinkedList[v]; + + for(int i=0;i(); + } + } + + public void addEdge(int source, int destination) { + adj[source].add(destination); + adj[destination].add(source); + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + + System.out.println("Enter number of vertices and edges"); + int v = sc.nextInt(); + int e = sc.nextInt(); + + Graph graph = new Graph(v); + System.out.println("Enter " + e + " edges"); + + for(int i=0;i map = new HashMap<>(); + + // Add elements to the map + map.put("vishal", 10); + map.put("sachin", 30); + map.put("vaibhav", 20); + + // Print size and content + System.out.println("Size of map is:- " + map.size()); + System.out.println(map); + + // Check if a key is present and if present, print value + if ( map.containsKey("vishal")) + { + Integer a = map.get("vishal"); + System.out.println("value for key vishal is:- "+ a); + } + } + +} diff --git a/data_from_eclipse_ide/basic_idea_of_DS/LinkedListDemo.java b/data_from_eclipse_ide/basic_idea_of_DS/LinkedListDemo.java new file mode 100644 index 0000000..2003b66 --- /dev/null +++ b/data_from_eclipse_ide/basic_idea_of_DS/LinkedListDemo.java @@ -0,0 +1,35 @@ +package basic_idea_of_DS; +import java.util.LinkedList; +public class LinkedListDemo { + + public static void main(String[] args) { + // Create a linked list + LinkedList ll = new LinkedList<>(); + + // Add elements to the linked list + ll.add("A"); + ll.add("M"); + ll.add("M"); + ll.add("N"); + ll.add("S"); + ll.addFirst("S1"); + ll.addLast("S2"); + ll.add(1,"A1"); + System.out.println("Original contents of ll:"+ll); + + //Remove elements from the linked list + ll.remove("A1"); + System.out.println("Content of ll after deletion:"+ll); + + //Remove first & last elements + ll.removeFirst(); + ll.removeLast(); + System.out.println("ll after deleting first & last:" + ll); + + //Get & set value + String val = ll.get(2); + ll.set(2, val + "Changed"); + System.out.println("ll after change:"+ll); + } + +} diff --git a/data_from_eclipse_ide/basic_idea_of_DS/List.java b/data_from_eclipse_ide/basic_idea_of_DS/List.java new file mode 100644 index 0000000..d52f469 --- /dev/null +++ b/data_from_eclipse_ide/basic_idea_of_DS/List.java @@ -0,0 +1,14 @@ +package basic_idea_of_DS; + +import java.util.LinkedList; +public class List{ + public static void main(String[] args) { + + LinkedList ll = new LinkedList<>(); + + ll.add("Aman"); + ll.add("Soni"); + ll.add(1, "Kumar"); + System.out.println(ll); + } +} diff --git a/data_from_eclipse_ide/basic_idea_of_DS/MYStackByList.java b/data_from_eclipse_ide/basic_idea_of_DS/MYStackByList.java new file mode 100644 index 0000000..42fd57c --- /dev/null +++ b/data_from_eclipse_ide/basic_idea_of_DS/MYStackByList.java @@ -0,0 +1,121 @@ +package basic_idea_of_DS; + +//Java program to Implement a stack +//using singly linked list +//import package +import static java.lang.System.exit; + +//Create Stack Using Linked list +class StackUsingLinkedlist { + + // A linked list node + private class Node { + + int data; // integer data + Node link; // reference variable Node type + } + // create global top reference variable global + Node top; + // Constructor + StackUsingLinkedlist() + { + this.top = null; + } + + // Utility function to add an element x in the stack + public void push(int x) // insert at the beginning + { + // create new node temp and allocate memory + Node temp = new Node(); + + // initialize data into data field + temp.data = x; + + // put top reference into link + temp.link = top; + + // update top reference + top = temp; + } + + // Utility function to check if the stack is empty or not + public boolean isEmpty() + { + return top == null; + } + + // Utility function to return top element in a stack + public int peek() + { + // check for empty stack + if (!isEmpty()) { + return top.data; + } + else { + System.out.println("Stack is empty"); + return -1; + } + } + + // Utility function to pop top element from the stack + public void pop() // remove at the beginning + { + // check for stack underflow + if (top == null) { + System.out.print("\nStack Underflow"); + return; + } + + // update the top pointer to point to the next node + top = (top).link; + } + + public void display() + { + // check for stack underflow + if (top == null) { + System.out.printf("\nStack Underflow"); + exit(1); + } + else { + Node temp = top; + while (temp != null) { + + // print node data + System.out.printf("%d->", temp.data); + + // assign temp link to temp + temp = temp.link; + } + } + } +} +//main class +public class MYStackByList { + public static void main(String[] args) + { + // create Object of Implementing class + StackUsingLinkedlist obj = new StackUsingLinkedlist(); + // insert Stack value + obj.push(11); + obj.push(22); + obj.push(33); + obj.push(44); + + // print Stack elements + obj.display(); + + // print Top element of Stack + System.out.printf("\nTop element is %d\n", obj.peek()); + + // Delete top element of Stack + obj.pop(); + obj.pop(); + + // print Stack elements + obj.display(); + + // print Top element of Stack + System.out.printf("\nTop element is %d\n", obj.peek()); + } +} diff --git a/data_from_eclipse_ide/basic_idea_of_DS/MyArrayList.java b/data_from_eclipse_ide/basic_idea_of_DS/MyArrayList.java new file mode 100644 index 0000000..bc0609a --- /dev/null +++ b/data_from_eclipse_ide/basic_idea_of_DS/MyArrayList.java @@ -0,0 +1,33 @@ +package basic_idea_of_DS; +import java.util.ArrayList; + +public class MyArrayList { + + public static void main(String[] args) { + + //Create an array list + ArrayList al = new ArrayList(); + System.out.println("Initial size of al:" + al.size()); + + //Add elements to array list + al.add("A"); + al.add("M"); + al.add("A"); + al.add("N"); + al.add("S"); + al.add("s1"); + System.out.println("Size of al after additions:" + al.size()); + + //Display the array list + System.out.println("Contents of al:" + al); + + //Remove elements from the array + al.remove("s1"); + + System.out.println("Size of al after deletions:"+ al.size()); + System.out.println("Contents of al:" + al); + + + } + +} diff --git a/data_from_eclipse_ide/basic_idea_of_DS/MyHashMap.java b/data_from_eclipse_ide/basic_idea_of_DS/MyHashMap.java new file mode 100644 index 0000000..abe8403 --- /dev/null +++ b/data_from_eclipse_ide/basic_idea_of_DS/MyHashMap.java @@ -0,0 +1,28 @@ +package basic_idea_of_DS; +import java.util.HashMap; +public class MyHashMap +{ + + public static void main(String[] args) + { + // Create an empty hash map + HashMap map = new HashMap<>(); + + // Add elements to the map + map.put("vishal", 10); + map.put("sachin", 30); + map.put("vaibhav", 20); + + // Print size and content + System.out.println("Size of map is:- " + map.size()); + System.out.println(map); + + // Check if a key is present and if present, print value + if ( map.containsKey("vishal")) + { + Integer a = map.get("vishal"); + System.out.println("value for key vishal is:- "+ a); + } + } + +} diff --git a/data_from_eclipse_ide/basic_idea_of_DS/MyHashSet.java b/data_from_eclipse_ide/basic_idea_of_DS/MyHashSet.java new file mode 100644 index 0000000..4632e34 --- /dev/null +++ b/data_from_eclipse_ide/basic_idea_of_DS/MyHashSet.java @@ -0,0 +1,21 @@ +package basic_idea_of_DS; + +import java.util.HashSet; + +public class MyHashSet { + + public static void main(String[] args) { + + HashSet hs = new HashSet<>(); + + hs.add("Beta"); + hs.add("Alpha"); + hs.add("Gama"); + hs.add("Eplision"); + hs.add("Omega"); + + System.out.println(hs); + + } + +} diff --git a/data_from_eclipse_ide/basic_idea_of_DS/MyLinkedList.java b/data_from_eclipse_ide/basic_idea_of_DS/MyLinkedList.java new file mode 100644 index 0000000..4d46031 --- /dev/null +++ b/data_from_eclipse_ide/basic_idea_of_DS/MyLinkedList.java @@ -0,0 +1,35 @@ +package basic_idea_of_DS; +import java.util.LinkedList; +public class MyLinkedList { + + public static void main(String[] args) { + // Create a linked list + LinkedList ll = new LinkedList<>(); + + // Add elements to the linked list + ll.add("A"); + ll.add("M"); + ll.add("M"); + ll.add("N"); + ll.add("S"); + ll.addFirst("S1"); + ll.addLast("S2"); + ll.add(1,"A1"); + System.out.println("Original contents of ll:"+ll); + + //Remove elements from the linked list + ll.remove("A1"); + System.out.println("Content of ll after deletion:"+ll); + + //Remove first & last elements + ll.removeFirst(); + ll.removeLast(); + System.out.println("ll after deleting first & last:" + ll); + + //Get & set value + String val = ll.get(2); + ll.set(2, val + "Changed"); + System.out.println("ll after change:"+ll); + } + +} diff --git a/data_from_eclipse_ide/basic_idea_of_DS/MyQueue.java b/data_from_eclipse_ide/basic_idea_of_DS/MyQueue.java new file mode 100644 index 0000000..ac6b1d0 --- /dev/null +++ b/data_from_eclipse_ide/basic_idea_of_DS/MyQueue.java @@ -0,0 +1,82 @@ +//Java program for array implementation of queue +package basic_idea_of_DS; +//A class to represent a queue +class Queue{ + int front, rear, size; + int capacity; + int array[]; + + public Queue(int capacity) { + this.capacity = capacity; + front = this.size = 0; + rear = capacity - 1; + array = new int[this.capacity]; + } + + //Queue is full when size becomes equal to capacity + boolean isFull(Queue queue) { + return(queue.size == queue.capacity); + } + + //Queue is Empty when size is 0 + boolean isEmpty(Queue queue){ + return(queue.size == 0); + } + + //Method to add an item to the queue + //It changes rear and size + void enqueue(int item) { + if(isFull(this)) + return; + this.rear = (this.rear+1)%this.capacity; + this.array[this.rear] = item; + this.size = this.size+1; + System.out.println(item + " enqueud to queue"); + } + + //Method to remove an item from queue + //It changes front and size + int dequeue() { + if(isEmpty(this)) + return Integer.MIN_VALUE; + + int item = this.array[this.front]; + this.front = (this.front + 1) % this.capacity; + this.size = this.size-1; + return item; + + } + + //Method to get front of queue + int front() { + if(isEmpty(this)) + return Integer.MIN_VALUE; + + return this.array[this.front]; + } + + //Method to get rear of queue + int rear() { + if(isEmpty(this)) + return Integer.MIN_VALUE; + + return this.array[this.rear]; + } +} + +//Driver Class +public class MyQueue{ + public static void main(String[] args){ + + Queue queue = new Queue(1000); + + queue.enqueue(10); + queue.enqueue(20); + queue.enqueue(30); + queue.enqueue(40); + + System.out.println(queue.dequeue()+(" dequeued from queue")); + System.out.println("Front item is " + queue.front()); + System.out.println("Rear item is "+ queue.rear()); + } +} diff --git a/data_from_eclipse_ide/basic_idea_of_DS/MyStack.java b/data_from_eclipse_ide/basic_idea_of_DS/MyStack.java new file mode 100644 index 0000000..a3ca5f1 --- /dev/null +++ b/data_from_eclipse_ide/basic_idea_of_DS/MyStack.java @@ -0,0 +1,58 @@ +package basic_idea_of_DS; + + class Stack { + static final int MAX = 1000; + int top; + int a[] = new int[MAX]; + + boolean isEmpty() { + return (top<0); + } + + Stack(){ + top = -1; + } + + boolean push(int x) { + if(top>= (MAX-1)) { + System.out.println(x+"pushed into stack"); + return false; + } + else { + a[++top] = x; + System.out.println(x+"pushed into stack"); + return true; + } + } + + int pop() { + if(top<0) { + System.out.println("Stack underflow"); + return 0; + } + else { + int x = a[top--]; + return x; + } + } + + int peek() { + if(top<0) { + System.out.println("Stack underflow"); + return 0; + } + else { + int x = a[top]; return x; + } + } + + class MyStack{ + public void main (String[] args) { + Stack s = new Stack(); + s.push(10); + s.push(20); + s.push(30); + System.out.println(s.pop() + " Popped from stack"); + } + } +} diff --git a/data_from_eclipse_ide/basic_idea_of_DS/SetExample.java b/data_from_eclipse_ide/basic_idea_of_DS/SetExample.java new file mode 100644 index 0000000..df7ea1d --- /dev/null +++ b/data_from_eclipse_ide/basic_idea_of_DS/SetExample.java @@ -0,0 +1,34 @@ +package basic_idea_of_DS; +// Java program to demonstrate the +// union, intersection and difference +// operations on sets +import java.util.*; +public class SetExample +{ + public static void main(String args[]) + { + Set a = new HashSet(); + a.addAll(Arrays.asList(new Integer[] {1, 3, 2, 4, 8, 9, 0})); + Set b = new HashSet(); + b.addAll(Arrays.asList(new Integer[] {1, 3, 7, 5, 4, 0, 7, 5})); + + // To find union + Set union = new HashSet(a); + union.addAll(b); + System.out.print("Union of the two Set"); + System.out.println(union); + + // To find intersection + Set intersection = new HashSet(a); + + intersection.retainAll(b); + System.out.print("Intersection of the two Set"); + System.out.println(intersection); + + // To find the symmetric difference + Set difference = new HashSet(a); + difference.removeAll(b); + System.out.print("Difference of the two Set"); + System.out.println(difference); + } +} diff --git a/data_from_eclipse_ide/basic_idea_of_DS/Tree.java b/data_from_eclipse_ide/basic_idea_of_DS/Tree.java new file mode 100644 index 0000000..0e79c30 --- /dev/null +++ b/data_from_eclipse_ide/basic_idea_of_DS/Tree.java @@ -0,0 +1,52 @@ +package basic_idea_of_DS; + +//class containing left & right child of current node & key value +class Node{ + int key; + Node left,right; + public Node(int item) { + key = item; + left = right = null; + } +} + +// A java program to introduce Binary Tree +public class Tree { + + //Root node of binary tree + Node root; + + //Constructors + Tree(int key){ + root = new Node(key); + } + + Tree(){ + root = null; + } + public static void main(String[] args) { + Tree t = new Tree(); + //create root + t.root = new Node(1); + + /* following is the tree after above statement + 1 + / \ + null null*/ + + t.root.left = new Node(2); + t.root.right = new Node(3); + /* 2 & 3 become left & right children of 1 + * 1 + * / \ + * 2 3 + * / \ | \ + * null null null null + */ + t.root.left.left = new Node(4); + t.root.right.right = new Node(5); + t.root.right.left = new Node(6); + t.root.left.right = new Node(7); + + } +} diff --git a/data_from_eclipse_ide/basics/ControlStatements.java b/data_from_eclipse_ide/basics/ControlStatements.java new file mode 100644 index 0000000..fd9f096 --- /dev/null +++ b/data_from_eclipse_ide/basics/ControlStatements.java @@ -0,0 +1,29 @@ +package basics; + +public class ControlStatements { + + public static void main(String[] args) { + + // for loop to implement switch case statement + for(int i = 0 ; i < 9 ; i++){ + + // switch control statement + switch(i) { + case 1: + System.out.println(" i is zero."); + break; + case 2: + System.out.println(" i is one."); + break; + case 3: + System.out.println(" i is zero."); + break; + default: + System.out.println(" i is greater than 3."); + } + + } + } +} + + diff --git a/data_from_eclipse_ide/basics/DoWhileLoop.java b/data_from_eclipse_ide/basics/DoWhileLoop.java new file mode 100644 index 0000000..a13f4c4 --- /dev/null +++ b/data_from_eclipse_ide/basics/DoWhileLoop.java @@ -0,0 +1,15 @@ +package basics; + +public class DoWhileLoop { + //method inside which do while loop will occur + public static void main(String[] args) { + + int n = 10; + //do while loop's do block + // must executes atleast once + do { + System.out.println(" tick " +n); + n--; + }while(n>0);// do while loop's while block + } // end of main method +}// end of class diff --git a/data_from_eclipse_ide/basics/Fast_Inputs_Main.java b/data_from_eclipse_ide/basics/Fast_Inputs_Main.java new file mode 100644 index 0000000..edd6bc2 --- /dev/null +++ b/data_from_eclipse_ide/basics/Fast_Inputs_Main.java @@ -0,0 +1,63 @@ +package basics; + +import java.io.OutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintWriter; +import java.util.StringTokenizer; +import java.io.IOException; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.InputStream; + + +// Remember that the class name should be "Main" and should be "public". +@SuppressWarnings("unused") +public class Fast_Inputs_Main { + public static void main(String[] args) { + // System.in and System.out are input and output streams, respectively. + InputStream inputStream = System.in; + + InputReader in = new InputReader(inputStream); + + int n = in.nextInt(); + int k = in.nextInt(); + + int ans = 0; + + for (int i = 0; i < n; i++) { + int x = in.nextInt(); + + if (x % k == 0) { + ans++; + } + } + + System.out.println(ans); + } + + static class InputReader { + public BufferedReader reader; + public StringTokenizer tokenizer; + + public InputReader(InputStream stream) { + reader = new BufferedReader(new InputStreamReader(stream), 32768); + tokenizer = null; + } + + public String next() { + while (tokenizer == null || !tokenizer.hasMoreTokens()) { + try { + tokenizer = new StringTokenizer(reader.readLine()); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + return tokenizer.nextToken(); + } + + public int nextInt() { + return Integer.parseInt(next()); + } + } +} diff --git a/data_from_eclipse_ide/basics/Operators.java b/data_from_eclipse_ide/basics/Operators.java new file mode 100644 index 0000000..0af28ee --- /dev/null +++ b/data_from_eclipse_ide/basics/Operators.java @@ -0,0 +1,17 @@ +package basics; + +public class Operators { + + public static void main(String[] args) { + int a = 7,b= 6; + int c = a*b; //* (multiplication) operator + int d = a+b; // + addition operator + int e = a/b; // - subtraction operator + int f = a%b; // % modulus operator + int g = a^b; // ^ power operator + long h = b^a; + System.out.println(c + " " + d + " " + e + " " + f + " " + g + " " + h); + + } + +} diff --git a/data_from_eclipse_ide/basics/VariablesandDataTypes.java b/data_from_eclipse_ide/basics/VariablesandDataTypes.java new file mode 100644 index 0000000..111d443 --- /dev/null +++ b/data_from_eclipse_ide/basics/VariablesandDataTypes.java @@ -0,0 +1,15 @@ +package basics; + +public class VariablesandDataTypes { + + public static void main(String[] args) { + + int age = 18; // integer data type + String name = "Aman"; // String data type + long number = 7023; // long data type + String address ="Behind Fort"; + System.out.println(age + " " + name + " " + number + " " + address); + + } + +} diff --git a/data_from_eclipse_ide/basics/WhileLoop.java b/data_from_eclipse_ide/basics/WhileLoop.java new file mode 100644 index 0000000..c54afa3 --- /dev/null +++ b/data_from_eclipse_ide/basics/WhileLoop.java @@ -0,0 +1,14 @@ +package basics; + +public class WhileLoop { + + public static void main(String[] args) { + + int n = 5; + while(n>0) { + System.out.println(" tick " + n); + // post subtraction operator + n--; + } + } + } diff --git a/data_from_eclipse_ide/binaryTree/BT_Problem_01.java b/data_from_eclipse_ide/binaryTree/BT_Problem_01.java new file mode 100644 index 0000000..09d155b --- /dev/null +++ b/data_from_eclipse_ide/binaryTree/BT_Problem_01.java @@ -0,0 +1,49 @@ +package binaryTree; +import java.util.*; + +// Find Level order traversal of binary tree +class Node{ + int data; + Node left, right; + + public Node(int item) { + data = item; + left = null; + right = null; + } +} +public class BT_Problem_01 { + + Node root; + + void printLevelOrder() { + Queue queue = new LinkedList<>(); + queue.add(root); + + while(!queue.isEmpty()) { + + Node tempNode = queue.poll(); + System.out.print(tempNode.data + " "); + + if(tempNode.left != null) + queue.add(tempNode.left); + + if(tempNode.right != null) + queue.add(tempNode.right); + } + } + public static void main(String[] args) { + + BT_Problem_01 tree_level = new BT_Problem_01(); + + tree_level.root = new Node(1); + tree_level.root.left = new Node(2); + tree_level.root.right = new Node(3); + tree_level.root.left.left = new Node(4); + tree_level.root.left.right = new Node(5); + + System.out.println("Level order traversal of binary tree is - "); + tree_level.printLevelOrder(); + } + +} diff --git a/data_from_eclipse_ide/binaryTree/BT_Problem_02.java b/data_from_eclipse_ide/binaryTree/BT_Problem_02.java new file mode 100644 index 0000000..2fc079d --- /dev/null +++ b/data_from_eclipse_ide/binaryTree/BT_Problem_02.java @@ -0,0 +1,10 @@ +package binaryTree; + +public class BT_Problem_02 { + + public static void main(String[] args) { + + + } + +} diff --git a/data_from_eclipse_ide/dp/CoinChoiseProblem.java b/data_from_eclipse_ide/dp/CoinChoiseProblem.java new file mode 100644 index 0000000..e20304e --- /dev/null +++ b/data_from_eclipse_ide/dp/CoinChoiseProblem.java @@ -0,0 +1,51 @@ +package dp; + +import java.util.*; + +public class CoinChoiseProblem { + + public static void main(String[] args) { + + + int n = 18; + int a[] = {7, 5, 1}; + int dp[] = new int[n+1]; + + Arrays.fill(dp, -1); + dp[0] = 0; + + int ans = minCoins(n, a, dp); + System.out.println(ans); + + for(int x: dp) + System.out.println(x + " "); + } + + static int minCoins(int n, int a[], int dp[]) { + + if(n == 0) + return 0; + + int ans = Integer.MAX_VALUE; + + for(int i = 0; i= 0) { + + int subAns = 0; + + if(dp[n-a[i]] != -1) + subAns = dp[n-a[i]]; + + else + subAns = minCoins(n-a[i],a, dp); + + if(subAns != Integer.MAX_VALUE && subAns + 1 < ans) + ans = subAns + 1; + } + } + + return dp[n] = ans; + + } +} diff --git a/data_from_eclipse_ide/graphs/Graph.java b/data_from_eclipse_ide/graphs/Graph.java new file mode 100644 index 0000000..6bf1150 --- /dev/null +++ b/data_from_eclipse_ide/graphs/Graph.java @@ -0,0 +1,41 @@ +package graphs; +import java.util.*; + +public class Graph { + + private LinkedList adj[]; + + @SuppressWarnings("unchecked") + public Graph(int v) { + //array of Linked List + adj = new LinkedList[v]; + + for(int i=0;i(); + } + } + + public void addEdge(int source, int destination) { + adj[source].add(destination); + adj[destination].add(source); + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + + System.out.println("Enter number of vertices and edges"); + int v = sc.nextInt(); + int e = sc.nextInt(); + + Graph graph = new Graph(v); + System.out.println("Enter " + e + " edges"); + + for(int i=0;i adj[]; + + @SuppressWarnings("unchecked") + public Graph_Traversal_DFS(int v){ + adj = new LinkedList[v]; + for(int i = 0 ; i < v ; ++i) + adj[i] = new LinkedList(); + } + + void addEdge(int v, int w) { + adj[v].add(w); + } + + void DFSUtil(int v, boolean visited[]) { + visited[v] = true; + System.out.println(v + " "); + + Iterator i = adj[v].listIterator(); + while(i.hasNext()) { + int n = i.next(); + if(!visited[n]) + DFSUtil(n,visited); + } + } + + void DFS(int v) { + boolean visited[] = new boolean[v]; + DFSUtil(v,visited); + } + + public static void main(String[] args) { + + Graph_Traversal_DFS d = new Graph_Traversal_DFS(4); + + d.addEdge(0, 1); + d.addEdge(0, 2); + d.addEdge(1, 2); + d.addEdge(2, 0); + d.addEdge(2, 3); + d.addEdge(3, 3); + + System.out.println( + "Following is Depth First Traversal " + + "(starting from vertex 2)"); + + d.DFS(2); + + } + +} diff --git a/data_from_eclipse_ide/linkedList/Deletion_in_Linked_List.java b/data_from_eclipse_ide/linkedList/Deletion_in_Linked_List.java new file mode 100644 index 0000000..9385416 --- /dev/null +++ b/data_from_eclipse_ide/linkedList/Deletion_in_Linked_List.java @@ -0,0 +1,100 @@ +package linkedList; + +class LinkedList +{ + Node head; // head of list + + /* Linked list Node*/ + class Node + { + int data; + Node next; + Node(int d) + { + data = d; + next = null; + } + } + + /* Inserts a new Node at front of the list. */ + public void push(int new_data) + { + /* 1 & 2: Allocate the Node & + Put in the data*/ + Node new_node = new Node(new_data); + + /* 3. Make next of new Node as head */ + new_node.next = head; + + /* 4. Move the head to point to new Node */ + head = new_node; + } + + /* Given a reference (pointer to pointer) to the head of a list + and a position, deletes the node at the given position */ + void deleteNode(int position) + { + // If linked list is empty + if (head == null) + return; + + // Store head node + Node temp = head; + + // If head needs to be removed + if (position == 0) + { + head = temp.next; // Change head + return; + } + + // Find previous node of the node to be deleted + for (int i=0; temp!=null && inext is the node to be deleted + // Store pointer to the next of node to be deleted + Node next = temp.next.next; + + temp.next = next; // Unlink the deleted node from list + } + + /* This function prints contents of linked list starting from + the given node */ + public void printList() + { + Node tnode = head; + while (tnode != null) + { + System.out.print(tnode.data+" "); + tnode = tnode.next; + } + } + + /* Driver program to test above functions. Ideally this function + should be in a separate user class. It is kept here to keep + code compact */ + public static void main(String[] args) + { + /* Start with the empty list */ + LinkedList llist = new LinkedList(); + + llist.push(7); + llist.push(1); + llist.push(3); + llist.push(2); + llist.push(8); + + System.out.println("\nCreated Linked list is: "); + llist.printList(); + + llist.deleteNode(4); // Delete node at position 4 + + System.out.println("\nLinked List after Deletion at position 4: "); + llist.printList(); + } +} \ No newline at end of file diff --git a/data_from_eclipse_ide/linkedList/Insertion_in_Linked_List.java b/data_from_eclipse_ide/linkedList/Insertion_in_Linked_List.java new file mode 100644 index 0000000..a1900ba --- /dev/null +++ b/data_from_eclipse_ide/linkedList/Insertion_in_Linked_List.java @@ -0,0 +1,99 @@ +package linkedList; + +public class Insertion_in_Linked_List { + + class Node{ + int data; + Node next; + + Node(int d){ + data = d; + next = null; + } + } + + Node head; + + public void push(int new_data ) { + Node new_node = new Node(new_data); + new_node.next = head; + head = new_node; + } + + public void insertAfter(Node prev_node, int new_data) + { + /* 1. Check if the given Node is null */ + if (prev_node == null) + { + System.out.println("The given previous node cannot be null"); + return; + } + + /* 2 & 3: Allocate the Node & Put in the data*/ + Node new_node = new Node(new_data); + + /* 4. Make next of new Node as next of prev_node */ + new_node.next = prev_node.next; + + /* 5. make next of prev_node as new_node */ + prev_node.next = new_node; + } + + public void append(int new_data) { + + //make an object of above mentioned Node class + Node new_node = new Node(new_data); + + if(head == null) { + head = new_node; + return; + } + + new_node.next = null; + + Node last = head; + while (last.next != null) + last = last.next; + + last.next = new_node; + return; + } + + public void printList() + { + Node tnode = head; + while (tnode != null) + { + System.out.print(tnode.data+" "); + tnode = tnode.next; + } + } + + public static void main(String[] args) { + Insertion_in_Linked_List llist = new Insertion_in_Linked_List(); + /* Start with the empty list */ + + // Insert 6. So linked list becomes 6->NUllist + llist.append(6); + + // Insert 7 at the beginning. So linked list becomes + // 7->6->NUllist + llist.push(7); + + // Insert 1 at the beginning. So linked list becomes + // 1->7->6->NUllist + llist.push(1); + + // Insert 4 at the end. So linked list becomes + // 1->7->6->4->NUllist + llist.append(4); + + // Insert 8, after 7. So linked list becomes + // 1->7->8->6->4->NUllist + llist.insertAfter(llist.head.next, 8); + + System.out.println("\nCreated Linked list is: "); + llist.printList(); + } + +} diff --git a/data_from_eclipse_ide/linkedList/MainList.java b/data_from_eclipse_ide/linkedList/MainList.java new file mode 100644 index 0000000..0d9bd2c --- /dev/null +++ b/data_from_eclipse_ide/linkedList/MainList.java @@ -0,0 +1,18 @@ +package linkedList; +public class MainList { + + public static void main(String[] args) { + + MyLL myll = new MyLL(); + + + myll.add(0); + myll.add(1); + myll.add(2); + myll.add(3); + myll.add(4); + + myll.print(); + } + +} diff --git a/data_from_eclipse_ide/linkedList/MyLL.java b/data_from_eclipse_ide/linkedList/MyLL.java new file mode 100644 index 0000000..cd9883c --- /dev/null +++ b/data_from_eclipse_ide/linkedList/MyLL.java @@ -0,0 +1,53 @@ +package linkedList; + +public class MyLL { + + static class Node{ + int data; + Node next; + + public Node(int data) { + this.data = data; + next = null; + } + } + + Node head; + Node position; + + void add(int data) { + Node toAdd = new Node(data); + + if(isEmpty()) { + head = toAdd; + return; + } + + Node temp = head; + while(temp.next != null) { + temp = temp.next; + } + temp.next = toAdd; + } + + void print() { + Node temp = head; + while(temp != null) { + System.out.println(temp.data + " "); + temp = temp.next; + } + + } + + boolean isEmpty() { + return head == null; + } + + void remove(int data) { + head = null; + } + + boolean isValue() { + return head == position; + } +} diff --git a/data_from_eclipse_ide/linkedList/Problem_1_1.java b/data_from_eclipse_ide/linkedList/Problem_1_1.java new file mode 100644 index 0000000..060090d --- /dev/null +++ b/data_from_eclipse_ide/linkedList/Problem_1_1.java @@ -0,0 +1,63 @@ +package linkedList; + +/* + * Write a Program to Reverse the Linked List Iteratively + */ + +public class Problem_1_1 { + + static Node head; + + static class Node{ + int data; + Node next; + Node(int d){ + data = d; + next = null; + } + } + + Node reverse (Node node) { + + Node prev = null; + Node current = node; + Node next = null; + + while(current != null) { + next = current.next; + current.next = prev; + prev = current; + current = next; + } + + node = prev; + return node; + } + + void printList(Node node) { + while(node != null) { + System.out.println(node.data + " "); + node = node.next; + } + } + + @SuppressWarnings("static-access") + public static void main(String[] args) { + + Problem_1_1 list = new Problem_1_1(); + + list.head = new Node(85); + list.head.next = new Node(15); + list.head.next.next = new Node(4); + list.head.next.next.next = new Node(20); + + System.out.println("Given Linked list"); + list.printList(head); + head = list.reverse(head); + System.out.println(" "); + System.out.println("Reversed linked list "); + list.printList(head); + + } + +} diff --git a/data_from_eclipse_ide/linkedList/Problem_1_2.java b/data_from_eclipse_ide/linkedList/Problem_1_2.java new file mode 100644 index 0000000..4744322 --- /dev/null +++ b/data_from_eclipse_ide/linkedList/Problem_1_2.java @@ -0,0 +1,67 @@ +package linkedList; + +/* + * Write a Program to Reverse the LinkedList Recursively + */ + +public class Problem_1_2 { + + static Node head; + + static class Node{ + int data; + Node next; + Node(int d){ + data = d; + next = null; + } + } + + static Node reverse(Node head) { + if(head == null || head.next == null) { + return head; + } + + Node rest = reverse(head.next); + head.next.next = head; + + + head.next = null; + + return rest; + } + + + static void print() { + Node temp = head; + while(temp != null) { + System.out.print(temp.data + " "); + temp = temp.next; + } + System.out.println(); + } + + static void push(int data) { + Node temp = new Node(data); + temp.next = head; + head = temp; + } + + public static void main(String[] args) { + + push(20); + push(4); + push(15); + push(85); + + System.out.println("Given linked list"); + print(); + + head = reverse(head); + + System.out.println("Reversed Linked list"); + print(); + + } + +} diff --git a/data_from_eclipse_ide/linkedList/Queue.java b/data_from_eclipse_ide/linkedList/Queue.java new file mode 100644 index 0000000..4df4cc3 --- /dev/null +++ b/data_from_eclipse_ide/linkedList/Queue.java @@ -0,0 +1,157 @@ +package linkedList; +import java.util.*; + +/* + * Code: Queue Using LL + * + * Send Feedback: + * You need to implement a Queue class using linked list. + * All the required data members should be private. + * + * Implement the following public functions: + * 1. Constructor - Initialise's the data members. + * 2. enqueue - This function should take one argument of type T and has return type void. + * This function should insert an element in the queue. + * Time complexity should be O(1). + * 3. dequeue - This function takes no arguments and has return type T. + * This should removes the first element which is entered and return that element as an answer. + * Time complexity should be O(1). + * 4. front - This function takes no input arguments and has return type T. + * This should return the first element which is entered and return that element as an answer. + * Time complexity should be O(1). + * 5. size - Return the size of stack i.e. count of elements which are present ins stack right now. + * Time complexity should be O(1). + * 6. isEmpty - Checks if the queue is empty or not. + * Return true or false + * + */ + +class QueueEmptyException extends Exception { + + private static final long serialVersionUID = 7243921724361015813L; + + public static void main(String[] args) { + + @SuppressWarnings("resource") + Scanner s = new Scanner(System.in); + + Queue st = new Queue(); + + int choice = s.nextInt(); + int input; + + while (choice !=-1) { + + if(choice == 1) { + input = s.nextInt(); + st.enqueue(input); + } + + else if(choice == 2) { + + try { + System.out.println(st.dequeue()); + }catch (QueueEmptyException e) { + System.out.println(-1); + } + } + + else if(choice == 3) { + + try { + System.out.println(st.front()); + } catch (QueueEmptyException e) { + System.out.println(-1); + } + } + + else if(choice == 4) + System.out.println(st.size()); + + else if(choice == 5) + System.out.println(st.isEmpty()); + + choice = s.nextInt(); + } + } +} + +class Node { + T data; + Node next; + + public Node(T data) { + this.data = data; + } +} + +public class Queue { + + private Node front; + private Node rear; + private int size; + + + public Queue() { + front=null; + rear=null; + size=0; + + } + + public int size() { + return size; + } + + public boolean isEmpty() { + return (size==0); + } + + public T front() throws QueueEmptyException { + + if(size==0) + throw new QueueEmptyException(); + + return front.data; + } + + public void enqueue(T data) { + + if(size==0){ + Node newnode=new Node(data); + front=newnode; + rear=newnode; + size++; + } + + else{ + Node newnode=new Node(data); + rear.next=newnode; + rear=rear.next; + size++; + } + } + + + public T dequeue() throws QueueEmptyException { + + if(size==0) + throw new QueueEmptyException(); + + if(size==1){ + T temp=front.data; + front=null; + rear=null; + size=0; + return temp; + } + + else{ + T temp = front.data; + front = front.next; + size--; + return temp; + } + } + +} \ No newline at end of file diff --git a/data_from_eclipse_ide/matrix/Matrix_Problem_01.java b/data_from_eclipse_ide/matrix/Matrix_Problem_01.java new file mode 100644 index 0000000..5b34422 --- /dev/null +++ b/data_from_eclipse_ide/matrix/Matrix_Problem_01.java @@ -0,0 +1,87 @@ +package matrix; +import java.io.*; + +/* + * Spiral traversal on a Matrix + */ + +/* + * GIven an 2D array, print it in spiral form. + * See the following examples. + * + * Inputs: + * 01 02 03 04 + * 05 06 07 08 + * 09 10 11 12 + * 13 14 15 16 + * + * Output: + * 1 2 3 4 8 12 16 15 14 13 9 5 6 7 11 10 + * + * Explanation: + * The output is matrix in spiral format. + */ + +/* Graphical Try: + * + * 01-- 02-- 03-- 04 + * | + * 05-- 06-- 07 08 + * | | | + * 09 10 11 12 + * | | + * 13-- 14-- 15 --16 + * + * Output: + * 1, 2, 3, 4, 8, 12, 16, 15, 14, 13, 9, 5, 6, 7, 11, 10 + */ + +@SuppressWarnings("unused") +public class Matrix_Problem_01 { + + static void spiralPrint(int m, int n, int[][] a) { + + System.out.println("Spiral Traversal of given matrix is: "); + int i, k = 0, l = 0; + + /* + * k - starting row index + * m - ending row index + * l - starting column index + * n - ending column index + * i - iterator + */ + + while(k < m && l < n) { + + + for( i = l ; i < n ; ++i) + System.out.print(a[k][i] + " "); + k++; + + for(i = k ; i < m ; ++i) + System.out.print(a[i][n - 1] + " "); + n--; + + if(l < n) { + for(i = m - 1 ; i >= k ; --i) + System.out.print(a[i][l] + " "); + l++; + } + } + + } + + public static void main(String[] args) { + + int R = 3; + int C = 6; + int a[][] = { { 1 , 2 , 3 , 4 , 5 , 6 }, + { 7 , 8 , 9 , 10 , 11 , 12 }, + { 13 , 14 , 15 , 16 , 17 , 18 } + }; + + spiralPrint(R,C,a); + } + +} diff --git a/data_from_eclipse_ide/matrix/Matrix_Problem_02.java b/data_from_eclipse_ide/matrix/Matrix_Problem_02.java new file mode 100644 index 0000000..1de28d7 --- /dev/null +++ b/data_from_eclipse_ide/matrix/Matrix_Problem_02.java @@ -0,0 +1,123 @@ +package matrix; + +//Search an element in a matrix + +/* + * Example; + * Consider: | 1 2 3 4| + * x = 3, + * mat = | 5 6 7 8| Middle column: + * | 9 10 11 12| = {2, 6, 10, 14} + * |13 14 15 16| + * perform binary search on them + * since, x < 6, + * discard the last 2 rows as 'a' will not lie in them(sorted matrix) + * Now, only two rows are left + * | 1 2 3 4| + * x = 3, mat = | 5 6 7 8| + * + * Check whether element is present on the middle elements of these rows = {2, 6} + * + * If x != 2 or 6 + * + * If not, consider the four sub-parts + * 1st half of 1st row = {1}, 2nd half of 1st row = {3, 4} + * 1st half of 2nd row = {5}, 2nd half of 2nd row = {7, 8} + * + * According the value of 'x' it will be searched in the + * 2nd half of 1st row = {3, 4} and found at (i, j): (0, 2) + */ +public class Matrix_Problem_02 { + + static int MAX = 100; + + static void binarySearch(int mat[][], int i, int j_low, int j_high, int x) { + + while(j_low <= j_high) { + + int j_mid = (j_low + j_high)/2; + + if(mat[i][j_mid] == x) { + System.out.println("Found at (" + i + "," + j_mid + ")"); + return; + } + + else if(mat[i][j_mid] < x) + j_high = j_mid - 1; + + else + j_low = j_mid + 1; + } + + System.out.println("Element Not Found: "); + } + + static void sortedMatrixSearch(int mat[][], int n, int m, int x) { + + + // Single row matrix + if (n == 1) + { + binarySearch(mat, 0, 0, m - 1, x); + return; + } + + // Do binary search in middle column. + // Condition to terminate the loop when the 2 desired rows are found + int i_low = 0; + int i_high = n - 1; + int j_mid = m / 2; + + while ((i_low + 1) < i_high) + { + int i_mid = (i_low + i_high) / 2; + + // element found + if (mat[i_mid][j_mid] == x) + { + System.out.println ( "Found at (" + i_mid +", " + j_mid +")"); + return; + } + + else if (mat[i_mid][j_mid] > x) + i_high = i_mid; + + else + i_low = i_mid; + } + + // If element is present on the mid of the two rows + if (mat[i_low][j_mid] == x) + System.out.println ( "Found at (" + i_low + "," + j_mid +")"); + + else if (mat[i_low + 1][j_mid] == x) + System.out.println ( "Found at (" + (i_low + 1) + ", " + j_mid +")"); + + // Search element on 1st half of 1st row + else if (x <= mat[i_low][j_mid - 1]) + binarySearch(mat, i_low, 0, j_mid - 1, x); + + // Search element on 2nd half of 1st row + else if (x >= mat[i_low][j_mid + 1] && x <= mat[i_low][m - 1]) + binarySearch(mat, i_low, j_mid + 1, m - 1, x); + + // Search element on 1st half of 2nd row + else if (x <= mat[i_low + 1][j_mid - 1]) + binarySearch(mat, i_low + 1, 0, j_mid - 1, x); + + // search element on 2nd half of 2nd row + else + binarySearch(mat, i_low + 1, j_mid + 1, m - 1, x); + } + + public static void main(String[] args) { + int n = 4, m = 5, x = 8; + int mat[][] = {{0, 6, 8, 9, 11}, + {20, 22, 28, 29, 31}, + {36, 38, 50, 61, 63}, + {64, 66, 100, 122, 128}}; + + sortedMatrixSearch(mat, n, m, x); + } + +} diff --git a/data_from_eclipse_ide/oops/A.java b/data_from_eclipse_ide/oops/A.java new file mode 100644 index 0000000..aec9a69 --- /dev/null +++ b/data_from_eclipse_ide/oops/A.java @@ -0,0 +1,10 @@ +package oops; + +public class A { + class B{ + int age; + } + static class C{ + String name; + } +} diff --git a/data_from_eclipse_ide/oops/MYStaticKeyword.java b/data_from_eclipse_ide/oops/MYStaticKeyword.java new file mode 100644 index 0000000..181746e --- /dev/null +++ b/data_from_eclipse_ide/oops/MYStaticKeyword.java @@ -0,0 +1,22 @@ +package oops; +import oops.A.C; +public class MYStaticKeyword { + + static { + System.out.println("in block 1"); + } + static { + System.out.println("in block 2"); + } + + public static void main(String[] args) { + + A objA = new A(); + @SuppressWarnings("unused") + A.B objB = objA.new B(); + @SuppressWarnings("unused") + C objC = new A.C(); + System.out.println("inside main"); + } + +} diff --git a/data_from_eclipse_ide/oops/Mor.java b/data_from_eclipse_ide/oops/Mor.java new file mode 100644 index 0000000..31ccaa6 --- /dev/null +++ b/data_from_eclipse_ide/oops/Mor.java @@ -0,0 +1,15 @@ +package oops; + +public class Mor extends Watches { + + //overrided function + @Override + public void Digital() { + System.out.println("Method_overriding is digital"); + } + //second function + public void Royal() { + System.out.println("Method_overriding is royal"); + } + +} diff --git a/data_from_eclipse_ide/oops/MyConstructor.java b/data_from_eclipse_ide/oops/MyConstructor.java new file mode 100644 index 0000000..d5ebf6b --- /dev/null +++ b/data_from_eclipse_ide/oops/MyConstructor.java @@ -0,0 +1,13 @@ +package oops; + +public class MyConstructor { + + MyConstructor(){ + System.out.println("Obj is now created"); + } + public static void main(String[] args) { + @SuppressWarnings("unused") + MyConstructor obj = new MyConstructor(); + } + +} diff --git a/data_from_eclipse_ide/oops/Person.java b/data_from_eclipse_ide/oops/Person.java new file mode 100644 index 0000000..d17564a --- /dev/null +++ b/data_from_eclipse_ide/oops/Person.java @@ -0,0 +1,7 @@ +package oops; + +public class Person { +int age; +String name; +final static String breed = "HomoSapiens"; +} diff --git a/data_from_eclipse_ide/oops/RepairShop.java b/data_from_eclipse_ide/oops/RepairShop.java new file mode 100644 index 0000000..f119ee3 --- /dev/null +++ b/data_from_eclipse_ide/oops/RepairShop.java @@ -0,0 +1,20 @@ +package oops; + +public class RepairShop { + + + public static void repair (Watches ws) { + System.out.println("watch is repaired"); + } + public static void repair(Sonata sn) { + System.out.println("watch is repaired"); + } + public static void main(String[] args) { + Mor Mo = new Mor(); + Sonata sn = new Sonata(); + + repair(Mo); + repair(sn); + } + +} diff --git a/data_from_eclipse_ide/oops/Sonata.java b/data_from_eclipse_ide/oops/Sonata.java new file mode 100644 index 0000000..7d8972d --- /dev/null +++ b/data_from_eclipse_ide/oops/Sonata.java @@ -0,0 +1,12 @@ +package oops; + +public class Sonata extends Watches{ + + @Override + public void Digital() { + System.out.println("Sonata is digital"); + } + public void Royal() { + System.out.println("Sonata is royal"); + } +} diff --git a/data_from_eclipse_ide/oops/StaticKeyword.java b/data_from_eclipse_ide/oops/StaticKeyword.java new file mode 100644 index 0000000..7ae5504 --- /dev/null +++ b/data_from_eclipse_ide/oops/StaticKeyword.java @@ -0,0 +1,13 @@ +package oops; + +public class StaticKeyword { + public static void main(String[] args) { + Person obj = new Person(); + obj.name ="Aman"; + obj.age = 19; + System.out.println(obj.name); + System.out.println(obj.age + " age"); + System.out.println(Person.breed); + } + +} diff --git a/data_from_eclipse_ide/oops/Vehicle.java b/data_from_eclipse_ide/oops/Vehicle.java new file mode 100644 index 0000000..b6058cb --- /dev/null +++ b/data_from_eclipse_ide/oops/Vehicle.java @@ -0,0 +1,19 @@ +package oops; + +class transport{ + int wheels; + transport(){ + wheels = 4; + } +} + +public class Vehicle { + + public static void main(String[] args) { + + transport car = new transport(); + System.out.println(car.wheels + " wheels"); + + } + +} diff --git a/data_from_eclipse_ide/oops/Watches.java b/data_from_eclipse_ide/oops/Watches.java new file mode 100644 index 0000000..863a6d9 --- /dev/null +++ b/data_from_eclipse_ide/oops/Watches.java @@ -0,0 +1,8 @@ +package oops; + +public abstract class Watches { + + public abstract void Digital(); + public abstract void Royal(); + +} diff --git a/data_from_eclipse_ide/oopsEncapsulation/EncapIntro.java b/data_from_eclipse_ide/oopsEncapsulation/EncapIntro.java new file mode 100644 index 0000000..e069086 --- /dev/null +++ b/data_from_eclipse_ide/oopsEncapsulation/EncapIntro.java @@ -0,0 +1,17 @@ +package oopsEncapsulation; + +public class EncapIntro { + + public static void main(String[] args) { + + S obj = new S(); + + obj.setName("Milan"); + obj.setAge(16); + System.out.println(obj.getName()); + System.out.println(obj.getAge()); + + + } + +} diff --git a/data_from_eclipse_ide/oopsEncapsulation/S.java b/data_from_eclipse_ide/oopsEncapsulation/S.java new file mode 100644 index 0000000..bb69bb6 --- /dev/null +++ b/data_from_eclipse_ide/oopsEncapsulation/S.java @@ -0,0 +1,31 @@ +package oopsEncapsulation; + +//Student class short name as S +public class S { + + /*we have to put the variables private to achieve encapsulation*/ + private int age; + + private String name; + + //setter methods + public void setAge(int age) { + if(age>20) System.out.println(" You are to old:"); + else this.age = age; + } + + public void setName(String name) { + this.name = name; + } + + //getter methods + public int getAge() { + return age; + } + + public String getName() { + return name; + } + + +} diff --git a/data_from_eclipse_ide/oopsabstraction/Audi.java b/data_from_eclipse_ide/oopsabstraction/Audi.java new file mode 100644 index 0000000..2475df8 --- /dev/null +++ b/data_from_eclipse_ide/oopsabstraction/Audi.java @@ -0,0 +1,15 @@ +package oopsabstraction; +//Audi Class + +public class Audi extends Car{ + + public void accelerate() { + System.out.println("Audi is accelerating"); + } + @Override + public void apply_break() { + System.out.println("Audi is breaking"); + + } + +} diff --git a/data_from_eclipse_ide/oopsabstraction/Car.java b/data_from_eclipse_ide/oopsabstraction/Car.java new file mode 100644 index 0000000..dceb3b5 --- /dev/null +++ b/data_from_eclipse_ide/oopsabstraction/Car.java @@ -0,0 +1,8 @@ +package oopsabstraction; + +public abstract class Car { + + public abstract void accelerate(); + public abstract void apply_break(); + +} diff --git a/data_from_eclipse_ide/oopsabstraction/RepairShop.java b/data_from_eclipse_ide/oopsabstraction/RepairShop.java new file mode 100644 index 0000000..6a09ac2 --- /dev/null +++ b/data_from_eclipse_ide/oopsabstraction/RepairShop.java @@ -0,0 +1,21 @@ +package oopsabstraction; + +public class RepairShop { + + public static void repairCar(Car car) { + System.out.println("car is repaired"); + } + + public static void repairCar(Car...Audi) { + System.out.println("car is repaired"); + } + + public static void main(String[] args) { + WagonR wagonR = new WagonR(); + Audi audi = new Audi(); + + repairCar(wagonR); + repairCar(audi); + } + +} diff --git a/data_from_eclipse_ide/oopsabstraction/WagonR.java b/data_from_eclipse_ide/oopsabstraction/WagonR.java new file mode 100644 index 0000000..8f8425b --- /dev/null +++ b/data_from_eclipse_ide/oopsabstraction/WagonR.java @@ -0,0 +1,20 @@ +package oopsabstraction; + +public class WagonR extends Car{ + + public static void main(String[] args) { + + } + @Override + public void accelerate() { + + System.out.println("WagonR is accelerating"); + } + + @Override + public void apply_break() { + + System.out.println("break is applied in WagonR"); + } + +} diff --git a/data_from_eclipse_ide/oopsinheritance/MainClass.java b/data_from_eclipse_ide/oopsinheritance/MainClass.java new file mode 100644 index 0000000..8332e70 --- /dev/null +++ b/data_from_eclipse_ide/oopsinheritance/MainClass.java @@ -0,0 +1,20 @@ +package oopsinheritance; + +public class MainClass { + + public static void main(String[] args) { + //Object of teacher class + Teacher T = new Teacher(); + T.name = "Mr Harry "; + T.eat(); + T.walk(); + T.teach(); + //Object of singer class + Singer s = new Singer(); + s.name = "Justin B "; + s.sing(); + s.eat(); + + } + +} diff --git a/data_from_eclipse_ide/oopsinheritance/Person.java b/data_from_eclipse_ide/oopsinheritance/Person.java new file mode 100644 index 0000000..d4c4805 --- /dev/null +++ b/data_from_eclipse_ide/oopsinheritance/Person.java @@ -0,0 +1,15 @@ +package oopsinheritance; + +public class Person { + + protected String name; + + public void walk() { + System.out.println(name + "is walking"); + } + + public void eat() { + System.out.println(name + "is eating"); + } + +} diff --git a/data_from_eclipse_ide/oopsinheritance/Singer.java b/data_from_eclipse_ide/oopsinheritance/Singer.java new file mode 100644 index 0000000..0d39ff4 --- /dev/null +++ b/data_from_eclipse_ide/oopsinheritance/Singer.java @@ -0,0 +1,9 @@ +package oopsinheritance; + +public class Singer extends Person { + + public void sing() { + System.out.println(name + "is singing"); + } + +} diff --git a/data_from_eclipse_ide/oopsinheritance/Teacher.java b/data_from_eclipse_ide/oopsinheritance/Teacher.java new file mode 100644 index 0000000..71e38d8 --- /dev/null +++ b/data_from_eclipse_ide/oopsinheritance/Teacher.java @@ -0,0 +1,9 @@ +package oopsinheritance; + +public class Teacher extends Person { + + public void teach() { + System.out.println(name + "is teaching"); + } + +} diff --git a/data_from_eclipse_ide/oopspolymorphism/Animal.java b/data_from_eclipse_ide/oopspolymorphism/Animal.java new file mode 100644 index 0000000..99bbd6b --- /dev/null +++ b/data_from_eclipse_ide/oopspolymorphism/Animal.java @@ -0,0 +1,5 @@ +package oopspolymorphism; +//An empty Animal class +public class Animal { + +} diff --git a/data_from_eclipse_ide/oopspolymorphism/Dog.java b/data_from_eclipse_ide/oopspolymorphism/Dog.java new file mode 100644 index 0000000..995b0d6 --- /dev/null +++ b/data_from_eclipse_ide/oopspolymorphism/Dog.java @@ -0,0 +1,10 @@ +package oopspolymorphism; + +public class Dog extends Pet { + + public void walk() { + System.out.println("dog is walking"); + } + + +} diff --git a/data_from_eclipse_ide/oopspolymorphism/MainClass.java b/data_from_eclipse_ide/oopspolymorphism/MainClass.java new file mode 100644 index 0000000..112fc11 --- /dev/null +++ b/data_from_eclipse_ide/oopspolymorphism/MainClass.java @@ -0,0 +1,29 @@ +package oopspolymorphism; + +public class MainClass { + + + public static void greetings() { + System.out.println("Hi,there"); + } + public static void greetings(String s) { + System.out.println(s); + } + public static void greetings(String s, int count) { + for(int i=0;i=i;j--) //j for horizontal stars + System.out.print("* "); //printing the stars + + System.out.println(); + } + } + +} diff --git a/data_from_eclipse_ide/patternsByloops/Pattern3.java b/data_from_eclipse_ide/patternsByloops/Pattern3.java new file mode 100644 index 0000000..d2a20ca --- /dev/null +++ b/data_from_eclipse_ide/patternsByloops/Pattern3.java @@ -0,0 +1,18 @@ +package patternsByloops; + +public class Pattern3 { + + public static void main(String[] args) { + + int n = 6; //size of the pattern + + for(int i=1;i<=n;i++) { //i for horizontal stars operation + + for(int j=n-1;j>=i;j--) //j for vertical stars operation + System.out.print("* "); //printing the stars + + System.out.println(); // for new line + } + } + +} diff --git a/data_from_eclipse_ide/patternsByloops/Pattern4.java b/data_from_eclipse_ide/patternsByloops/Pattern4.java new file mode 100644 index 0000000..3635f7e --- /dev/null +++ b/data_from_eclipse_ide/patternsByloops/Pattern4.java @@ -0,0 +1,20 @@ +package patternsByloops; + +public class Pattern4 { + public static void main(String[] args) { + + int n=6; //size of the pattern + + for(int i=n;i>=1;i--){ //i for horizontal stars + + for(int j=n-1;j>=i;j--) //j for vertical and for print & handling the spaces + System.out.print(" "); + + for(int k=1;k<=i;k++) //k variable for print the values + System.out.print("* "); //printing the stars + + System.out.println(); + } + } + +} diff --git a/data_from_eclipse_ide/patternsByloops/Pattern5.java b/data_from_eclipse_ide/patternsByloops/Pattern5.java new file mode 100644 index 0000000..a93e554 --- /dev/null +++ b/data_from_eclipse_ide/patternsByloops/Pattern5.java @@ -0,0 +1,30 @@ +package patternsByloops; + +public class Pattern5 { + + public static void main(String[] args) { + + int min_stars =0; /*change value to set minimum no. of stars in pyramid + take odd no.for odd no. of stars in each row 1-3-5 + etc + take even no. for even no. stars in each row,2-4-6 etc */ + + int p_height=6; //change value to increase or decrease the size of pyramid + + int p_space = p_height - 1; + + for(int i= 1;ii;j--) + System.out.print(" "); + + for(int k=0;k<=min_stars;k++) + System.out.print("* "); + + min_stars+=2; + System.out.println(); + } + + }//end of main +}//end of class diff --git a/data_from_eclipse_ide/patternsByloops/Pattern5_2.java b/data_from_eclipse_ide/patternsByloops/Pattern5_2.java new file mode 100644 index 0000000..3728cec --- /dev/null +++ b/data_from_eclipse_ide/patternsByloops/Pattern5_2.java @@ -0,0 +1,24 @@ +package patternsByloops; + +public class Pattern5_2 { + + public static void main(String[] args) { + + int n = 5; //size of pattern + + int px =n; //left print control + int py =n; //right print control + + for(int i=1;i<=n;i++) //i for horizontal stars + { + for(int j=1;j=px && j<=py) System.out.print("* "); //if condition is true then print the stars + else System.out.print(" "); //else print the spaces + + px--; //post decrementing the left print control + py++; //post incrementing the right print control + System.out.println(); + } + + } +} diff --git a/data_from_eclipse_ide/patternsByloops/Pattern6.java b/data_from_eclipse_ide/patternsByloops/Pattern6.java new file mode 100644 index 0000000..efb017c --- /dev/null +++ b/data_from_eclipse_ide/patternsByloops/Pattern6.java @@ -0,0 +1,21 @@ +package patternsByloops; + +public class Pattern6 { + + public static void main(String[] args) + { + int n=5; + //size of pattern + for(int i= n;i>=1;i--) + { + for(int j=n-1;j>=i;j--) // loop for print the spaces + System.out.print(" "); //printing the spaces + + for(int k =1;k<=i;k++) // loop for print the stars + System.out.print("*"); //printing the stars + + System.out.println(); //for new line + }//end of loop + + }//end of main +}//end of class diff --git a/data_from_eclipse_ide/patternsByloops/Pattern7.java b/data_from_eclipse_ide/patternsByloops/Pattern7.java new file mode 100644 index 0000000..4365cb5 --- /dev/null +++ b/data_from_eclipse_ide/patternsByloops/Pattern7.java @@ -0,0 +1,18 @@ +package patternsByloops; + +public class Pattern7 +{ + public static void main(String[] args) + { + + int size = 3; //size of the pattern + + for(int i=size;i>=-size;i--) //loop to print the stars + { + for( int j=size;j>=Math.abs(i);j--) //inner or nested loop for print the stars + System.out.print("* "); + + System.out.println(); //for new line + }//end of loop + }//end of main +}//end of class diff --git a/data_from_eclipse_ide/patternsByloops/Pattern8.java b/data_from_eclipse_ide/patternsByloops/Pattern8.java new file mode 100644 index 0000000..8ef97cb --- /dev/null +++ b/data_from_eclipse_ide/patternsByloops/Pattern8.java @@ -0,0 +1,21 @@ +package patternsByloops; + +public class Pattern8 +{ + public static void main(String[] args) + { + int size = 3; //size of pattern + + for(int i=size;i>=-size;i--) { //loop for handling spaces & stars + + for(int j=1;j<=Math.abs(i);j++) //inner or nested loop to handle or print spaces + System.out.print(" "); //printing the spaces + + for(int k=size;k>=Math.abs(i);k--) //inner or nested loop to handle or print stars + System.out.print("*"); //printing the stars + + System.out.println(); //for new line + }//end of loop + + }//end of main +}//end of class diff --git a/data_from_eclipse_ide/patternsByloops/Pattern9.java b/data_from_eclipse_ide/patternsByloops/Pattern9.java new file mode 100644 index 0000000..d9ea106 --- /dev/null +++ b/data_from_eclipse_ide/patternsByloops/Pattern9.java @@ -0,0 +1,19 @@ +package patternsByloops; + +public class Pattern9 { + + public static void main(String[] args) { + + int size = 3; //size of pattern + for(int i=size;i>=-size;i--) //loop for handle stars & spaces + { + for(int j=1;j<=Math.abs(i);j++) //inner or nested loop for spaces + System.out.print(" "); //printing the spaces + + for(int k=size;k>=Math.abs(i);k--) //inner or nested loop for stars + System.out.print("* "); //printing the stars + + System.out.println(); //new line + } + }//end of main +}//end of class diff --git a/data_from_eclipse_ide/practiceProblems/Cylinder.java b/data_from_eclipse_ide/practiceProblems/Cylinder.java new file mode 100644 index 0000000..72c0b2f --- /dev/null +++ b/data_from_eclipse_ide/practiceProblems/Cylinder.java @@ -0,0 +1,26 @@ +package practiceProblems; + +public class Cylinder { + + public static void main(String[] args) { + + //The below line represent's the , Object of the Setter_Getters class + Getters_Setters_For_Cylinder sg = new Getters_Setters_For_Cylinder(); + + //setting values of pie, height & radius by using setter method with use of other class & by calling it + sg.setHeight(35); + sg.setRadius(3.0); + sg.setPie(3.14); + + //getting values of pie, radius & height + System.out.println("The value of the Pie is: " + sg.getPie()); + System.out.println("The height of the cylinder is: " + sg.getHeight() + " cm"); + System.out.println("The radius of the cylinder is: " + sg.getRadius() + " cm"); + + // volume of cylinder => (V = 3.14*(r)^2*h) + double V = sg.getPie()*(sg.getRadius()*sg.getRadius())*sg.getHeight(); + System.out.println("The volume of the cylinder is: " + V + " cm^3"); + + } + +} diff --git a/data_from_eclipse_ide/practiceProblems/Exercise1.java b/data_from_eclipse_ide/practiceProblems/Exercise1.java new file mode 100644 index 0000000..a62e265 --- /dev/null +++ b/data_from_eclipse_ide/practiceProblems/Exercise1.java @@ -0,0 +1,33 @@ +package practiceProblems; +import java.util.*; + +/* To calculate percentage of a given student in CBSE Board exam. + * His marks from 5 subjects must be taken as input from the keyboard + * (Marks are out of 100) + * */ + +public class Exercise1 { + + static Scanner sc = new Scanner(System.in); + + static int subject_1_marks = sc.nextInt(); + static int subject_2_marks = sc.nextInt(); + static int subject_3_marks = sc.nextInt(); + static int subject_4_marks = sc.nextInt(); + static int subject_5_marks = sc.nextInt(); + + public static void main(String[] args) { + + int total = (subject_1_marks + subject_2_marks + subject_3_marks + subject_4_marks + subject_5_marks); + float percentage = (total)/5; + + System.out.println("The marks of the subject's are: \n " + "\n" + "subject_1_marks:- " + subject_1_marks + "\n" + + "subject_2_marks:- " + subject_2_marks + "\n" + "subject_3_marks:- " + subject_3_marks + "\n" + + "subject_4_marks:- " + subject_4_marks + "\n" + "subject_5_marks:- " + subject_5_marks + "\n"); + + System.out.println("The total no. of marks are: " + total); + System.out.println("Total percentage is: " + percentage); + + } + +} diff --git a/data_from_eclipse_ide/practiceProblems/Exercise2.java b/data_from_eclipse_ide/practiceProblems/Exercise2.java new file mode 100644 index 0000000..794539d --- /dev/null +++ b/data_from_eclipse_ide/practiceProblems/Exercise2.java @@ -0,0 +1,34 @@ +package practiceProblems; +import java.util.Scanner; + +/* + * Take an array as input & print all of its content at particular index wise + */ + +public class Exercise2 { + + public static void main(String[] args) { + try (Scanner sc = new Scanner(System.in)) { + int n,sum =0; + + System.out.println("Enter no. of elements you want in array:"); + n = sc.nextInt(); + + int A[] = new int[n]; + System.out.println("Enter all the elements: "); + + for(int i=0;i 40) System.out.println(" The height of cylender is to high to to find vol & surface area: "); + else this.height = height; + } + + //setter method to set radius of cylinder + public void setRadius(double radius) { + this.radius = radius; + } + + //setter method to set the value of pie + public void setPie(double pie) { + this.pie = pie; + } + + //getter method to get the height of cylinder + public int getHeight() { + return height; + } + + //getter method to get the radius of cylinder + public double getRadius() { + return radius; + } + + //getter method to get the value of pie + public double getPie() { + return pie; + } + + + +} diff --git a/data_from_eclipse_ide/recursion/Factorial.java b/data_from_eclipse_ide/recursion/Factorial.java new file mode 100644 index 0000000..6091555 --- /dev/null +++ b/data_from_eclipse_ide/recursion/Factorial.java @@ -0,0 +1,21 @@ +package recursion; +import java.util.Scanner; + +public class Factorial { + public static long multiplyNumbers(int num) + { + if (num >= 1) + return num * multiplyNumbers(num - 1); + else + return 1; + } + public static void main(String[] args) { + + @SuppressWarnings("resource") + Scanner sc = new Scanner(System.in); + int num = sc.nextInt(); + long factorial = multiplyNumbers(num); + System.out.println("Factorial of " + num + " = " + factorial); + } + +} diff --git a/data_from_eclipse_ide/recursion/NRaiseP.java b/data_from_eclipse_ide/recursion/NRaiseP.java new file mode 100644 index 0000000..1aff02b --- /dev/null +++ b/data_from_eclipse_ide/recursion/NRaiseP.java @@ -0,0 +1,15 @@ +package recursion; + +public class NRaiseP { + + public static int nRaisep(int n, int p) { + if(p == 0) + return 1; + return n*nRaisep(n,p-1); + } + + public static void main(String[] args) { + System.out.println(nRaisep(3,4)); + } + +} diff --git a/data_from_eclipse_ide/recursion/NaturalNoSum.java b/data_from_eclipse_ide/recursion/NaturalNoSum.java new file mode 100644 index 0000000..6c52af4 --- /dev/null +++ b/data_from_eclipse_ide/recursion/NaturalNoSum.java @@ -0,0 +1,20 @@ +package recursion; + +/* + * Find sum of first N natural numbers using recursion + */ +public class NaturalNoSum { + + public static void main(String[] args) { + System.out.println(sum(5)); + } + + static int sum(int N) { + //Base case + if(N == 1) return 1; + + //Recursive call + return N+sum(N-1) ; + } + +} diff --git a/data_from_eclipse_ide/recursion/Subsequences.java b/data_from_eclipse_ide/recursion/Subsequences.java new file mode 100644 index 0000000..87719e9 --- /dev/null +++ b/data_from_eclipse_ide/recursion/Subsequences.java @@ -0,0 +1,50 @@ +package recursion; + +//Program to Find the Subsequences of Given String by using RECURSION +public class Subsequences { + + public static String[] findSubsequences(String str) { + + if(str.length() == 0) { + String ans[] = {""}; + return ans; + } + + String smallAns[] = findSubsequences(str.substring(1)); + String ans[] = new String[2 * smallAns.length]; + + /* + * Otherwise: + * int k = 0; + */ + for(int i = 0 ; i < smallAns.length ; i++) { + ans[i] = smallAns[i]; + /* + * Otherwise: + * ans[k] = smallAns[i]; + * k++; + */ + } + + for(int i = 0 ; i< smallAns.length ; i++) { + /* + * otherwise: ans[k] in place of ans[i + smallAns] and + * k++; + */ + ans[i + smallAns.length] = str.charAt(0) + smallAns[i]; + } + + return ans; + } + + public static void main(String[] args) { + + String str = "xyz"; + String ans[] = findSubsequences(str); + for(int i = 0 ; i < ans.length; i++) { + System.out.println(ans[i]); + } + + } + +} diff --git a/data_from_eclipse_ide/recursion/Tower_Of_Hanoi.java b/data_from_eclipse_ide/recursion/Tower_Of_Hanoi.java new file mode 100644 index 0000000..567e397 --- /dev/null +++ b/data_from_eclipse_ide/recursion/Tower_Of_Hanoi.java @@ -0,0 +1,29 @@ +package recursion; + +/* + * Stack Application :- Tower of Hanoi Problem(Puzzle 1) + */ +public class Tower_Of_Hanoi { + + //function to solve the tower of hanoi proble + static void towerOfHanoi(int n, char from_rod, char to_rod, char aux_rod) { + + if(n == 1) { + System.out.println("Move disk 1 from rod " + from_rod + " to_rod " + to_rod); + return; + } + + towerOfHanoi(n-1, from_rod, to_rod, aux_rod); + System.out.println("Move disk "+ n +" from_rod "+from_rod+" to rod "+to_rod); + + } + + //Driver Method + public static void main(String[] args) { + + int n =4; + towerOfHanoi(n,'A','C','B'); + + } + +} diff --git a/data_from_eclipse_ide/searchingAlgorithms/BinarySearch.java b/data_from_eclipse_ide/searchingAlgorithms/BinarySearch.java new file mode 100644 index 0000000..3eda77a --- /dev/null +++ b/data_from_eclipse_ide/searchingAlgorithms/BinarySearch.java @@ -0,0 +1,47 @@ +package searchingAlgorithms; + +//Binary Search Algorithm +public class BinarySearch { + + // Returns index of x if it is present in arr[l.. + // r], else return -1 + int binarySearch(int arr[], int l, int r, int x) + { + if (r >= l) { + int mid = l + (r - l) / 2; + + // If the element is present at the + // middle itself + if (arr[mid] == x) + return mid; + + // If element is smaller than mid, then + // it can only be present in left subarray + if (arr[mid] > x) + return binarySearch(arr, l, mid - 1, x); + + // Else the element can only be present + // in right subarray + return binarySearch(arr, mid + 1, r, x); + } + + // We reach here when element is not present + // in array + return -1; + } + + // Driver method to test above + public static void main(String args[]) + { + BinarySearch ob = new BinarySearch(); + int arr[] = { 2, 3, 4, 10, 40, 50, 90, 130, 230, 740}; + int n = arr.length; + int x = 130; + int result = ob.binarySearch(arr, 0, n - 1, x); + if (result == -1) + System.out.println("Element not present"); + else + System.out.println("Element found at index " + result); + } +} + diff --git a/data_from_eclipse_ide/searchingAlgorithms/LinearSearch.java b/data_from_eclipse_ide/searchingAlgorithms/LinearSearch.java new file mode 100644 index 0000000..ff4718c --- /dev/null +++ b/data_from_eclipse_ide/searchingAlgorithms/LinearSearch.java @@ -0,0 +1,28 @@ +package searchingAlgorithms; + +public class LinearSearch { + + public static int search(int arr[], int x) + { + int n = arr.length; + for(int i = 0; i < n; i++) + { + if(arr[i] == x) + return i; + } + return -1; + } + + public static void main(String args[]) + { + int arr[] = { 1, 2, 3, 4, 10, 40, 50, 60, 90, 80, 70}; + int x = 90; + + int result = search(arr, x); + if(result == -1) + System.out.print("Element is not present in array"); + else + System.out.print("Element is present at index " + result); + } + +} diff --git a/data_from_eclipse_ide/sortingAlgorithms/BubbleSort.java b/data_from_eclipse_ide/sortingAlgorithms/BubbleSort.java new file mode 100644 index 0000000..f22a31c --- /dev/null +++ b/data_from_eclipse_ide/sortingAlgorithms/BubbleSort.java @@ -0,0 +1,43 @@ +package sortingAlgorithms; + +//Program to demonstrate the bubble sort algorithm... +public class BubbleSort { + + void bubbleSort(int a[]) { + + int n = a.length; + for(int i=0;i a[j+1]) { + //swap a[j+1] and a[i] + int temp = a[j]; + a[j] = a[j+1]; + a[j+1] = temp; + } + } + } + } + + //function to print the array + void printArray(int a[]) { + + int n = a.length; + for(int i=0;i=0;i--) + heapify(A,n,i); + + for(int i = n-1;i>0;i--) { + int temp = A[0]; + A[0] = A[i]; + A[i] = temp; + + heapify(A,i,0); + } + } + + void heapify(int A[], int n, int i) { + + int largest = i; // Initialize largest as root + int l = 2*i + 1; // left = 2*i + 1 + int r = 2*i + 2; // right = 2*i + 2 + + // If left child is larger than root + if (l < n && A[l] > A[largest]) + largest = l; + + // If right child is larger than largest so far + if (r < n && A[r] > A[largest]) + largest = r; + + // If largest is not root + if (largest != i) + { + int swap = A[i]; + A[i] = A[largest]; + A[largest] = swap; + + // Recursively heapify the affected sub-tree + heapify(A, n, largest); + } + } + + /* A utility function to print array of size n */ + static void printArray(int A[]) + { + int n = A.length; + for (int i=0; i= 0 && arr[j] > key) { + arr[j + 1] = arr[j]; + j = j - 1; + } + arr[j + 1] = key; + } + } + + /* A utility function to print array of size n*/ + static void printArray(int arr[]) + { + int n = arr.length; + for (int i = 0; i < n; ++i) + System.out.print(arr[i] + " "); + + System.out.println(); + } + + // Driver method + public static void main(String args[]) + { + int arr[] = { 12, 11, 13, 5, 6 }; + + InsertionSort ob = new InsertionSort(); + ob.sort(arr); + + printArray(arr); + } +} + diff --git a/data_from_eclipse_ide/sortingAlgorithms/MergeSort.java b/data_from_eclipse_ide/sortingAlgorithms/MergeSort.java new file mode 100644 index 0000000..2281119 --- /dev/null +++ b/data_from_eclipse_ide/sortingAlgorithms/MergeSort.java @@ -0,0 +1,98 @@ +package sortingAlgorithms; + +public class MergeSort { + // Merges two subarrays of arr[]. + // First subarray is arr[l..m] + // Second subarray is arr[m+1..r] + void merge(int arr[], int l, int m, int r) + { + // Find sizes of two subarrays to be merged + int n1 = m - l + 1; + int n2 = r - m; + + /* Create temp arrays */ + int L[] = new int[n1]; + int R[] = new int[n2]; + + /*Copy data to temp arrays*/ + for (int i = 0; i < n1; ++i) + L[i] = arr[l + i]; + for (int j = 0; j < n2; ++j) + R[j] = arr[m + 1 + j]; + + /* Merge the temp arrays */ + + // Initial indexes of first and second subarrays + int i = 0, j = 0; + + // Initial index of merged subarry array + int k = l; + while (i < n1 && j < n2) { + if (L[i] <= R[j]) { + arr[k] = L[i]; + i++; + } + else { + arr[k] = R[j]; + j++; + } + k++; + } + + /* Copy remaining elements of L[] if any */ + while (i < n1) { + arr[k] = L[i]; + i++; + k++; + } + + /* Copy remaining elements of R[] if any */ + while (j < n2) { + arr[k] = R[j]; + j++; + k++; + } + } + + // Main function that sorts arr[l..r] using + // merge() + void sort(int arr[], int l, int r) + { + if (l < r) { + // Find the middle point + int m = (l + r) / 2; + + // Sort first and second halves + sort(arr, l, m); + sort(arr, m + 1, r); + + // Merge the sorted halves + merge(arr, l, m, r); + } + } + + /* A utility function to print array of size n */ + static void printArray(int arr[]) + { + int n = arr.length; + for (int i = 0; i < n; ++i) + System.out.print(arr[i] + " "); + System.out.println(); + } + + // Driver method + public static void main(String args[]) + { + int arr[] = { 12, 11, 13, 5, 6, 7 }; + + System.out.println("Given Array"); + printArray(arr); + + MergeSort ob = new MergeSort(); + ob.sort(arr, 0, arr.length - 1); + + System.out.println("\nSorted array"); + printArray(arr); + } + +} diff --git a/data_from_eclipse_ide/sortingAlgorithms/QuickSort.java b/data_from_eclipse_ide/sortingAlgorithms/QuickSort.java new file mode 100644 index 0000000..fdefc10 --- /dev/null +++ b/data_from_eclipse_ide/sortingAlgorithms/QuickSort.java @@ -0,0 +1,80 @@ +package sortingAlgorithms; + +public class QuickSort { + + /* This function takes last element as pivot, + places the pivot element at its correct + position in sorted array, and places all + smaller (smaller than pivot) to left of + pivot and all greater elements to right + of pivot */ + int partition(int arr[], int low, int high) + { + int pivot = arr[high]; + int i = (low-1); // index of smaller element + for (int j=low; j Array to be sorted, + low --> Starting index, + high --> Ending index */ + void sort(int arr[], int low, int high) + { + if (low < high) + { + /* pi is partitioning index, arr[pi] is + now at right place */ + int pi = partition(arr, low, high); + + // Recursively sort elements before + // partition and after partition + sort(arr, low, pi-1); + sort(arr, pi+1, high); + } + } + + /* A utility function to print array of size n */ + static void printArray(int arr[]) + { + int n = arr.length; + for (int i=0; i mx) + mx = arr[i]; + return mx; + } + + // A function to do counting sort of array[] according to + // the digit represented by exponential. + static void countSort(int arr[], int n, int exp) { + int output[] = new int[n]; // output array + int i; + int count[] = new int[10]; + Arrays.fill(count,0); + + // Store count of occurrences in count[] + for (i = 0; i < n; i++) + count[ (arr[i]/exp)%10 ]++; + + // Change count[i] so that count[i] now contains + // actual position of this digit in output[] + for (i = 1; i < 10; i++) + count[i] += count[i - 1]; + + // Build the output array + for (i = n - 1; i >= 0; i--) + { + output[count[ (arr[i]/exp)%10 ] - 1] = arr[i]; + count[ (arr[i]/exp)%10 ]--; + } + + // Copy the output array to arr[], so that arr[] now + // contains sorted numbers according to curent digit + for (i = 0; i < n; i++) + arr[i] = output[i]; + } + + // The main function to that sorts arr[] of size n using Radix Sort + static void radixsort(int arr[], int n) { + // Find the maximum number to know number of digits + int m = getMax(arr, n); + + /* Do counting sort for every digit. + * Note that instead of passing digit number, exponential is passed. + * exponential is 10^i where i is current digit number . + */ + for (int exp = 1; m/exp > 0; exp *= 10) + countSort(arr, n, exp); + } + + // A utility function to print an array + static void print(int arr[], int n) { + for (int i=0; i stack = new Stack<>(); + + for(int i = 0 ; i < exp.length() ; ++i){ + char c = exp.charAt(i); + + if(Character.isLetterOrDigit(c)) + result += c; + + else if(c == '(') + stack.push(c); + + else if (c == ')'){ + while (!stack.isEmpty() && stack.peek() != '(') + result += stack.pop(); + + stack.pop(); + } + + else{ + while(!stack.isEmpty() && Prec(c) <= Prec(stack.peek())){ + result += stack.pop(); + } + } + + stack.push(c); + } + + while (!stack.isEmpty()) { + + if(stack.peek() == '(') + return "Invalid Expression"; + + result += stack.pop(); + } + + return result; + } + + public static void main(String[] args) { + + Scanner sc = new Scanner(System.in); + String exp = sc.nextLine(); + + @SuppressWarnings("unused") + Infix_To_Postfix post = new Infix_To_Postfix(); + + System.out.println(infixToPostfix(exp)); + sc.close(); + } + +} diff --git a/data_from_eclipse_ide/stack_and_queue/Parenthesis_Checker_Problem.java b/data_from_eclipse_ide/stack_and_queue/Parenthesis_Checker_Problem.java new file mode 100644 index 0000000..83fcaf5 --- /dev/null +++ b/data_from_eclipse_ide/stack_and_queue/Parenthesis_Checker_Problem.java @@ -0,0 +1,75 @@ +package stack_and_queue; +import java.util.Scanner; +import java.util.Stack; + +public class Parenthesis_Checker_Problem { + + @SuppressWarnings("resource") + public static void main(String[] args) { + + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-- != 0) { + + String s = sc.nextLine(); + Stack stack = new Stack<>(); + + boolean isBalanced = true; + + for(int i = 0 ; i < s.length() ; i++) { + + char ch = s.charAt(i); + if(ch == '(' || ch == '{' || ch == '[') { + stack.push(ch); + continue; + } + + if(stack.isEmpty()) { + isBalanced = false; + break; + } + + if(ch == ')') { + if(stack.peek() == '(') { + stack.pop(); + }else { + isBalanced = false; + break; + } + } + + if(ch == '}') { + if(stack.peek() == '{') { + stack.pop(); + }else { + isBalanced = false; + break; + } + } + + if(ch == ']') { + if(stack.peek() == '[') { + stack.pop(); + }else { + isBalanced = false; + break; + } + } + + } + + if(!stack.isEmpty()) { + isBalanced = false; + } + + if(isBalanced) { + System.out.println("isBalanced"); + }else { + System.out.println("not balanced"); + } + + } + + } + +} diff --git a/data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_01_i.java b/data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_01_i.java new file mode 100644 index 0000000..92da5de --- /dev/null +++ b/data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_01_i.java @@ -0,0 +1,69 @@ +package stack_and_queue; +import java.util.*; + +/* + * Implement Stack from Scratch Array Implementation + */ +public class Stack_Queue_Problem_01_i implements Iterable { + + @SuppressWarnings("unchecked") + private Item[] a = (Item[]) new Object[1]; // Stack Items + private int N = 0; // number of items + + public boolean isEmpty() { + return N == 0; + } + + public int size() { + return N; + } + + private void resize(int max) { + @SuppressWarnings("unchecked") + Item[] temp = (Item[]) new Object[max]; + for (int i = 0; i < N; i++) + temp[i] = a[i]; + a = temp; + } + + public void push(Item item) { + if (N == a.length) + resize(2 * a.length); + a[N++] = item; + + } + + public Item pop() { + Item item = a[--N]; + a[N] = null; + + if (N > 0 && N == a.length / 4) + resize(a.length / 2); + + return item; + } + + public Iterator iterator() { + return new ReverseArrayIterator(); + } + + private class ReverseArrayIterator implements Iterator { + public int i = N; + + public boolean hasNext() { + return i > 0; + } + + public Item next() { + return a[--i]; + } + + public void remove() { + + } + } + + public static void main(String[] args) { + + } +} diff --git a/data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_01_ii.java b/data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_01_ii.java new file mode 100644 index 0000000..4bbcb8b --- /dev/null +++ b/data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_01_ii.java @@ -0,0 +1,115 @@ +package stack_and_queue; +import static java.lang.System.exit; + +//Java program to Implement a stack using singly linked list + +//Create Stack Using Linked list +class StackUsingLinkedlist { + + // A linked list node + private class Node { + + int data; // integer data + Node link; // reference variable Node type + } + + // create global top reference variable global + Node top; + + // Constructor + StackUsingLinkedlist() { + this.top = null; + } + + // Utility function to add an element x in the stack + public void push(int x) // insert at the beginning + { + // create new node tempt and allocate memory + Node temp = new Node(); + + // initialize data into data field + temp.data = x; + + // put top reference into link + temp.link = top; + + // update top reference + top = temp; + } + + // Utility function to check if the stack is empty or not + public boolean isEmpty() { + return top == null; + } + + // Utility function to return top element in a stack + public int peek() { + // check for empty stack + if (!isEmpty()) { + return top.data; + } else { + System.out.println("Stack is empty"); + return -1; + } + } + + // Utility function to pop top element from the stack + public void pop() // remove at the beginning + { + // check for stack underflow + if (top == null) { + System.out.print("\nStack Underflow"); + return; + } + + // update the top pointer to point to the next node + top = (top).link; + } + + public void display() { + // check for stack underflow + if (top == null) { + System.out.printf("\nStack Underflow"); + exit(1); + } else { + Node temp = top; + while (temp != null) { + + // print node data + System.out.printf("%d->", temp.data); + + // assign temp link to temp + temp = temp.link; + } + } + } +} + +//main class +public class Stack_Queue_Problem_01_ii { + public static void main(String[] args) { + // create Object of Implementing class + StackUsingLinkedlist obj = new StackUsingLinkedlist(); + // insert Stack value + obj.push(11); + obj.push(22); + obj.push(33); + obj.push(44); + + // print Stack elements + obj.display(); + + // print Top element of Stack + System.out.printf("\nTop element is %d\n", obj.peek()); + + // Delete top element of Stack + obj.pop(); + obj.pop(); + + // print Stack elements + obj.display(); + + // print Top element of Stack + System.out.printf("\nTop element is %d\n", obj.peek()); + } +} diff --git a/data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_02_i.java b/data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_02_i.java new file mode 100644 index 0000000..d00f8bb --- /dev/null +++ b/data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_02_i.java @@ -0,0 +1,67 @@ +package stack_and_queue; + +//Queue From Scratch using Array +class Queue { + int front, rear, size, capacity, array[]; + + public Queue(int capacity) { + this.capacity = capacity; + front = this.size = 0; + rear = capacity - 1; + array = new int[this.capacity]; + } + + boolean isFull(Queue queue) { + return (queue.size == queue.capacity); + } + + boolean isEmpty(Queue queue) { + return (queue.size == 0); + } + + void enqueue(int item) { + if (isFull(this)) + return; + this.rear = (this.rear + 1) % this.capacity; + this.array[this.rear] = item; + this.size = this.size + 1; + System.out.println(item + " enqueued to queue"); + } + + int dequeue() { + if (isEmpty(this)) + return Integer.MIN_VALUE; + int item = this.array[this.front]; + this.front = (this.front + 1) % this.capacity; + this.size = this.size - 1; + return item; + } + + int front() { + if (isEmpty(this)) + return Integer.MIN_VALUE; + return this.array[this.front]; + } + + int rear() { + if (isEmpty(this)) + return Integer.MIN_VALUE; + return this.array[this.rear]; + } +} + +public class Stack_Queue_Problem_02_i { + + public static void main(String[] args) { + Queue queue = new Queue(1000); + queue.enqueue(10); + queue.enqueue(20); + queue.enqueue(30); + queue.enqueue(40); + + System.out.println(queue.dequeue() + " dequeued from queue \n "); + System.out.println("Front item is " + queue.front()); + System.out.println("Rear item is " + queue.rear()); + } + +} diff --git a/data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_02_ii.java b/data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_02_ii.java new file mode 100644 index 0000000..d4f041f --- /dev/null +++ b/data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_02_ii.java @@ -0,0 +1,10 @@ +package stack_and_queue; + +public class Stack_Queue_Problem_02_ii { + + public static void main(String[] args) { + + + } + +} diff --git a/src b/src deleted file mode 160000 index 26d2d57..0000000 --- a/src +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 26d2d577f3d9fe69db155171c374a6391232703f From 010a654940ba3b5d5411e574518e7d02b802465d Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Sat, 2 Jan 2021 14:48:22 +0530 Subject: [PATCH 18/56] #Modification 15 --- ...java_4cd5b7badd85dac4f4b1d9cce25274ef.prob | 1 + stack_and_queue/Infix_To_Postfix.java | 76 ++++++++++++ .../Parenthesis_Checker_Problem.java | 75 ++++++++++++ stack_and_queue/Stack_Queue_Problem_01_i.java | 69 +++++++++++ .../Stack_Queue_Problem_01_ii.java | 115 ++++++++++++++++++ stack_and_queue/Stack_Queue_Problem_02_i.java | 67 ++++++++++ .../Stack_Queue_Problem_02_ii.java | 11 ++ stack_and_queue/Stack_Queue_Problem_03.class | Bin 0 -> 1836 bytes stack_and_queue/Stack_Queue_Problem_03.java | 75 ++++++++++++ .../Stack_Queue_Problem_03.class | Bin 0 -> 1840 bytes 10 files changed, 489 insertions(+) create mode 100644 stack_and_queue/.cph/.Stack_Queue_Problem_03.java_4cd5b7badd85dac4f4b1d9cce25274ef.prob create mode 100644 stack_and_queue/Infix_To_Postfix.java create mode 100644 stack_and_queue/Parenthesis_Checker_Problem.java create mode 100644 stack_and_queue/Stack_Queue_Problem_01_i.java create mode 100644 stack_and_queue/Stack_Queue_Problem_01_ii.java create mode 100644 stack_and_queue/Stack_Queue_Problem_02_i.java create mode 100644 stack_and_queue/Stack_Queue_Problem_02_ii.java create mode 100644 stack_and_queue/Stack_Queue_Problem_03.class create mode 100644 stack_and_queue/Stack_Queue_Problem_03.java create mode 100644 stack_and_queue/stack_and_queue/Stack_Queue_Problem_03.class diff --git a/stack_and_queue/.cph/.Stack_Queue_Problem_03.java_4cd5b7badd85dac4f4b1d9cce25274ef.prob b/stack_and_queue/.cph/.Stack_Queue_Problem_03.java_4cd5b7badd85dac4f4b1d9cce25274ef.prob new file mode 100644 index 0000000..a5fc956 --- /dev/null +++ b/stack_and_queue/.cph/.Stack_Queue_Problem_03.java_4cd5b7badd85dac4f4b1d9cce25274ef.prob @@ -0,0 +1 @@ +{"name":"Local: Stack_Queue_Problem_03","url":"c:\\Users\\AmanSoni\\Desktop\\Java Program's\\Java-Eclipse\\Placement Prepration\\src\\stack_and_queue\\Stack_Queue_Problem_03.java","tests":[{"id":1609222893914,"input":"","output":""}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"c:\\Users\\AmanSoni\\Desktop\\Java Program's\\Java-Eclipse\\Placement Prepration\\src\\stack_and_queue\\Stack_Queue_Problem_03.java","group":"local","local":true} \ No newline at end of file diff --git a/stack_and_queue/Infix_To_Postfix.java b/stack_and_queue/Infix_To_Postfix.java new file mode 100644 index 0000000..b042525 --- /dev/null +++ b/stack_and_queue/Infix_To_Postfix.java @@ -0,0 +1,76 @@ +package stack_and_queue; +import java.util.*; + +public class Infix_To_Postfix { + + static int Prec(char ch){ + switch(ch){ + case '+': + case '-': + return 1; + + case '*': + case '/': + return 2; + + case '^': + return 3; + } + + return -1; + } + + static String infixToPostfix(String exp){ + + String result = new String(" "); + Stack stack = new Stack<>(); + + for(int i = 0 ; i < exp.length() ; ++i){ + char c = exp.charAt(i); + + if(Character.isLetterOrDigit(c)) + result += c; + + else if(c == '(') + stack.push(c); + + else if (c == ')'){ + while (!stack.isEmpty() && stack.peek() != '(') + result += stack.pop(); + + stack.pop(); + } + + else{ + while(!stack.isEmpty() && Prec(c) <= Prec(stack.peek())){ + result += stack.pop(); + } + } + + stack.push(c); + } + + while (!stack.isEmpty()) { + + if(stack.peek() == '(') + return "Invalid Expression"; + + result += stack.pop(); + } + + return result; + } + + public static void main(String[] args) { + + Scanner sc = new Scanner(System.in); + String exp = sc.nextLine(); + + @SuppressWarnings("unused") + Infix_To_Postfix post = new Infix_To_Postfix(); + + System.out.println(infixToPostfix(exp)); + sc.close(); + } + +} diff --git a/stack_and_queue/Parenthesis_Checker_Problem.java b/stack_and_queue/Parenthesis_Checker_Problem.java new file mode 100644 index 0000000..83fcaf5 --- /dev/null +++ b/stack_and_queue/Parenthesis_Checker_Problem.java @@ -0,0 +1,75 @@ +package stack_and_queue; +import java.util.Scanner; +import java.util.Stack; + +public class Parenthesis_Checker_Problem { + + @SuppressWarnings("resource") + public static void main(String[] args) { + + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-- != 0) { + + String s = sc.nextLine(); + Stack stack = new Stack<>(); + + boolean isBalanced = true; + + for(int i = 0 ; i < s.length() ; i++) { + + char ch = s.charAt(i); + if(ch == '(' || ch == '{' || ch == '[') { + stack.push(ch); + continue; + } + + if(stack.isEmpty()) { + isBalanced = false; + break; + } + + if(ch == ')') { + if(stack.peek() == '(') { + stack.pop(); + }else { + isBalanced = false; + break; + } + } + + if(ch == '}') { + if(stack.peek() == '{') { + stack.pop(); + }else { + isBalanced = false; + break; + } + } + + if(ch == ']') { + if(stack.peek() == '[') { + stack.pop(); + }else { + isBalanced = false; + break; + } + } + + } + + if(!stack.isEmpty()) { + isBalanced = false; + } + + if(isBalanced) { + System.out.println("isBalanced"); + }else { + System.out.println("not balanced"); + } + + } + + } + +} diff --git a/stack_and_queue/Stack_Queue_Problem_01_i.java b/stack_and_queue/Stack_Queue_Problem_01_i.java new file mode 100644 index 0000000..92da5de --- /dev/null +++ b/stack_and_queue/Stack_Queue_Problem_01_i.java @@ -0,0 +1,69 @@ +package stack_and_queue; +import java.util.*; + +/* + * Implement Stack from Scratch Array Implementation + */ +public class Stack_Queue_Problem_01_i implements Iterable { + + @SuppressWarnings("unchecked") + private Item[] a = (Item[]) new Object[1]; // Stack Items + private int N = 0; // number of items + + public boolean isEmpty() { + return N == 0; + } + + public int size() { + return N; + } + + private void resize(int max) { + @SuppressWarnings("unchecked") + Item[] temp = (Item[]) new Object[max]; + for (int i = 0; i < N; i++) + temp[i] = a[i]; + a = temp; + } + + public void push(Item item) { + if (N == a.length) + resize(2 * a.length); + a[N++] = item; + + } + + public Item pop() { + Item item = a[--N]; + a[N] = null; + + if (N > 0 && N == a.length / 4) + resize(a.length / 2); + + return item; + } + + public Iterator iterator() { + return new ReverseArrayIterator(); + } + + private class ReverseArrayIterator implements Iterator { + public int i = N; + + public boolean hasNext() { + return i > 0; + } + + public Item next() { + return a[--i]; + } + + public void remove() { + + } + } + + public static void main(String[] args) { + + } +} diff --git a/stack_and_queue/Stack_Queue_Problem_01_ii.java b/stack_and_queue/Stack_Queue_Problem_01_ii.java new file mode 100644 index 0000000..4bbcb8b --- /dev/null +++ b/stack_and_queue/Stack_Queue_Problem_01_ii.java @@ -0,0 +1,115 @@ +package stack_and_queue; +import static java.lang.System.exit; + +//Java program to Implement a stack using singly linked list + +//Create Stack Using Linked list +class StackUsingLinkedlist { + + // A linked list node + private class Node { + + int data; // integer data + Node link; // reference variable Node type + } + + // create global top reference variable global + Node top; + + // Constructor + StackUsingLinkedlist() { + this.top = null; + } + + // Utility function to add an element x in the stack + public void push(int x) // insert at the beginning + { + // create new node tempt and allocate memory + Node temp = new Node(); + + // initialize data into data field + temp.data = x; + + // put top reference into link + temp.link = top; + + // update top reference + top = temp; + } + + // Utility function to check if the stack is empty or not + public boolean isEmpty() { + return top == null; + } + + // Utility function to return top element in a stack + public int peek() { + // check for empty stack + if (!isEmpty()) { + return top.data; + } else { + System.out.println("Stack is empty"); + return -1; + } + } + + // Utility function to pop top element from the stack + public void pop() // remove at the beginning + { + // check for stack underflow + if (top == null) { + System.out.print("\nStack Underflow"); + return; + } + + // update the top pointer to point to the next node + top = (top).link; + } + + public void display() { + // check for stack underflow + if (top == null) { + System.out.printf("\nStack Underflow"); + exit(1); + } else { + Node temp = top; + while (temp != null) { + + // print node data + System.out.printf("%d->", temp.data); + + // assign temp link to temp + temp = temp.link; + } + } + } +} + +//main class +public class Stack_Queue_Problem_01_ii { + public static void main(String[] args) { + // create Object of Implementing class + StackUsingLinkedlist obj = new StackUsingLinkedlist(); + // insert Stack value + obj.push(11); + obj.push(22); + obj.push(33); + obj.push(44); + + // print Stack elements + obj.display(); + + // print Top element of Stack + System.out.printf("\nTop element is %d\n", obj.peek()); + + // Delete top element of Stack + obj.pop(); + obj.pop(); + + // print Stack elements + obj.display(); + + // print Top element of Stack + System.out.printf("\nTop element is %d\n", obj.peek()); + } +} diff --git a/stack_and_queue/Stack_Queue_Problem_02_i.java b/stack_and_queue/Stack_Queue_Problem_02_i.java new file mode 100644 index 0000000..d00f8bb --- /dev/null +++ b/stack_and_queue/Stack_Queue_Problem_02_i.java @@ -0,0 +1,67 @@ +package stack_and_queue; + +//Queue From Scratch using Array +class Queue { + int front, rear, size, capacity, array[]; + + public Queue(int capacity) { + this.capacity = capacity; + front = this.size = 0; + rear = capacity - 1; + array = new int[this.capacity]; + } + + boolean isFull(Queue queue) { + return (queue.size == queue.capacity); + } + + boolean isEmpty(Queue queue) { + return (queue.size == 0); + } + + void enqueue(int item) { + if (isFull(this)) + return; + this.rear = (this.rear + 1) % this.capacity; + this.array[this.rear] = item; + this.size = this.size + 1; + System.out.println(item + " enqueued to queue"); + } + + int dequeue() { + if (isEmpty(this)) + return Integer.MIN_VALUE; + int item = this.array[this.front]; + this.front = (this.front + 1) % this.capacity; + this.size = this.size - 1; + return item; + } + + int front() { + if (isEmpty(this)) + return Integer.MIN_VALUE; + return this.array[this.front]; + } + + int rear() { + if (isEmpty(this)) + return Integer.MIN_VALUE; + return this.array[this.rear]; + } +} + +public class Stack_Queue_Problem_02_i { + + public static void main(String[] args) { + Queue queue = new Queue(1000); + queue.enqueue(10); + queue.enqueue(20); + queue.enqueue(30); + queue.enqueue(40); + + System.out.println(queue.dequeue() + " dequeued from queue \n "); + System.out.println("Front item is " + queue.front()); + System.out.println("Rear item is " + queue.rear()); + } + +} diff --git a/stack_and_queue/Stack_Queue_Problem_02_ii.java b/stack_and_queue/Stack_Queue_Problem_02_ii.java new file mode 100644 index 0000000..a861152 --- /dev/null +++ b/stack_and_queue/Stack_Queue_Problem_02_ii.java @@ -0,0 +1,11 @@ +package stack_and_queue; + +//Queue from scratch using Linked-list +public class Stack_Queue_Problem_02_ii { + + public static void main(String[] args) { + + + } + +} diff --git a/stack_and_queue/Stack_Queue_Problem_03.class b/stack_and_queue/Stack_Queue_Problem_03.class new file mode 100644 index 0000000000000000000000000000000000000000..a4f4b590a97abcf58ba39810bdea2bbef503d979 GIT binary patch literal 1836 zcmai!TXWk)6vzK-%kd?O?WQ=PH3T=L!Iw0*w)EnV(i%dXtBX@Qojw>P-X>~n$yjnA zd;z`!GraM_OJ87`lnD$UfDgs+U&%BM$t0uES?$@~^V|Q~v-+?!GzGGTnI&WXrj)*p%!#S0q+UORjaAo3g!OY&Pf#wK~oY z0}NDMV{3QSX!ZITQEPeegV~&dv7>xV!?Xm3vd>pu8hgf6!?3oes&3n~wu=fDtJ#ZGS@IF zkbGp@uH&|i)~a-O?7EZa!(s$w9ZOi&@gYVdSmCr|)$5xt<(4bJ{7`t$Ky}}7Ws?JT zhr=m9QKmgrVU}FxN*c|gz-2GeNw+|_r6x6);#BtR3~TZ`(~V&jYXX^y-D=5tMl!L| zax*X5b~EE;Av2RPos19|ZW_C?WLsN?`_y!I_{DL{brhhSJB>Iu=&TnsjCGZjs=(NB zHcV^J-c>1ArQq`xj4ju0?}zb(MY&?zyPcMRUbZaRE;S6tk=(?Oy(+sg`~z6zIX0v- z<}WOs-f55L#KMjJmONv6Z^8OUSL~JF4N)>0jjHL&Vi-Ks>!j%h*lbAq~PYRbfrhX-?_-@>71iiR3jG*xiY4x9RHUEq~?Q0eJH9730 z*MC9cH}nmL4-wIRM^vE#J*X66L%g-a7~{4l2$<&R2b`rLFxJnOH|#wa KpT44J=l=!x@p)zd literal 0 HcmV?d00001 diff --git a/stack_and_queue/Stack_Queue_Problem_03.java b/stack_and_queue/Stack_Queue_Problem_03.java new file mode 100644 index 0000000..979fbf7 --- /dev/null +++ b/stack_and_queue/Stack_Queue_Problem_03.java @@ -0,0 +1,75 @@ +package stack_and_queue; + +//Implement two stack in an array + +public class Stack_Queue_Problem_03 { + + int size, top1, top2; + int a[]; + + Stack_Queue_Problem_03(int n) { + a = new int[n]; + size = n; + top1 = -1; + top2 = size; + } + + void push1(int x) { + if (top1 < top2 - 1) { + top1++; + a[top1] = x; + } else { + System.out.println("Stack Overflow"); + System.exit(1); + } + } + + void push2(int x) { + if (top1 < top2 - 1) { + top2--; + a[top2] = x; + } else { + System.out.println("Stack Overflow"); + System.exit(1); + } + } + + int pop1() { + if (top1 >= 0) { + int x = a[top1]; + top1--; + return x; + } else { + System.out.println("Stack Underflow"); + System.exit(1); + } + return 0; + } + + int pop2() { + if (top1 < size) { + int x = a[top2]; + top2++; + return x; + } else { + System.out.println("Stack Underflow"); + System.exit(1); + } + return 0; + } + + public static void main(String[] args) { + + Stack_Queue_Problem_03 ts = new Stack_Queue_Problem_03(5); + ts.push1(5); + ts.push2(10); + ts.push2(15); + ts.push1(11); + ts.push2(7); + + System.out.println("Popped element from" + " stack 1 is " + ts.pop1()); + ts.push2(40); + System.out.println("Popped element from" + " stack 2 is " + ts.pop2()); + } + +} diff --git a/stack_and_queue/stack_and_queue/Stack_Queue_Problem_03.class b/stack_and_queue/stack_and_queue/Stack_Queue_Problem_03.class new file mode 100644 index 0000000000000000000000000000000000000000..c55e8e086c1a5f8f86e12a3b1ce7adc6137eb0bb GIT binary patch literal 1840 zcmai#ZC4XV6vzLQY)D9!B!Xx)N`nIC!SblZ8tMbFNE8GctjFUEx{wi8lHF}~LrcFv zze3OHJKyw;Z`vd1p*{To{ZKvq&t`>CsGgj?GjnI={^oz@?&j}*_WuGfji+(+A=ixr z^2!vHDJpZd8=qk`hOs!tF%jorGKQ%ruEjZdU7637nO5dTFJsN9-j}@)n2F-HfaaP% zN&!(}*R!38b~8zjArN{_ch`(*ncgi<h||h+|%(D=5*XghI-nwPpn#dT42OgI#vy&x7n5gc!o@{W! zZgIN5ohZ{DTV|F#=1Llkl0csy>8M*E>ZnC^rnoDIoNX9evTR%HhWFI;HreC6<+%z_$sb32FzBQoG>Rpam8!td zVKz)_+ul+sSEbPA%^B;S-Q0=d35#;Uwzpc2fL^gI*(}!$*OffP&z&lR80`y~=RMY? zJJjA-I)2g)&ykHQJB~bId1t}4uddW7KL}Aa>h-GW$x;-&)Zt_LPCA>wz=zkd!V>%* z02&__J1tbb`z=e}Z}}#$?c&4o2;jMh~MWIhRsV4&rVg?8lv81dUHbtG&Yc!ZVJvZ&lLri;zZiNbUpn3`D<6CZI;l&ds^h7xS~h6Q5&A4)uB1klJw zp%)0fNYntKSwaU1y?g}9H#&gU0;NSI=NFuNuWWRtt(IUd^IA!a2NJ`t4>S%S%KixL z6`VqjO7a93F-&M4qdqbWp)$|!LqOaNh+~S#C;aMw8fjA_D#wwJP$zkTQ@p%uq+F-O zX%cVn@8afr>L9wQe>kB26i^@jfyA@eTj&eL*dBU{Y063#(<$F3d=Kw3Nx{WEr1n`M zpzdNici=p=5B~4ad018jmK1QCz&k9ayS(jL7HOHuzsKy%@qG7D!aU2h!efm1`MZLz Z*~WRiWvt*atKtieldPVb^p$*j>tB2Ld6xhH literal 0 HcmV?d00001 From 828b120191639a2b37551143c3a5216109d550b2 Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Sat, 2 Jan 2021 14:52:46 +0530 Subject: [PATCH 19/56] Update README.md --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 64f387a..08ac2a6 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ -# Java-Programs +# Java-Programs java This is a repository where, I will upload and keep up to date my Java, DataStructure and algorithms code and question regarding to them,which i practiced on eclipse & IntelliJ with help of Books and programming websites. The books I prefer and use for learning java and algorithms are: 1. Java for Dummies. -2. Java The Complete Reference by Herberth Schildt. -3. Algorithms by Sedwig. -4. Algorithms by Cormen. +2. Algorithms by Sedwig. +3. Algorithms by Cormen. From 7d2871c8ff99e06da7a6acd75d7b2243de9ca4c9 Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Tue, 12 Jan 2021 14:07:03 +0530 Subject: [PATCH 20/56] #Modification 20 --- arrays/Array_Problem_12.java | 4 +- arrays/Array_Problem_13.java | 30 +--------- arrays/Array_Problem_14.java | 36 +----------- arrays/Array_Problem_15.java | 4 ++ arrays/Array_Problem_16.java | 4 ++ arrays/Array_Problem_17.java | 4 ++ arrays/Array_Problem_18.java | 9 +-- arrays/Array_Problem_19.java | 4 ++ arrays/Array_Problem_20.java | 4 ++ arrays/Array_Problem_21.java | 4 ++ arrays/Array_Problem_22.java | 4 ++ arrays/Array_Problem_23.java | 9 +-- arrays/Array_Problem_24.java | 4 ++ arrays/Array_Problem_25.java | 4 ++ arrays/Array_Problem_26.java | 4 ++ arrays/Array_Problem_27.java | 7 +++ arrays/Array_Problem_28.java | 4 ++ arrays/Array_Problem_29.java | 4 ++ arrays/Array_Problem_30.java | 37 ++++++++++++ arrays/Array_Problem_31.java | 4 ++ arrays/Array_Problem_32.java | 56 ++++++++---------- arrays/Array_Problem_33.java | 8 +++ arrays/Array_Problem_34.java | 42 +++++++++++++ arrays/Array_Problem_35.java | 33 +++++++++++ arrays/Array_Problem_36.java | 66 +++++++++++++++++++++ arrays/Array_Problem_37.java | 65 ++++++++++++++++++++ arrays/FRE.java | 40 +++++++++++++ arrays/KadanesAlgorithm.java | 2 +- matrix/Matrix_Problem_03.java | 108 ++++++++++++++++++++++++++++++++++ matrix/Matrix_Problem_04.java | 86 +++++++++++++++++++++++++++ matrix/Matrix_Problem_05.java | 69 ++++++++++++++++++++++ matrix/Matrix_Problem_06.java | 82 ++++++++++++++++++++++++++ matrix/Matrix_Problem_07.java | 38 ++++++++++++ matrix/Matrix_Problem_08.java | 41 +++++++++++++ matrix/Matrix_Problem_09.java | 71 ++++++++++++++++++++++ matrix/Matrix_Problem_10.java | 53 +++++++++++++++++ 36 files changed, 934 insertions(+), 110 deletions(-) create mode 100644 arrays/Array_Problem_15.java create mode 100644 arrays/Array_Problem_16.java create mode 100644 arrays/Array_Problem_17.java create mode 100644 arrays/Array_Problem_19.java create mode 100644 arrays/Array_Problem_20.java create mode 100644 arrays/Array_Problem_21.java create mode 100644 arrays/Array_Problem_22.java create mode 100644 arrays/Array_Problem_24.java create mode 100644 arrays/Array_Problem_25.java create mode 100644 arrays/Array_Problem_26.java create mode 100644 arrays/Array_Problem_27.java create mode 100644 arrays/Array_Problem_28.java create mode 100644 arrays/Array_Problem_29.java create mode 100644 arrays/Array_Problem_30.java create mode 100644 arrays/Array_Problem_31.java create mode 100644 arrays/Array_Problem_33.java create mode 100644 arrays/Array_Problem_34.java create mode 100644 arrays/Array_Problem_35.java create mode 100644 arrays/Array_Problem_36.java create mode 100644 arrays/Array_Problem_37.java create mode 100644 arrays/FRE.java create mode 100644 matrix/Matrix_Problem_03.java create mode 100644 matrix/Matrix_Problem_04.java create mode 100644 matrix/Matrix_Problem_05.java create mode 100644 matrix/Matrix_Problem_06.java create mode 100644 matrix/Matrix_Problem_07.java create mode 100644 matrix/Matrix_Problem_08.java create mode 100644 matrix/Matrix_Problem_09.java create mode 100644 matrix/Matrix_Problem_10.java diff --git a/arrays/Array_Problem_12.java b/arrays/Array_Problem_12.java index e878764..d0728fa 100644 --- a/arrays/Array_Problem_12.java +++ b/arrays/Array_Problem_12.java @@ -34,8 +34,8 @@ public class Array_Problem_12 { - static int arr1[] = new int[] {1, 5 , 9, 10, 15, 20}; - static int arr2[] = new int[] {2, 3, 8, 13}; + static int[] arr1 = new int[] {1, 5 , 9, 10, 15, 20}; + static int[] arr2 = new int[] {2, 3, 8, 13}; static void merge(int m , int n) { diff --git a/arrays/Array_Problem_13.java b/arrays/Array_Problem_13.java index 05d3dd9..1b7d192 100644 --- a/arrays/Array_Problem_13.java +++ b/arrays/Array_Problem_13.java @@ -1,32 +1,4 @@ package arrays; -import java.util.*; - -/* - * Kadane's Algorithm to find the maxSubarray Sum in O(n)[Linear Time Complexity] - */ +/* Problem Title :-> */ public class Array_Problem_13 { - public static void main(String[] args) { - @SuppressWarnings("resource") - Scanner sc = new Scanner(System.in); - int n = sc.nextInt(); - int a[] = new int[n]; - - for(int i=0;i */ public class Array_Problem_14 { - public static void mergeIntervals(Interval a[]) { - if (a.length <= 0) { - return; - } - - Stack stack = new Stack<>(); - Arrays.sort(a.new Comparator() { - public int compare(Interval i1, Interval i2) { - return i1.start - i2.start; - } - }); - - stack.push(a[0]); - } - - public static void main(String[] args) { - Interval a[] = new Interval[4]; - - } -} - -/** - * Interval - */ -class Interval { - - int start, end; - - Interval(int start, int end) { - this.start = start; - this.end = end; - } } diff --git a/arrays/Array_Problem_15.java b/arrays/Array_Problem_15.java new file mode 100644 index 0000000..e5554ef --- /dev/null +++ b/arrays/Array_Problem_15.java @@ -0,0 +1,4 @@ +package arrays; +/* Problem Title :-> */ +public class Array_Problem_15 { +} diff --git a/arrays/Array_Problem_16.java b/arrays/Array_Problem_16.java new file mode 100644 index 0000000..e273955 --- /dev/null +++ b/arrays/Array_Problem_16.java @@ -0,0 +1,4 @@ +package arrays; +/* Problem Title :-> */ +public class Array_Problem_16 { +} diff --git a/arrays/Array_Problem_17.java b/arrays/Array_Problem_17.java new file mode 100644 index 0000000..f3e0edc --- /dev/null +++ b/arrays/Array_Problem_17.java @@ -0,0 +1,4 @@ +package arrays; +/* Problem Title :-> */ +public class Array_Problem_17 { +} diff --git a/arrays/Array_Problem_18.java b/arrays/Array_Problem_18.java index 709bf09..1a09b73 100644 --- a/arrays/Array_Problem_18.java +++ b/arrays/Array_Problem_18.java @@ -1,15 +1,10 @@ package arrays; -/* - * find all pairs on integer array whose sum is equal to given number - * OR - * Equal_Sum_Pairs_of_Array - */ - +/* Problem Title :-> find all pairs on integer array whose sum is equal to given number OR Equal_Sum_Pairs_of_Array */ public class Array_Problem_18 { //function to find & print the sum & elements - static void pairs_value(int iA[], int iN) { + static void pairs_value(int[] iA, int iN) { System.out.println("Pairs of elements & their sum : "); //loop to iterate & find the pair of elements whose sum is equal diff --git a/arrays/Array_Problem_19.java b/arrays/Array_Problem_19.java new file mode 100644 index 0000000..204ec01 --- /dev/null +++ b/arrays/Array_Problem_19.java @@ -0,0 +1,4 @@ +package arrays; +/* Problem Title :-> */ +public class Array_Problem_19 { +} diff --git a/arrays/Array_Problem_20.java b/arrays/Array_Problem_20.java new file mode 100644 index 0000000..97d0f95 --- /dev/null +++ b/arrays/Array_Problem_20.java @@ -0,0 +1,4 @@ +package arrays; +/* Problem Title :-> */ +public class Array_Problem_20 { +} diff --git a/arrays/Array_Problem_21.java b/arrays/Array_Problem_21.java new file mode 100644 index 0000000..edd0ff8 --- /dev/null +++ b/arrays/Array_Problem_21.java @@ -0,0 +1,4 @@ +package arrays; +/* Problem Title :-> */ +public class Array_Problem_21 { +} diff --git a/arrays/Array_Problem_22.java b/arrays/Array_Problem_22.java new file mode 100644 index 0000000..9279cf2 --- /dev/null +++ b/arrays/Array_Problem_22.java @@ -0,0 +1,4 @@ +package arrays; +/* Problem Title :-> */ +public class Array_Problem_22 { +} diff --git a/arrays/Array_Problem_23.java b/arrays/Array_Problem_23.java index 9aedc89..52d1b1e 100644 --- a/arrays/Array_Problem_23.java +++ b/arrays/Array_Problem_23.java @@ -1,12 +1,9 @@ package arrays; -/* - * Java program for maximum product sub-array problem - */ - +/* Problem Title :-> Java program for maximum product sub-array problem */ public class Array_Problem_23 { - static void maxSubArraySum(int a[], int size) + static void maxSubArraySum(int[] a, int size) { int max_so_far = Integer.MIN_VALUE, max_ending_here = 0,start = 0, @@ -37,7 +34,7 @@ static void maxSubArraySum(int a[], int size) // Driver code public static void main(String[] args) { - int a[] = { -2, -3, 4, -1, -2, 1, 5, -3 }; + int[] a = { -2, -3, 4, -1, -2, 1, 5, -3 }; int n = a.length; maxSubArraySum(a, n); } diff --git a/arrays/Array_Problem_24.java b/arrays/Array_Problem_24.java new file mode 100644 index 0000000..da2f3c3 --- /dev/null +++ b/arrays/Array_Problem_24.java @@ -0,0 +1,4 @@ +package arrays; +/* Problem Title :-> */ +public class Array_Problem_24 { +} diff --git a/arrays/Array_Problem_25.java b/arrays/Array_Problem_25.java new file mode 100644 index 0000000..4655de6 --- /dev/null +++ b/arrays/Array_Problem_25.java @@ -0,0 +1,4 @@ +package arrays; +/* Problem Title :-> */ +public class Array_Problem_25 { +} diff --git a/arrays/Array_Problem_26.java b/arrays/Array_Problem_26.java new file mode 100644 index 0000000..da75c41 --- /dev/null +++ b/arrays/Array_Problem_26.java @@ -0,0 +1,4 @@ +package arrays; +/* Problem Title :-> */ +public class Array_Problem_26 { +} diff --git a/arrays/Array_Problem_27.java b/arrays/Array_Problem_27.java new file mode 100644 index 0000000..4a5df23 --- /dev/null +++ b/arrays/Array_Problem_27.java @@ -0,0 +1,7 @@ +package arrays; + +/* Problem Title :-> */ +public class Array_Problem_27 { + + +} diff --git a/arrays/Array_Problem_28.java b/arrays/Array_Problem_28.java new file mode 100644 index 0000000..5de85b5 --- /dev/null +++ b/arrays/Array_Problem_28.java @@ -0,0 +1,4 @@ +package arrays; +/* Problem Title :-> */ +public class Array_Problem_28 { +} diff --git a/arrays/Array_Problem_29.java b/arrays/Array_Problem_29.java new file mode 100644 index 0000000..3c1293b --- /dev/null +++ b/arrays/Array_Problem_29.java @@ -0,0 +1,4 @@ +package arrays; +/* Problem Title :-> */ +public class Array_Problem_29 { +} diff --git a/arrays/Array_Problem_30.java b/arrays/Array_Problem_30.java new file mode 100644 index 0000000..ffc59d0 --- /dev/null +++ b/arrays/Array_Problem_30.java @@ -0,0 +1,37 @@ +package arrays; +/* Problem Title :-> Trapping Rain water problem */ +public class Array_Problem_30 { + //Function to return the maximum water that can be stored + public static int maxWater(int[] a, int n) { + + int res = 0; + + //For every element of the array, except first and last element + for(int i = 1; i < n - 1; i++) { + + //Find max element on its left + int left = a[i]; + for(int j = 0; j < i; j++) { + left = Math.max(left, a[j]); + } + + //Find max element on its left + int right = a[i]; + for(int j = i + 1; j < n; j++) { + right = Math.max(right, a[j]); + } + + //Update maximum water value + res += Math.min(left, right) - a[i]; + } + + return res; + } + //Driver Code + public static void main(String[] args) { + int[] a = {0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1}; + int n = a.length; + System.out.print(maxWater(a, n)); + } + +} diff --git a/arrays/Array_Problem_31.java b/arrays/Array_Problem_31.java new file mode 100644 index 0000000..c24a124 --- /dev/null +++ b/arrays/Array_Problem_31.java @@ -0,0 +1,4 @@ +package arrays; +/* Problem Title :-> */ +public class Array_Problem_31 { +} diff --git a/arrays/Array_Problem_32.java b/arrays/Array_Problem_32.java index 7f50762..52738bf 100644 --- a/arrays/Array_Problem_32.java +++ b/arrays/Array_Problem_32.java @@ -1,35 +1,31 @@ package arrays; -//Java program to find minimum number of operations to make an array palindrome +/* Problem Title :-> find minimum number of operations to make an array palindrome */ public class Array_Problem_32 { - - static int findMinOps(int[] a, int n) { - - //Initialize result - int ans = 0; - - //Start from two corners - for(int i=0,j=n-1;i<=j;) { - - if(a[i] == a[j]) { - i++; - j--; - }else if(a[i] > a[j]) { - j--; - a[j] += a[j+1]; - ans++; - }else { - i++; - a[i] += a[i-1]; - ans++; - } - } - return ans; - } - - public static void main(String[] args) { - int a[] = new int[] {1,2,3,4,5,6,7,8,9,10}; - System.out.println("Count of minimum operations is " + findMinOps(a , a.length)); - } + + static int findMinOps(int[] a, int n){ + int ans = 0; + for(int i = 0, j = n-1; i <= j;){ + if(a[i] == a[j]){ + i++; + j--; + } + else if(a[i] > a[j]){ + j--; + a[j] += a[j+1]; + ans++; + } + else{ + i++; + a[i] += a[i - 1]; + ans++; + } + } + return ans; + } + public static void main(String[] args) { + int[] a = new int[]{1, 4, 5, 9, 1}; + System.out.println("Count of minimum operations is" + findMinOps(a, a.length)); + } } diff --git a/arrays/Array_Problem_33.java b/arrays/Array_Problem_33.java new file mode 100644 index 0000000..86ca067 --- /dev/null +++ b/arrays/Array_Problem_33.java @@ -0,0 +1,8 @@ +package arrays; + +/* Problem Title :-> Three way partitioning of an array around a given value */ +public class Array_Problem_33 { + + + +} diff --git a/arrays/Array_Problem_34.java b/arrays/Array_Problem_34.java new file mode 100644 index 0000000..f4b4ebc --- /dev/null +++ b/arrays/Array_Problem_34.java @@ -0,0 +1,42 @@ +package arrays; +import java.lang.*; + +/* Problem Title :-> Minimum swaps required bring elements less equal K together */ +public class Array_Problem_34 { + + static int minSwap(int[] a, int n, int k){ + int count = 0; + for (int i = 0; i < n; ++i){ + if (a[i] <= k) + ++count; + } + + int bad = 0; + for (int i = 0; i < count; ++i){ + if (a[i] > k) + ++bad; + } + int ans = bad; + for (int i = 0, j = count; j < n; ++i, ++j ){ + if(a[i] > k) + --bad; + if(a[j] > k) + ++bad; + ans = Math.min(ans, bad); + } + return ans; + } + + public static void main(String[] args) { + int[] a = {2, 1, 5, 6, 3}; + int n = a.length; + int k = 3; + System.out.print(minSwap(a, n, k) + "\n"); + + int[] a1 = {2, 7, 9, 5, 8, 7, 4}; + n = a1.length; + k = 5; + System.out.print(minSwap(a1, n, k)); + } + +} diff --git a/arrays/Array_Problem_35.java b/arrays/Array_Problem_35.java new file mode 100644 index 0000000..56016ce --- /dev/null +++ b/arrays/Array_Problem_35.java @@ -0,0 +1,33 @@ +package arrays; +/* Problem Title :-> Minimum no. of operations required to make an array palindrome */ +public class Array_Problem_35 { + + static int findMinOps(int[] a, int n) { + + //Initialize result + int ans = 0; + + //Start from two corners + for(int i=0,j=n-1;i<=j;) { + + if(a[i] == a[j]) { + i++; + j--; + }else if(a[i] > a[j]) { + j--; + a[j] += a[j+1]; + ans++; + }else { + i++; + a[i] += a[i-1]; + ans++; + } + } + return ans; + } + + public static void main(String[] args) { + int[] a = new int[] {1,2,3,4,5,6,7,8,9,10}; + System.out.println("Count of minimum operations is " + findMinOps(a , a.length)); + } +} diff --git a/arrays/Array_Problem_36.java b/arrays/Array_Problem_36.java new file mode 100644 index 0000000..7b523f3 --- /dev/null +++ b/arrays/Array_Problem_36.java @@ -0,0 +1,66 @@ +package arrays; +/* Problem Title :-> Median of 2 sorted arrays of equal size */ +public class Array_Problem_36 { + + //function to calculate median + static int getMedian(int[] a1, int[] a2, int n) { + + int i = 0; + int j = 0; + int count; + int m1 = -1, m2 = -1; + + /* Since there are 2n elements , + * median will be average of elements at index n-1 + * & n in the array obtained after merging a1[] & a2[]*/ + + for(count = 0; count <= n; count++) { + + /* Below is to handle case where all elements of a1[] are + * smaller than smallest(or first) element of a2[] */ + if(i == n) { + m1 = m2; + m2 = a2[0]; + break; + } + + /* Below is to handle case where all elements of a2[] + * are smaller than smaller than + * smallest(or first) element of a1[]*/ + else if(j == n) { + m1 = m2; + m2 = a1[0]; + break; + } + + /* equals sign because if two arrays have some common elements*/ + if(a1[i] <= a2[j]) { + /* Store the previous median */ + m1 = m2; + m2 = a1[i]; + i++; + } + + else { + /* Store the previous median */ + m1 = m2; + m2 = a2[j]; + j++; + } + } + + return (m1 + m2)/2; + } + + /* Driver program to test above function */ + public static void main(String[] args) { + + int[] a1 = {1, 12, 15, 26, 38}; + int[] a2 = {2, 13, 17, 30, 45}; + + int n1 = a1.length,n2 = a2.length; + + System.out.println("Median is " + getMedian(a1, a2, n1)); + + } +} diff --git a/arrays/Array_Problem_37.java b/arrays/Array_Problem_37.java new file mode 100644 index 0000000..9373662 --- /dev/null +++ b/arrays/Array_Problem_37.java @@ -0,0 +1,65 @@ +package arrays; +/* Problem Title :-> Median of 2 sorted arrays of different size */ +public class Array_Problem_37 { + static int getMedian(int[] a1, int[] a2, int n, int m) { + + //Current index of input array a1[] + int i = 0; + //Current index of input array a2[] + int j = 0; + int count; + int m1 = -1, m2 = -1; + /* + * Since there are (n + m) elements , + * There are following two cases :-> + * if n + m is odd then the middle index is median + * i.e. (m + n)/2 + */ + if ((m + n) % 2 == 1){ + for (count = 0; count <= (n + m) / 2; count++){ + if(i != n && j != m){ + m1 = (a1[i] > a2[j]) ? a2[j++] : a1[i++]; + } + else if(i < n) + m1 = a1[i++]; + // for case when j < m. + else + m1 = a2[j++]; + } + return m1; + } + /* + * median will be average of elements + * at index (( m + n) / 2 - 1) and (m + n) / 2 + * in the array obtained after merging a1 and a2. + */ + else{ + for (count = 0; count <= (n + m) / 2; count++){ + m2 = m1; + if (i != n && j != m) + m1 = (a1[i] > a2[j]) ? a2[j++] : a1[i++]; + + else if(i < n) + m1 = a1[i++]; + + // for case when j < m. + else + m1 = a2[j++]; + } + return (m1 + m2) / 2; + } + } + + /* Driver program to test above function */ + public static void main(String[] args) { + + int[] a1 = {900}; + int[] a2 = {5, 8, 10, 20}; + + int n1 = a1.length; + int n2 = a2.length; + + System.out.println("Median is " + getMedian(a1, a2, n1, n2)); + + } +} diff --git a/arrays/FRE.java b/arrays/FRE.java new file mode 100644 index 0000000..5813ff5 --- /dev/null +++ b/arrays/FRE.java @@ -0,0 +1,40 @@ +package arrays; +import java.util.*; + +//Java Program for First Repeating Element +public class FRE { + + public static void main(String[] args) { + + @SuppressWarnings("resource") + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + + int a[] = new int[n]; + for(int i = 0; i < n; i++) + a[i] = sc.nextInt(); + + int N = (int) (1e6+2); + + //Array Input in Java + int idx[] = new int[N]; + for (int i = 0; i < N; i++) + idx[i] = -1; + + int minidx = Integer.MAX_VALUE; + + for (int i = 0; i < n; i++){ + if(idx[a[i]] != -1) + minidx = Math.min(minidx, idx[a[i]]); + else + idx[a[i]] = i; + } + + if(minidx == Integer.MAX_VALUE) + System.out.println("-1"); + + else + System.out.println(minidx + 1); + } + +} diff --git a/arrays/KadanesAlgorithm.java b/arrays/KadanesAlgorithm.java index 089335a..de15f21 100644 --- a/arrays/KadanesAlgorithm.java +++ b/arrays/KadanesAlgorithm.java @@ -10,7 +10,7 @@ public static void main(String[] args) { @SuppressWarnings("resource") Scanner sc = new Scanner(System.in); int n = sc.nextInt(); - int a[] = new int[n]; + int a[]=new int[n]; for(int i=0;i max) + max = m[i][c - 1]; + } + + int desired = (r * c + 1) / 2; + while (min < max) { + int mid = min + (max - min) / 2; + int place = 0; + int get = 0; + // find count of elements smaller than mid + for (int i = 0; i < r; ++i) { + get = Arrays.binarySearch(m[i], mid); + /* + * if element is not found in the array the binarySearch() method returns + * searched element by the following calculation + */ + if (get < 0) + get = Math.abs(get) - 1; + /* + * If the element is found in the array it returns the index(any index in case + * of duplicate). + * + * So we go to last index of element, which will give the number of elements + * smaller than the number including the searched element. + */ + else { + while (get < m[i].length && m[i][get] == mid) + get += 1; + } + place = place + get; + } + + if (place < desired) + min = mid + 1; + else + max = mid; + } + return min; + } + + // Driver program to test above method + public static void main(String[] args) { + int r = 3, c = 3; + int m[][] = { { 1, 3, 5 }, { 2, 6, 9 }, { 3, 6, 9 } }; + System.out.println("Median is" + binaryMedian(m, r, c)); + } + +} + diff --git a/matrix/Matrix_Problem_04.java b/matrix/Matrix_Problem_04.java new file mode 100644 index 0000000..633e9e6 --- /dev/null +++ b/matrix/Matrix_Problem_04.java @@ -0,0 +1,86 @@ +package matrix; + +/* + * Title: Find row with maximum no. of 1's + * We are given a boolean 2D array, where each row is sorted. + * Find the row with the maximum number of 1s. + */ + +/* + * Example: + * 0 1 1 1 + * 0 0 1 1 + * 1 1 1 1 "THIS ROW HAS MAXIMUM 1S" + * 0 0 0 0 + * + * Output: 2 + */ + +/* + * "A Simplex Method" is to do a row wise traversal of the matrix, + * count the number of 1s in each row and compare the count with max. + * Finally, return the index of row with maximum 1s. + * The time complexity of this method is O(m*n), + * where m is number of rows and n is number of columns in matrix. + * + * We can do it better. + * Since each row is sorted, we can use Binary Search to count of 1s in each row. + * The count of 1s will be equal to total number of columns minus the index of first 1. + */ + +public class Matrix_Problem_04 { + + static int R = 4, C = 4; + + // Function to find the index of first index of 1 in a boolean array arr[]. + static int first(int arr[], int low , int high) { + + if(high >= low) { + + //Get the middle index + int mid = low + (high - low)/2; + + //Check if the element at middle is first 1 + if((mid == 0 || (arr[mid - 1] == 0)) && arr[mid] == 1) + return mid; + + //If the element is 0, recur for right side + else if (arr[mid] == 0) + return first(arr, (mid + 1), high); + + //If the element is not first 1, recur for left side + else + return first(arr, low, (mid - 1)); + } + + return -1; + } + + //Function that returns index of row with maximum number of 1s + static int rowWithMaxis(int mat[][]) { + //Initialize max values + int max_row_index = 0, max = -1; + //Traverse for each row and count number of 1s by finding the index of first 1 + int i, index; + for(i = 0; i < R; i++) { + index = first(mat[i], 0, C - 1); + if(index != -1 && C - index > max) { + max = C - index ; + max_row_index = i; + } + } + return max_row_index; + } + + //Driver Code + public static void main(String[] args) { + int mat[][] = { + {0, 0, 0, 1}, + {0, 1, 1, 1}, + {1, 1, 1, 1}, + {0, 0, 0, 0} }; + + System.out.println("Index of row with maximum index is : " + rowWithMaxis(mat)); + } + +} diff --git a/matrix/Matrix_Problem_05.java b/matrix/Matrix_Problem_05.java new file mode 100644 index 0000000..183f898 --- /dev/null +++ b/matrix/Matrix_Problem_05.java @@ -0,0 +1,69 @@ +package matrix; +/* + * Title: A java program to Print all elements in sorted order from row and column wise sorted matrix + */ +public class Matrix_Problem_05 { + + static final int INF = Integer.MAX_VALUE; + static final int N = 4; + + /* + * A utility function to youngify a Young Tableau, + * This is different from standard youngify. + * It assumnes that the value at mat[0][0] is infinite. + */ + static void youngify(int mat[][], int i, int j) { + + //Find the values at down and right sides of mat[i][j] + int downVal = (i + 1 < N)? mat[i + 1][j] : INF; + int rightVal = (j + 1 < N)? mat[i][j + 1] : INF; + + // if mat[i][j] is the down right corner element. return. + if(downVal == INF && rightVal == INF) { + return; + } + + /* + * Move the smaller of two values(downVal and rightVal to mat[i][j] + * and recur for smaller value + */ + if(downVal < rightVal) { + mat[i][j] = downVal; + mat[i + 1][j] = INF; + youngify(mat, i + 1, j); + } + + else { + mat[i][j] = rightVal; + mat[i][j + 1] = INF; + youngify(mat, i, j + 1); + } + } + + // A utility function to extract minimum element from Young Tableau. + static int extractMin(int mat[][]) { + int ret = mat[0][0]; + mat[0][0] = INF; + youngify(mat, 0, 0); + return ret; + } + + //This function uses extractMin() to print elements in sorted order + static void printSorted(int mat[][]) { + System.out.println("Element of matrix in sorted order n"); + for(int i = 0; i < N * N; i++) { + System.out.print(extractMin(mat) + " "); + } + } + + //Driver Code + public static void main(String[] args) { + int mat[][] = { + {10, 20, 30, 40}, + {15, 25, 35, 45}, + {27, 29, 37, 48}, + {32, 33, 39, 50}}; + printSorted(mat); + } + +} diff --git a/matrix/Matrix_Problem_06.java b/matrix/Matrix_Problem_06.java new file mode 100644 index 0000000..0a2ac41 --- /dev/null +++ b/matrix/Matrix_Problem_06.java @@ -0,0 +1,82 @@ +package matrix; +import java.util.*; + +/* + * Title: Maximum size rectangle binary sub-matrix with all 1s + * + * Given a binary matrix, find the maximum size rectangle binary-sub-matrix with all 1's + */ +public class Matrix_Problem_06 { + + static int maxHist(int C, int[] row) { + + Stack result = new Stack<>(); + int top_val; + int max_area = 0; + int area; + + int i = 0; + while(i < C) { + if(result.empty() || row[result.peek()] <= row[i]) + result.push(i++); + + else { + top_val = row[result.peek()]; + result.pop(); + area = top_val * i; + + if(!result.empty()) + area = top_val * (i - result.peek() - 1); + max_area = Math.max(area, max_area); + } + } + + //Now pop the remaining bars stack and calculate area with every popped bar as the smallest bar + while(!result.empty()) { + top_val = row[result.peek()]; + result.pop(); + area = top_val * i; + if(!result.empty()) + area = top_val * (i - result.peek() - 1); + + max_area = Math.max(area, max_area); + } + return max_area; + } + + //Returns area of the largest rectangle with all 1s in A[][] + static int maxRectangle(int R, int C, int[][] A) { + + //Calculate area for first row and initialize it as result + int result = maxHist(C, A[0]); + + //iterate over row to find maximum rectangular area considering each row as histogram + for(int i = 1; i < R; i++) { + for(int j = 0; j < C; j ++) { + //if A[i][j] is 1 then Add A[i - 1][j] + if(A[i][j] == 1) + A[i][j] += A[i - 1][j]; + } + + //Update result if area with current row (as last row of rectangle) is more + result = Math.max(result, maxHist(C, A[i])); + } + return result; + } + + //Driver Code + public static void main(String[] args) { + int R = 4; + int C = 4; + + int[][] A = { + {0, 1, 1, 0}, + {1, 1, 1, 1}, + {1, 1, 1, 1}, + {1, 1, 0, 0}, + }; + + System.out.print("Area of maximum rectangle is " + maxRectangle(R, C, A)); + } + +} diff --git a/matrix/Matrix_Problem_07.java b/matrix/Matrix_Problem_07.java new file mode 100644 index 0000000..ba9b436 --- /dev/null +++ b/matrix/Matrix_Problem_07.java @@ -0,0 +1,38 @@ +package matrix; +/* Problem Title :-> Find a specific pair in Matrix */ +/* Approach :-> A Naive method to find maximum value of mat1[d][e] - mat[a][b] such that d > a and e > b */ +public class Matrix_Problem_07{ + + //The Function returns maximum value A(d, e) - A(a, b) + // over all choices of indexes such that both d > a and e > b. + static int findMaxValue(int N, int[][] mat){ + //stores maximum value + int maxValue = Integer.MIN_VALUE; + //Consider all possible pairs mat[a][b] and mat1[d][e] + for(int a = 0; a < N - 1; a++){ + for(int b = 0; b < N - 1 - 1; b++) { + for (int d = a + 1; d < N; d++) { + for (int e = b + 1; e < N; e++){ + if (maxValue < mat[d][e] - mat[a][b]) + maxValue = mat[d][e] - mat[a][b]; + } + } + } + } + return maxValue; + } + + //Drier Code + public static void main(String[] args) { + int N = 5; + int[][] mat = { + {1, 2, -1, -4, -20}, + {-8, -3, 4, 2, 1}, + {3, 8, 6, 1, 3}, + {-4, -1, 1, 7, -6}, + {0, -4, 10, -5, 1}, + }; + + System.out.println("Maximum Value is " + findMaxValue(N, mat)); + } +} \ No newline at end of file diff --git a/matrix/Matrix_Problem_08.java b/matrix/Matrix_Problem_08.java new file mode 100644 index 0000000..a59417c --- /dev/null +++ b/matrix/Matrix_Problem_08.java @@ -0,0 +1,41 @@ +package matrix; +/*Rotate Matrix by 90 degrees*/ + +public class Matrix_Problem_08{ + static int N = 4; + //Function to rotate the matrix 90 degree clockwise + static void rotate90(int[][] a){ + //Traverse Each Cycle + for(int i = 0; i < N/2; i++){ + for(int j = i; j < N - i - 1; j++){ + //Swap elements of each cycle in clockwise direction + int temp = a[i][j]; + a[N - 1 - j][i] = a[N - 1 - i][N - 1 - j]; + a[N - 1 - i][N - 1 - j] = a[j][N - 1 -i]; + a[j][N - 1 - i] = temp; + } + } + } + + //Function for print matrix + static void printMatrix(int[][] a){ + for (int i = 0; i < N; i++){ + for (int j = 0; j < N; j++){ + System.out.print(a[i][j] + " "); + System.out.println(); + } + } + } + + //Drier Code + public static void main(String[] args) { + int[][] a = { + {1, 2, 3, 4}, + {5, 6, 7, 8}, + {9, 10, 11, 12}, + {13, 14, 15, 16}, + }; + rotate90(a); + printMatrix(a); + } +} diff --git a/matrix/Matrix_Problem_09.java b/matrix/Matrix_Problem_09.java new file mode 100644 index 0000000..37019ee --- /dev/null +++ b/matrix/Matrix_Problem_09.java @@ -0,0 +1,71 @@ +package matrix; +//Kth smallest element in a row-column wise sorted matrix +public class Matrix_Problem_09 { + static class HeapNode{ + int val; + int r, c; + + HeapNode(int val, int r, int c){ + this.val = val; + this.c = c; + this.r = r; + } + } + static void swap(int i, int min, HeapNode[] a){ + HeapNode temp = a[i]; + a[i] = a[min]; + a[min] = temp; + } + + static void minHeapify(HeapNode[] ha, int i, int heap_size){ + int l = 2 * i + 1; + int r = 2 * i + 2; + int min = i; + + if(l < heap_size && ha[l].val < ha[i].val) + min = l; + if(r < heap_size && ha[r].val < ha[i].val) + min = r; + if(min != i){ + swap(i, min, ha); + minHeapify(ha, min, heap_size); + } + } + static void buildHeap(HeapNode[] ha, int n){ + int i = (n - 1)/2; + while(i > 0){ + minHeapify(ha, i, n); + i--; + } + } + public static int kthSmallest(int[][] mat, int n, int k){ + if(k <= 0 || k > n*n) + return Integer.MAX_VALUE; + + HeapNode[] ha = new HeapNode[n]; + for (int i = 0; i < n; i++) + ha[i]= new HeapNode(mat[0][i], 0, i); + + buildHeap(ha, n); + + HeapNode hr = new HeapNode(0,0,0); + + for (int i = 1; i < k; i++){ + hr = ha[0]; + int nextVal = hr.r < n - 1 ? mat[hr.r+1][hr.c] : Integer.MAX_VALUE; + ha[0] = new HeapNode(nextVal, hr.r + 1, hr.c); + minHeapify(ha, 0, n); + } + return hr.val; + } + public static void main(String[] args) { + int[][] mat = { + {10, 20, 30, 40}, + {15, 25, 35, 45}, + {25, 29, 37, 48}, + {32, 33, 39, 50} + }; + int res = kthSmallest(mat, 4, 7); + System.out.print("7th smallest element is " + res); + } +} diff --git a/matrix/Matrix_Problem_10.java b/matrix/Matrix_Problem_10.java new file mode 100644 index 0000000..bb81470 --- /dev/null +++ b/matrix/Matrix_Problem_10.java @@ -0,0 +1,53 @@ +package matrix; +//Common elements in all rows of a given matrix +public class Matrix_Problem_10 { + static final int M = 4; + static final int N = 5; + + static int findCommon(int[][] mat){ + int[] col = new int[M]; + int min_row, i; + + for(i = 0; i < M; i++) + col[i] = N - 1; + + min_row = 0; + + while(col[min_row] >= 0){ + for (i = 0; i < M; i++){ + if (mat[i][col[i]] < mat[min_row][col[min_row]]) + min_row = i; + } + + int eq_count = 0; + + for (i = 0; i < M; i++){ + if (mat[i][col[i]] > mat[min_row][col[min_row]]){ + if (col[i] == 0) + return -1; + + col[i] -= 1; + } + else + eq_count++; + } + if (eq_count == M) + return mat[min_row][col[min_row]]; + } + return -1; + } + + public static void main(String[] args) { + int[][] mat = { + {1, 2, 3, 4, 5}, + {2, 4, 5, 8, 10}, + {3, 5, 7, 9, 11}, + {1, 3, 5, 7, 9} + }; + int result = findCommon(mat); + if (result == -1) + System.out.print("No common element"); + else + System.out.print("Common element is " + result); + } +} From 5655527b55219dea7168aaf596c031ed4cf9129d Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Sun, 17 Jan 2021 15:40:09 +0530 Subject: [PATCH 21/56] #Modification 21 --- src | 1 + 1 file changed, 1 insertion(+) create mode 160000 src diff --git a/src b/src new file mode 160000 index 0000000..26d2d57 --- /dev/null +++ b/src @@ -0,0 +1 @@ +Subproject commit 26d2d577f3d9fe69db155171c374a6391232703f From 2ba21141abae16d0f79a26994cd1c424c61bc057 Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Thu, 21 Jan 2021 11:18:58 +0530 Subject: [PATCH 22/56] #Modification 22 --- .../BT_Problem_01.java | 0 binaryTree/BT_Problem_02.java | 92 ++++++++++ binaryTree/BT_Problem_03.java | 50 ++++++ binaryTree/BT_Problem_04.java | 61 +++++++ binaryTree/BT_Problem_05.java | 84 ++++++++++ binaryTree/BT_Problem_06_a.java | 62 +++++++ binaryTree/BT_Problem_06_b.java | 98 +++++++++++ binaryTree/BT_Problem_07.java | 15 ++ binaryTree/BT_Problem_08.java | 10 ++ binaryTree/BT_Problem_09.java | 51 ++++++ binaryTree/BT_Problem_10.java | 15 ++ .../BT_Problem_11.java | 3 +- binaryTree/BT_Problem_12.java | 10 ++ binaryTree/BT_Problem_13.java | 10 ++ binaryTree/BT_Problem_14.java | 10 ++ binaryTree/BT_Problem_15.java | 9 + binaryTree/BT_Problem_16.java | 10 ++ binaryTree/BT_Problem_17.java | 10 ++ binaryTree/BT_Problem_18.java | 10 ++ binaryTree/BT_Problem_19.java | 9 + binaryTree/BT_Problem_31.java | 76 +++++++++ binaryTree/BT_Problem_35.java | 66 ++++++++ data_from_eclipse_ide/arrays/ArrayLevel1.java | 17 -- data_from_eclipse_ide/arrays/ArrayLevel2.java | 34 ---- .../arrays/Array_Problem_1.java | 41 ----- .../arrays/Array_Problem_10.java | 51 ------ .../arrays/Array_Problem_11.java | 33 ---- .../arrays/Array_Problem_12.java | 69 -------- .../arrays/Array_Problem_18.java | 29 ---- .../arrays/Array_Problem_2.java | 55 ------ .../arrays/Array_Problem_23.java | 45 ----- .../arrays/Array_Problem_3.java | 122 -------------- .../arrays/Array_Problem_32.java | 35 ---- .../arrays/Array_Problem_4_Approach1.java | 63 ------- .../arrays/Array_Problem_4_Approach2.java | 47 ------ .../arrays/Array_Problem_5.java | 41 ----- .../arrays/Array_Problem_6.java | 118 ------------- .../arrays/Array_Problem_7.java | 42 ----- .../arrays/Array_Problem_8.java | 32 ---- .../arrays/Array_Problem_9.java | 65 ------- .../arrays/Array_of_objects.java | 44 ----- .../arrays/Candy_Distribution_Problem.java | 49 ------ data_from_eclipse_ide/arrays/FRE.java | 40 ----- .../arrays/KadanesAlgorithm.java | 31 ---- data_from_eclipse_ide/arrays/MultiDArray.java | 16 -- .../backtracking/Rat_In_A_Maze.java | 90 ---------- .../basicProblems/Armstrong_Number.java | 26 --- .../basicProblems/Factorial.class | Bin 1124 -> 0 bytes .../basicProblems/Factorial.java | 20 --- .../basicProblems/Fibonacci_Series.java | 26 --- .../Multiplicative_Table_till_20.java | 27 --- .../basicProblems/Palindrome_Number.java | 9 - .../basicProblems/Prime_Number_Or_Not.java | 28 ---- ...ive_decimal_number_from_right_to_left.java | 19 --- .../basicProblems/Reverse_Given_number.java | 22 --- .../basicProblems/Series_Sum_1.java | 22 --- .../basicProblems/Series_Sum_2.java | 32 ---- .../basicProblems/Swap_two_numbers.java | 17 -- .../basicProblems/Swapping_2.java | 24 --- .../basicProblems/X_raisedTo_power_Y.java | 18 -- .../basic_idea_of_DS/ArrayDequeDemo.java | 24 --- .../basic_idea_of_DS/ArrayListDemo.java | 33 ---- .../basic_idea_of_DS/Graph.java | 41 ----- .../basic_idea_of_DS/HashMapIntro.java | 28 ---- .../basic_idea_of_DS/LinkedListDemo.java | 35 ---- .../basic_idea_of_DS/List.java | 14 -- .../basic_idea_of_DS/MYStackByList.java | 121 -------------- .../basic_idea_of_DS/MyArrayList.java | 33 ---- .../basic_idea_of_DS/MyHashMap.java | 28 ---- .../basic_idea_of_DS/MyHashSet.java | 21 --- .../basic_idea_of_DS/MyLinkedList.java | 35 ---- .../basic_idea_of_DS/MyQueue.java | 82 --------- .../basic_idea_of_DS/MyStack.java | 58 ------- .../basic_idea_of_DS/SetExample.java | 34 ---- .../basic_idea_of_DS/Tree.java | 52 ------ .../basics/ControlStatements.java | 29 ---- data_from_eclipse_ide/basics/DoWhileLoop.java | 15 -- .../basics/Fast_Inputs_Main.java | 63 ------- data_from_eclipse_ide/basics/Operators.java | 17 -- .../basics/VariablesandDataTypes.java | 15 -- data_from_eclipse_ide/basics/WhileLoop.java | 14 -- .../dp/CoinChoiseProblem.java | 51 ------ .../graphs/Graph_Traversal_DFS.java | 57 ------- .../matrix/Matrix_Problem_01.java | 87 ---------- .../matrix/Matrix_Problem_02.java | 123 -------------- data_from_eclipse_ide/oops/A.java | 10 -- .../oops/MYStaticKeyword.java | 22 --- data_from_eclipse_ide/oops/Mor.java | 15 -- data_from_eclipse_ide/oops/MyConstructor.java | 13 -- data_from_eclipse_ide/oops/Person.java | 7 - data_from_eclipse_ide/oops/RepairShop.java | 20 --- data_from_eclipse_ide/oops/Sonata.java | 12 -- data_from_eclipse_ide/oops/StaticKeyword.java | 13 -- data_from_eclipse_ide/oops/Vehicle.java | 19 --- data_from_eclipse_ide/oops/Watches.java | 8 - .../oopsEncapsulation/EncapIntro.java | 17 -- .../oopsEncapsulation/S.java | 31 ---- .../oopsabstraction/Audi.java | 15 -- .../oopsabstraction/Car.java | 8 - .../oopsabstraction/RepairShop.java | 21 --- .../oopsabstraction/WagonR.java | 20 --- .../oopsinheritance/MainClass.java | 20 --- .../oopsinheritance/Person.java | 15 -- .../oopsinheritance/Singer.java | 9 - .../oopsinheritance/Teacher.java | 9 - .../oopspolymorphism/Animal.java | 5 - .../oopspolymorphism/Dog.java | 10 -- .../oopspolymorphism/MainClass.java | 29 ---- .../oopspolymorphism/Pet.java | 9 - .../patternsByloops/Pattern1.java | 19 --- .../patternsByloops/Pattern2.java | 17 -- .../patternsByloops/Pattern3.java | 18 -- .../patternsByloops/Pattern4.java | 20 --- .../patternsByloops/Pattern5.java | 30 ---- .../patternsByloops/Pattern5_2.java | 24 --- .../patternsByloops/Pattern6.java | 21 --- .../patternsByloops/Pattern7.java | 18 -- .../patternsByloops/Pattern8.java | 21 --- .../patternsByloops/Pattern9.java | 19 --- .../practiceProblems/Cylinder.java | 26 --- .../practiceProblems/Exercise1.java | 33 ---- .../practiceProblems/Exercise2.java | 34 ---- .../Getters_Setters_For_Cylinder.java | 44 ----- .../recursion/Factorial.java | 21 --- data_from_eclipse_ide/recursion/NRaiseP.java | 15 -- .../recursion/NaturalNoSum.java | 20 --- .../recursion/Subsequences.java | 50 ------ .../recursion/Tower_Of_Hanoi.java | 29 ---- .../searchingAlgorithms/BinarySearch.java | 47 ------ .../searchingAlgorithms/LinearSearch.java | 28 ---- .../sortingAlgorithms/BubbleSort.java | 43 ----- .../sortingAlgorithms/HeapSort.java | 76 --------- .../sortingAlgorithms/InsertionSort.java | 42 ----- .../sortingAlgorithms/MergeSort.java | 98 ----------- .../sortingAlgorithms/QuickSort.java | 80 --------- .../sortingAlgorithms/RadixSort.java | 73 -------- .../sortingAlgorithms/SelectionSort.java | 42 ----- .../stack_and_queue/Infix_To_Postfix.java | 76 --------- .../Parenthesis_Checker_Problem.java | 75 --------- .../Stack_Queue_Problem_01_i.java | 69 -------- .../Stack_Queue_Problem_01_ii.java | 115 ------------- .../Stack_Queue_Problem_02_i.java | 67 -------- .../Stack_Queue_Problem_02_ii.java | 10 -- graphs/Graph.java | 2 +- graphs/Graph_Problem_01_i.java | 50 ++++++ .../Graph_Problem_01_ii.java | 16 +- graphs/Graph_Problem_02.java | 75 +++++++++ graphs/Graph_Problem_03.java | 75 +++++++++ greedy/Greedy_Problem_01.java | 45 +++++ .../Deletion_in_Linked_List.java | 0 .../Insertion_in_Linked_List.java | 0 .../linkedList => linkedList}/MainList.java | 0 .../linkedList => linkedList}/MyLL.java | 0 .../Problem_1_1.java | 0 .../Problem_1_2.java | 0 .../linkedList => linkedList}/Queue.java | 0 list/MainList.java | 24 +-- list/MyLL.java | 103 ++++++++---- oopsEncapsulation/EncapIntro.java | 5 +- oopsEncapsulation/S.java | 14 +- oopsabstraction/Audi.java | 7 +- oopsabstraction/Car.java | 2 - queues/ArrayDequeDemo.java | 1 - src | 1 - ssp/SSP_Problem_01.java | 66 ++++++++ ssp/SSP_Problem_02.java | 30 ++++ ssp/SSP_Problem_03.java | 50 ++++++ t/trees/BST_Deletion.java | 158 ------------------ t/trees/BT_Traversal.java | 82 --------- t/trees/BinarySearchTree.java | 88 ---------- t/trees/BinaryTreeNode.java | 13 -- t/trees/BinaryTreeUse.java | 51 ------ t/trees/BinaryTree_LOT.java | 99 ----------- ...struct_Tree_from_Preorder_and_Inorder.java | 69 -------- t/trees/Count_Nodes.java | 63 ------- t/trees/Count_leaf_nodes.java | 44 ----- t/trees/Insertion_In_BinaryTree.java | 80 --------- t/trees/Problem_01.java | 88 ---------- trees/BST_Deletion.java | 4 +- trees/BinarySearchTree.java | 4 +- trees/Count_leaf_nodes.java | 43 ++--- trees/FindFullNodesInABinaryTree.java | 84 +++++----- trees/Problem_01.java | 9 +- 183 files changed, 1308 insertions(+), 5384 deletions(-) rename {data_from_eclipse_ide/binaryTree => binaryTree}/BT_Problem_01.java (100%) create mode 100644 binaryTree/BT_Problem_02.java create mode 100644 binaryTree/BT_Problem_03.java create mode 100644 binaryTree/BT_Problem_04.java create mode 100644 binaryTree/BT_Problem_05.java create mode 100644 binaryTree/BT_Problem_06_a.java create mode 100644 binaryTree/BT_Problem_06_b.java create mode 100644 binaryTree/BT_Problem_07.java create mode 100644 binaryTree/BT_Problem_08.java create mode 100644 binaryTree/BT_Problem_09.java create mode 100644 binaryTree/BT_Problem_10.java rename data_from_eclipse_ide/binaryTree/BT_Problem_02.java => binaryTree/BT_Problem_11.java (68%) create mode 100644 binaryTree/BT_Problem_12.java create mode 100644 binaryTree/BT_Problem_13.java create mode 100644 binaryTree/BT_Problem_14.java create mode 100644 binaryTree/BT_Problem_15.java create mode 100644 binaryTree/BT_Problem_16.java create mode 100644 binaryTree/BT_Problem_17.java create mode 100644 binaryTree/BT_Problem_18.java create mode 100644 binaryTree/BT_Problem_19.java create mode 100644 binaryTree/BT_Problem_31.java create mode 100644 binaryTree/BT_Problem_35.java delete mode 100644 data_from_eclipse_ide/arrays/ArrayLevel1.java delete mode 100644 data_from_eclipse_ide/arrays/ArrayLevel2.java delete mode 100644 data_from_eclipse_ide/arrays/Array_Problem_1.java delete mode 100644 data_from_eclipse_ide/arrays/Array_Problem_10.java delete mode 100644 data_from_eclipse_ide/arrays/Array_Problem_11.java delete mode 100644 data_from_eclipse_ide/arrays/Array_Problem_12.java delete mode 100644 data_from_eclipse_ide/arrays/Array_Problem_18.java delete mode 100644 data_from_eclipse_ide/arrays/Array_Problem_2.java delete mode 100644 data_from_eclipse_ide/arrays/Array_Problem_23.java delete mode 100644 data_from_eclipse_ide/arrays/Array_Problem_3.java delete mode 100644 data_from_eclipse_ide/arrays/Array_Problem_32.java delete mode 100644 data_from_eclipse_ide/arrays/Array_Problem_4_Approach1.java delete mode 100644 data_from_eclipse_ide/arrays/Array_Problem_4_Approach2.java delete mode 100644 data_from_eclipse_ide/arrays/Array_Problem_5.java delete mode 100644 data_from_eclipse_ide/arrays/Array_Problem_6.java delete mode 100644 data_from_eclipse_ide/arrays/Array_Problem_7.java delete mode 100644 data_from_eclipse_ide/arrays/Array_Problem_8.java delete mode 100644 data_from_eclipse_ide/arrays/Array_Problem_9.java delete mode 100644 data_from_eclipse_ide/arrays/Array_of_objects.java delete mode 100644 data_from_eclipse_ide/arrays/Candy_Distribution_Problem.java delete mode 100644 data_from_eclipse_ide/arrays/FRE.java delete mode 100644 data_from_eclipse_ide/arrays/KadanesAlgorithm.java delete mode 100644 data_from_eclipse_ide/arrays/MultiDArray.java delete mode 100644 data_from_eclipse_ide/backtracking/Rat_In_A_Maze.java delete mode 100644 data_from_eclipse_ide/basicProblems/Armstrong_Number.java delete mode 100644 data_from_eclipse_ide/basicProblems/Factorial.class delete mode 100644 data_from_eclipse_ide/basicProblems/Factorial.java delete mode 100644 data_from_eclipse_ide/basicProblems/Fibonacci_Series.java delete mode 100644 data_from_eclipse_ide/basicProblems/Multiplicative_Table_till_20.java delete mode 100644 data_from_eclipse_ide/basicProblems/Palindrome_Number.java delete mode 100644 data_from_eclipse_ide/basicProblems/Prime_Number_Or_Not.java delete mode 100644 data_from_eclipse_ide/basicProblems/Print_all_digits_of_positive_decimal_number_from_right_to_left.java delete mode 100644 data_from_eclipse_ide/basicProblems/Reverse_Given_number.java delete mode 100644 data_from_eclipse_ide/basicProblems/Series_Sum_1.java delete mode 100644 data_from_eclipse_ide/basicProblems/Series_Sum_2.java delete mode 100644 data_from_eclipse_ide/basicProblems/Swap_two_numbers.java delete mode 100644 data_from_eclipse_ide/basicProblems/Swapping_2.java delete mode 100644 data_from_eclipse_ide/basicProblems/X_raisedTo_power_Y.java delete mode 100644 data_from_eclipse_ide/basic_idea_of_DS/ArrayDequeDemo.java delete mode 100644 data_from_eclipse_ide/basic_idea_of_DS/ArrayListDemo.java delete mode 100644 data_from_eclipse_ide/basic_idea_of_DS/Graph.java delete mode 100644 data_from_eclipse_ide/basic_idea_of_DS/HashMapIntro.java delete mode 100644 data_from_eclipse_ide/basic_idea_of_DS/LinkedListDemo.java delete mode 100644 data_from_eclipse_ide/basic_idea_of_DS/List.java delete mode 100644 data_from_eclipse_ide/basic_idea_of_DS/MYStackByList.java delete mode 100644 data_from_eclipse_ide/basic_idea_of_DS/MyArrayList.java delete mode 100644 data_from_eclipse_ide/basic_idea_of_DS/MyHashMap.java delete mode 100644 data_from_eclipse_ide/basic_idea_of_DS/MyHashSet.java delete mode 100644 data_from_eclipse_ide/basic_idea_of_DS/MyLinkedList.java delete mode 100644 data_from_eclipse_ide/basic_idea_of_DS/MyQueue.java delete mode 100644 data_from_eclipse_ide/basic_idea_of_DS/MyStack.java delete mode 100644 data_from_eclipse_ide/basic_idea_of_DS/SetExample.java delete mode 100644 data_from_eclipse_ide/basic_idea_of_DS/Tree.java delete mode 100644 data_from_eclipse_ide/basics/ControlStatements.java delete mode 100644 data_from_eclipse_ide/basics/DoWhileLoop.java delete mode 100644 data_from_eclipse_ide/basics/Fast_Inputs_Main.java delete mode 100644 data_from_eclipse_ide/basics/Operators.java delete mode 100644 data_from_eclipse_ide/basics/VariablesandDataTypes.java delete mode 100644 data_from_eclipse_ide/basics/WhileLoop.java delete mode 100644 data_from_eclipse_ide/dp/CoinChoiseProblem.java delete mode 100644 data_from_eclipse_ide/graphs/Graph_Traversal_DFS.java delete mode 100644 data_from_eclipse_ide/matrix/Matrix_Problem_01.java delete mode 100644 data_from_eclipse_ide/matrix/Matrix_Problem_02.java delete mode 100644 data_from_eclipse_ide/oops/A.java delete mode 100644 data_from_eclipse_ide/oops/MYStaticKeyword.java delete mode 100644 data_from_eclipse_ide/oops/Mor.java delete mode 100644 data_from_eclipse_ide/oops/MyConstructor.java delete mode 100644 data_from_eclipse_ide/oops/Person.java delete mode 100644 data_from_eclipse_ide/oops/RepairShop.java delete mode 100644 data_from_eclipse_ide/oops/Sonata.java delete mode 100644 data_from_eclipse_ide/oops/StaticKeyword.java delete mode 100644 data_from_eclipse_ide/oops/Vehicle.java delete mode 100644 data_from_eclipse_ide/oops/Watches.java delete mode 100644 data_from_eclipse_ide/oopsEncapsulation/EncapIntro.java delete mode 100644 data_from_eclipse_ide/oopsEncapsulation/S.java delete mode 100644 data_from_eclipse_ide/oopsabstraction/Audi.java delete mode 100644 data_from_eclipse_ide/oopsabstraction/Car.java delete mode 100644 data_from_eclipse_ide/oopsabstraction/RepairShop.java delete mode 100644 data_from_eclipse_ide/oopsabstraction/WagonR.java delete mode 100644 data_from_eclipse_ide/oopsinheritance/MainClass.java delete mode 100644 data_from_eclipse_ide/oopsinheritance/Person.java delete mode 100644 data_from_eclipse_ide/oopsinheritance/Singer.java delete mode 100644 data_from_eclipse_ide/oopsinheritance/Teacher.java delete mode 100644 data_from_eclipse_ide/oopspolymorphism/Animal.java delete mode 100644 data_from_eclipse_ide/oopspolymorphism/Dog.java delete mode 100644 data_from_eclipse_ide/oopspolymorphism/MainClass.java delete mode 100644 data_from_eclipse_ide/oopspolymorphism/Pet.java delete mode 100644 data_from_eclipse_ide/patternsByloops/Pattern1.java delete mode 100644 data_from_eclipse_ide/patternsByloops/Pattern2.java delete mode 100644 data_from_eclipse_ide/patternsByloops/Pattern3.java delete mode 100644 data_from_eclipse_ide/patternsByloops/Pattern4.java delete mode 100644 data_from_eclipse_ide/patternsByloops/Pattern5.java delete mode 100644 data_from_eclipse_ide/patternsByloops/Pattern5_2.java delete mode 100644 data_from_eclipse_ide/patternsByloops/Pattern6.java delete mode 100644 data_from_eclipse_ide/patternsByloops/Pattern7.java delete mode 100644 data_from_eclipse_ide/patternsByloops/Pattern8.java delete mode 100644 data_from_eclipse_ide/patternsByloops/Pattern9.java delete mode 100644 data_from_eclipse_ide/practiceProblems/Cylinder.java delete mode 100644 data_from_eclipse_ide/practiceProblems/Exercise1.java delete mode 100644 data_from_eclipse_ide/practiceProblems/Exercise2.java delete mode 100644 data_from_eclipse_ide/practiceProblems/Getters_Setters_For_Cylinder.java delete mode 100644 data_from_eclipse_ide/recursion/Factorial.java delete mode 100644 data_from_eclipse_ide/recursion/NRaiseP.java delete mode 100644 data_from_eclipse_ide/recursion/NaturalNoSum.java delete mode 100644 data_from_eclipse_ide/recursion/Subsequences.java delete mode 100644 data_from_eclipse_ide/recursion/Tower_Of_Hanoi.java delete mode 100644 data_from_eclipse_ide/searchingAlgorithms/BinarySearch.java delete mode 100644 data_from_eclipse_ide/searchingAlgorithms/LinearSearch.java delete mode 100644 data_from_eclipse_ide/sortingAlgorithms/BubbleSort.java delete mode 100644 data_from_eclipse_ide/sortingAlgorithms/HeapSort.java delete mode 100644 data_from_eclipse_ide/sortingAlgorithms/InsertionSort.java delete mode 100644 data_from_eclipse_ide/sortingAlgorithms/MergeSort.java delete mode 100644 data_from_eclipse_ide/sortingAlgorithms/QuickSort.java delete mode 100644 data_from_eclipse_ide/sortingAlgorithms/RadixSort.java delete mode 100644 data_from_eclipse_ide/sortingAlgorithms/SelectionSort.java delete mode 100644 data_from_eclipse_ide/stack_and_queue/Infix_To_Postfix.java delete mode 100644 data_from_eclipse_ide/stack_and_queue/Parenthesis_Checker_Problem.java delete mode 100644 data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_01_i.java delete mode 100644 data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_01_ii.java delete mode 100644 data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_02_i.java delete mode 100644 data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_02_ii.java create mode 100644 graphs/Graph_Problem_01_i.java rename data_from_eclipse_ide/graphs/Graph.java => graphs/Graph_Problem_01_ii.java (74%) create mode 100644 graphs/Graph_Problem_02.java create mode 100644 graphs/Graph_Problem_03.java create mode 100644 greedy/Greedy_Problem_01.java rename {data_from_eclipse_ide/linkedList => linkedList}/Deletion_in_Linked_List.java (100%) rename {data_from_eclipse_ide/linkedList => linkedList}/Insertion_in_Linked_List.java (100%) rename {data_from_eclipse_ide/linkedList => linkedList}/MainList.java (100%) rename {data_from_eclipse_ide/linkedList => linkedList}/MyLL.java (100%) rename {data_from_eclipse_ide/linkedList => linkedList}/Problem_1_1.java (100%) rename {data_from_eclipse_ide/linkedList => linkedList}/Problem_1_2.java (100%) rename {data_from_eclipse_ide/linkedList => linkedList}/Queue.java (100%) delete mode 160000 src create mode 100644 ssp/SSP_Problem_01.java create mode 100644 ssp/SSP_Problem_02.java create mode 100644 ssp/SSP_Problem_03.java delete mode 100644 t/trees/BST_Deletion.java delete mode 100644 t/trees/BT_Traversal.java delete mode 100644 t/trees/BinarySearchTree.java delete mode 100644 t/trees/BinaryTreeNode.java delete mode 100644 t/trees/BinaryTreeUse.java delete mode 100644 t/trees/BinaryTree_LOT.java delete mode 100644 t/trees/Construct_Tree_from_Preorder_and_Inorder.java delete mode 100644 t/trees/Count_Nodes.java delete mode 100644 t/trees/Count_leaf_nodes.java delete mode 100644 t/trees/Insertion_In_BinaryTree.java delete mode 100644 t/trees/Problem_01.java diff --git a/data_from_eclipse_ide/binaryTree/BT_Problem_01.java b/binaryTree/BT_Problem_01.java similarity index 100% rename from data_from_eclipse_ide/binaryTree/BT_Problem_01.java rename to binaryTree/BT_Problem_01.java diff --git a/binaryTree/BT_Problem_02.java b/binaryTree/BT_Problem_02.java new file mode 100644 index 0000000..e5eaae4 --- /dev/null +++ b/binaryTree/BT_Problem_02.java @@ -0,0 +1,92 @@ +package binaryTree; +import java.util.*; + +// Find Reverse Level Order traversal + +public class BT_Problem_02 { + + Node root; + + /* Given a binary tree, print its nodes in reverse level order */ + @SuppressWarnings({ "unchecked", "rawtypes" }) + void reverseLevelOrder(Node node) { + + //Logic for O(n^2) Time Complexity approach +// int h = height(node); +// int i; +// for(i = h; i >= 1; i--) +// printGivenLevel(node, i); + + Stack S = new Stack(); + Queue Q = new LinkedList(); + Q.add(node); + + // Do something like normal level order traversal order. + // Following are the differences with normal level order traversal: + // 1. Instead of printing a node, we push the node to stack + // 2. Right subtree is visited before left subtree. + while(Q.isEmpty() == false) { + + //Dequeue node and make it root + node = Q.peek(); + Q.remove(); + S.push(node); + + //Enqueue right child + if(node.right != null) + Q.add(node.right); //Node RIGHT CHILD IS ENQUEUED BEFORE LEFT + + // Enqueue left child + if(node.left != null) + Q.add(node.left); + } + + // Now pop all items from stack one by one and print them + while(S.empty() == false) { + node = S.peek(); + System.out.print(node.data + " "); + S.pop(); + } + + } + +// void printGivenLevel(Node node, int level) { +// if(node == null) +// return; +// if(level == 1) +// System.out.print(node.data + " "); +// else if(level > 1) { +// printGivenLevel(node.left, level - 1); +// printGivenLevel(node.right, level - 1); +// } +// } +// +// int height(Node node) { +// if(node == null) +// return 0; +// else { +// int lheight = height(node.left); +// int rheight = height(node.right); +// +// if(lheight > rheight) +// return (lheight + 1); +// else +// return (rheight + 1); +// } +// } +// + public static void main(String[] args) { + + BT_Problem_02 tree = new BT_Problem_02(); + + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + + System.out.println("Level Order traversal of binary tree is : "); + + tree.reverseLevelOrder(tree.root); + } +} diff --git a/binaryTree/BT_Problem_03.java b/binaryTree/BT_Problem_03.java new file mode 100644 index 0000000..200411c --- /dev/null +++ b/binaryTree/BT_Problem_03.java @@ -0,0 +1,50 @@ +package binaryTree; + +/* Problem Title :- Find the Height of a tree or Maximum Depth of a tree. + * + * Height of tree :- + * The height of a tree is the number of edges on the longest downward path + * between the root and a leaf. + */ +public class BT_Problem_03 { + + Node root; + + /* + * Compute the "maxDepth" of a tree -- + * the number of nodes along the longest path from the root node + * down to the farthest leaf node + */ + int maxDepth(Node node) { + + if(node == null) return 0; + + else { + /* compute the depth of each subtree */ + int lDepth = maxDepth(node.left); + int rDepth = maxDepth(node.right); + + /* use the larger one*/ + if(lDepth > rDepth) + return (lDepth + 1); + else + return (rDepth + 1); + } + } + + /* Driver program to test above functions */ + public static void main(String[] args) { + + BT_Problem_03 tree = new BT_Problem_03(); + + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + + System.out.println("Height of tree is : " + tree.maxDepth(tree.root)); + + } + +} diff --git a/binaryTree/BT_Problem_04.java b/binaryTree/BT_Problem_04.java new file mode 100644 index 0000000..c39aab9 --- /dev/null +++ b/binaryTree/BT_Problem_04.java @@ -0,0 +1,61 @@ +package binaryTree; +/* Problem Title :- Find the Diameter of a tree or Width of tree. + * + * Diameter of a tree :- + * The Diameter of a tree is the number of nodes on the longest path + * between two end nodes. + */ + +// Class to print the Diameter. +public class BT_Problem_04 { + + Node root; + + // Method to calculate the diameter and return it to main + int diameter(Node root) { + // base case if tree is empty + if(root == null) + return 0; + + // get the height of left and right sub-trees + int lheight = height(root.left); + int rheight = height(root.right); + + // get the diameter of left and right sub-trees + int ldiameter = diameter(root.left); + int rdiameter = diameter(root.right); + + return Math.max(lheight + rheight + 1, Math.max(ldiameter, rdiameter)); + } + + // A wrapper over diameter(Node root) + int diameter() {return diameter(root);} + + /* + * The function Compute the "height" of a tree. + * Height is the number of nodes along the longest path + * from the root node to the farthest leaf node. + */ + static int height(Node node) { + if(node == null) + return 0; + // If tree is not empty then height = 1 + max of left height and right heights. + return (1 + Math.max(height(node.left), height(node.left))); + } + + // Driver Code + public static void main(String[] args) { + + BT_Problem_04 tree = new BT_Problem_04(); + + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + + // Function Call + System.out.println("The diameter of given bianry tree is : " + tree.diameter()); + } + +} diff --git a/binaryTree/BT_Problem_05.java b/binaryTree/BT_Problem_05.java new file mode 100644 index 0000000..2d79344 --- /dev/null +++ b/binaryTree/BT_Problem_05.java @@ -0,0 +1,84 @@ +package binaryTree; + +/* Problem Title :- Find Mirror of a tree. + * + * Mirror of a tree :- + * The Diameter of a tree is the number of nodes on the longest path + * between two end nodes. + */ +public class BT_Problem_05 { + + /* + * A binary tree node has data, + * pointer to left child + * & a pointer to right child + */ + static class node{ + int val; + node left; + node right; + } + + /* + * Helper function that allocates a new node with the given data + * & null left and right pointers + */ + static node createNode(int val) { + node newNode = new node(); + newNode.val = val; + newNode.left = null; + newNode.right = null; + return newNode; + } + + /* + * Helper function to print + * In-order Traversal + */ + static void inorder(node root) { + if(root == null) + return; + inorder(root.left); + System.out.println(root.val); + inorder(root.right); + } + + /* + * mirror-i-f-y function takes two trees, + * original tree and a mirror tree + * It recurses on both the trees. + * but when original tree recurses on left, + * mirror tree recurses on right and vice-versa + */ + static node mirrorify(node root) { + if(root == null) + return null; + + // Create new mirror node from original tree node + node mirror = createNode(root.val); + mirror.right = mirrorify(root.left); + mirror.left = mirrorify(root.right); + return mirror; + } + + // Driver Code + public static void main(String[] args) { + + node tree = createNode(5); + tree.left = createNode(5); + tree.right = createNode(5); + tree.left.right = createNode(5); + tree.left.left = createNode(5); + + // print in-order traversal of the original input tree + System.out.print("\n Inorderr of original tree: "); + inorder(tree); + node mirror = null; + mirror = mirrorify(tree); + + // print in-order traversal of the mirror tree + System.out.print("\n Inorderr of mirror tree: "); + inorder(mirror); + } + +} diff --git a/binaryTree/BT_Problem_06_a.java b/binaryTree/BT_Problem_06_a.java new file mode 100644 index 0000000..9886cdd --- /dev/null +++ b/binaryTree/BT_Problem_06_a.java @@ -0,0 +1,62 @@ +package binaryTree; +import java.util.*; +/* + * Problem Title :- In-order Traversal of a tree both using Recursion + */ +// Class to print the in-order traversal +public class BT_Problem_06_a { + + // Root of Binary Tree + Node root; + + /* + * Given a binary tree, + * print its nodes in in-order + */ + void inorder() { + + if(root == null) return; + + Stack s = new Stack<>(); + Node curr = root; + + // traverse the tree + while(curr != null || s.size() > 0) { + /* Reach the left most Node of the current Node */ + while(curr != null) { + /* place pointer to a tree node on + * the stack before traversing + * the node,s left subtree */ + s.push(curr); + curr = curr.left; + } + + /*Current must be NULL at this point */ + curr = s.pop(); + + System.out.print(curr.data + " "); + + /* we have visited the node and its left subtree. + * Now, its right subtree's turn */ + curr = curr.right; + } + } + + // Driver method + public static void main(String[] args) { + + // creating a binary tree and entering the nodes + BT_Problem_06_a tree = new BT_Problem_06_a(); + + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + + tree.inorder(); + + } + +} + diff --git a/binaryTree/BT_Problem_06_b.java b/binaryTree/BT_Problem_06_b.java new file mode 100644 index 0000000..1bb728f --- /dev/null +++ b/binaryTree/BT_Problem_06_b.java @@ -0,0 +1,98 @@ +package binaryTree; + +/* + * Problem Title :- In-order Traversal of a tree both using Recursion + */ +public class BT_Problem_06_b { + + // Root of Binary Tree + Node root; + + // Constructor + BT_Problem_06_b(){ + root = null; + } + + /* + * Given a binary tree, + * print its nodes according to the + * "bottom-up" post-order traversal. + */ + void printPostorder(Node node) { + if(node == null) + return; + // first recur on left subtree + printPostorder(node.left); + + // then recur on right subtree + printPostorder(node.right); + + // now deal with the node + System.out.print(node.data + " "); + } + + /* + * Given a binary tree, + * print its nodes in in-order + */ + void printInorder(Node node) { + + if(node == null) return; + + /* first recur on left child */ + printPreorder(node.left); + + /* then print data of node */ + System.out.print(node.data + " "); + + /* now recur on right child */ + printPreorder(node.right); + } + + /* + * Given a binary tree, + * print its nodes in preorder + */ + void printPreorder(Node node) { + + if(node == null) return; + + /* first print data of node */ + System.out.print(node.data + " "); + + /* then recur on left subtree */ + printPreorder(node.left); + + /* now recur on right subtree */ + printPreorder(node.right); + } + + // Wrappers over above recursive functions + void printPostorder() { printPostorder(root);} + void printInorder() { printInorder(root); } + void printPreorder() { printPreorder(root); } + + // Driver method + public static void main(String[] args) { + + BT_Problem_06_b tree = new BT_Problem_06_b(); + + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + + System.out.println("Preorder traversal of binary tree is "); + tree.printPreorder(); + + System.out.println("\nInorder traversal of binary tree is "); + tree.printInorder(); + + System.out.println("\nPostorder traversal of binary tree is "); + tree.printPostorder(); + + } + + +} diff --git a/binaryTree/BT_Problem_07.java b/binaryTree/BT_Problem_07.java new file mode 100644 index 0000000..6d2485b --- /dev/null +++ b/binaryTree/BT_Problem_07.java @@ -0,0 +1,15 @@ +package binaryTree; +/* Problem Title :- Write a Java program to find Left View of a tree + * + * Left View of a tree :- + * The left view of a binary tree, is set of nodes visible when tree is visited from left side + * between two end nodes. + */ + +public class BT_Problem_07 { + + public static void main(String[] args) { + + } + +} diff --git a/binaryTree/BT_Problem_08.java b/binaryTree/BT_Problem_08.java new file mode 100644 index 0000000..c894fb8 --- /dev/null +++ b/binaryTree/BT_Problem_08.java @@ -0,0 +1,10 @@ +package binaryTree; +// Post-order Traversal of a tree both using recursion and Iteration +public class BT_Problem_08 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/binaryTree/BT_Problem_09.java b/binaryTree/BT_Problem_09.java new file mode 100644 index 0000000..2f2a45f --- /dev/null +++ b/binaryTree/BT_Problem_09.java @@ -0,0 +1,51 @@ +package binaryTree; + +/* Problem Title :- Write a Java program to find Left View of a tree + * + * Left View of a tree :- + * The left view of a binary tree, is set of nodes visible when tree is visited from left side + * between two end nodes. + */ +public class BT_Problem_09 { + + Node root; + static int max_level = 0; + + // recursive function to print the left view + void leftViewUtil(Node node, int level) { + // Base Case + if(node == null) + return; + + // If this is the first node of its level + if(max_level < level) { + System.out.print(" " + node.data); + max_level = level; + } + + // Recur for left and right subtrees + leftViewUtil(node.left, level + 1); + leftViewUtil(node.right, level + 1); + } + + // A wrapper over leftViewUtil() + void leftView() { + leftViewUtil(root, 1); + } + + // Driver Code + public static void main(String[] args) { + + /* creating a binary tree and entering the nodes */ + BT_Problem_09 tree = new BT_Problem_09(); + + tree.root = new Node(12); + tree.root.left = new Node(10); + tree.root.right = new Node(30); + tree.root.right.left = new Node(25); + tree.root.right.right = new Node(40); + + tree.leftView(); + } + +} diff --git a/binaryTree/BT_Problem_10.java b/binaryTree/BT_Problem_10.java new file mode 100644 index 0000000..a0eced6 --- /dev/null +++ b/binaryTree/BT_Problem_10.java @@ -0,0 +1,15 @@ +package binaryTree; +/* Problem Title :- Write a Java program to find Right View of Tree. + * + * Right View of a tree :- + * The right view of a binary tree, is set of nodes visible when tree is visited from rights side + * between two end nodes. + */ +public class BT_Problem_10 { + + public static void main(String[] args) { + + + } + +} diff --git a/data_from_eclipse_ide/binaryTree/BT_Problem_02.java b/binaryTree/BT_Problem_11.java similarity index 68% rename from data_from_eclipse_ide/binaryTree/BT_Problem_02.java rename to binaryTree/BT_Problem_11.java index 2fc079d..0c6ae7c 100644 --- a/data_from_eclipse_ide/binaryTree/BT_Problem_02.java +++ b/binaryTree/BT_Problem_11.java @@ -1,9 +1,8 @@ package binaryTree; -public class BT_Problem_02 { +public class BT_Problem_11 { public static void main(String[] args) { - } diff --git a/binaryTree/BT_Problem_12.java b/binaryTree/BT_Problem_12.java new file mode 100644 index 0000000..de59952 --- /dev/null +++ b/binaryTree/BT_Problem_12.java @@ -0,0 +1,10 @@ +package binaryTree; + +public class BT_Problem_12 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/binaryTree/BT_Problem_13.java b/binaryTree/BT_Problem_13.java new file mode 100644 index 0000000..218bc72 --- /dev/null +++ b/binaryTree/BT_Problem_13.java @@ -0,0 +1,10 @@ +package binaryTree; + +public class BT_Problem_13 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/binaryTree/BT_Problem_14.java b/binaryTree/BT_Problem_14.java new file mode 100644 index 0000000..1589c68 --- /dev/null +++ b/binaryTree/BT_Problem_14.java @@ -0,0 +1,10 @@ +package binaryTree; + +public class BT_Problem_14 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/binaryTree/BT_Problem_15.java b/binaryTree/BT_Problem_15.java new file mode 100644 index 0000000..772bf9d --- /dev/null +++ b/binaryTree/BT_Problem_15.java @@ -0,0 +1,9 @@ +package binaryTree; + +public class BT_Problem_15 { + + public static void main(String[] args) { + + } + +} diff --git a/binaryTree/BT_Problem_16.java b/binaryTree/BT_Problem_16.java new file mode 100644 index 0000000..209772f --- /dev/null +++ b/binaryTree/BT_Problem_16.java @@ -0,0 +1,10 @@ +package binaryTree; + +public class BT_Problem_16 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/binaryTree/BT_Problem_17.java b/binaryTree/BT_Problem_17.java new file mode 100644 index 0000000..d5a38e4 --- /dev/null +++ b/binaryTree/BT_Problem_17.java @@ -0,0 +1,10 @@ +package binaryTree; + +public class BT_Problem_17 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/binaryTree/BT_Problem_18.java b/binaryTree/BT_Problem_18.java new file mode 100644 index 0000000..6f39679 --- /dev/null +++ b/binaryTree/BT_Problem_18.java @@ -0,0 +1,10 @@ +package binaryTree; + +public class BT_Problem_18 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/binaryTree/BT_Problem_19.java b/binaryTree/BT_Problem_19.java new file mode 100644 index 0000000..777ba6f --- /dev/null +++ b/binaryTree/BT_Problem_19.java @@ -0,0 +1,9 @@ +package binaryTree; + +public class BT_Problem_19 { + + public static void main(String[] args) { + + } + +} diff --git a/binaryTree/BT_Problem_31.java b/binaryTree/BT_Problem_31.java new file mode 100644 index 0000000..d0cd8b9 --- /dev/null +++ b/binaryTree/BT_Problem_31.java @@ -0,0 +1,76 @@ +package binaryTree; +import java.util.*; + +/* + * Title: Find LCA in a Binary tree + */ + +class Solution{ + + @SuppressWarnings("unused") + private BT_Problem_31 ans; + + public Solution() { + this.ans = null; + } + + @SuppressWarnings("unused") + private boolean recurseTree(BT_Problem_31 currentNode, BT_Problem_31 p, BT_Problem_31 q) { + + if(currentNode == null) + return false; + + int left = this.recurseTree(currentNode.left, p, q) ? 1 : 0; + int right = this.recurseTree(currentNode.right, p, q) ? 1 : 0; + int mid = (currentNode == p || currentNode == q) ? 1 : 0; + + if(mid + left + right >= 2) + this.ans = currentNode; + + return (mid + left + right > 0); + } + + public BT_Problem_31 lowestCommonAncestor(BT_Problem_31 root, BT_Problem_31 p, BT_Problem_31 q) { + + Deque stack = new ArrayDeque<>(); + Map parent = new HashMap<>(); + + parent.put(root, null); + stack.push(root); + + while(!parent.containsKey(p) || !parent.containsKey(q)) { + BT_Problem_31 node = stack.pop(); + + if(node.left != null) { + parent.put(node.left, node); + stack.push(node.left); + } + + if(node.right != null) { + parent.put(node.right, node); + stack.push(node.right); + } + } + + Set ancestors = new HashSet<>(); + + while(p != null) { + ancestors.add(p); + p = parent.get(p); + } + + while(!ancestors.contains(q)) + q = parent.get(q); + + return q; + } +} + +public class BT_Problem_31{ + int val; + BT_Problem_31 left; + BT_Problem_31 right; + BT_Problem_31(int x){ + val = x; + } +} diff --git a/binaryTree/BT_Problem_35.java b/binaryTree/BT_Problem_35.java new file mode 100644 index 0000000..904be56 --- /dev/null +++ b/binaryTree/BT_Problem_35.java @@ -0,0 +1,66 @@ +package binaryTree; + +// Tree Isomorphism Problem +public class BT_Problem_35 { + + Node root1, root2; + boolean isIsomorphic(Node n1, Node n2) + { + // Both roots are NULL, trees isomorphic by definition + if (n1 == null && n2 == null) + return true; + + // Exactly one of the n1 and n2 is NULL, trees not isomorphic + if (n1 == null || n2 == null) + return false; + + if (n1.data != n2.data) + return false; + + // There are two possible cases for n1 and n2 to be isomorphic + // Case 1: The subtrees rooted at these nodes have NOT been "Flipped". + // Both of these subtrees have to be isomorphic. + // Case 2: The subtrees rooted at these nodes have been "Flipped" + return ( + isIsomorphic(n1.left, n2.left) + && + isIsomorphic(n1.right, n2.right) + ) + || + ( + isIsomorphic(n1.left, n2.right) + && + isIsomorphic(n1.right, n2.left) + ); + } + + // Driver program to test above functions + public static void main(String args[]) + { + BT_Problem_35 tree = new BT_Problem_35(); + + // Let us create trees shown in above diagram + tree.root1 = new Node(1); + tree.root1.left = new Node(2); + tree.root1.right = new Node(3); + tree.root1.left.left = new Node(4); + tree.root1.left.right = new Node(5); + tree.root1.right.left = new Node(6); + tree.root1.left.right.left = new Node(7); + tree.root1.left.right.right = new Node(8); + + tree.root2 = new Node(1); + tree.root2.left = new Node(3); + tree.root2.right = new Node(2); + tree.root2.right.left = new Node(4); + tree.root2.right.right = new Node(5); + tree.root2.left.right = new Node(6); + tree.root2.right.right.left = new Node(8); + tree.root2.right.right.right = new Node(7); + + if (tree.isIsomorphic(tree.root1, tree.root2) == true) + System.out.println("Yes"); + else + System.out.println("No"); + } + } \ No newline at end of file diff --git a/data_from_eclipse_ide/arrays/ArrayLevel1.java b/data_from_eclipse_ide/arrays/ArrayLevel1.java deleted file mode 100644 index c065dd2..0000000 --- a/data_from_eclipse_ide/arrays/ArrayLevel1.java +++ /dev/null @@ -1,17 +0,0 @@ -package arrays; - -public class ArrayLevel1 { - - public static void main(String[] args) { - int[] arr; - arr = new int[5]; - - arr[0] = 10; - arr[1] = 20; - arr[2] = 30; - arr[3] = 40; - arr[4] = 50; - - for(int i = 0 ; i =0) m[Math.abs(m[i])] = -m[Math.abs(m[i])]; - else System.out.print(Math.abs(m[i]) + " "); - } - } - - //Driver Method - public static void main(String[] args) { - - Array_Problem_11 dublicate= new Array_Problem_11(); - - int m[] = {1,2,3,1,3,6,6}; - int m_size = m.length; - - dublicate.printRepeating(m,m_size); - - } - -} - diff --git a/data_from_eclipse_ide/arrays/Array_Problem_12.java b/data_from_eclipse_ide/arrays/Array_Problem_12.java deleted file mode 100644 index e878764..0000000 --- a/data_from_eclipse_ide/arrays/Array_Problem_12.java +++ /dev/null @@ -1,69 +0,0 @@ -package arrays; - -import java.util.Arrays; - -/* - * Problem :- - * Merge two sorted array without using extra space - */ - -/* - * Understanding of the Problem :- - * - * We are given two sorted array. - * We need to merge these two arrays, - * such that the initial numbers(after complete sorting) are in the first array , - * and the remaining numbers are in the second array. - * Extra space allowed in O(1). - */ - -/* - * Simple Discussion : - * This task is simple and O(m+n) if we are allowed to use extra space. - * But it becomes really complicated when extra space is not allowed, - * and doesn't look possible in less than O(m*n) worst case time. - */ - -/* - * Idea or Approach of Solution :- - * The idea is to begin from last element of ar2[] and search it in ar1[]. - * If there is a greater element in ae1[], then we moe lastt element of ar2[] at correct place in ar1[]. - * - * We can use INSERTION Sort type of insertion for this. - */ - -public class Array_Problem_12 { - - static int arr1[] = new int[] {1, 5 , 9, 10, 15, 20}; - static int arr2[] = new int[] {2, 3, 8, 13}; - - static void merge(int m , int n) { - - //Iterate through all elements of the last element - for(int i = n-1; i >= 0; i--) { - - /* - * FInd the smallest element greater than ar2[i]. - * Move all elements one position ahead till the smallest greater element is not found. - */ - int j , last = arr1[m -1]; - for( j = m-2 ; j>= 0 && arr1[j] > arr2[i] ; j--) - arr1[j+1] = arr1[j]; - - //if there was a greater element - if(j != m-2 || last > arr2[i]) { - arr1[j+1] = arr2[i]; - arr2[i] = last; - } - } - } - - public static void main(String[] args) { - merge(arr1.length, arr2.length); - System.out.println("After Merging nFirst Array: "); - System.out.println(Arrays.toString(arr1)); - System.out.println("Second Array: "); - System.out.println(Arrays.toString(arr2)); - } - -} diff --git a/data_from_eclipse_ide/arrays/Array_Problem_18.java b/data_from_eclipse_ide/arrays/Array_Problem_18.java deleted file mode 100644 index 709bf09..0000000 --- a/data_from_eclipse_ide/arrays/Array_Problem_18.java +++ /dev/null @@ -1,29 +0,0 @@ -package arrays; - -/* - * find all pairs on integer array whose sum is equal to given number - * OR - * Equal_Sum_Pairs_of_Array - */ - -public class Array_Problem_18 { - - //function to find & print the sum & elements - static void pairs_value(int iA[], int iN) { - System.out.println("Pairs of elements & their sum : "); - - //loop to iterate & find the pair of elements whose sum is equal - for(int i = 0 ; i < iA.length ; i++) { - for(int j = i + 1 ; j < iA.length ; j++) - //check if the sum of pair is equal, if equal then print the pair of elements & their sum - if(iA[i]+iA[j] == iN) System.out.println(iA[i] + " + " + iA[j] + " = " + iN); - } - } - - //Driver Method - public static void main(String[] args) { - pairs_value(new int[] {2,7,4,-5,11,5,20}, 15); - pairs_value(new int[] {14,-15,9,16,25,45,12,8},30); - } - -} diff --git a/data_from_eclipse_ide/arrays/Array_Problem_2.java b/data_from_eclipse_ide/arrays/Array_Problem_2.java deleted file mode 100644 index 63dc567..0000000 --- a/data_from_eclipse_ide/arrays/Array_Problem_2.java +++ /dev/null @@ -1,55 +0,0 @@ -package arrays; - -//Java program to find the maximum & minimum element in given or array as user input -public class Array_Problem_2 { -/* Class Pair is used to return two values from getMinMax() */ - static class Pair { - - int min; - int max; - } - - static Pair getMinMax(int arr[], int n) { - Pair minmax = new Pair(); - int i; - - /*If there is only one element then return it as min and max both*/ - if (n == 1) { - minmax.max = arr[0]; - minmax.min = arr[0]; - return minmax; - } - - /* If there are more than one elements, then initialize min - and max*/ - if (arr[0] > arr[1]) { - minmax.max = arr[0]; - minmax.min = arr[1]; - } else { - minmax.max = arr[1]; - minmax.min = arr[0]; - } - - for (i = 2; i < n; i++) { - if (arr[i] > minmax.max) { - minmax.max = arr[i]; - } else if (arr[i] < minmax.min) { - minmax.min = arr[i]; - } - } - - return minmax; - } - - /* Driver program to test above function */ - public static void main(String args[]) { - int arr[] = {1000, 11, 445, 1, 330, 3000}; - int arr_size = 6; - Pair minmax = getMinMax(arr, arr_size); - System.out.printf("\nMinimum element is %d", minmax.min); - System.out.printf("\nMaximum element is %d", minmax.max); - - } - -} - diff --git a/data_from_eclipse_ide/arrays/Array_Problem_23.java b/data_from_eclipse_ide/arrays/Array_Problem_23.java deleted file mode 100644 index 9aedc89..0000000 --- a/data_from_eclipse_ide/arrays/Array_Problem_23.java +++ /dev/null @@ -1,45 +0,0 @@ -package arrays; - -/* - * Java program for maximum product sub-array problem - */ - -public class Array_Problem_23 { - - static void maxSubArraySum(int a[], int size) - { - int max_so_far = Integer.MIN_VALUE, - max_ending_here = 0,start = 0, - end = 0, s = 0; - - for (int i = 0; i < size; i++) - { - max_ending_here += a[i]; - - if (max_so_far < max_ending_here) - { - max_so_far = max_ending_here; - start = s; - end = i; - } - - if (max_ending_here < 0) - { - max_ending_here = 0; - s = i + 1; - } - } - System.out.println("Maximum contiguous sum is " + max_so_far); - System.out.println("Starting index " + start); - System.out.println("Ending index " + end); - } - - // Driver code - public static void main(String[] args) - { - int a[] = { -2, -3, 4, -1, -2, 1, 5, -3 }; - int n = a.length; - maxSubArraySum(a, n); - } - } - diff --git a/data_from_eclipse_ide/arrays/Array_Problem_3.java b/data_from_eclipse_ide/arrays/Array_Problem_3.java deleted file mode 100644 index 0a9c3ad..0000000 --- a/data_from_eclipse_ide/arrays/Array_Problem_3.java +++ /dev/null @@ -1,122 +0,0 @@ -package arrays; - -import java.util.Arrays; - -/* - * (Find K^the smallest element) - * Given an array array[] and a number K where K is smaller than size of array, - * the task is to find the K^the smallest element in the given array. - * It is given that all array elements are distinct. - */ -public class Array_Problem_3 { - - // int partition(int array[], int l, int r, int k); - - // A simple function to find median of arr[]. This is called - // only for an array of size 5 in this program. - static int findMedian(int arr[], int i,int n) - { - if(i <= n) - Arrays.sort(arr, i, n); // Sort the array - else - Arrays.sort(arr, n, i); - return arr[n/2]; // Return middle element - } - - // Returns k'th smallest element - // in arr[l..r] in worst case - // linear time. ASSUMPTION: ALL - // ELEMENTS IN ARR[] ARE DISTINCT - static int kthSmallest(int arr[], int l, int r, int k) - { - // If k is smaller than - // number of elements in array - if (k > 0 && k <= r - l + 1) - { - int n = r - l + 1 ; // Number of elements in arr[l..r] - - // Divide arr[] in groups of size 5, - // calculate median of every group - // and store it in median[] array. - int i; - - // There will be floor((n+4)/5) groups; - int []median = new int[(n + 4) / 5]; - for (i = 0; i < n/5; i++) - median[i] = findMedian(arr,l + i * 5, 5); - - // For last group with less than 5 elements - if (i*5 < n) - { - median[i] = findMedian(arr,l + i * 5, n % 5); - i++; - } - - // Find median of all medians using recursive call. - // If median[] has only one element, then no need - // of recursive call - int medOfMed = (i == 1)? median[i - 1]: - kthSmallest(median, 0, i - 1, i / 2); - - // Partition the array around a random element and - // get position of pivot element in sorted array - int pos = partition(arr, l, r, medOfMed); - - // If position is same as k - if (pos-l == k - 1) - return arr[pos]; - if (pos-l > k - 1) // If position is more, recur for left - return kthSmallest(arr, l, pos - 1, k); - - // Else recur for right subarray - return kthSmallest(arr, pos + 1, r, k - pos + l - 1); - } - - // If k is more than number of elements in array - return Integer.MAX_VALUE; - } - - static int[] swap(int []arr, int i, int j) - { - int temp = arr[i]; - arr[i] = arr[j]; - arr[j] = temp; - return arr; - } - - // It searches for x in arr[l..r], and - // partitions the array around x. - static int partition(int arr[], int l, - int r, int x) - { - // Search for x in arr[l..r] and move it to end - int i; - for (i = l; i < r; i++) - if (arr[i] == x) - break; - swap(arr, i, r); - - // Standard partition algorithm - i = l; - for (int j = l; j <= r - 1; j++) - { - if (arr[j] <= x) - { - swap(arr, i, j); - i++; - } - } - swap(arr, i, r); - return i; - } - - // Driver code - public static void main(String[] args) - { - int arr[] = {12, 3, 5, 7, 4, 19, 26}; - int n = arr.length, k = 3; - System.out.println("K'th smallest element is " - + kthSmallest(arr, 0, n - 1, k)); - } - -} diff --git a/data_from_eclipse_ide/arrays/Array_Problem_32.java b/data_from_eclipse_ide/arrays/Array_Problem_32.java deleted file mode 100644 index 7f50762..0000000 --- a/data_from_eclipse_ide/arrays/Array_Problem_32.java +++ /dev/null @@ -1,35 +0,0 @@ -package arrays; - -//Java program to find minimum number of operations to make an array palindrome -public class Array_Problem_32 { - - static int findMinOps(int[] a, int n) { - - //Initialize result - int ans = 0; - - //Start from two corners - for(int i=0,j=n-1;i<=j;) { - - if(a[i] == a[j]) { - i++; - j--; - }else if(a[i] > a[j]) { - j--; - a[j] += a[j+1]; - ans++; - }else { - i++; - a[i] += a[i-1]; - ans++; - } - } - return ans; - } - - public static void main(String[] args) { - int a[] = new int[] {1,2,3,4,5,6,7,8,9,10}; - System.out.println("Count of minimum operations is " + findMinOps(a , a.length)); - } - -} diff --git a/data_from_eclipse_ide/arrays/Array_Problem_4_Approach1.java b/data_from_eclipse_ide/arrays/Array_Problem_4_Approach1.java deleted file mode 100644 index b1e4e48..0000000 --- a/data_from_eclipse_ide/arrays/Array_Problem_4_Approach1.java +++ /dev/null @@ -1,63 +0,0 @@ -package arrays; -import java.io.*; - -/* - * Java program to solve that, - * Given an array A of size N containing 0s, 1s, and 2s; - * you need to sort the array in ascending order without using any sorting algorithm - */ - -@SuppressWarnings("unused") -public class Array_Problem_4_Approach1 { - - // Sort the input array, the array is assumed to - // have values in {0, 1, 2} - static void sort012(int a[], int arr_size) - { - int lo = 0; - int hi = arr_size - 1; - int mid = 0, temp = 0; - while (mid <= hi) { - switch (a[mid]) { - case 0: { - temp = a[lo]; - a[lo] = a[mid]; - a[mid] = temp; - lo++; - mid++; - break; - } - case 1: - mid++; - break; - case 2: { - temp = a[mid]; - a[mid] = a[hi]; - a[hi] = temp; - hi--; - break; - } - } - } - } - - /* Utility function to print array arr[] */ - static void printArray(int arr[], int arr_size) - { - int i; - for (i = 0; i < arr_size; i++) - System.out.print(arr[i] + " "); - System.out.println(""); - } - - /*Driver function to check for above functions*/ - public static void main(String[] args) - { - int arr[] = { 0, 1, 1, 0, 1, 2, 1, 2, 0, 0, 0, 1 }; - int arr_size = arr.length; - sort012(arr, arr_size); - System.out.println("Array after seggregation "); - printArray(arr, arr_size); - } - -} diff --git a/data_from_eclipse_ide/arrays/Array_Problem_4_Approach2.java b/data_from_eclipse_ide/arrays/Array_Problem_4_Approach2.java deleted file mode 100644 index 1116d1d..0000000 --- a/data_from_eclipse_ide/arrays/Array_Problem_4_Approach2.java +++ /dev/null @@ -1,47 +0,0 @@ -package arrays; -import java.util.Arrays; - -/* - * Sort_an_array_of_0s_1s_2s_without_using_extra_space_or_sorting_algo - */ - -public class Array_Problem_4_Approach2 { - - static int arr1[] = new int[]{1, 5, 9, 10, 15, 20}; - static int arr2[] = new int[]{2, 3, 8, 13}; - - static void merge(int m, int n) - { - // Iterate through all elements of ar2[] starting from to the last element - for (int i=n-1; i>=0; i--) - { - - /* Find the smallest element greater than ar2[i]. - * Move all elements one position ahead, - * till the smallest greater element is not found - */ - int j, last = arr1[m-1]; - - for (j=m-2; j >= 0 && arr1[j] > arr2[i]; j--) - arr1[j+1] = arr1[j]; - - // If there was a greater element - if (j != m-2 || last > arr2[i]) { - arr1[j+1] = arr2[i]; - arr2[i] = last; - } - } - } - - // Driver method to test the above function - public static void main1(String[] args) - { - merge(arr1.length,arr2.length); - - System.out.print("After Merging nFirst Array: "); - System.out.println(Arrays.toString(arr1)); - - System.out.print("Second Array: "); - System.out.println(Arrays.toString(arr2)); - } -} diff --git a/data_from_eclipse_ide/arrays/Array_Problem_5.java b/data_from_eclipse_ide/arrays/Array_Problem_5.java deleted file mode 100644 index d2a4008..0000000 --- a/data_from_eclipse_ide/arrays/Array_Problem_5.java +++ /dev/null @@ -1,41 +0,0 @@ -package arrays; - -/* - * Move all the negative elements to one side of the array - */ - -public class Array_Problem_5 { - - static void rearrange(int arr[], int n) - { - int j = 0, temp; - for (int i = 0; i < n; i++) { - if (arr[i] < 0) { - if (i != j) { - temp = arr[i]; - arr[i] = arr[j]; - arr[j] = temp; - } - j++; - } - } - } - - // A utility function to print an array - static void printArray(int arr[], int n) - { - for (int i = 0; i < n; i++) - System.out.print(arr[i] + " "); - } - - //Driver Method - public static void main(String[] args) { - int arr[] = { -1, 2, -3, 4, 5, 6, -7, 8, 9 , -47}; - int n = arr.length; - - rearrange(arr, n); - printArray(arr, n); - - } - -} diff --git a/data_from_eclipse_ide/arrays/Array_Problem_6.java b/data_from_eclipse_ide/arrays/Array_Problem_6.java deleted file mode 100644 index 5552ee1..0000000 --- a/data_from_eclipse_ide/arrays/Array_Problem_6.java +++ /dev/null @@ -1,118 +0,0 @@ -package arrays; - -// A Java program to print union and intersection of two unsorted arrays -import java.util.Arrays; - -/* - * Find the Union and Intersection of the two sorted arrays. - */ - -public class Array_Problem_6 { - - - void printUnion(int arr1[], int arr2[], int m, int n) - { - // Before finding union, make sure arr1[0..m-1] - // is smaller - if (m > n) { - int tempp[] = arr1; - arr1 = arr2; - arr2 = tempp; - - int temp = m; - m = n; - n = temp; - } - - // Now arr1[] is smaller - // Sort the first array and print its elements - // (these two steps can be swapped as order in - // output is not important) - Arrays.sort(arr1); - for (int i = 0; i < m; i++) - System.out.print(arr1[i] + " "); - - // Search every element of bigger array in smaller - // array and print the element if not found - for (int i = 0; i < n; i++) { - if (binarySearch(arr1, 0, m - 1, arr2[i]) == -1) - System.out.print(arr2[i] + " "); - } - } - - // Prints intersection of arr1[0..m-1] and arr2[0..n-1] - void printIntersection(int arr1[], int arr2[], int m, - int n) - { - // Before finding intersection, make sure - // arr1[0..m-1] is smaller - if (m > n) { - int tempp[] = arr1; - arr1 = arr2; - arr2 = tempp; - - int temp = m; - m = n; - n = temp; - } - - // Now arr1[] is smaller - // Sort smaller array arr1[0..m-1] - Arrays.sort(arr1); - - // Search every element of bigger array in smaller - // array and print the element if found - for (int i = 0; i < n; i++) { - if (binarySearch(arr1, 0, m - 1, arr2[i]) != -1) - System.out.print(arr2[i] + " "); - } - } - - // A recursive binary search function. It returns - // location of x in given array arr[l..r] is present, - // otherwise -1 - int binarySearch(int arr[], int l, int r, int x) - { - if (r >= l) { - int mid = l + (r - l) / 2; - - // If the element is present at the middle - // itself - if (arr[mid] == x) - return mid; - - // If element is smaller than mid, then it can - // only be present in left subarray - if (arr[mid] > x) - return binarySearch(arr, l, mid - 1, x); - - // Else the element can only be present in right - // subarray - return binarySearch(arr, mid + 1, r, x); - } - - // We reach here when element is not present in - // array - return -1; - } - - // Driver code - public static void main(String[] args) - { - Array_Problem_6 u_i= new Array_Problem_6(); - - int arr1[] = { 7, 1, 5, 2, 3, 6 }; - int arr2[] = { 3, 8, 6, 20, 7 }; - int m = arr1.length; - int n = arr2.length; - - // Function call - System.out.println("Union of two arrays is "); - u_i.printUnion(arr1, arr2, m, n); - System.out.println(""); - System.out.println( - "Intersection of two arrays is "); - u_i.printIntersection(arr1, arr2, m, n); - } - } - diff --git a/data_from_eclipse_ide/arrays/Array_Problem_7.java b/data_from_eclipse_ide/arrays/Array_Problem_7.java deleted file mode 100644 index 948018d..0000000 --- a/data_from_eclipse_ide/arrays/Array_Problem_7.java +++ /dev/null @@ -1,42 +0,0 @@ -package arrays; - -/* - * Write a program to cyclically rotate an array by one. - */ - -public class Array_Problem_7 { - - //function to rotate the elements of an array - - void rotateL(int a[], int d, int n) { - for(int i= 0;i big) - { - temp = small; - small = big; - big = temp; - } - - // Traverse middle elements - for (int i = 1; i < n-1; i ++) - { - int subtract = arr[i] - k; - int add = arr[i] + k; - - // If both subtraction and addition - // do not change diff - if (subtract >= small || add <= big) - continue; - - // Either subtraction causes a smaller number or addition causes a greater number. - // Update small or big using greedy approach (If big - subtract causes smaller difference , - // update small Else update big) - if (big - subtract <= add - small) - small = subtract; - else - big = add; - } - - return Math.min(ans, big - small); - } - - // Driver function to test the above function - public static void main(String[] args) - { - int arr[] = {4, 6}; - int n = arr.length; - int k = 10; - System.out.println("Maximum difference is "+ - getMinDiff(arr, n, k)); - } - -} diff --git a/data_from_eclipse_ide/arrays/Array_of_objects.java b/data_from_eclipse_ide/arrays/Array_of_objects.java deleted file mode 100644 index adb9674..0000000 --- a/data_from_eclipse_ide/arrays/Array_of_objects.java +++ /dev/null @@ -1,44 +0,0 @@ -package arrays; - -//Program to demonstrate the array of objects - -//Cricketer class -class Cricketer{ - public int batting_position; - public String name; - - Cricketer(int batting_position, String name) - { - this.batting_position = batting_position; - this.name = name; - } -} - -//Driver Class -public class Array_of_objects { - - //Driver Method - public static void main(String[] args) { - - // Declaring or making the array of type Cricketer , which is known as Array of Objects - Cricketer[] arr; - // array capacity is of storing 5 elements in it. - arr = new Cricketer[11]; - - arr[0 ] = new Cricketer(1, "Rohit Sharma(W.C)"); - arr[1 ] = new Cricketer(2, "Shikhar Dhawan"); - arr[2 ] = new Cricketer(3, "Virat Kohli(C.)"); - arr[3 ] = new Cricketer(4, "K.L Rahul"); - arr[4 ] = new Cricketer(5, "Rishabh Pant(W.K)"); - arr[5 ] = new Cricketer(6, "Hardik Pandaya"); - arr[6 ] = new Cricketer(7, "Bhuvaneshwar Kumar"); - arr[7 ] = new Cricketer(8, "Mohammed Shami"); - arr[8 ] = new Cricketer(9, "Jaspreet Bumrah"); - arr[9 ] = new Cricketer(10, "Yuzvendre Chahal"); - arr[10] = new Cricketer(11, "Kuldeep Yadav"); - - - for(int i = 0 ; i < arr.length ; i++) - System.out.println("Element at index " + i + " : " + "Batting Position: " + arr[i].batting_position + " " + "Player Name: " + arr[i].name); - } -} diff --git a/data_from_eclipse_ide/arrays/Candy_Distribution_Problem.java b/data_from_eclipse_ide/arrays/Candy_Distribution_Problem.java deleted file mode 100644 index 806cd6d..0000000 --- a/data_from_eclipse_ide/arrays/Candy_Distribution_Problem.java +++ /dev/null @@ -1,49 +0,0 @@ -package arrays; -import java.util.*; - -//Language: Java -//Time Complexity: O(n) 3 Linear traversals. -//Space Complexity: O(n) Array of candies. - -public class Candy_Distribution_Problem{ - - public int candy(int[] ratings) { - if (ratings.length < 2) - return ratings.length; - - - int[] candies = new int[ratings.length]; - Arrays.fill(candies, 1); - - // ** Step 1: Forward ** - for (int i=0; i= ratings[i+1]) { - continue; - } - candies[i+1] = candies[i] + 1; - } - - // ** Step 2: Backward ** - for (int i=ratings.length-1; i>0; i--) { - if (ratings[i] >= ratings[i-1]) { - continue; - } - candies[i-1] = Math.max(candies[i] + 1, candies[i-1]); - } - - // ** Step 3: Count Candies ** - int count = 0; - for (int i=0; i= 0 && x < N && y >= 0 - && y < N && maze[x][y] == 1); - } - - /* - * This function solves the Maze problem using Backtracking. - * It mainly uses solvemazeUtil() function to solve the problem. - * It returns false if no path is possible, otherwise return true & - * prints the path in the form of 1s. - * Please note :-> that there may be more than one solutions, - * this function prints one of the feasible solutions. - */ - boolean solveMaze(int maze[][]){ - int sol[][] = new int[N][N]; - - if(solveMazeUtil(maze, 0, 0, sol) == false) { - System.out.print("Solution doesn't exist"); - return false; - } - printSolution(sol); - return true; - } - - /* - * A recursive utility function to solve Maze problem - */ - boolean solveMazeUtil( int maze[][] , int x , int y , int sol[][]) { - - //if (x , y is goal) than return true - if(x == N - 1 && y == N-1 && maze[x][y] == 1) { - sol[x][y] = 1; - return true; - } - - //Check if maze[x][y] is valid - if(isSafe(maze, x, y) == true) { - //mark x, y as part of solution path - sol[x][y] = 1; - - //if moving in x direction doesn't give solution then Move down in y direction - if(solveMazeUtil(maze , x+1 , y , sol)) - return true; - /* - * If none of the above movements works then BACKTRACK: remove mark of x, y as part of solution path - */ - if(solveMazeUtil(maze , x , y+1 , sol)) - return true; - - sol[x][y] = 0; - return false; - } - - return false; - } - - //Driver Method - public static void main(String[] args) { - - Rat_In_A_Maze rat = new Rat_In_A_Maze(); - int maze[][] = {{ 1, 1, 1, 0 }, - { 1, 1, 1, 1 }, - { 1, 1, 1, 1 }, - { 1, 1, 1, 1 } }; - - N = maze.length; - rat.solveMaze(maze); - } //end of main -} //end of class diff --git a/data_from_eclipse_ide/basicProblems/Armstrong_Number.java b/data_from_eclipse_ide/basicProblems/Armstrong_Number.java deleted file mode 100644 index 5230826..0000000 --- a/data_from_eclipse_ide/basicProblems/Armstrong_Number.java +++ /dev/null @@ -1,26 +0,0 @@ -package basicProblems; -import java.util.*; - -public class Armstrong_Number { - - @SuppressWarnings("resource") - public static void main(String[] args) { - - Scanner sc = new Scanner(System.in); - int n = sc.nextInt(); - - int sum = 0; - int original_no = n; - - while(n>0) { - int last_digit = n % 10; - sum += Math.pow(last_digit,3); - n=n/10; - } - - if(sum == original_no) System.out.println("Armstrong number"); - else System.out.println("Not Armstrong"); - - } - -} diff --git a/data_from_eclipse_ide/basicProblems/Factorial.class b/data_from_eclipse_ide/basicProblems/Factorial.class deleted file mode 100644 index 89634d6bd6e83a204a8e7d37834186fbd03e9f1a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1124 zcmaJ=O-~b16g_V`?UZr&wtQH@f`A2)svxMXENnt-0!mV%F|J;R2MnFgG&8S6*7_sd zx^gWGNHFmS_;Xyk5bv8-DQV*@?tLHko_o%{Z+`qf{|;ac>n2R342<+(6k{edj4N|P zZPP;(a?3;pQwF9D+-67=9M6&K46*F|YX-gO?+S+gO~(^28?}lEc6i056TQYAk6|SH zZu5{I@tn)O{ajfFj<=sziM?gX?dle7Vct^Vc@y%%TNZqz9r;=zZ>=^a4(4^3pw03 z@W8@DEHjK&c<9*MflsV!VeVg50=VS;s&Xi7$uQhS%$30MaVSNNK~vgOP34ZCD|z*X zB=LgR@(g3yt{18+h9}<3l1HVey(O}KgVvWo+tk0mKqgl3h#Iv=jmr3Y8J2Ov3?oG~ zUKK^(v$=fZ$OBr1l6x{#!zh*JJI6t~BB?~Q4WG!=RW(;BX)(S!L<6g;nNJyJE?ebz zM}AebCf#Jw?CG(A0zIEi->)|63|2`^ujukH6h!S)dxaK8b8auVx9f^qXY{30 z`a$8Ne(~kv=Lr%M>2nysDUu3Vi;$<0jPNz`y@WqRWYR<@Lw=5`EmOTgibz4bAQLw* k#0+Tky6}sxVi=B~uHy-Llc=pBkH;9tP1+}EuM|!G0c+YBD*ylh diff --git a/data_from_eclipse_ide/basicProblems/Factorial.java b/data_from_eclipse_ide/basicProblems/Factorial.java deleted file mode 100644 index c73f54c..0000000 --- a/data_from_eclipse_ide/basicProblems/Factorial.java +++ /dev/null @@ -1,20 +0,0 @@ -package basicProblems; -import java.util.*; - -public class Factorial { - - public static void main(String[] args) { - - int fact=1; - @SuppressWarnings("resource") - Scanner sc = new Scanner(System.in); - int n = sc.nextInt(); - - for(int i = n ; i >= 1 ; i--) { - fact = fact*i; - } - System.out.println("fact of " + n + " is " + fact ); - } -} - - diff --git a/data_from_eclipse_ide/basicProblems/Fibonacci_Series.java b/data_from_eclipse_ide/basicProblems/Fibonacci_Series.java deleted file mode 100644 index f1fb26d..0000000 --- a/data_from_eclipse_ide/basicProblems/Fibonacci_Series.java +++ /dev/null @@ -1,26 +0,0 @@ -package basicProblems; -import java.util.*; - -public class Fibonacci_Series { - - public static void main(String[] args) { - - @SuppressWarnings("resource") - Scanner sc = new Scanner(System.in); - int n = sc.nextInt(); - int a=0,b=1; - - System.out.println("a = " + a + " "); - System.out.println("b = " + b + " "); - System.out.println("Fibonacci Series:"); - - for(int i=0;i 0) { - int rem = n % 10; - System.out.print(rem); - n = n/10; - } - - } - -} diff --git a/data_from_eclipse_ide/basicProblems/Reverse_Given_number.java b/data_from_eclipse_ide/basicProblems/Reverse_Given_number.java deleted file mode 100644 index f3c5371..0000000 --- a/data_from_eclipse_ide/basicProblems/Reverse_Given_number.java +++ /dev/null @@ -1,22 +0,0 @@ -package basicProblems; - -import java.util.*; -public class Reverse_Given_number { - - @SuppressWarnings("resource") - public static void main(String[] args) { - Scanner sc = new Scanner(System.in); - int n = sc.nextInt(); - - int reverse=0; - - while(n>0) { - int last_digit = n % 10; - reverse = reverse*10 + last_digit; - n = n/10; - } - - System.out.println(reverse); - } - -} diff --git a/data_from_eclipse_ide/basicProblems/Series_Sum_1.java b/data_from_eclipse_ide/basicProblems/Series_Sum_1.java deleted file mode 100644 index 8d0b704..0000000 --- a/data_from_eclipse_ide/basicProblems/Series_Sum_1.java +++ /dev/null @@ -1,22 +0,0 @@ -package basicProblems; -import java.util.*; - -public class Series_Sum_1 { - - public static void main(String[] args) { - - //taking user input - @SuppressWarnings("resource") - Scanner sc = new Scanner(System.in); - int n = sc.nextInt(); - - float result = 0; - - for(float i=1;i<=n;i++) - result +=1/i; - - System.out.println(result); - - } - -} diff --git a/data_from_eclipse_ide/basicProblems/Series_Sum_2.java b/data_from_eclipse_ide/basicProblems/Series_Sum_2.java deleted file mode 100644 index bb798c9..0000000 --- a/data_from_eclipse_ide/basicProblems/Series_Sum_2.java +++ /dev/null @@ -1,32 +0,0 @@ -package basicProblems; -import java.util.Scanner; - -/* This series is also known as TAYLOR series*/ -// program to demonstrate series sum of "1 + 1/2 + 1/3 + 1/4 + 1/5 + ...1 /n" this before mentioned series - -public class Series_Sum_2 { - - public static void main(String[] args) { - - @SuppressWarnings("resource") - Scanner sc = new Scanner(System.in); - int n = sc.nextInt(); - - float result = 0; - - for(float i=1;i<=n;i++) { - - if(i%2==0) { - result -= 1/i; - } - - else { - result += 1/i; - } - - System.out.println(result); - } - - } - -} diff --git a/data_from_eclipse_ide/basicProblems/Swap_two_numbers.java b/data_from_eclipse_ide/basicProblems/Swap_two_numbers.java deleted file mode 100644 index 066a354..0000000 --- a/data_from_eclipse_ide/basicProblems/Swap_two_numbers.java +++ /dev/null @@ -1,17 +0,0 @@ -package basicProblems; -import java.util.*; -public class Swap_two_numbers { - - public static void main(String[] args) { - - @SuppressWarnings("resource") - Scanner sc = new Scanner(System.in); - int a = sc.nextInt() , b = sc.nextInt() , swap; - - System.out.println( " elements before swapping " + a + " " + b ); - swap = a; - a = b; - b = swap; - System.out.println( " elements after swapping " + a + " " + b ); - } -} diff --git a/data_from_eclipse_ide/basicProblems/Swapping_2.java b/data_from_eclipse_ide/basicProblems/Swapping_2.java deleted file mode 100644 index dd56abc..0000000 --- a/data_from_eclipse_ide/basicProblems/Swapping_2.java +++ /dev/null @@ -1,24 +0,0 @@ -package basicProblems; - -/* - * swap two given numbers without using third variable - */ - -public class Swapping_2 { - - public static void main(String[] args) { - - int a = 20; - int b = 40; - - System.out.println("Number's before swapping: " + "a = " + a + "," + " b =" + " " + b); - - a = a + b; - b = a - b; - a = a - b; - - System.out.println("Number's after swapping: " + "a = " + a + "," + " b =" + " " + b); - - } - -} diff --git a/data_from_eclipse_ide/basicProblems/X_raisedTo_power_Y.java b/data_from_eclipse_ide/basicProblems/X_raisedTo_power_Y.java deleted file mode 100644 index 36ade66..0000000 --- a/data_from_eclipse_ide/basicProblems/X_raisedTo_power_Y.java +++ /dev/null @@ -1,18 +0,0 @@ -package basicProblems; -import java.util.*; -public class X_raisedTo_power_Y { - - public static void main(String[] args) { - - @SuppressWarnings("resource") - Scanner sc= new Scanner(System.in); - int a = sc.nextInt(); - int b = sc.nextInt(); - int result = 1; - for(int i=0;i adq = new ArrayDeque(); - - adq.push("A"); - adq.push("B"); - adq.push("C"); - adq.push("D"); - adq.push("E"); - - System.out.print("Popping the stack:"); - - while(adq.peek()!=null) - System.out.print(adq.pop()+" "); - - System.out.println(); - - } - -} diff --git a/data_from_eclipse_ide/basic_idea_of_DS/ArrayListDemo.java b/data_from_eclipse_ide/basic_idea_of_DS/ArrayListDemo.java deleted file mode 100644 index eaa79d5..0000000 --- a/data_from_eclipse_ide/basic_idea_of_DS/ArrayListDemo.java +++ /dev/null @@ -1,33 +0,0 @@ -package basic_idea_of_DS; -import java.util.ArrayList; - -public class ArrayListDemo { - - public static void main(String[] args) { - - //Create an array list - ArrayList al = new ArrayList(); - System.out.println("Initial size of al:" + al.size()); - - //Add elements to array list - al.add("A"); - al.add("M"); - al.add("A"); - al.add("N"); - al.add("S"); - al.add("s1"); - System.out.println("Size of al after additions:" + al.size()); - - //Display the array list - System.out.println("Contents of al:" + al); - - //Remove elements from the array - al.remove("s1"); - - System.out.println("Size of al after deletions:"+ al.size()); - System.out.println("Contents of al:" + al); - - - } - -} diff --git a/data_from_eclipse_ide/basic_idea_of_DS/Graph.java b/data_from_eclipse_ide/basic_idea_of_DS/Graph.java deleted file mode 100644 index 91bd1e8..0000000 --- a/data_from_eclipse_ide/basic_idea_of_DS/Graph.java +++ /dev/null @@ -1,41 +0,0 @@ -package basic_idea_of_DS; -import java.util.*; - -public class Graph { - - private LinkedList adj[]; - - @SuppressWarnings("unchecked") - public Graph(int v) { - //array of Linked List - adj = new LinkedList[v]; - - for(int i=0;i(); - } - } - - public void addEdge(int source, int destination) { - adj[source].add(destination); - adj[destination].add(source); - } - - public static void main(String[] args) { - Scanner sc = new Scanner(System.in); - - System.out.println("Enter number of vertices and edges"); - int v = sc.nextInt(); - int e = sc.nextInt(); - - Graph graph = new Graph(v); - System.out.println("Enter " + e + " edges"); - - for(int i=0;i map = new HashMap<>(); - - // Add elements to the map - map.put("vishal", 10); - map.put("sachin", 30); - map.put("vaibhav", 20); - - // Print size and content - System.out.println("Size of map is:- " + map.size()); - System.out.println(map); - - // Check if a key is present and if present, print value - if ( map.containsKey("vishal")) - { - Integer a = map.get("vishal"); - System.out.println("value for key vishal is:- "+ a); - } - } - -} diff --git a/data_from_eclipse_ide/basic_idea_of_DS/LinkedListDemo.java b/data_from_eclipse_ide/basic_idea_of_DS/LinkedListDemo.java deleted file mode 100644 index 2003b66..0000000 --- a/data_from_eclipse_ide/basic_idea_of_DS/LinkedListDemo.java +++ /dev/null @@ -1,35 +0,0 @@ -package basic_idea_of_DS; -import java.util.LinkedList; -public class LinkedListDemo { - - public static void main(String[] args) { - // Create a linked list - LinkedList ll = new LinkedList<>(); - - // Add elements to the linked list - ll.add("A"); - ll.add("M"); - ll.add("M"); - ll.add("N"); - ll.add("S"); - ll.addFirst("S1"); - ll.addLast("S2"); - ll.add(1,"A1"); - System.out.println("Original contents of ll:"+ll); - - //Remove elements from the linked list - ll.remove("A1"); - System.out.println("Content of ll after deletion:"+ll); - - //Remove first & last elements - ll.removeFirst(); - ll.removeLast(); - System.out.println("ll after deleting first & last:" + ll); - - //Get & set value - String val = ll.get(2); - ll.set(2, val + "Changed"); - System.out.println("ll after change:"+ll); - } - -} diff --git a/data_from_eclipse_ide/basic_idea_of_DS/List.java b/data_from_eclipse_ide/basic_idea_of_DS/List.java deleted file mode 100644 index d52f469..0000000 --- a/data_from_eclipse_ide/basic_idea_of_DS/List.java +++ /dev/null @@ -1,14 +0,0 @@ -package basic_idea_of_DS; - -import java.util.LinkedList; -public class List{ - public static void main(String[] args) { - - LinkedList ll = new LinkedList<>(); - - ll.add("Aman"); - ll.add("Soni"); - ll.add(1, "Kumar"); - System.out.println(ll); - } -} diff --git a/data_from_eclipse_ide/basic_idea_of_DS/MYStackByList.java b/data_from_eclipse_ide/basic_idea_of_DS/MYStackByList.java deleted file mode 100644 index 42fd57c..0000000 --- a/data_from_eclipse_ide/basic_idea_of_DS/MYStackByList.java +++ /dev/null @@ -1,121 +0,0 @@ -package basic_idea_of_DS; - -//Java program to Implement a stack -//using singly linked list -//import package -import static java.lang.System.exit; - -//Create Stack Using Linked list -class StackUsingLinkedlist { - - // A linked list node - private class Node { - - int data; // integer data - Node link; // reference variable Node type - } - // create global top reference variable global - Node top; - // Constructor - StackUsingLinkedlist() - { - this.top = null; - } - - // Utility function to add an element x in the stack - public void push(int x) // insert at the beginning - { - // create new node temp and allocate memory - Node temp = new Node(); - - // initialize data into data field - temp.data = x; - - // put top reference into link - temp.link = top; - - // update top reference - top = temp; - } - - // Utility function to check if the stack is empty or not - public boolean isEmpty() - { - return top == null; - } - - // Utility function to return top element in a stack - public int peek() - { - // check for empty stack - if (!isEmpty()) { - return top.data; - } - else { - System.out.println("Stack is empty"); - return -1; - } - } - - // Utility function to pop top element from the stack - public void pop() // remove at the beginning - { - // check for stack underflow - if (top == null) { - System.out.print("\nStack Underflow"); - return; - } - - // update the top pointer to point to the next node - top = (top).link; - } - - public void display() - { - // check for stack underflow - if (top == null) { - System.out.printf("\nStack Underflow"); - exit(1); - } - else { - Node temp = top; - while (temp != null) { - - // print node data - System.out.printf("%d->", temp.data); - - // assign temp link to temp - temp = temp.link; - } - } - } -} -//main class -public class MYStackByList { - public static void main(String[] args) - { - // create Object of Implementing class - StackUsingLinkedlist obj = new StackUsingLinkedlist(); - // insert Stack value - obj.push(11); - obj.push(22); - obj.push(33); - obj.push(44); - - // print Stack elements - obj.display(); - - // print Top element of Stack - System.out.printf("\nTop element is %d\n", obj.peek()); - - // Delete top element of Stack - obj.pop(); - obj.pop(); - - // print Stack elements - obj.display(); - - // print Top element of Stack - System.out.printf("\nTop element is %d\n", obj.peek()); - } -} diff --git a/data_from_eclipse_ide/basic_idea_of_DS/MyArrayList.java b/data_from_eclipse_ide/basic_idea_of_DS/MyArrayList.java deleted file mode 100644 index bc0609a..0000000 --- a/data_from_eclipse_ide/basic_idea_of_DS/MyArrayList.java +++ /dev/null @@ -1,33 +0,0 @@ -package basic_idea_of_DS; -import java.util.ArrayList; - -public class MyArrayList { - - public static void main(String[] args) { - - //Create an array list - ArrayList al = new ArrayList(); - System.out.println("Initial size of al:" + al.size()); - - //Add elements to array list - al.add("A"); - al.add("M"); - al.add("A"); - al.add("N"); - al.add("S"); - al.add("s1"); - System.out.println("Size of al after additions:" + al.size()); - - //Display the array list - System.out.println("Contents of al:" + al); - - //Remove elements from the array - al.remove("s1"); - - System.out.println("Size of al after deletions:"+ al.size()); - System.out.println("Contents of al:" + al); - - - } - -} diff --git a/data_from_eclipse_ide/basic_idea_of_DS/MyHashMap.java b/data_from_eclipse_ide/basic_idea_of_DS/MyHashMap.java deleted file mode 100644 index abe8403..0000000 --- a/data_from_eclipse_ide/basic_idea_of_DS/MyHashMap.java +++ /dev/null @@ -1,28 +0,0 @@ -package basic_idea_of_DS; -import java.util.HashMap; -public class MyHashMap -{ - - public static void main(String[] args) - { - // Create an empty hash map - HashMap map = new HashMap<>(); - - // Add elements to the map - map.put("vishal", 10); - map.put("sachin", 30); - map.put("vaibhav", 20); - - // Print size and content - System.out.println("Size of map is:- " + map.size()); - System.out.println(map); - - // Check if a key is present and if present, print value - if ( map.containsKey("vishal")) - { - Integer a = map.get("vishal"); - System.out.println("value for key vishal is:- "+ a); - } - } - -} diff --git a/data_from_eclipse_ide/basic_idea_of_DS/MyHashSet.java b/data_from_eclipse_ide/basic_idea_of_DS/MyHashSet.java deleted file mode 100644 index 4632e34..0000000 --- a/data_from_eclipse_ide/basic_idea_of_DS/MyHashSet.java +++ /dev/null @@ -1,21 +0,0 @@ -package basic_idea_of_DS; - -import java.util.HashSet; - -public class MyHashSet { - - public static void main(String[] args) { - - HashSet hs = new HashSet<>(); - - hs.add("Beta"); - hs.add("Alpha"); - hs.add("Gama"); - hs.add("Eplision"); - hs.add("Omega"); - - System.out.println(hs); - - } - -} diff --git a/data_from_eclipse_ide/basic_idea_of_DS/MyLinkedList.java b/data_from_eclipse_ide/basic_idea_of_DS/MyLinkedList.java deleted file mode 100644 index 4d46031..0000000 --- a/data_from_eclipse_ide/basic_idea_of_DS/MyLinkedList.java +++ /dev/null @@ -1,35 +0,0 @@ -package basic_idea_of_DS; -import java.util.LinkedList; -public class MyLinkedList { - - public static void main(String[] args) { - // Create a linked list - LinkedList ll = new LinkedList<>(); - - // Add elements to the linked list - ll.add("A"); - ll.add("M"); - ll.add("M"); - ll.add("N"); - ll.add("S"); - ll.addFirst("S1"); - ll.addLast("S2"); - ll.add(1,"A1"); - System.out.println("Original contents of ll:"+ll); - - //Remove elements from the linked list - ll.remove("A1"); - System.out.println("Content of ll after deletion:"+ll); - - //Remove first & last elements - ll.removeFirst(); - ll.removeLast(); - System.out.println("ll after deleting first & last:" + ll); - - //Get & set value - String val = ll.get(2); - ll.set(2, val + "Changed"); - System.out.println("ll after change:"+ll); - } - -} diff --git a/data_from_eclipse_ide/basic_idea_of_DS/MyQueue.java b/data_from_eclipse_ide/basic_idea_of_DS/MyQueue.java deleted file mode 100644 index ac6b1d0..0000000 --- a/data_from_eclipse_ide/basic_idea_of_DS/MyQueue.java +++ /dev/null @@ -1,82 +0,0 @@ -//Java program for array implementation of queue -package basic_idea_of_DS; -//A class to represent a queue -class Queue{ - int front, rear, size; - int capacity; - int array[]; - - public Queue(int capacity) { - this.capacity = capacity; - front = this.size = 0; - rear = capacity - 1; - array = new int[this.capacity]; - } - - //Queue is full when size becomes equal to capacity - boolean isFull(Queue queue) { - return(queue.size == queue.capacity); - } - - //Queue is Empty when size is 0 - boolean isEmpty(Queue queue){ - return(queue.size == 0); - } - - //Method to add an item to the queue - //It changes rear and size - void enqueue(int item) { - if(isFull(this)) - return; - this.rear = (this.rear+1)%this.capacity; - this.array[this.rear] = item; - this.size = this.size+1; - System.out.println(item + " enqueud to queue"); - } - - //Method to remove an item from queue - //It changes front and size - int dequeue() { - if(isEmpty(this)) - return Integer.MIN_VALUE; - - int item = this.array[this.front]; - this.front = (this.front + 1) % this.capacity; - this.size = this.size-1; - return item; - - } - - //Method to get front of queue - int front() { - if(isEmpty(this)) - return Integer.MIN_VALUE; - - return this.array[this.front]; - } - - //Method to get rear of queue - int rear() { - if(isEmpty(this)) - return Integer.MIN_VALUE; - - return this.array[this.rear]; - } -} - -//Driver Class -public class MyQueue{ - public static void main(String[] args){ - - Queue queue = new Queue(1000); - - queue.enqueue(10); - queue.enqueue(20); - queue.enqueue(30); - queue.enqueue(40); - - System.out.println(queue.dequeue()+(" dequeued from queue")); - System.out.println("Front item is " + queue.front()); - System.out.println("Rear item is "+ queue.rear()); - } -} diff --git a/data_from_eclipse_ide/basic_idea_of_DS/MyStack.java b/data_from_eclipse_ide/basic_idea_of_DS/MyStack.java deleted file mode 100644 index a3ca5f1..0000000 --- a/data_from_eclipse_ide/basic_idea_of_DS/MyStack.java +++ /dev/null @@ -1,58 +0,0 @@ -package basic_idea_of_DS; - - class Stack { - static final int MAX = 1000; - int top; - int a[] = new int[MAX]; - - boolean isEmpty() { - return (top<0); - } - - Stack(){ - top = -1; - } - - boolean push(int x) { - if(top>= (MAX-1)) { - System.out.println(x+"pushed into stack"); - return false; - } - else { - a[++top] = x; - System.out.println(x+"pushed into stack"); - return true; - } - } - - int pop() { - if(top<0) { - System.out.println("Stack underflow"); - return 0; - } - else { - int x = a[top--]; - return x; - } - } - - int peek() { - if(top<0) { - System.out.println("Stack underflow"); - return 0; - } - else { - int x = a[top]; return x; - } - } - - class MyStack{ - public void main (String[] args) { - Stack s = new Stack(); - s.push(10); - s.push(20); - s.push(30); - System.out.println(s.pop() + " Popped from stack"); - } - } -} diff --git a/data_from_eclipse_ide/basic_idea_of_DS/SetExample.java b/data_from_eclipse_ide/basic_idea_of_DS/SetExample.java deleted file mode 100644 index df7ea1d..0000000 --- a/data_from_eclipse_ide/basic_idea_of_DS/SetExample.java +++ /dev/null @@ -1,34 +0,0 @@ -package basic_idea_of_DS; -// Java program to demonstrate the -// union, intersection and difference -// operations on sets -import java.util.*; -public class SetExample -{ - public static void main(String args[]) - { - Set a = new HashSet(); - a.addAll(Arrays.asList(new Integer[] {1, 3, 2, 4, 8, 9, 0})); - Set b = new HashSet(); - b.addAll(Arrays.asList(new Integer[] {1, 3, 7, 5, 4, 0, 7, 5})); - - // To find union - Set union = new HashSet(a); - union.addAll(b); - System.out.print("Union of the two Set"); - System.out.println(union); - - // To find intersection - Set intersection = new HashSet(a); - - intersection.retainAll(b); - System.out.print("Intersection of the two Set"); - System.out.println(intersection); - - // To find the symmetric difference - Set difference = new HashSet(a); - difference.removeAll(b); - System.out.print("Difference of the two Set"); - System.out.println(difference); - } -} diff --git a/data_from_eclipse_ide/basic_idea_of_DS/Tree.java b/data_from_eclipse_ide/basic_idea_of_DS/Tree.java deleted file mode 100644 index 0e79c30..0000000 --- a/data_from_eclipse_ide/basic_idea_of_DS/Tree.java +++ /dev/null @@ -1,52 +0,0 @@ -package basic_idea_of_DS; - -//class containing left & right child of current node & key value -class Node{ - int key; - Node left,right; - public Node(int item) { - key = item; - left = right = null; - } -} - -// A java program to introduce Binary Tree -public class Tree { - - //Root node of binary tree - Node root; - - //Constructors - Tree(int key){ - root = new Node(key); - } - - Tree(){ - root = null; - } - public static void main(String[] args) { - Tree t = new Tree(); - //create root - t.root = new Node(1); - - /* following is the tree after above statement - 1 - / \ - null null*/ - - t.root.left = new Node(2); - t.root.right = new Node(3); - /* 2 & 3 become left & right children of 1 - * 1 - * / \ - * 2 3 - * / \ | \ - * null null null null - */ - t.root.left.left = new Node(4); - t.root.right.right = new Node(5); - t.root.right.left = new Node(6); - t.root.left.right = new Node(7); - - } -} diff --git a/data_from_eclipse_ide/basics/ControlStatements.java b/data_from_eclipse_ide/basics/ControlStatements.java deleted file mode 100644 index fd9f096..0000000 --- a/data_from_eclipse_ide/basics/ControlStatements.java +++ /dev/null @@ -1,29 +0,0 @@ -package basics; - -public class ControlStatements { - - public static void main(String[] args) { - - // for loop to implement switch case statement - for(int i = 0 ; i < 9 ; i++){ - - // switch control statement - switch(i) { - case 1: - System.out.println(" i is zero."); - break; - case 2: - System.out.println(" i is one."); - break; - case 3: - System.out.println(" i is zero."); - break; - default: - System.out.println(" i is greater than 3."); - } - - } - } -} - - diff --git a/data_from_eclipse_ide/basics/DoWhileLoop.java b/data_from_eclipse_ide/basics/DoWhileLoop.java deleted file mode 100644 index a13f4c4..0000000 --- a/data_from_eclipse_ide/basics/DoWhileLoop.java +++ /dev/null @@ -1,15 +0,0 @@ -package basics; - -public class DoWhileLoop { - //method inside which do while loop will occur - public static void main(String[] args) { - - int n = 10; - //do while loop's do block - // must executes atleast once - do { - System.out.println(" tick " +n); - n--; - }while(n>0);// do while loop's while block - } // end of main method -}// end of class diff --git a/data_from_eclipse_ide/basics/Fast_Inputs_Main.java b/data_from_eclipse_ide/basics/Fast_Inputs_Main.java deleted file mode 100644 index edd6bc2..0000000 --- a/data_from_eclipse_ide/basics/Fast_Inputs_Main.java +++ /dev/null @@ -1,63 +0,0 @@ -package basics; - -import java.io.OutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintWriter; -import java.util.StringTokenizer; -import java.io.IOException; -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.io.InputStream; - - -// Remember that the class name should be "Main" and should be "public". -@SuppressWarnings("unused") -public class Fast_Inputs_Main { - public static void main(String[] args) { - // System.in and System.out are input and output streams, respectively. - InputStream inputStream = System.in; - - InputReader in = new InputReader(inputStream); - - int n = in.nextInt(); - int k = in.nextInt(); - - int ans = 0; - - for (int i = 0; i < n; i++) { - int x = in.nextInt(); - - if (x % k == 0) { - ans++; - } - } - - System.out.println(ans); - } - - static class InputReader { - public BufferedReader reader; - public StringTokenizer tokenizer; - - public InputReader(InputStream stream) { - reader = new BufferedReader(new InputStreamReader(stream), 32768); - tokenizer = null; - } - - public String next() { - while (tokenizer == null || !tokenizer.hasMoreTokens()) { - try { - tokenizer = new StringTokenizer(reader.readLine()); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - return tokenizer.nextToken(); - } - - public int nextInt() { - return Integer.parseInt(next()); - } - } -} diff --git a/data_from_eclipse_ide/basics/Operators.java b/data_from_eclipse_ide/basics/Operators.java deleted file mode 100644 index 0af28ee..0000000 --- a/data_from_eclipse_ide/basics/Operators.java +++ /dev/null @@ -1,17 +0,0 @@ -package basics; - -public class Operators { - - public static void main(String[] args) { - int a = 7,b= 6; - int c = a*b; //* (multiplication) operator - int d = a+b; // + addition operator - int e = a/b; // - subtraction operator - int f = a%b; // % modulus operator - int g = a^b; // ^ power operator - long h = b^a; - System.out.println(c + " " + d + " " + e + " " + f + " " + g + " " + h); - - } - -} diff --git a/data_from_eclipse_ide/basics/VariablesandDataTypes.java b/data_from_eclipse_ide/basics/VariablesandDataTypes.java deleted file mode 100644 index 111d443..0000000 --- a/data_from_eclipse_ide/basics/VariablesandDataTypes.java +++ /dev/null @@ -1,15 +0,0 @@ -package basics; - -public class VariablesandDataTypes { - - public static void main(String[] args) { - - int age = 18; // integer data type - String name = "Aman"; // String data type - long number = 7023; // long data type - String address ="Behind Fort"; - System.out.println(age + " " + name + " " + number + " " + address); - - } - -} diff --git a/data_from_eclipse_ide/basics/WhileLoop.java b/data_from_eclipse_ide/basics/WhileLoop.java deleted file mode 100644 index c54afa3..0000000 --- a/data_from_eclipse_ide/basics/WhileLoop.java +++ /dev/null @@ -1,14 +0,0 @@ -package basics; - -public class WhileLoop { - - public static void main(String[] args) { - - int n = 5; - while(n>0) { - System.out.println(" tick " + n); - // post subtraction operator - n--; - } - } - } diff --git a/data_from_eclipse_ide/dp/CoinChoiseProblem.java b/data_from_eclipse_ide/dp/CoinChoiseProblem.java deleted file mode 100644 index e20304e..0000000 --- a/data_from_eclipse_ide/dp/CoinChoiseProblem.java +++ /dev/null @@ -1,51 +0,0 @@ -package dp; - -import java.util.*; - -public class CoinChoiseProblem { - - public static void main(String[] args) { - - - int n = 18; - int a[] = {7, 5, 1}; - int dp[] = new int[n+1]; - - Arrays.fill(dp, -1); - dp[0] = 0; - - int ans = minCoins(n, a, dp); - System.out.println(ans); - - for(int x: dp) - System.out.println(x + " "); - } - - static int minCoins(int n, int a[], int dp[]) { - - if(n == 0) - return 0; - - int ans = Integer.MAX_VALUE; - - for(int i = 0; i= 0) { - - int subAns = 0; - - if(dp[n-a[i]] != -1) - subAns = dp[n-a[i]]; - - else - subAns = minCoins(n-a[i],a, dp); - - if(subAns != Integer.MAX_VALUE && subAns + 1 < ans) - ans = subAns + 1; - } - } - - return dp[n] = ans; - - } -} diff --git a/data_from_eclipse_ide/graphs/Graph_Traversal_DFS.java b/data_from_eclipse_ide/graphs/Graph_Traversal_DFS.java deleted file mode 100644 index a8ec9fb..0000000 --- a/data_from_eclipse_ide/graphs/Graph_Traversal_DFS.java +++ /dev/null @@ -1,57 +0,0 @@ -package graphs; -import java.util.*; - -public class Graph_Traversal_DFS{ - - @SuppressWarnings("unused") - private int v; - private LinkedList adj[]; - - @SuppressWarnings("unchecked") - public Graph_Traversal_DFS(int v){ - adj = new LinkedList[v]; - for(int i = 0 ; i < v ; ++i) - adj[i] = new LinkedList(); - } - - void addEdge(int v, int w) { - adj[v].add(w); - } - - void DFSUtil(int v, boolean visited[]) { - visited[v] = true; - System.out.println(v + " "); - - Iterator i = adj[v].listIterator(); - while(i.hasNext()) { - int n = i.next(); - if(!visited[n]) - DFSUtil(n,visited); - } - } - - void DFS(int v) { - boolean visited[] = new boolean[v]; - DFSUtil(v,visited); - } - - public static void main(String[] args) { - - Graph_Traversal_DFS d = new Graph_Traversal_DFS(4); - - d.addEdge(0, 1); - d.addEdge(0, 2); - d.addEdge(1, 2); - d.addEdge(2, 0); - d.addEdge(2, 3); - d.addEdge(3, 3); - - System.out.println( - "Following is Depth First Traversal " - + "(starting from vertex 2)"); - - d.DFS(2); - - } - -} diff --git a/data_from_eclipse_ide/matrix/Matrix_Problem_01.java b/data_from_eclipse_ide/matrix/Matrix_Problem_01.java deleted file mode 100644 index 5b34422..0000000 --- a/data_from_eclipse_ide/matrix/Matrix_Problem_01.java +++ /dev/null @@ -1,87 +0,0 @@ -package matrix; -import java.io.*; - -/* - * Spiral traversal on a Matrix - */ - -/* - * GIven an 2D array, print it in spiral form. - * See the following examples. - * - * Inputs: - * 01 02 03 04 - * 05 06 07 08 - * 09 10 11 12 - * 13 14 15 16 - * - * Output: - * 1 2 3 4 8 12 16 15 14 13 9 5 6 7 11 10 - * - * Explanation: - * The output is matrix in spiral format. - */ - -/* Graphical Try: - * - * 01-- 02-- 03-- 04 - * | - * 05-- 06-- 07 08 - * | | | - * 09 10 11 12 - * | | - * 13-- 14-- 15 --16 - * - * Output: - * 1, 2, 3, 4, 8, 12, 16, 15, 14, 13, 9, 5, 6, 7, 11, 10 - */ - -@SuppressWarnings("unused") -public class Matrix_Problem_01 { - - static void spiralPrint(int m, int n, int[][] a) { - - System.out.println("Spiral Traversal of given matrix is: "); - int i, k = 0, l = 0; - - /* - * k - starting row index - * m - ending row index - * l - starting column index - * n - ending column index - * i - iterator - */ - - while(k < m && l < n) { - - - for( i = l ; i < n ; ++i) - System.out.print(a[k][i] + " "); - k++; - - for(i = k ; i < m ; ++i) - System.out.print(a[i][n - 1] + " "); - n--; - - if(l < n) { - for(i = m - 1 ; i >= k ; --i) - System.out.print(a[i][l] + " "); - l++; - } - } - - } - - public static void main(String[] args) { - - int R = 3; - int C = 6; - int a[][] = { { 1 , 2 , 3 , 4 , 5 , 6 }, - { 7 , 8 , 9 , 10 , 11 , 12 }, - { 13 , 14 , 15 , 16 , 17 , 18 } - }; - - spiralPrint(R,C,a); - } - -} diff --git a/data_from_eclipse_ide/matrix/Matrix_Problem_02.java b/data_from_eclipse_ide/matrix/Matrix_Problem_02.java deleted file mode 100644 index 1de28d7..0000000 --- a/data_from_eclipse_ide/matrix/Matrix_Problem_02.java +++ /dev/null @@ -1,123 +0,0 @@ -package matrix; - -//Search an element in a matrix - -/* - * Example; - * Consider: | 1 2 3 4| - * x = 3, - * mat = | 5 6 7 8| Middle column: - * | 9 10 11 12| = {2, 6, 10, 14} - * |13 14 15 16| - * perform binary search on them - * since, x < 6, - * discard the last 2 rows as 'a' will not lie in them(sorted matrix) - * Now, only two rows are left - * | 1 2 3 4| - * x = 3, mat = | 5 6 7 8| - * - * Check whether element is present on the middle elements of these rows = {2, 6} - * - * If x != 2 or 6 - * - * If not, consider the four sub-parts - * 1st half of 1st row = {1}, 2nd half of 1st row = {3, 4} - * 1st half of 2nd row = {5}, 2nd half of 2nd row = {7, 8} - * - * According the value of 'x' it will be searched in the - * 2nd half of 1st row = {3, 4} and found at (i, j): (0, 2) - */ -public class Matrix_Problem_02 { - - static int MAX = 100; - - static void binarySearch(int mat[][], int i, int j_low, int j_high, int x) { - - while(j_low <= j_high) { - - int j_mid = (j_low + j_high)/2; - - if(mat[i][j_mid] == x) { - System.out.println("Found at (" + i + "," + j_mid + ")"); - return; - } - - else if(mat[i][j_mid] < x) - j_high = j_mid - 1; - - else - j_low = j_mid + 1; - } - - System.out.println("Element Not Found: "); - } - - static void sortedMatrixSearch(int mat[][], int n, int m, int x) { - - - // Single row matrix - if (n == 1) - { - binarySearch(mat, 0, 0, m - 1, x); - return; - } - - // Do binary search in middle column. - // Condition to terminate the loop when the 2 desired rows are found - int i_low = 0; - int i_high = n - 1; - int j_mid = m / 2; - - while ((i_low + 1) < i_high) - { - int i_mid = (i_low + i_high) / 2; - - // element found - if (mat[i_mid][j_mid] == x) - { - System.out.println ( "Found at (" + i_mid +", " + j_mid +")"); - return; - } - - else if (mat[i_mid][j_mid] > x) - i_high = i_mid; - - else - i_low = i_mid; - } - - // If element is present on the mid of the two rows - if (mat[i_low][j_mid] == x) - System.out.println ( "Found at (" + i_low + "," + j_mid +")"); - - else if (mat[i_low + 1][j_mid] == x) - System.out.println ( "Found at (" + (i_low + 1) + ", " + j_mid +")"); - - // Search element on 1st half of 1st row - else if (x <= mat[i_low][j_mid - 1]) - binarySearch(mat, i_low, 0, j_mid - 1, x); - - // Search element on 2nd half of 1st row - else if (x >= mat[i_low][j_mid + 1] && x <= mat[i_low][m - 1]) - binarySearch(mat, i_low, j_mid + 1, m - 1, x); - - // Search element on 1st half of 2nd row - else if (x <= mat[i_low + 1][j_mid - 1]) - binarySearch(mat, i_low + 1, 0, j_mid - 1, x); - - // search element on 2nd half of 2nd row - else - binarySearch(mat, i_low + 1, j_mid + 1, m - 1, x); - } - - public static void main(String[] args) { - int n = 4, m = 5, x = 8; - int mat[][] = {{0, 6, 8, 9, 11}, - {20, 22, 28, 29, 31}, - {36, 38, 50, 61, 63}, - {64, 66, 100, 122, 128}}; - - sortedMatrixSearch(mat, n, m, x); - } - -} diff --git a/data_from_eclipse_ide/oops/A.java b/data_from_eclipse_ide/oops/A.java deleted file mode 100644 index aec9a69..0000000 --- a/data_from_eclipse_ide/oops/A.java +++ /dev/null @@ -1,10 +0,0 @@ -package oops; - -public class A { - class B{ - int age; - } - static class C{ - String name; - } -} diff --git a/data_from_eclipse_ide/oops/MYStaticKeyword.java b/data_from_eclipse_ide/oops/MYStaticKeyword.java deleted file mode 100644 index 181746e..0000000 --- a/data_from_eclipse_ide/oops/MYStaticKeyword.java +++ /dev/null @@ -1,22 +0,0 @@ -package oops; -import oops.A.C; -public class MYStaticKeyword { - - static { - System.out.println("in block 1"); - } - static { - System.out.println("in block 2"); - } - - public static void main(String[] args) { - - A objA = new A(); - @SuppressWarnings("unused") - A.B objB = objA.new B(); - @SuppressWarnings("unused") - C objC = new A.C(); - System.out.println("inside main"); - } - -} diff --git a/data_from_eclipse_ide/oops/Mor.java b/data_from_eclipse_ide/oops/Mor.java deleted file mode 100644 index 31ccaa6..0000000 --- a/data_from_eclipse_ide/oops/Mor.java +++ /dev/null @@ -1,15 +0,0 @@ -package oops; - -public class Mor extends Watches { - - //overrided function - @Override - public void Digital() { - System.out.println("Method_overriding is digital"); - } - //second function - public void Royal() { - System.out.println("Method_overriding is royal"); - } - -} diff --git a/data_from_eclipse_ide/oops/MyConstructor.java b/data_from_eclipse_ide/oops/MyConstructor.java deleted file mode 100644 index d5ebf6b..0000000 --- a/data_from_eclipse_ide/oops/MyConstructor.java +++ /dev/null @@ -1,13 +0,0 @@ -package oops; - -public class MyConstructor { - - MyConstructor(){ - System.out.println("Obj is now created"); - } - public static void main(String[] args) { - @SuppressWarnings("unused") - MyConstructor obj = new MyConstructor(); - } - -} diff --git a/data_from_eclipse_ide/oops/Person.java b/data_from_eclipse_ide/oops/Person.java deleted file mode 100644 index d17564a..0000000 --- a/data_from_eclipse_ide/oops/Person.java +++ /dev/null @@ -1,7 +0,0 @@ -package oops; - -public class Person { -int age; -String name; -final static String breed = "HomoSapiens"; -} diff --git a/data_from_eclipse_ide/oops/RepairShop.java b/data_from_eclipse_ide/oops/RepairShop.java deleted file mode 100644 index f119ee3..0000000 --- a/data_from_eclipse_ide/oops/RepairShop.java +++ /dev/null @@ -1,20 +0,0 @@ -package oops; - -public class RepairShop { - - - public static void repair (Watches ws) { - System.out.println("watch is repaired"); - } - public static void repair(Sonata sn) { - System.out.println("watch is repaired"); - } - public static void main(String[] args) { - Mor Mo = new Mor(); - Sonata sn = new Sonata(); - - repair(Mo); - repair(sn); - } - -} diff --git a/data_from_eclipse_ide/oops/Sonata.java b/data_from_eclipse_ide/oops/Sonata.java deleted file mode 100644 index 7d8972d..0000000 --- a/data_from_eclipse_ide/oops/Sonata.java +++ /dev/null @@ -1,12 +0,0 @@ -package oops; - -public class Sonata extends Watches{ - - @Override - public void Digital() { - System.out.println("Sonata is digital"); - } - public void Royal() { - System.out.println("Sonata is royal"); - } -} diff --git a/data_from_eclipse_ide/oops/StaticKeyword.java b/data_from_eclipse_ide/oops/StaticKeyword.java deleted file mode 100644 index 7ae5504..0000000 --- a/data_from_eclipse_ide/oops/StaticKeyword.java +++ /dev/null @@ -1,13 +0,0 @@ -package oops; - -public class StaticKeyword { - public static void main(String[] args) { - Person obj = new Person(); - obj.name ="Aman"; - obj.age = 19; - System.out.println(obj.name); - System.out.println(obj.age + " age"); - System.out.println(Person.breed); - } - -} diff --git a/data_from_eclipse_ide/oops/Vehicle.java b/data_from_eclipse_ide/oops/Vehicle.java deleted file mode 100644 index b6058cb..0000000 --- a/data_from_eclipse_ide/oops/Vehicle.java +++ /dev/null @@ -1,19 +0,0 @@ -package oops; - -class transport{ - int wheels; - transport(){ - wheels = 4; - } -} - -public class Vehicle { - - public static void main(String[] args) { - - transport car = new transport(); - System.out.println(car.wheels + " wheels"); - - } - -} diff --git a/data_from_eclipse_ide/oops/Watches.java b/data_from_eclipse_ide/oops/Watches.java deleted file mode 100644 index 863a6d9..0000000 --- a/data_from_eclipse_ide/oops/Watches.java +++ /dev/null @@ -1,8 +0,0 @@ -package oops; - -public abstract class Watches { - - public abstract void Digital(); - public abstract void Royal(); - -} diff --git a/data_from_eclipse_ide/oopsEncapsulation/EncapIntro.java b/data_from_eclipse_ide/oopsEncapsulation/EncapIntro.java deleted file mode 100644 index e069086..0000000 --- a/data_from_eclipse_ide/oopsEncapsulation/EncapIntro.java +++ /dev/null @@ -1,17 +0,0 @@ -package oopsEncapsulation; - -public class EncapIntro { - - public static void main(String[] args) { - - S obj = new S(); - - obj.setName("Milan"); - obj.setAge(16); - System.out.println(obj.getName()); - System.out.println(obj.getAge()); - - - } - -} diff --git a/data_from_eclipse_ide/oopsEncapsulation/S.java b/data_from_eclipse_ide/oopsEncapsulation/S.java deleted file mode 100644 index bb69bb6..0000000 --- a/data_from_eclipse_ide/oopsEncapsulation/S.java +++ /dev/null @@ -1,31 +0,0 @@ -package oopsEncapsulation; - -//Student class short name as S -public class S { - - /*we have to put the variables private to achieve encapsulation*/ - private int age; - - private String name; - - //setter methods - public void setAge(int age) { - if(age>20) System.out.println(" You are to old:"); - else this.age = age; - } - - public void setName(String name) { - this.name = name; - } - - //getter methods - public int getAge() { - return age; - } - - public String getName() { - return name; - } - - -} diff --git a/data_from_eclipse_ide/oopsabstraction/Audi.java b/data_from_eclipse_ide/oopsabstraction/Audi.java deleted file mode 100644 index 2475df8..0000000 --- a/data_from_eclipse_ide/oopsabstraction/Audi.java +++ /dev/null @@ -1,15 +0,0 @@ -package oopsabstraction; -//Audi Class - -public class Audi extends Car{ - - public void accelerate() { - System.out.println("Audi is accelerating"); - } - @Override - public void apply_break() { - System.out.println("Audi is breaking"); - - } - -} diff --git a/data_from_eclipse_ide/oopsabstraction/Car.java b/data_from_eclipse_ide/oopsabstraction/Car.java deleted file mode 100644 index dceb3b5..0000000 --- a/data_from_eclipse_ide/oopsabstraction/Car.java +++ /dev/null @@ -1,8 +0,0 @@ -package oopsabstraction; - -public abstract class Car { - - public abstract void accelerate(); - public abstract void apply_break(); - -} diff --git a/data_from_eclipse_ide/oopsabstraction/RepairShop.java b/data_from_eclipse_ide/oopsabstraction/RepairShop.java deleted file mode 100644 index 6a09ac2..0000000 --- a/data_from_eclipse_ide/oopsabstraction/RepairShop.java +++ /dev/null @@ -1,21 +0,0 @@ -package oopsabstraction; - -public class RepairShop { - - public static void repairCar(Car car) { - System.out.println("car is repaired"); - } - - public static void repairCar(Car...Audi) { - System.out.println("car is repaired"); - } - - public static void main(String[] args) { - WagonR wagonR = new WagonR(); - Audi audi = new Audi(); - - repairCar(wagonR); - repairCar(audi); - } - -} diff --git a/data_from_eclipse_ide/oopsabstraction/WagonR.java b/data_from_eclipse_ide/oopsabstraction/WagonR.java deleted file mode 100644 index 8f8425b..0000000 --- a/data_from_eclipse_ide/oopsabstraction/WagonR.java +++ /dev/null @@ -1,20 +0,0 @@ -package oopsabstraction; - -public class WagonR extends Car{ - - public static void main(String[] args) { - - } - @Override - public void accelerate() { - - System.out.println("WagonR is accelerating"); - } - - @Override - public void apply_break() { - - System.out.println("break is applied in WagonR"); - } - -} diff --git a/data_from_eclipse_ide/oopsinheritance/MainClass.java b/data_from_eclipse_ide/oopsinheritance/MainClass.java deleted file mode 100644 index 8332e70..0000000 --- a/data_from_eclipse_ide/oopsinheritance/MainClass.java +++ /dev/null @@ -1,20 +0,0 @@ -package oopsinheritance; - -public class MainClass { - - public static void main(String[] args) { - //Object of teacher class - Teacher T = new Teacher(); - T.name = "Mr Harry "; - T.eat(); - T.walk(); - T.teach(); - //Object of singer class - Singer s = new Singer(); - s.name = "Justin B "; - s.sing(); - s.eat(); - - } - -} diff --git a/data_from_eclipse_ide/oopsinheritance/Person.java b/data_from_eclipse_ide/oopsinheritance/Person.java deleted file mode 100644 index d4c4805..0000000 --- a/data_from_eclipse_ide/oopsinheritance/Person.java +++ /dev/null @@ -1,15 +0,0 @@ -package oopsinheritance; - -public class Person { - - protected String name; - - public void walk() { - System.out.println(name + "is walking"); - } - - public void eat() { - System.out.println(name + "is eating"); - } - -} diff --git a/data_from_eclipse_ide/oopsinheritance/Singer.java b/data_from_eclipse_ide/oopsinheritance/Singer.java deleted file mode 100644 index 0d39ff4..0000000 --- a/data_from_eclipse_ide/oopsinheritance/Singer.java +++ /dev/null @@ -1,9 +0,0 @@ -package oopsinheritance; - -public class Singer extends Person { - - public void sing() { - System.out.println(name + "is singing"); - } - -} diff --git a/data_from_eclipse_ide/oopsinheritance/Teacher.java b/data_from_eclipse_ide/oopsinheritance/Teacher.java deleted file mode 100644 index 71e38d8..0000000 --- a/data_from_eclipse_ide/oopsinheritance/Teacher.java +++ /dev/null @@ -1,9 +0,0 @@ -package oopsinheritance; - -public class Teacher extends Person { - - public void teach() { - System.out.println(name + "is teaching"); - } - -} diff --git a/data_from_eclipse_ide/oopspolymorphism/Animal.java b/data_from_eclipse_ide/oopspolymorphism/Animal.java deleted file mode 100644 index 99bbd6b..0000000 --- a/data_from_eclipse_ide/oopspolymorphism/Animal.java +++ /dev/null @@ -1,5 +0,0 @@ -package oopspolymorphism; -//An empty Animal class -public class Animal { - -} diff --git a/data_from_eclipse_ide/oopspolymorphism/Dog.java b/data_from_eclipse_ide/oopspolymorphism/Dog.java deleted file mode 100644 index 995b0d6..0000000 --- a/data_from_eclipse_ide/oopspolymorphism/Dog.java +++ /dev/null @@ -1,10 +0,0 @@ -package oopspolymorphism; - -public class Dog extends Pet { - - public void walk() { - System.out.println("dog is walking"); - } - - -} diff --git a/data_from_eclipse_ide/oopspolymorphism/MainClass.java b/data_from_eclipse_ide/oopspolymorphism/MainClass.java deleted file mode 100644 index 112fc11..0000000 --- a/data_from_eclipse_ide/oopspolymorphism/MainClass.java +++ /dev/null @@ -1,29 +0,0 @@ -package oopspolymorphism; - -public class MainClass { - - - public static void greetings() { - System.out.println("Hi,there"); - } - public static void greetings(String s) { - System.out.println(s); - } - public static void greetings(String s, int count) { - for(int i=0;i=i;j--) //j for horizontal stars - System.out.print("* "); //printing the stars - - System.out.println(); - } - } - -} diff --git a/data_from_eclipse_ide/patternsByloops/Pattern3.java b/data_from_eclipse_ide/patternsByloops/Pattern3.java deleted file mode 100644 index d2a20ca..0000000 --- a/data_from_eclipse_ide/patternsByloops/Pattern3.java +++ /dev/null @@ -1,18 +0,0 @@ -package patternsByloops; - -public class Pattern3 { - - public static void main(String[] args) { - - int n = 6; //size of the pattern - - for(int i=1;i<=n;i++) { //i for horizontal stars operation - - for(int j=n-1;j>=i;j--) //j for vertical stars operation - System.out.print("* "); //printing the stars - - System.out.println(); // for new line - } - } - -} diff --git a/data_from_eclipse_ide/patternsByloops/Pattern4.java b/data_from_eclipse_ide/patternsByloops/Pattern4.java deleted file mode 100644 index 3635f7e..0000000 --- a/data_from_eclipse_ide/patternsByloops/Pattern4.java +++ /dev/null @@ -1,20 +0,0 @@ -package patternsByloops; - -public class Pattern4 { - public static void main(String[] args) { - - int n=6; //size of the pattern - - for(int i=n;i>=1;i--){ //i for horizontal stars - - for(int j=n-1;j>=i;j--) //j for vertical and for print & handling the spaces - System.out.print(" "); - - for(int k=1;k<=i;k++) //k variable for print the values - System.out.print("* "); //printing the stars - - System.out.println(); - } - } - -} diff --git a/data_from_eclipse_ide/patternsByloops/Pattern5.java b/data_from_eclipse_ide/patternsByloops/Pattern5.java deleted file mode 100644 index a93e554..0000000 --- a/data_from_eclipse_ide/patternsByloops/Pattern5.java +++ /dev/null @@ -1,30 +0,0 @@ -package patternsByloops; - -public class Pattern5 { - - public static void main(String[] args) { - - int min_stars =0; /*change value to set minimum no. of stars in pyramid - take odd no.for odd no. of stars in each row 1-3-5 - etc - take even no. for even no. stars in each row,2-4-6 etc */ - - int p_height=6; //change value to increase or decrease the size of pyramid - - int p_space = p_height - 1; - - for(int i= 1;ii;j--) - System.out.print(" "); - - for(int k=0;k<=min_stars;k++) - System.out.print("* "); - - min_stars+=2; - System.out.println(); - } - - }//end of main -}//end of class diff --git a/data_from_eclipse_ide/patternsByloops/Pattern5_2.java b/data_from_eclipse_ide/patternsByloops/Pattern5_2.java deleted file mode 100644 index 3728cec..0000000 --- a/data_from_eclipse_ide/patternsByloops/Pattern5_2.java +++ /dev/null @@ -1,24 +0,0 @@ -package patternsByloops; - -public class Pattern5_2 { - - public static void main(String[] args) { - - int n = 5; //size of pattern - - int px =n; //left print control - int py =n; //right print control - - for(int i=1;i<=n;i++) //i for horizontal stars - { - for(int j=1;j=px && j<=py) System.out.print("* "); //if condition is true then print the stars - else System.out.print(" "); //else print the spaces - - px--; //post decrementing the left print control - py++; //post incrementing the right print control - System.out.println(); - } - - } -} diff --git a/data_from_eclipse_ide/patternsByloops/Pattern6.java b/data_from_eclipse_ide/patternsByloops/Pattern6.java deleted file mode 100644 index efb017c..0000000 --- a/data_from_eclipse_ide/patternsByloops/Pattern6.java +++ /dev/null @@ -1,21 +0,0 @@ -package patternsByloops; - -public class Pattern6 { - - public static void main(String[] args) - { - int n=5; - //size of pattern - for(int i= n;i>=1;i--) - { - for(int j=n-1;j>=i;j--) // loop for print the spaces - System.out.print(" "); //printing the spaces - - for(int k =1;k<=i;k++) // loop for print the stars - System.out.print("*"); //printing the stars - - System.out.println(); //for new line - }//end of loop - - }//end of main -}//end of class diff --git a/data_from_eclipse_ide/patternsByloops/Pattern7.java b/data_from_eclipse_ide/patternsByloops/Pattern7.java deleted file mode 100644 index 4365cb5..0000000 --- a/data_from_eclipse_ide/patternsByloops/Pattern7.java +++ /dev/null @@ -1,18 +0,0 @@ -package patternsByloops; - -public class Pattern7 -{ - public static void main(String[] args) - { - - int size = 3; //size of the pattern - - for(int i=size;i>=-size;i--) //loop to print the stars - { - for( int j=size;j>=Math.abs(i);j--) //inner or nested loop for print the stars - System.out.print("* "); - - System.out.println(); //for new line - }//end of loop - }//end of main -}//end of class diff --git a/data_from_eclipse_ide/patternsByloops/Pattern8.java b/data_from_eclipse_ide/patternsByloops/Pattern8.java deleted file mode 100644 index 8ef97cb..0000000 --- a/data_from_eclipse_ide/patternsByloops/Pattern8.java +++ /dev/null @@ -1,21 +0,0 @@ -package patternsByloops; - -public class Pattern8 -{ - public static void main(String[] args) - { - int size = 3; //size of pattern - - for(int i=size;i>=-size;i--) { //loop for handling spaces & stars - - for(int j=1;j<=Math.abs(i);j++) //inner or nested loop to handle or print spaces - System.out.print(" "); //printing the spaces - - for(int k=size;k>=Math.abs(i);k--) //inner or nested loop to handle or print stars - System.out.print("*"); //printing the stars - - System.out.println(); //for new line - }//end of loop - - }//end of main -}//end of class diff --git a/data_from_eclipse_ide/patternsByloops/Pattern9.java b/data_from_eclipse_ide/patternsByloops/Pattern9.java deleted file mode 100644 index d9ea106..0000000 --- a/data_from_eclipse_ide/patternsByloops/Pattern9.java +++ /dev/null @@ -1,19 +0,0 @@ -package patternsByloops; - -public class Pattern9 { - - public static void main(String[] args) { - - int size = 3; //size of pattern - for(int i=size;i>=-size;i--) //loop for handle stars & spaces - { - for(int j=1;j<=Math.abs(i);j++) //inner or nested loop for spaces - System.out.print(" "); //printing the spaces - - for(int k=size;k>=Math.abs(i);k--) //inner or nested loop for stars - System.out.print("* "); //printing the stars - - System.out.println(); //new line - } - }//end of main -}//end of class diff --git a/data_from_eclipse_ide/practiceProblems/Cylinder.java b/data_from_eclipse_ide/practiceProblems/Cylinder.java deleted file mode 100644 index 72c0b2f..0000000 --- a/data_from_eclipse_ide/practiceProblems/Cylinder.java +++ /dev/null @@ -1,26 +0,0 @@ -package practiceProblems; - -public class Cylinder { - - public static void main(String[] args) { - - //The below line represent's the , Object of the Setter_Getters class - Getters_Setters_For_Cylinder sg = new Getters_Setters_For_Cylinder(); - - //setting values of pie, height & radius by using setter method with use of other class & by calling it - sg.setHeight(35); - sg.setRadius(3.0); - sg.setPie(3.14); - - //getting values of pie, radius & height - System.out.println("The value of the Pie is: " + sg.getPie()); - System.out.println("The height of the cylinder is: " + sg.getHeight() + " cm"); - System.out.println("The radius of the cylinder is: " + sg.getRadius() + " cm"); - - // volume of cylinder => (V = 3.14*(r)^2*h) - double V = sg.getPie()*(sg.getRadius()*sg.getRadius())*sg.getHeight(); - System.out.println("The volume of the cylinder is: " + V + " cm^3"); - - } - -} diff --git a/data_from_eclipse_ide/practiceProblems/Exercise1.java b/data_from_eclipse_ide/practiceProblems/Exercise1.java deleted file mode 100644 index a62e265..0000000 --- a/data_from_eclipse_ide/practiceProblems/Exercise1.java +++ /dev/null @@ -1,33 +0,0 @@ -package practiceProblems; -import java.util.*; - -/* To calculate percentage of a given student in CBSE Board exam. - * His marks from 5 subjects must be taken as input from the keyboard - * (Marks are out of 100) - * */ - -public class Exercise1 { - - static Scanner sc = new Scanner(System.in); - - static int subject_1_marks = sc.nextInt(); - static int subject_2_marks = sc.nextInt(); - static int subject_3_marks = sc.nextInt(); - static int subject_4_marks = sc.nextInt(); - static int subject_5_marks = sc.nextInt(); - - public static void main(String[] args) { - - int total = (subject_1_marks + subject_2_marks + subject_3_marks + subject_4_marks + subject_5_marks); - float percentage = (total)/5; - - System.out.println("The marks of the subject's are: \n " + "\n" + "subject_1_marks:- " + subject_1_marks + "\n" + - "subject_2_marks:- " + subject_2_marks + "\n" + "subject_3_marks:- " + subject_3_marks + "\n" + - "subject_4_marks:- " + subject_4_marks + "\n" + "subject_5_marks:- " + subject_5_marks + "\n"); - - System.out.println("The total no. of marks are: " + total); - System.out.println("Total percentage is: " + percentage); - - } - -} diff --git a/data_from_eclipse_ide/practiceProblems/Exercise2.java b/data_from_eclipse_ide/practiceProblems/Exercise2.java deleted file mode 100644 index 794539d..0000000 --- a/data_from_eclipse_ide/practiceProblems/Exercise2.java +++ /dev/null @@ -1,34 +0,0 @@ -package practiceProblems; -import java.util.Scanner; - -/* - * Take an array as input & print all of its content at particular index wise - */ - -public class Exercise2 { - - public static void main(String[] args) { - try (Scanner sc = new Scanner(System.in)) { - int n,sum =0; - - System.out.println("Enter no. of elements you want in array:"); - n = sc.nextInt(); - - int A[] = new int[n]; - System.out.println("Enter all the elements: "); - - for(int i=0;i 40) System.out.println(" The height of cylender is to high to to find vol & surface area: "); - else this.height = height; - } - - //setter method to set radius of cylinder - public void setRadius(double radius) { - this.radius = radius; - } - - //setter method to set the value of pie - public void setPie(double pie) { - this.pie = pie; - } - - //getter method to get the height of cylinder - public int getHeight() { - return height; - } - - //getter method to get the radius of cylinder - public double getRadius() { - return radius; - } - - //getter method to get the value of pie - public double getPie() { - return pie; - } - - - -} diff --git a/data_from_eclipse_ide/recursion/Factorial.java b/data_from_eclipse_ide/recursion/Factorial.java deleted file mode 100644 index 6091555..0000000 --- a/data_from_eclipse_ide/recursion/Factorial.java +++ /dev/null @@ -1,21 +0,0 @@ -package recursion; -import java.util.Scanner; - -public class Factorial { - public static long multiplyNumbers(int num) - { - if (num >= 1) - return num * multiplyNumbers(num - 1); - else - return 1; - } - public static void main(String[] args) { - - @SuppressWarnings("resource") - Scanner sc = new Scanner(System.in); - int num = sc.nextInt(); - long factorial = multiplyNumbers(num); - System.out.println("Factorial of " + num + " = " + factorial); - } - -} diff --git a/data_from_eclipse_ide/recursion/NRaiseP.java b/data_from_eclipse_ide/recursion/NRaiseP.java deleted file mode 100644 index 1aff02b..0000000 --- a/data_from_eclipse_ide/recursion/NRaiseP.java +++ /dev/null @@ -1,15 +0,0 @@ -package recursion; - -public class NRaiseP { - - public static int nRaisep(int n, int p) { - if(p == 0) - return 1; - return n*nRaisep(n,p-1); - } - - public static void main(String[] args) { - System.out.println(nRaisep(3,4)); - } - -} diff --git a/data_from_eclipse_ide/recursion/NaturalNoSum.java b/data_from_eclipse_ide/recursion/NaturalNoSum.java deleted file mode 100644 index 6c52af4..0000000 --- a/data_from_eclipse_ide/recursion/NaturalNoSum.java +++ /dev/null @@ -1,20 +0,0 @@ -package recursion; - -/* - * Find sum of first N natural numbers using recursion - */ -public class NaturalNoSum { - - public static void main(String[] args) { - System.out.println(sum(5)); - } - - static int sum(int N) { - //Base case - if(N == 1) return 1; - - //Recursive call - return N+sum(N-1) ; - } - -} diff --git a/data_from_eclipse_ide/recursion/Subsequences.java b/data_from_eclipse_ide/recursion/Subsequences.java deleted file mode 100644 index 87719e9..0000000 --- a/data_from_eclipse_ide/recursion/Subsequences.java +++ /dev/null @@ -1,50 +0,0 @@ -package recursion; - -//Program to Find the Subsequences of Given String by using RECURSION -public class Subsequences { - - public static String[] findSubsequences(String str) { - - if(str.length() == 0) { - String ans[] = {""}; - return ans; - } - - String smallAns[] = findSubsequences(str.substring(1)); - String ans[] = new String[2 * smallAns.length]; - - /* - * Otherwise: - * int k = 0; - */ - for(int i = 0 ; i < smallAns.length ; i++) { - ans[i] = smallAns[i]; - /* - * Otherwise: - * ans[k] = smallAns[i]; - * k++; - */ - } - - for(int i = 0 ; i< smallAns.length ; i++) { - /* - * otherwise: ans[k] in place of ans[i + smallAns] and - * k++; - */ - ans[i + smallAns.length] = str.charAt(0) + smallAns[i]; - } - - return ans; - } - - public static void main(String[] args) { - - String str = "xyz"; - String ans[] = findSubsequences(str); - for(int i = 0 ; i < ans.length; i++) { - System.out.println(ans[i]); - } - - } - -} diff --git a/data_from_eclipse_ide/recursion/Tower_Of_Hanoi.java b/data_from_eclipse_ide/recursion/Tower_Of_Hanoi.java deleted file mode 100644 index 567e397..0000000 --- a/data_from_eclipse_ide/recursion/Tower_Of_Hanoi.java +++ /dev/null @@ -1,29 +0,0 @@ -package recursion; - -/* - * Stack Application :- Tower of Hanoi Problem(Puzzle 1) - */ -public class Tower_Of_Hanoi { - - //function to solve the tower of hanoi proble - static void towerOfHanoi(int n, char from_rod, char to_rod, char aux_rod) { - - if(n == 1) { - System.out.println("Move disk 1 from rod " + from_rod + " to_rod " + to_rod); - return; - } - - towerOfHanoi(n-1, from_rod, to_rod, aux_rod); - System.out.println("Move disk "+ n +" from_rod "+from_rod+" to rod "+to_rod); - - } - - //Driver Method - public static void main(String[] args) { - - int n =4; - towerOfHanoi(n,'A','C','B'); - - } - -} diff --git a/data_from_eclipse_ide/searchingAlgorithms/BinarySearch.java b/data_from_eclipse_ide/searchingAlgorithms/BinarySearch.java deleted file mode 100644 index 3eda77a..0000000 --- a/data_from_eclipse_ide/searchingAlgorithms/BinarySearch.java +++ /dev/null @@ -1,47 +0,0 @@ -package searchingAlgorithms; - -//Binary Search Algorithm -public class BinarySearch { - - // Returns index of x if it is present in arr[l.. - // r], else return -1 - int binarySearch(int arr[], int l, int r, int x) - { - if (r >= l) { - int mid = l + (r - l) / 2; - - // If the element is present at the - // middle itself - if (arr[mid] == x) - return mid; - - // If element is smaller than mid, then - // it can only be present in left subarray - if (arr[mid] > x) - return binarySearch(arr, l, mid - 1, x); - - // Else the element can only be present - // in right subarray - return binarySearch(arr, mid + 1, r, x); - } - - // We reach here when element is not present - // in array - return -1; - } - - // Driver method to test above - public static void main(String args[]) - { - BinarySearch ob = new BinarySearch(); - int arr[] = { 2, 3, 4, 10, 40, 50, 90, 130, 230, 740}; - int n = arr.length; - int x = 130; - int result = ob.binarySearch(arr, 0, n - 1, x); - if (result == -1) - System.out.println("Element not present"); - else - System.out.println("Element found at index " + result); - } -} - diff --git a/data_from_eclipse_ide/searchingAlgorithms/LinearSearch.java b/data_from_eclipse_ide/searchingAlgorithms/LinearSearch.java deleted file mode 100644 index ff4718c..0000000 --- a/data_from_eclipse_ide/searchingAlgorithms/LinearSearch.java +++ /dev/null @@ -1,28 +0,0 @@ -package searchingAlgorithms; - -public class LinearSearch { - - public static int search(int arr[], int x) - { - int n = arr.length; - for(int i = 0; i < n; i++) - { - if(arr[i] == x) - return i; - } - return -1; - } - - public static void main(String args[]) - { - int arr[] = { 1, 2, 3, 4, 10, 40, 50, 60, 90, 80, 70}; - int x = 90; - - int result = search(arr, x); - if(result == -1) - System.out.print("Element is not present in array"); - else - System.out.print("Element is present at index " + result); - } - -} diff --git a/data_from_eclipse_ide/sortingAlgorithms/BubbleSort.java b/data_from_eclipse_ide/sortingAlgorithms/BubbleSort.java deleted file mode 100644 index f22a31c..0000000 --- a/data_from_eclipse_ide/sortingAlgorithms/BubbleSort.java +++ /dev/null @@ -1,43 +0,0 @@ -package sortingAlgorithms; - -//Program to demonstrate the bubble sort algorithm... -public class BubbleSort { - - void bubbleSort(int a[]) { - - int n = a.length; - for(int i=0;i a[j+1]) { - //swap a[j+1] and a[i] - int temp = a[j]; - a[j] = a[j+1]; - a[j+1] = temp; - } - } - } - } - - //function to print the array - void printArray(int a[]) { - - int n = a.length; - for(int i=0;i=0;i--) - heapify(A,n,i); - - for(int i = n-1;i>0;i--) { - int temp = A[0]; - A[0] = A[i]; - A[i] = temp; - - heapify(A,i,0); - } - } - - void heapify(int A[], int n, int i) { - - int largest = i; // Initialize largest as root - int l = 2*i + 1; // left = 2*i + 1 - int r = 2*i + 2; // right = 2*i + 2 - - // If left child is larger than root - if (l < n && A[l] > A[largest]) - largest = l; - - // If right child is larger than largest so far - if (r < n && A[r] > A[largest]) - largest = r; - - // If largest is not root - if (largest != i) - { - int swap = A[i]; - A[i] = A[largest]; - A[largest] = swap; - - // Recursively heapify the affected sub-tree - heapify(A, n, largest); - } - } - - /* A utility function to print array of size n */ - static void printArray(int A[]) - { - int n = A.length; - for (int i=0; i= 0 && arr[j] > key) { - arr[j + 1] = arr[j]; - j = j - 1; - } - arr[j + 1] = key; - } - } - - /* A utility function to print array of size n*/ - static void printArray(int arr[]) - { - int n = arr.length; - for (int i = 0; i < n; ++i) - System.out.print(arr[i] + " "); - - System.out.println(); - } - - // Driver method - public static void main(String args[]) - { - int arr[] = { 12, 11, 13, 5, 6 }; - - InsertionSort ob = new InsertionSort(); - ob.sort(arr); - - printArray(arr); - } -} - diff --git a/data_from_eclipse_ide/sortingAlgorithms/MergeSort.java b/data_from_eclipse_ide/sortingAlgorithms/MergeSort.java deleted file mode 100644 index 2281119..0000000 --- a/data_from_eclipse_ide/sortingAlgorithms/MergeSort.java +++ /dev/null @@ -1,98 +0,0 @@ -package sortingAlgorithms; - -public class MergeSort { - // Merges two subarrays of arr[]. - // First subarray is arr[l..m] - // Second subarray is arr[m+1..r] - void merge(int arr[], int l, int m, int r) - { - // Find sizes of two subarrays to be merged - int n1 = m - l + 1; - int n2 = r - m; - - /* Create temp arrays */ - int L[] = new int[n1]; - int R[] = new int[n2]; - - /*Copy data to temp arrays*/ - for (int i = 0; i < n1; ++i) - L[i] = arr[l + i]; - for (int j = 0; j < n2; ++j) - R[j] = arr[m + 1 + j]; - - /* Merge the temp arrays */ - - // Initial indexes of first and second subarrays - int i = 0, j = 0; - - // Initial index of merged subarry array - int k = l; - while (i < n1 && j < n2) { - if (L[i] <= R[j]) { - arr[k] = L[i]; - i++; - } - else { - arr[k] = R[j]; - j++; - } - k++; - } - - /* Copy remaining elements of L[] if any */ - while (i < n1) { - arr[k] = L[i]; - i++; - k++; - } - - /* Copy remaining elements of R[] if any */ - while (j < n2) { - arr[k] = R[j]; - j++; - k++; - } - } - - // Main function that sorts arr[l..r] using - // merge() - void sort(int arr[], int l, int r) - { - if (l < r) { - // Find the middle point - int m = (l + r) / 2; - - // Sort first and second halves - sort(arr, l, m); - sort(arr, m + 1, r); - - // Merge the sorted halves - merge(arr, l, m, r); - } - } - - /* A utility function to print array of size n */ - static void printArray(int arr[]) - { - int n = arr.length; - for (int i = 0; i < n; ++i) - System.out.print(arr[i] + " "); - System.out.println(); - } - - // Driver method - public static void main(String args[]) - { - int arr[] = { 12, 11, 13, 5, 6, 7 }; - - System.out.println("Given Array"); - printArray(arr); - - MergeSort ob = new MergeSort(); - ob.sort(arr, 0, arr.length - 1); - - System.out.println("\nSorted array"); - printArray(arr); - } - -} diff --git a/data_from_eclipse_ide/sortingAlgorithms/QuickSort.java b/data_from_eclipse_ide/sortingAlgorithms/QuickSort.java deleted file mode 100644 index fdefc10..0000000 --- a/data_from_eclipse_ide/sortingAlgorithms/QuickSort.java +++ /dev/null @@ -1,80 +0,0 @@ -package sortingAlgorithms; - -public class QuickSort { - - /* This function takes last element as pivot, - places the pivot element at its correct - position in sorted array, and places all - smaller (smaller than pivot) to left of - pivot and all greater elements to right - of pivot */ - int partition(int arr[], int low, int high) - { - int pivot = arr[high]; - int i = (low-1); // index of smaller element - for (int j=low; j Array to be sorted, - low --> Starting index, - high --> Ending index */ - void sort(int arr[], int low, int high) - { - if (low < high) - { - /* pi is partitioning index, arr[pi] is - now at right place */ - int pi = partition(arr, low, high); - - // Recursively sort elements before - // partition and after partition - sort(arr, low, pi-1); - sort(arr, pi+1, high); - } - } - - /* A utility function to print array of size n */ - static void printArray(int arr[]) - { - int n = arr.length; - for (int i=0; i mx) - mx = arr[i]; - return mx; - } - - // A function to do counting sort of array[] according to - // the digit represented by exponential. - static void countSort(int arr[], int n, int exp) { - int output[] = new int[n]; // output array - int i; - int count[] = new int[10]; - Arrays.fill(count,0); - - // Store count of occurrences in count[] - for (i = 0; i < n; i++) - count[ (arr[i]/exp)%10 ]++; - - // Change count[i] so that count[i] now contains - // actual position of this digit in output[] - for (i = 1; i < 10; i++) - count[i] += count[i - 1]; - - // Build the output array - for (i = n - 1; i >= 0; i--) - { - output[count[ (arr[i]/exp)%10 ] - 1] = arr[i]; - count[ (arr[i]/exp)%10 ]--; - } - - // Copy the output array to arr[], so that arr[] now - // contains sorted numbers according to curent digit - for (i = 0; i < n; i++) - arr[i] = output[i]; - } - - // The main function to that sorts arr[] of size n using Radix Sort - static void radixsort(int arr[], int n) { - // Find the maximum number to know number of digits - int m = getMax(arr, n); - - /* Do counting sort for every digit. - * Note that instead of passing digit number, exponential is passed. - * exponential is 10^i where i is current digit number . - */ - for (int exp = 1; m/exp > 0; exp *= 10) - countSort(arr, n, exp); - } - - // A utility function to print an array - static void print(int arr[], int n) { - for (int i=0; i stack = new Stack<>(); - - for(int i = 0 ; i < exp.length() ; ++i){ - char c = exp.charAt(i); - - if(Character.isLetterOrDigit(c)) - result += c; - - else if(c == '(') - stack.push(c); - - else if (c == ')'){ - while (!stack.isEmpty() && stack.peek() != '(') - result += stack.pop(); - - stack.pop(); - } - - else{ - while(!stack.isEmpty() && Prec(c) <= Prec(stack.peek())){ - result += stack.pop(); - } - } - - stack.push(c); - } - - while (!stack.isEmpty()) { - - if(stack.peek() == '(') - return "Invalid Expression"; - - result += stack.pop(); - } - - return result; - } - - public static void main(String[] args) { - - Scanner sc = new Scanner(System.in); - String exp = sc.nextLine(); - - @SuppressWarnings("unused") - Infix_To_Postfix post = new Infix_To_Postfix(); - - System.out.println(infixToPostfix(exp)); - sc.close(); - } - -} diff --git a/data_from_eclipse_ide/stack_and_queue/Parenthesis_Checker_Problem.java b/data_from_eclipse_ide/stack_and_queue/Parenthesis_Checker_Problem.java deleted file mode 100644 index 83fcaf5..0000000 --- a/data_from_eclipse_ide/stack_and_queue/Parenthesis_Checker_Problem.java +++ /dev/null @@ -1,75 +0,0 @@ -package stack_and_queue; -import java.util.Scanner; -import java.util.Stack; - -public class Parenthesis_Checker_Problem { - - @SuppressWarnings("resource") - public static void main(String[] args) { - - Scanner sc = new Scanner(System.in); - int t = sc.nextInt(); - while(t-- != 0) { - - String s = sc.nextLine(); - Stack stack = new Stack<>(); - - boolean isBalanced = true; - - for(int i = 0 ; i < s.length() ; i++) { - - char ch = s.charAt(i); - if(ch == '(' || ch == '{' || ch == '[') { - stack.push(ch); - continue; - } - - if(stack.isEmpty()) { - isBalanced = false; - break; - } - - if(ch == ')') { - if(stack.peek() == '(') { - stack.pop(); - }else { - isBalanced = false; - break; - } - } - - if(ch == '}') { - if(stack.peek() == '{') { - stack.pop(); - }else { - isBalanced = false; - break; - } - } - - if(ch == ']') { - if(stack.peek() == '[') { - stack.pop(); - }else { - isBalanced = false; - break; - } - } - - } - - if(!stack.isEmpty()) { - isBalanced = false; - } - - if(isBalanced) { - System.out.println("isBalanced"); - }else { - System.out.println("not balanced"); - } - - } - - } - -} diff --git a/data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_01_i.java b/data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_01_i.java deleted file mode 100644 index 92da5de..0000000 --- a/data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_01_i.java +++ /dev/null @@ -1,69 +0,0 @@ -package stack_and_queue; -import java.util.*; - -/* - * Implement Stack from Scratch Array Implementation - */ -public class Stack_Queue_Problem_01_i implements Iterable { - - @SuppressWarnings("unchecked") - private Item[] a = (Item[]) new Object[1]; // Stack Items - private int N = 0; // number of items - - public boolean isEmpty() { - return N == 0; - } - - public int size() { - return N; - } - - private void resize(int max) { - @SuppressWarnings("unchecked") - Item[] temp = (Item[]) new Object[max]; - for (int i = 0; i < N; i++) - temp[i] = a[i]; - a = temp; - } - - public void push(Item item) { - if (N == a.length) - resize(2 * a.length); - a[N++] = item; - - } - - public Item pop() { - Item item = a[--N]; - a[N] = null; - - if (N > 0 && N == a.length / 4) - resize(a.length / 2); - - return item; - } - - public Iterator iterator() { - return new ReverseArrayIterator(); - } - - private class ReverseArrayIterator implements Iterator { - public int i = N; - - public boolean hasNext() { - return i > 0; - } - - public Item next() { - return a[--i]; - } - - public void remove() { - - } - } - - public static void main(String[] args) { - - } -} diff --git a/data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_01_ii.java b/data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_01_ii.java deleted file mode 100644 index 4bbcb8b..0000000 --- a/data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_01_ii.java +++ /dev/null @@ -1,115 +0,0 @@ -package stack_and_queue; -import static java.lang.System.exit; - -//Java program to Implement a stack using singly linked list - -//Create Stack Using Linked list -class StackUsingLinkedlist { - - // A linked list node - private class Node { - - int data; // integer data - Node link; // reference variable Node type - } - - // create global top reference variable global - Node top; - - // Constructor - StackUsingLinkedlist() { - this.top = null; - } - - // Utility function to add an element x in the stack - public void push(int x) // insert at the beginning - { - // create new node tempt and allocate memory - Node temp = new Node(); - - // initialize data into data field - temp.data = x; - - // put top reference into link - temp.link = top; - - // update top reference - top = temp; - } - - // Utility function to check if the stack is empty or not - public boolean isEmpty() { - return top == null; - } - - // Utility function to return top element in a stack - public int peek() { - // check for empty stack - if (!isEmpty()) { - return top.data; - } else { - System.out.println("Stack is empty"); - return -1; - } - } - - // Utility function to pop top element from the stack - public void pop() // remove at the beginning - { - // check for stack underflow - if (top == null) { - System.out.print("\nStack Underflow"); - return; - } - - // update the top pointer to point to the next node - top = (top).link; - } - - public void display() { - // check for stack underflow - if (top == null) { - System.out.printf("\nStack Underflow"); - exit(1); - } else { - Node temp = top; - while (temp != null) { - - // print node data - System.out.printf("%d->", temp.data); - - // assign temp link to temp - temp = temp.link; - } - } - } -} - -//main class -public class Stack_Queue_Problem_01_ii { - public static void main(String[] args) { - // create Object of Implementing class - StackUsingLinkedlist obj = new StackUsingLinkedlist(); - // insert Stack value - obj.push(11); - obj.push(22); - obj.push(33); - obj.push(44); - - // print Stack elements - obj.display(); - - // print Top element of Stack - System.out.printf("\nTop element is %d\n", obj.peek()); - - // Delete top element of Stack - obj.pop(); - obj.pop(); - - // print Stack elements - obj.display(); - - // print Top element of Stack - System.out.printf("\nTop element is %d\n", obj.peek()); - } -} diff --git a/data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_02_i.java b/data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_02_i.java deleted file mode 100644 index d00f8bb..0000000 --- a/data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_02_i.java +++ /dev/null @@ -1,67 +0,0 @@ -package stack_and_queue; - -//Queue From Scratch using Array -class Queue { - int front, rear, size, capacity, array[]; - - public Queue(int capacity) { - this.capacity = capacity; - front = this.size = 0; - rear = capacity - 1; - array = new int[this.capacity]; - } - - boolean isFull(Queue queue) { - return (queue.size == queue.capacity); - } - - boolean isEmpty(Queue queue) { - return (queue.size == 0); - } - - void enqueue(int item) { - if (isFull(this)) - return; - this.rear = (this.rear + 1) % this.capacity; - this.array[this.rear] = item; - this.size = this.size + 1; - System.out.println(item + " enqueued to queue"); - } - - int dequeue() { - if (isEmpty(this)) - return Integer.MIN_VALUE; - int item = this.array[this.front]; - this.front = (this.front + 1) % this.capacity; - this.size = this.size - 1; - return item; - } - - int front() { - if (isEmpty(this)) - return Integer.MIN_VALUE; - return this.array[this.front]; - } - - int rear() { - if (isEmpty(this)) - return Integer.MIN_VALUE; - return this.array[this.rear]; - } -} - -public class Stack_Queue_Problem_02_i { - - public static void main(String[] args) { - Queue queue = new Queue(1000); - queue.enqueue(10); - queue.enqueue(20); - queue.enqueue(30); - queue.enqueue(40); - - System.out.println(queue.dequeue() + " dequeued from queue \n "); - System.out.println("Front item is " + queue.front()); - System.out.println("Rear item is " + queue.rear()); - } - -} diff --git a/data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_02_ii.java b/data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_02_ii.java deleted file mode 100644 index d4f041f..0000000 --- a/data_from_eclipse_ide/stack_and_queue/Stack_Queue_Problem_02_ii.java +++ /dev/null @@ -1,10 +0,0 @@ -package stack_and_queue; - -public class Stack_Queue_Problem_02_ii { - - public static void main(String[] args) { - - - } - -} diff --git a/graphs/Graph.java b/graphs/Graph.java index 6bf1150..2ff08b8 100644 --- a/graphs/Graph.java +++ b/graphs/Graph.java @@ -1,4 +1,4 @@ -package graphs; +package dataStructures.graphs; import java.util.*; public class Graph { diff --git a/graphs/Graph_Problem_01_i.java b/graphs/Graph_Problem_01_i.java new file mode 100644 index 0000000..93a729d --- /dev/null +++ b/graphs/Graph_Problem_01_i.java @@ -0,0 +1,50 @@ +package graphs; +import java.util.*; + +// Problem Title :-> Create a Graph, print it +public class Graph_Problem_01_i { + + // A utility function to add an edge in an undirected graph + static void addEdge(ArrayList> adj, int u, int v) { + adj.get(u).add(v); + adj.get(v).add(u); + } + + // A utility function to print representation of graph + static void printGraph(ArrayList> adj) { + + for(int i = 0; i < adj.size(); i++) { + + System.out.println("\n Adjacency list of vertex" + i); + System.out.print("head"); + + for(int j = 0; j < adj.get(i).size(); j++) + System.out.print(" -> " + adj.get(i).get(j)); + + System.out.println(); + } + } + + // Driver Code + public static void main(String[] args) { + + // Creating a graph with 5 vertices + int V = 5; + ArrayList> adj = new ArrayList>(V); + + for(int i = 0; i < V; i++) + adj.add(new ArrayList()); + + // Adding edges one by one + addEdge(adj, 0, 1); + addEdge(adj, 0, 4); + addEdge(adj, 1, 2); + addEdge(adj, 1, 3); + addEdge(adj, 1, 4); + addEdge(adj, 2, 3); + addEdge(adj, 3, 4); + + printGraph(adj); + } + +} diff --git a/data_from_eclipse_ide/graphs/Graph.java b/graphs/Graph_Problem_01_ii.java similarity index 74% rename from data_from_eclipse_ide/graphs/Graph.java rename to graphs/Graph_Problem_01_ii.java index 6bf1150..739804d 100644 --- a/data_from_eclipse_ide/graphs/Graph.java +++ b/graphs/Graph_Problem_01_ii.java @@ -1,18 +1,18 @@ package graphs; import java.util.*; -public class Graph { +public class Graph_Problem_01_ii { private LinkedList adj[]; @SuppressWarnings("unchecked") - public Graph(int v) { + public Graph_Problem_01_ii(int v) { + //array of Linked List adj = new LinkedList[v]; - for(int i=0;i(); - } } public void addEdge(int source, int destination) { @@ -21,19 +21,21 @@ public void addEdge(int source, int destination) { } public static void main(String[] args) { - Scanner sc = new Scanner(System.in); System.out.println("Enter number of vertices and edges"); + Scanner sc = new Scanner(System.in); + int v = sc.nextInt(); int e = sc.nextInt(); - Graph graph = new Graph(v); + Graph_Problem_01_ii graph_Problem_01_ii = new Graph_Problem_01_ii(v); + System.out.println("Enter " + e + " edges"); for(int i=0;i Implement BFS Algorithm of Traversal of Graph. + */ +public class Graph_Problem_02 { + // No. of vertices. + private int V; + // Adjacency List + private LinkedList[] adj; + + @SuppressWarnings({ "unchecked", "rawtypes" }) + // Constructor + Graph_Problem_02(int v){ + V = v; + adj = new LinkedList[v]; + for(int i = 0; i < v; ++i) + adj[i] = new LinkedList(); + } + + // Function to add an edge into the graph + void addEdge(int v, int w) { + adj[v].add(w); + } + + // prints BFS traversal from a given source s + void BFS(int s) { + // Mark all the verices as not visited(By Default set as false) + boolean visited[] = new boolean[V]; + + // Create a queue for BFS + LinkedList queue = new LinkedList<>(); + + visited[s] = true; + queue.add(s); + + while(queue.size() != 0) { + // Dequeue a vertex from queue and print + s = queue.poll(); + System.out.println(s + " "); + + // Get all adjacent vertices of the dequeued vertex s. + // If a adjacent has not been visited, + // then mark it visited & enqueue it. + Iterator i = adj[s].listIterator(); + while(i.hasNext()) { + int n = i.next(); + if(!visited[n]) { + visited[n] = true; + queue.add(n); + } + } + } + } + + public static void main(String[] args) { + + System.out.println("Enter number of vertices and edges"); + Scanner sc = new Scanner(System.in); + + int v = sc.nextInt(); + int e = sc.nextInt(); + + Graph_Problem_02 g = new Graph_Problem_02(v); + + for(int i = 0; i < e; i++) { + v = sc.nextInt(); + e = sc.nextInt(); + g.addEdge(v, e); + } + + sc.close(); + } +} diff --git a/graphs/Graph_Problem_03.java b/graphs/Graph_Problem_03.java new file mode 100644 index 0000000..41a7ff2 --- /dev/null +++ b/graphs/Graph_Problem_03.java @@ -0,0 +1,75 @@ +package graphs; +import java.util.*; + +/* + * Problem Title :-> Implement Graph DFS Algorithm + * This class represents a directed graph using adjacency list representation + */ +public class Graph_Problem_03{ + + @SuppressWarnings("unused") + // No. of vertices + private int V; + + // Array of lists for "Adjacency List Representation". + private LinkedList adj[]; + + // Constructor + @SuppressWarnings("unchecked") + public Graph_Problem_03(int v){ + V = v; + adj = new LinkedList[v]; + for(int i = 0; i < v; ++i) + adj[i] = new LinkedList(); + } + + // Function to add an edge into the graph + void addEdge(int v, int w) { + // Add w to v's list. + adj[v].add(w); + } + + // A function used by DFS + void DFSUtil(int v, boolean visited[]) { + + //Mark the current node as visited & print it + visited[v] = true; + System.out.println(v + " "); + + // Recur for all the vertices adjacent to this vertex + Iterator i = adj[v].listIterator(); + while(i.hasNext()) { + int n = i.next(); + if(!visited[n]) + DFSUtil(n,visited); + } + } + + // The function do DFS traversal. It uses recursive DFSUtil(). + void DFS(int v) { + boolean visited[] = new boolean[v]; + DFSUtil(v,visited); + } + + // Driver Code + public static void main(String[] args) { + + //Making Object of Graph_Problem_03 class + Graph_Problem_03 d = new Graph_Problem_03(4); + + // Adding edges one by one + d.addEdge(0, 1); + d.addEdge(0, 2); + d.addEdge(1, 2); + d.addEdge(2, 0); + d.addEdge(2, 3); + d.addEdge(3, 3); + + System.out.println("Following is Depth First Traversal " + "(starting from vertex 2)"); + + //Calling DFS method by using class object d + d.DFS(2); + + } + +} diff --git a/greedy/Greedy_Problem_01.java b/greedy/Greedy_Problem_01.java new file mode 100644 index 0000000..e645601 --- /dev/null +++ b/greedy/Greedy_Problem_01.java @@ -0,0 +1,45 @@ +package greedy; + +/* + * Problem Title :- Activity Selection Problem + */ +public class Greedy_Problem_01 { + + /* + * Prints a maximum set of activities that can be done by a single person, + * one at a time. + * n --> Total number of activities. + * s[] --> An array that contains start time of all activities. + * f[] --> An array that contains finish time of all activities. + */ + public static void printMaxActivities(int[] s, int[] f, int n) { + int i, j; + System.out.println("Following activities are selected : n"); + + // The first activity always gets selected + i = 0; + System.out.print(i + " "); + + // Consider rest of the activities + for(j = 1; j < n; j++) { + /* + * If this activity has start time greater than + * or equal to the finish time of previously selected + * activity, then select it + */ + if(s[j] >= f[i]) { + System.out.print(j + " "); + i = j; + } + } + } + // driver program to test above function + public static void main(String[] args) { + int[] s = {1, 3, 0, 5, 8, 5}; + int[] f = {2, 4, 6, 7, 9, 9}; + int n = s.length; + + printMaxActivities(s, f, n); + } + +} diff --git a/data_from_eclipse_ide/linkedList/Deletion_in_Linked_List.java b/linkedList/Deletion_in_Linked_List.java similarity index 100% rename from data_from_eclipse_ide/linkedList/Deletion_in_Linked_List.java rename to linkedList/Deletion_in_Linked_List.java diff --git a/data_from_eclipse_ide/linkedList/Insertion_in_Linked_List.java b/linkedList/Insertion_in_Linked_List.java similarity index 100% rename from data_from_eclipse_ide/linkedList/Insertion_in_Linked_List.java rename to linkedList/Insertion_in_Linked_List.java diff --git a/data_from_eclipse_ide/linkedList/MainList.java b/linkedList/MainList.java similarity index 100% rename from data_from_eclipse_ide/linkedList/MainList.java rename to linkedList/MainList.java diff --git a/data_from_eclipse_ide/linkedList/MyLL.java b/linkedList/MyLL.java similarity index 100% rename from data_from_eclipse_ide/linkedList/MyLL.java rename to linkedList/MyLL.java diff --git a/data_from_eclipse_ide/linkedList/Problem_1_1.java b/linkedList/Problem_1_1.java similarity index 100% rename from data_from_eclipse_ide/linkedList/Problem_1_1.java rename to linkedList/Problem_1_1.java diff --git a/data_from_eclipse_ide/linkedList/Problem_1_2.java b/linkedList/Problem_1_2.java similarity index 100% rename from data_from_eclipse_ide/linkedList/Problem_1_2.java rename to linkedList/Problem_1_2.java diff --git a/data_from_eclipse_ide/linkedList/Queue.java b/linkedList/Queue.java similarity index 100% rename from data_from_eclipse_ide/linkedList/Queue.java rename to linkedList/Queue.java diff --git a/list/MainList.java b/list/MainList.java index 62e39df..e3332f6 100644 --- a/list/MainList.java +++ b/list/MainList.java @@ -1,18 +1,18 @@ package list; + public class MainList { public static void main(String[] args) { - - MyLL myll = new MyLL(); - - - myll.add(0); - myll.add(1); - myll.add(2); - myll.add(3); - myll.add(4); - - myll.print(); + + MyLL myLL = new MyLL<>(); + + for (int i = 0; i < 10; i++) { + // add method use to add a element in the last node of the linked list + myLL.add(i + "added"); + + } +// print method use to print the linked list + myLL.print(); } - + } diff --git a/list/MyLL.java b/list/MyLL.java index 478b1da..b4e4cc9 100644 --- a/list/MyLL.java +++ b/list/MyLL.java @@ -1,53 +1,84 @@ package list; -public class MyLL { - - static class Node{ - int data; - Node next; - - public Node(int data) { - this.data = data; - next = null; - } - } - - Node head; - Node position; - - void add(int data) { - Node toAdd = new Node(data); - - if(isEmpty()) { +public class MyLL { + + + //E is the Class defining the type of the inputs accepted + Node head; + + public void add(E data) { + Node toAdd = new Node<>(data); + + if (isEmpty()) { head = toAdd; return; } - - Node temp = head; - while(temp.next != null) { + +//initialising temp as head to traverse the Linked list without breaking the chain + Node temp = head; + // control from loop exits as soon as next element becomes null + while (temp.next != null) { + temp = temp.next; } + // adding the new node after reaching to the end of linked list temp.next = toAdd; } - + void print() { - Node temp = head; - while(temp != null) { - System.out.println(temp.data + " "); + Node temp = head; + while (temp != null) { + System.out.print(temp.data + " "); temp = temp.next; } - } - - boolean isEmpty() { + + public boolean isEmpty() { return head == null; } - - void remove(int data) { - head = null; + + public E removeLast() throws Exception { + Node temp = head; + + if (temp == null) { + throw new Exception("Cannot remove last element from empty linked list"); + } + + if (temp.next == null) { + Node toRemove = head; + head = null; + return toRemove.data; + } + + while (temp.next.next != null) { + temp = temp.next; + } + Node toRemove = temp.next; + temp.next = null; // changing the pointer of temp.next from toRemove to null,and garbage collection is done automatically + return toRemove.data; + } + + public E getLast() throws Exception { + Node temp = head; + + if (temp == null) { + throw new Exception("Cannot peek last element from empty linked list"); + } + while (temp.next != null) { + temp = temp.next; + } + return temp.data; } - - boolean isValue() { - return head == position; + + public static class Node { + public E data; + public Node next; + + //constructor + public Node(E data) { + + this.data = data; + next = null; + } } -} +} \ No newline at end of file diff --git a/oopsEncapsulation/EncapIntro.java b/oopsEncapsulation/EncapIntro.java index e069086..c243ead 100644 --- a/oopsEncapsulation/EncapIntro.java +++ b/oopsEncapsulation/EncapIntro.java @@ -3,15 +3,12 @@ public class EncapIntro { public static void main(String[] args) { - S obj = new S(); obj.setName("Milan"); obj.setAge(16); + System.out.println(obj.getName()); System.out.println(obj.getAge()); - - } - } diff --git a/oopsEncapsulation/S.java b/oopsEncapsulation/S.java index bb69bb6..ad56e91 100644 --- a/oopsEncapsulation/S.java +++ b/oopsEncapsulation/S.java @@ -19,13 +19,11 @@ public void setName(String name) { } //getter methods - public int getAge() { - return age; - } - - public String getName() { - return name; - } + public int getAge() { + return age; + } - + public String getName() { + return name; + } } diff --git a/oopsabstraction/Audi.java b/oopsabstraction/Audi.java index 2475df8..fd35932 100644 --- a/oopsabstraction/Audi.java +++ b/oopsabstraction/Audi.java @@ -1,15 +1,14 @@ package oopsabstraction; -//Audi Class +//Audi Class public class Audi extends Car{ public void accelerate() { System.out.println("Audi is accelerating"); } + @Override public void apply_break() { - System.out.println("Audi is breaking"); - + System.out.println("Audi is breaking"); } - } diff --git a/oopsabstraction/Car.java b/oopsabstraction/Car.java index dceb3b5..9a5d83e 100644 --- a/oopsabstraction/Car.java +++ b/oopsabstraction/Car.java @@ -1,8 +1,6 @@ package oopsabstraction; public abstract class Car { - public abstract void accelerate(); public abstract void apply_break(); - } diff --git a/queues/ArrayDequeDemo.java b/queues/ArrayDequeDemo.java index 675d25d..4443dd3 100644 --- a/queues/ArrayDequeDemo.java +++ b/queues/ArrayDequeDemo.java @@ -1,6 +1,5 @@ package queues; import java.util.*; -//program inside queue package public class ArrayDequeDemo { public static void main(String[] args) { diff --git a/src b/src deleted file mode 160000 index 26d2d57..0000000 --- a/src +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 26d2d577f3d9fe69db155171c374a6391232703f diff --git a/ssp/SSP_Problem_01.java b/ssp/SSP_Problem_01.java new file mode 100644 index 0000000..552380b --- /dev/null +++ b/ssp/SSP_Problem_01.java @@ -0,0 +1,66 @@ +package ssp; + +// Problem Title :- Find first and last positions of an element in a sorted array +// An optimized approach using binary search in O(n) Time Complexity. +public class SSP_Problem_01 { + + /* + * if x is present in a[] then returns the index of + * FIRST occurrence of x in a[0...n-1], + * otherwise returns -1. + */ + public static int first(int[] a, int low, int high, int x, int n) { + + if(high >= low) { + + int mid = low + (high - low)/2; + + if( (mid == 0 || x > a[mid - 1]) && a[mid] == x) + return mid; + + else if(x > a[mid]) + return first(a, (mid + 1), high, x, n); + + else + return first(a, low, (mid - 1 ), x, n); + } + return -1; + } + + /* + * if x is present in a[] then returns the index of + * LAST occurrence of x in a[0..n-1], + * otherwise returns -1 + */ + public static int last(int a[], int low, int high, int x, int n) { + + if(high >= low) { + + int mid = low + (high - low)/2; + + if((mid == n-1 || x < a[mid + 1]) && a[mid] == x) + return mid; + + else if(x < a[mid]) + return last(a, low, (mid - 1), x, n); + + else + return last(a, (mid + 1), high, x, n); + } + + return -1; + } + + // Driver Code + public static void main(String[] args) { + + int[] a = {1, 2, 2, 2, 2, 3, 4, 7, 8, 8}; + + int n = a.length; + int x = 8; + + System.out.println("First Occurence = " + first(a, 0, n - 1, x, n)); + System.out.println("last Occurence = " + last(a, 0, n-1, x, n)); + } + +} diff --git a/ssp/SSP_Problem_02.java b/ssp/SSP_Problem_02.java new file mode 100644 index 0000000..3781f9a --- /dev/null +++ b/ssp/SSP_Problem_02.java @@ -0,0 +1,30 @@ +package ssp; + +// Problem Title :-> Find a Fixed Point (Value equal to index) in a given array +public class SSP_Problem_02 { + static int binarySearch(int[] a, int low, int high) { + + if(high >= low) { + + /* low + (high - low)/2;*/ + int mid = (low + high)/2; + + if(mid == a[mid]) + return mid; + + if(mid > a[mid]) + return binarySearch(a, (mid + 1), high); + + else + return binarySearch(a, low, (mid - 1)); + } + /* Return -1 if there is no Fixed Point */ + return -1; + } + // Driver Code + public static void main(String[] args) { + int[] a= {-10, -1, 0, 3, 10, 11, 30, 50, 100}; + int n = a.length; + System.out.println("Fixed Point is " + binarySearch(a, 0, n-1)); + } +} diff --git a/ssp/SSP_Problem_03.java b/ssp/SSP_Problem_03.java new file mode 100644 index 0000000..d940050 --- /dev/null +++ b/ssp/SSP_Problem_03.java @@ -0,0 +1,50 @@ +package ssp; +// Problem Title :-> Search in a rotated sorted array +// Approach :-> Using single pass of Binary Search. +// Complexity Analysis :-> Time Complexity is O(log n) & Space Complexity O(1) as no extra space is required. +public class SSP_Problem_03 { + /* + * Returns index of key in a[1..h] if key is present, + * otherwise returns -1. + */ + static int search(int[] a, int l, int h, int key) { + if(l > h) + return -1; + + int mid = (l + h) / 2; + if(a[mid] == key) + return mid; + + /* If a[1...mid] first sub-array is sorted */ + if(a[l] <= a[mid]) { + if(key >= a[l] && key <= a[mid]) + return search(a, l, mid - 1, key); + return search(a, mid + 1, h, key); + } + + /* + * If a[1..mid] first sub-array is not sorted, + * then a[mid...h] must be sorted sub-array + */ + if(key >= a[mid] && key <= a[h]) + return search(a, mid + 1, h, key); + + /* + * if key not lies in first half sub-array, + * Divide other half into two sub-arrays, + * such that we can quickly check if key lies in other half + */ + return search(a, l, mid - 1, key); + } + // Driver Code + public static void main(String[] args) { + int[] a = {4, 5, 6, 7, 8, 9, 1, 2, 3}; + int n = a.length; + int key = 6; + int i = search(a, 0, n - 1, key); + if(i != -1) + System.out.println("Index: " + i); + else + System.out.println("Key not found"); + } +} diff --git a/t/trees/BST_Deletion.java b/t/trees/BST_Deletion.java deleted file mode 100644 index 6d6d3ce..0000000 --- a/t/trees/BST_Deletion.java +++ /dev/null @@ -1,158 +0,0 @@ -package trees; - -//Java program to demonstrate delete operation in binary search tree -class BST_Deletion{ - - // Class to make a Node - class Node { - int key; - Node left, right; - - public Node(int item) { - key = item; - left = right = null; - } - } - - // Root of BST - Node root; - - // Constructor - BST_Deletion() { - root = null; - } - - // This method mainly calls deleteRec() - void deleteKey(int key) { - root = deleteRec(root, key); - } - - /* A recursive function to insert a new key in BST */ - Node deleteRec(Node root, int key) { - /* Base Case: If the tree is empty */ - if (root == null) return root; - - /* Otherwise, recur down the tree */ - if (key < root.key) - root.left = deleteRec(root.left, key); - else if (key > root.key) - root.right = deleteRec(root.right, key); - - // if key is same as root's key, then This is the node - // to be deleted - else - { - // node with only one child or no child - if (root.left == null) - return root.right; - else if (root.right == null) - return root.left; - - // node with two children: Get the inorder successor (smallest - // in the right subtree) - root.key = minValue(root.right); - - // Delete the inorder successor - root.right = deleteRec(root.right, root.key); - } - - return root; - } - - int minValue(Node root) - { - int minv = root.key; - while (root.left != null) - { - minv = root.left.key; - root = root.left; - } - return minv; - } - - // This method mainly calls insertRec() - void insert(int key) - { - root = insertRec(root, key); - } - - /* A recursive function to insert a new key in BST */ - Node insertRec(Node root, int key) - { - - /* If the tree is empty, return a new node */ - if (root == null) - { - root = new Node(key); - return root; - } - - /* Otherwise, recur down the tree */ - if (key < root.key) - root.left = insertRec(root.left, key); - else if (key > root.key) - root.right = insertRec(root.right, key); - - /* return the (unchanged) node pointer */ - return root; - } - - // This method mainly calls InorderRec() - void inorder() - { - inorderRec(root); - } - - // A utility function to do inorder traversal of BST - void inorderRec(Node root) - { - if (root != null) - { - inorderRec(root.left); - System.out.print(root.key + " "); - inorderRec(root.right); - } - } - - // Driver Program to test above functions - public static void main(String[] args) - { - BST_Deletion tree = new BST_Deletion(); - - /* Let us create following BST - 50 - / \ - 30 70 - / \ / \ - 20 40 60 80 */ - - tree.insert(50); - tree.insert(30); - tree.insert(20); - tree.insert(40); - tree.insert(70); - tree.insert(60); - tree.insert(80); - - System.out.println("Inorder traversal of the given tree"); - tree.inorder(); - - System.out.println("\nDelete 20"); - tree.deleteKey(20); - - System.out.println("Inorder traversal of the modified tree"); - tree.inorder(); - - System.out.println("\nDelete 30"); - tree.deleteKey(30); - - System.out.println("Inorder traversal of the modified tree"); - tree.inorder(); - - System.out.println("\nDelete 50"); - tree.deleteKey(50); - - System.out.println("Inorder traversal of the modified tree"); - tree.inorder(); - } -} \ No newline at end of file diff --git a/t/trees/BT_Traversal.java b/t/trees/BT_Traversal.java deleted file mode 100644 index 3ed9851..0000000 --- a/t/trees/BT_Traversal.java +++ /dev/null @@ -1,82 +0,0 @@ -package trees; - -public class BT_Traversal { - - static class Node{ - int key; - Node left,right; - public Node(int item) { - key = item; - left = right = null; - } - } - - static Node root; - BT_Traversal(){ - root = null; - } - - static void printPostorder(Node node) { - if(node == null) { - return; - } - printPostorder(node.left); - System.out.print(node.key + " "); - printPostorder(node.right); - } - - static void printInorder(Node node) { - if(node == null) { - return; - } - printInorder(node.left); - System.out.print(node.key + " "); - printInorder(node.right); - } - - static void printPreorder(Node node) { - if(node == null) { - return; - } - printPreorder(node.left); - System.out.print(node.key + " "); - printPreorder(node.right); - } - - static void printPostorder() { - printPostorder(root); - } - - static void printInorder() { - printInorder(root); - } - - static void printPreorder() { - printPreorder(root); - } - - - public static void main(String[] args) { - @SuppressWarnings("unused") - BT_Traversal tree = new BT_Traversal(); - - root = new Node(1); - root.left = new Node(11); - root.right = new Node(9); - root.left.left = new Node(7); - root.right.left = new Node(15); - root.right.right = new Node(8); - - System.out.println( "Inorder traversal of given tree is:"); - BT_Traversal.printInorder(); - System.out.println(); - - System.out.println( "Postorder traversal of given tree is:"); - BT_Traversal.printPostorder(); - System.out.println(); - - System.out.println( "Preorder traversal of given tree is:"); - BT_Traversal.printPreorder(); - } - -} diff --git a/t/trees/BinarySearchTree.java b/t/trees/BinarySearchTree.java deleted file mode 100644 index 5da44fb..0000000 --- a/t/trees/BinarySearchTree.java +++ /dev/null @@ -1,88 +0,0 @@ -package trees; - -class BinarySearchTree { - - /* Class containing left and right child of current node and key value*/ - class Node { - int key; - Node left, right; - - public Node(int item) { - key = item; - left = right = null; - } - } - - // Root of BST - Node root; - - // Constructor - BinarySearchTree() { - root = null; - } - - // This method mainly calls insertRec() - void insert(int key) { - root = insertRec(root, key); - } - - /* A recursive function to insert a new key in BST */ - Node insertRec(Node root, int key) { - - /* If the tree is empty, return a new node */ - if (root == null) { - root = new Node(key); - return root; - } - - /* Otherwise, recur down the tree */ - if (key < root.key) - root.left = insertRec(root.left, key); - else if (key > root.key) - root.right = insertRec(root.right, key); - - /* return the (unchanged) node pointer */ - return root; - } - - // This method mainly calls InorderRec() - void inorder() { - inorderRec(root); - } - - // A utility function to do inorder traversal of BST - void inorderRec(Node root) { - if (root != null) { - inorderRec(root.left); - System.out.println(root.key); - inorderRec(root.right); - } - } - - // Driver Program to test above functions - public static void main(String[] args) { - BinarySearchTree tree = new BinarySearchTree(); - - /* - * Let us create following BST - * |50| - * / \ - * / \ - * 30 70 - * / \ / \ - * 20 40 60 80 - * - */ - - tree.insert(50); - tree.insert(30); - tree.insert(20); - tree.insert(40); - tree.insert(70); - tree.insert(60); - tree.insert(80); - - // print in-order traversal of the BST - tree.inorder(); - } -} diff --git a/t/trees/BinaryTreeNode.java b/t/trees/BinaryTreeNode.java deleted file mode 100644 index fe8e3f1..0000000 --- a/t/trees/BinaryTreeNode.java +++ /dev/null @@ -1,13 +0,0 @@ -package trees; - -public class BinaryTreeNode { - - public T data; - public BinaryTreeNode left; - public BinaryTreeNode right; - - BinaryTreeNode(T data){ - this.data = data; - } - -} diff --git a/t/trees/BinaryTreeUse.java b/t/trees/BinaryTreeUse.java deleted file mode 100644 index f28e6a3..0000000 --- a/t/trees/BinaryTreeUse.java +++ /dev/null @@ -1,51 +0,0 @@ -package trees; -import java.util.*; - -public class BinaryTreeUse { - - public static BinaryTreeNode takeInput(Scanner s){ - int rootdata; - System.out.println("Enter root data: "); - rootdata = s.nextInt(); - - if(rootdata == -1) return null; - - - BinaryTreeNode root = new BinaryTreeNode<>(rootdata); - root.left = takeInput(s); - root.right = takeInput(s); - return root; - - } - - public static void printTree(BinaryTreeNode root) { - if(root == null) return; - String s = root.data+" "; - - if(root.left!=null) - s+="L. "+root.left.data+" ,"; - - if(root.right!=null) - s+="R. "+root.right.data; - - System.out.println(s); - printTree(root.left); - printTree(root.right); - } - - public static void main(String[] args) { - -// BinaryTreeNode root= new BinaryTreeNode(1); -// BinaryTreeNode node1=new BinaryTreeNode(2); -// root.left=node1; -// BinaryTreeNode node2=new BinaryTreeNode(3); -// root.left=node2; - - Scanner s = new Scanner(System.in); - BinaryTreeNode root = takeInput(s); - printTree(root); - s.close(); - - } - -} diff --git a/t/trees/BinaryTree_LOT.java b/t/trees/BinaryTree_LOT.java deleted file mode 100644 index 43777cd..0000000 --- a/t/trees/BinaryTree_LOT.java +++ /dev/null @@ -1,99 +0,0 @@ -package trees; - -//Node of tree -class Node{ - int data; - Node left,right; - - //making public constructor of Node class - public Node(int item) { - data = item; - left = right = null; - } -} - -//main class to find linear order traversal -public class BinaryTree_LOT { - - //root node - Node root; - - //making an constructor - public BinaryTree_LOT() { - root = null; - } - - //function to print level order - void printLevelOrder() { - - //variable to store height which will be received from height function - int h = height(root), i; - - //loop for calculating given level - for(i = 1 ; i<= h ; i++) - printGivenLevel(root, i); - } - - //function to find the height of tree - int height(Node root) { - - //if their is no value at root node or node is empty then simply return 0; - if(root == null) - return 0; - - else { - //declare l-height for height of left & r-height variables for height of right, by using recursive call - int lheight = height(root.left); - int rheight = height(root.right); - - //if(l-height is greater then r-height then return(l-height + 1); - if(lheight > rheight) - return(lheight + 1); - - //else return r-height + 1; - else return(rheight + 1); - } - } - - //function to print the given level of tree - void printGivenLevel(Node root, int level) { - - //if their is no value at root node or node is empty then simply return; - if(root == null) - return; - - //if level is equal to 1 then print the data of root node - if(level == 1) - System.out.print(root.data + " "); - - //else if level is greater then 1, then call the function "RECUSIVELY" for left node & -1th level - else if(level > 1) { - //recursive call for left node at level-1 level - printGivenLevel(root.left, level-1); - - //recursive call for right node at level-1 level - printGivenLevel(root.right, level-1); - } - } - - //main or driver method - public static void main(String[] args) { - - //Making an object of BinaryTree_LOT class - BinaryTree_LOT tree = new BinaryTree_LOT(); - - //setting values of the different nodes of tree with use of tree object of tree classs - tree.root = new Node(1); - tree.root.left = new Node(2); - tree.root.right = new Node(3); - tree.root.left.left = new Node(4); - tree.root.left.right = new Node(5); - - System.out.println("Level order traversal of binary tree is "); - - //calling printLevelOrder() function - tree.printLevelOrder(); - - } - -} diff --git a/t/trees/Construct_Tree_from_Preorder_and_Inorder.java b/t/trees/Construct_Tree_from_Preorder_and_Inorder.java deleted file mode 100644 index 0531425..0000000 --- a/t/trees/Construct_Tree_from_Preorder_and_Inorder.java +++ /dev/null @@ -1,69 +0,0 @@ -package trees; - - -/* - * Code: Construct Tree from Preorder and Inorder - * - * - *Given Pre-order and In-order traversal of a binary tree, - *create the binary tree associated with the traversals. - *You just need to construct the tree and return the root. - * - *Note: Assume binary tree contains only unique elements. - * - * Input format : - * - * Line 1 : n (Total number of nodes in binary tree) - * Line 2 : Pre order traversal - * Line 3 : Inorder Traversal - * - * Output Format : - * - * Elements are printed level wise, each level in new line (separated by space). - * - * Sample Input : - * 12 - * 1 2 3 4 15 5 6 7 8 10 9 12 - * 4 15 3 2 5 1 6 10 8 7 9 12 - * - * Sample Output : - * 1 - * 2 6 - * 3 5 7 - * 4 8 9 - * 15 10 12 - */ -public class Construct_Tree_from_Preorder_and_Inorder { - - public static BinaryTreeNode getTreeFromPreorderAndInorder(int[] pre , int[] in){ - return helper (0, 0, in.length - 1, pre, in); - } - - private static BinaryTreeNode helper(int preStart , int inStart , int inEnd , int[] preorder , int[] inorder){ - - //Base Case - if(preStart > preorder.length || inStart > inEnd) - return null; - - - //get the root node with current pre-order element - BinaryTreeNode root = new BinaryTreeNode(preorder[preStart]); - - //get inIndex; finding preorder's element's index in in-order - int inIndex = 0; - - for(int i = inStart ; i<= inEnd ; i++) { - if(inorder[i] == root.data) - inIndex = i; - } - - //(next, left of inIndex is the end for left subtree) - root.left = helper(preStart + 1, inStart, inIndex - 1, preorder, inorder); - - //(prestart + length of left subtree + 1) - root.right = helper(preStart + inIndex - inStart + 1, inIndex + 1, inEnd, preorder, inorder); - - return root; - } - -} diff --git a/t/trees/Count_Nodes.java b/t/trees/Count_Nodes.java deleted file mode 100644 index b288091..0000000 --- a/t/trees/Count_Nodes.java +++ /dev/null @@ -1,63 +0,0 @@ -package trees; - -import java.util.*; - -//A Binary Tree Node -class Node { - - int data; - Node left, right; - - // Constructor of Node Class - Node(int data) { - this.data = data; - left = right = null; - } -} - -public class Count_Nodes { - - Node root; - - // Traverse given tree in In-order fashion & prints all nodes that have both - // children as non-empty - int getFullCount() { - if (root == null) - return 0; - - Queue queue = new LinkedList<>(); - - queue.add(root); - int count = 0; - - while (!queue.isEmpty()) { - Node temp = queue.poll(); - if (temp.left != null && temp.right != null) - count++; - - if (temp.left != null) - queue.add(temp.left); - - if (temp.right != null) - queue.add(temp.right); - - } - - return count; - } - - public static void main(String[] args) { - Count_Nodes tree_level = new Count_Nodes(); - tree_level.root = new Node(2); - tree_level.root.left = new Node(7); - tree_level.root.right = new Node(5); - tree_level.root.left.right = new Node(6); - tree_level.root.left.right.left = new Node(1); - tree_level.root.left.right.right = new Node(11); - tree_level.root.right.right = new Node(9); - tree_level.root.right.right.left = new Node(4); - - System.out.println(tree_level.getFullCount()); - } - -} diff --git a/t/trees/Count_leaf_nodes.java b/t/trees/Count_leaf_nodes.java deleted file mode 100644 index d618bf7..0000000 --- a/t/trees/Count_leaf_nodes.java +++ /dev/null @@ -1,44 +0,0 @@ -package trees; -import java.util.*; - - /*Code : Count leaf nodes - * Send Feedback - * Given a generic tree, count and return the number of leaf nodes present in the given tree. - * Input format : - * Elements in level order form separated by space (as per done in class). Order is - - * Root_data, n (No_Of_Child_Of_Root), n children, and so on for every element - * Output Format : - * Count of leaf nodes - * Sample Input 1 : - * 10 3 20 30 40 2 40 50 0 0 0 0 - * Sample Output 1 : - * 4 */ - -public class Count_leaf_nodes { - - class BinaryTreeNode { - T data; - ArrayList> children; - - BinaryTreeNode(T data){ - this.data = data; - children = new ArrayList>(); - } - - public int countLeafNodes(BinaryTreeNode root){ - - int leaf = 0; - - if (root == null ) - return 0; - - if (root.children.size() == 0) - return 1; - - for (BinaryTreeNode child : root.children) - leaf += countLeafNodes(child); - - return leaf ; - } - } -} diff --git a/t/trees/Insertion_In_BinaryTree.java b/t/trees/Insertion_In_BinaryTree.java deleted file mode 100644 index efdb19a..0000000 --- a/t/trees/Insertion_In_BinaryTree.java +++ /dev/null @@ -1,80 +0,0 @@ -package trees; -import java.util.*; - -//Java program to insert element in binary tree -public class Insertion_In_BinaryTree { - - /* A binary tree node has key, pointer to - left child and a pointer to right child */ - static class Node { - int key; - Node left, right; - - // constructor - Node(int key){ - this.key = key; - left = right = null; - } - } - static Node root; - static Node temp = root; - - //In-order traversal of a binary tree - static void inorder(Node temp) - { - if (temp == null) - return; - - inorder(temp.left); - - System.out.print(temp.key+" "); - inorder(temp.right); - } - - //function to insert element in binary tree - static void insert(Node temp, int key) - { - Queue q = new LinkedList(); - q.add(temp); - - // Do level order traversal until we find - // an empty place. - while (!q.isEmpty()) { - temp = q.peek(); - q.remove(); - - if (temp.left == null) { - temp.left = new Node(key); - break; - } else - q.add(temp.left); - - if (temp.right == null) { - temp.right = new Node(key); - break; - } - else - q.add(temp.right); - } - } - - // Driver code - public static void main(String args[]) - { - root = new Node(10); - root.left = new Node(11); - root.right = new Node(9); - root.left.left = new Node(7); - root.right.left = new Node(15); - root.right.right = new Node(8); - - System.out.print( "Inorder traversal before insertion:"); - inorder(root); - - int key = 12; - insert(root, key); - - System.out.print("\nInorder traversal after insertion:"); - inorder(root); - } -} diff --git a/t/trees/Problem_01.java b/t/trees/Problem_01.java deleted file mode 100644 index c668090..0000000 --- a/t/trees/Problem_01.java +++ /dev/null @@ -1,88 +0,0 @@ -package trees; -import java.util.*; - -/* - * Check if generic tree contain element x - * - * Send Feedback - * Given a generic tree and an integer x, check if x is present in the given tree or not. - * Return : true :- if x is present, - * Return : false :- otherwise. - * - * Input format : - * Line 1 : Integer x - * Line 2 : Elements in level order form separated by space (as per done in class). - * - * Order is - - * Root_data , n (No_Of_Child_Of_Root) , n children , and so on for every element. - * - * Output format : true or false - * Sample Input 1 : - * 40 - * 10 3 20 30 40 2 40 50 0 0 0 0 - * - * Sample Output 1 : - * true - * - * Sample Input 2 : - * 4 - * 10 3 20 30 40 2 40 50 0 0 0 0 - * - * Sample Output 2: - * false - */ - - -public class Problem_01 { - // TreeNode class - class TreeNode { - T data; - ArrayList> children; - - TreeNode(T data){ - this.data = data; - children = new ArrayList>(); - } - } - - public static boolean checkIfContainsX(TreeNode root, int x){ - - // Write your code here - if(root==null) - return false; - - // Write your code here - Queue> queue = new LinkedList<>(); - - //added 1st level here - queue.add(root); - queue.add(null); - @SuppressWarnings("unused") - int ans=0; - - // if(x frontNode = queue.remove(); - if(frontNode == null) - { - if(queue.isEmpty()) - break; - - queue.add(null); - } - - else{ - - if(frontNode.data==x) - return true; - System.out.print(frontNode.data+" "); - - for(int i=0;i { - T data; - ArrayList> children; - - BinaryTreeNode(T data){ - this.data = data; - children = new ArrayList>(); - } - - public int countLeafNodes(BinaryTreeNode root){ - - int leaf = 0; - - if (root == null ) - return 0; - - if (root.children.size() == 0) - return 1; - - for (BinaryTreeNode child : root.children) - leaf += countLeafNodes(child); - - return leaf ; - } - } + static int calcNodes(int N, int I){ + int result; + result = I * (N - 1) + 1; + return result; + } + public static void main(String[] args) { + int N = 5, I = 2; + System.out.println("Leaf nodes = " + calcNodes(N, I)); + } } diff --git a/trees/FindFullNodesInABinaryTree.java b/trees/FindFullNodesInABinaryTree.java index e25fb09..cde6448 100644 --- a/trees/FindFullNodesInABinaryTree.java +++ b/trees/FindFullNodesInABinaryTree.java @@ -1,63 +1,55 @@ package trees; -import java.util.*; - //A Binary Tree Node -class Node { - +class Node{ + int data; - Node left, right; - - // Constructor of Node Class + Node left , right; + + //Constructor of Node Class Node(int data) { this.data = data; - left = right = null; + left = right = null ; } } public class FindFullNodesInABinaryTree { - - Node root; - - // Traverse given tree in In-order fashion & prints all nodes that have both - // children as non-empty - int getFullCount() { - if (root == null) - return 0; - - Queue queue = new LinkedList<>(); - - queue.add(root); - int count = 0; - - while (!queue.isEmpty()) { - Node temp = queue.poll(); - if (temp.left != null && temp.right != null) - count++; - - if (temp.left != null) - queue.add(temp.left); - - if (temp.right != null) - queue.add(temp.right); - + + //Traverse given tree in In-order fashion & prints all nodes that have both children as non-empty + public static void findFullNode(Node root) { + if (root != null) { + findFullNode(root.left); + + if(root.left != null && root.right != null) + System.out.println(root.data +" "); + + findFullNode(root.right); } - - return count; } - + + //Driver method public static void main(String[] args) { - FindFullNodesInABinaryTree tree_level = new FindFullNodesInABinaryTree(); - tree_level.root = new Node(2); - tree_level.root.left = new Node(7); - tree_level.root.right = new Node(5); - tree_level.root.left.right = new Node(6); - tree_level.root.left.right.left = new Node(1); - tree_level.root.left.right.right = new Node(11); - tree_level.root.right.right = new Node(9); - tree_level.root.right.right.left = new Node(4); + + //Calling Node class by making an object of it (means by making a root node) + Node root = new Node(1); + + root.left = new Node(2); + root.right = new Node(3); + root.left.left = new Node(4); + root.left.right = new Node(5); + root.right.left = new Node(6); + root.right.right = new Node(7); + root.left.left.left= new Node(8); + root.right.left.left = new Node(9); + root.left.left.right = new Node(10); + root.left.right.left = new Node(11); + root.right.left.right = new Node(12); + root.left.right.right = new Node(13); + root.right.right.right = new Node(14); + + //calling the find full nodes by passing values of or as root or root valuess in it + findFullNode(root); - System.out.println(tree_level.getFullCount()); } } diff --git a/trees/Problem_01.java b/trees/Problem_01.java index c668090..c7bf03c 100644 --- a/trees/Problem_01.java +++ b/trees/Problem_01.java @@ -1,6 +1,3 @@ -package trees; -import java.util.*; - /* * Check if generic tree contain element x * @@ -32,6 +29,8 @@ * false */ +package trees; +import java.util.*; public class Problem_01 { // TreeNode class @@ -72,10 +71,8 @@ public static boolean checkIfContainsX(TreeNode root, int x){ queue.add(null); } - else{ - - if(frontNode.data==x) + if(frontNode.data==x) return true; System.out.print(frontNode.data+" "); From 8831f7ca12b9bd9936e34ce36817873d349427c6 Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Sat, 23 Jan 2021 12:03:18 +0530 Subject: [PATCH 23/56] #Modification 21 --- binaryTree/BT_Problem_01.java | 5 +-- binaryTree/BT_Problem_10.java | 15 ++++++++ binaryTree/BT_Problem_11.java | 66 +++++++++++++++++++++++++++++++++++ binaryTree/BT_Problem_12.java | 58 ++++++++++++++++++++++++++++-- bitManipulation/BM_01.java | 24 +++++++++++++ bitManipulation/BM_02.java | 10 ++++++ bitManipulation/BM_03.java | 10 ++++++ bitManipulation/BM_04.java | 10 ++++++ bitManipulation/BM_05.java | 10 ++++++ bitManipulation/BM_06.java | 10 ++++++ bitManipulation/BM_07.java | 10 ++++++ bitManipulation/BM_08.java | 10 ++++++ bitManipulation/BM_09.java | 10 ++++++ bitManipulation/BM_10.java | 10 ++++++ 14 files changed, 254 insertions(+), 4 deletions(-) create mode 100644 bitManipulation/BM_01.java create mode 100644 bitManipulation/BM_02.java create mode 100644 bitManipulation/BM_03.java create mode 100644 bitManipulation/BM_04.java create mode 100644 bitManipulation/BM_05.java create mode 100644 bitManipulation/BM_06.java create mode 100644 bitManipulation/BM_07.java create mode 100644 bitManipulation/BM_08.java create mode 100644 bitManipulation/BM_09.java create mode 100644 bitManipulation/BM_10.java diff --git a/binaryTree/BT_Problem_01.java b/binaryTree/BT_Problem_01.java index 09d155b..53031b4 100644 --- a/binaryTree/BT_Problem_01.java +++ b/binaryTree/BT_Problem_01.java @@ -4,12 +4,13 @@ // Find Level order traversal of binary tree class Node{ int data; + int hd; Node left, right; public Node(int item) { data = item; - left = null; - right = null; + hd = Integer.MAX_VALUE; + left = right = null; } } public class BT_Problem_01 { diff --git a/binaryTree/BT_Problem_10.java b/binaryTree/BT_Problem_10.java index a0eced6..5b9101a 100644 --- a/binaryTree/BT_Problem_10.java +++ b/binaryTree/BT_Problem_10.java @@ -7,6 +7,21 @@ */ public class BT_Problem_10 { + Node root; + static int max_level = 0; + + void leftViewUtil(Node node, int level) { + + if(node == null) + return; + + if(max_level < level) { + System.out.print(" " + node.data); + max_level = level; + } + + + } public static void main(String[] args) { diff --git a/binaryTree/BT_Problem_11.java b/binaryTree/BT_Problem_11.java index 0c6ae7c..73993e3 100644 --- a/binaryTree/BT_Problem_11.java +++ b/binaryTree/BT_Problem_11.java @@ -1,9 +1,75 @@ package binaryTree; +import java.util.*; +import java.util.Map.Entry; +/* + * Problem Title :- Write a Java program to find Top View of Tree. + */ +// Class of binary Tree public class BT_Problem_11 { + Node root; + + public BT_Problem_11() { + root = null; + } + + // function should print the topView of the binary tree + private void TopView(Node root) { + class QueueObj{ + Node node; + int hd; + QueueObj(Node node, int hd){ + this.node = node; + this.hd = hd; + } + } + + Queue q = new LinkedList<>(); + Map topViewMap = new TreeMap(); + + if(root == null) + return; + else + q.add(new QueueObj(root, 0)); + + System.out.println("The top view of the tree is : "); + + /* count function returns 1 if the container + * contains an element whose key is equivalent to hd, + * or returns zero otherwise. */ + while(!q.isEmpty()) { + QueueObj tempNode = q.poll(); + + if(!topViewMap.containsKey(tempNode.hd)) + topViewMap.put(tempNode.hd, tempNode.node); + + if(tempNode.node.left != null) + q.add(new QueueObj(tempNode.node.left, tempNode.hd + 1)); + + if(tempNode.node.left != null) + q.add(new QueueObj(tempNode.node.left, tempNode.hd + 1)); + } + + for(Entry entry : topViewMap.entrySet()) + System.out.print(entry.getValue().data); + } + + // Driver Program to test & run above functions public static void main(String[] args) { + BT_Problem_11 tree = new BT_Problem_11(); + + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.right = new Node(4); + tree.root.left.right.right = new Node(4); + tree.root.left.right.right.right = new Node(4); + + System.out.println("Following are nodes in top view of Binary Tree"); + tree.TopView(tree.root); + } } diff --git a/binaryTree/BT_Problem_12.java b/binaryTree/BT_Problem_12.java index de59952..2a8491a 100644 --- a/binaryTree/BT_Problem_12.java +++ b/binaryTree/BT_Problem_12.java @@ -1,10 +1,64 @@ package binaryTree; +import java.util.*; +/* + * Problem Title :- Write a Java program to find Bottom View of Tree. + */ public class BT_Problem_12 { + Node root; + + public BT_Problem_12() {} + + public BT_Problem_12(Node node){ + root = node; + } + + private void BottomView() { + + if(root == null) + return; + + // Initialize a variable 'hd' with 0 for the root element. + int hd = 0; + + // TreeMap which stores key value pair sorted on key value + Map map= new TreeMap<>(); + + // Queue to store tree nodes in level order traversal + Queue q = new LinkedList<>(); + + // Assign initialized horizontal distance value to root node and add it to the queue. + root.hd = hd; + q.add(root); + + while(!q.isEmpty()) { + Node temp = q.remove(); + + hd = temp.hd; + + map.put(hd, temp.data); + + if(temp.left != null) { + temp.left.hd = hd-1; + q.add(temp.left); + } + + if(temp.right != null) { + temp.right.hd = hd+1; + q.add(temp.right); + } + + } + + Set> set = map.entrySet(); + + Iterator> iterator = set.iterator(); + } + + public static void main(String[] args) { - // TODO Auto-generated method stub - + } } diff --git a/bitManipulation/BM_01.java b/bitManipulation/BM_01.java new file mode 100644 index 0000000..420b9d3 --- /dev/null +++ b/bitManipulation/BM_01.java @@ -0,0 +1,24 @@ +package bitManipulation; + +/* + * Problem Title :-> Count set bits in an integer + */ +public class BM_01 { + + // Function to get no of set bits in binary representation of positive integer n + static int countSetBits(int n) { + int count = 0; + while(n > 0) { + count += n & 1; + n >>= 1; + } + return count; + } + + // driver program + public static void main(String[] args) { + int i = 9; + System.out.println(countSetBits(i)); + } + +} diff --git a/bitManipulation/BM_02.java b/bitManipulation/BM_02.java new file mode 100644 index 0000000..2caa1c6 --- /dev/null +++ b/bitManipulation/BM_02.java @@ -0,0 +1,10 @@ +package bitManipulation; + +public class BM_02 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/bitManipulation/BM_03.java b/bitManipulation/BM_03.java new file mode 100644 index 0000000..6a15b06 --- /dev/null +++ b/bitManipulation/BM_03.java @@ -0,0 +1,10 @@ +package bitManipulation; + +public class BM_03 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/bitManipulation/BM_04.java b/bitManipulation/BM_04.java new file mode 100644 index 0000000..e61a030 --- /dev/null +++ b/bitManipulation/BM_04.java @@ -0,0 +1,10 @@ +package bitManipulation; + +public class BM_04 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/bitManipulation/BM_05.java b/bitManipulation/BM_05.java new file mode 100644 index 0000000..8dd10a5 --- /dev/null +++ b/bitManipulation/BM_05.java @@ -0,0 +1,10 @@ +package bitManipulation; + +public class BM_05 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/bitManipulation/BM_06.java b/bitManipulation/BM_06.java new file mode 100644 index 0000000..9f93c54 --- /dev/null +++ b/bitManipulation/BM_06.java @@ -0,0 +1,10 @@ +package bitManipulation; + +public class BM_06 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/bitManipulation/BM_07.java b/bitManipulation/BM_07.java new file mode 100644 index 0000000..d4fedae --- /dev/null +++ b/bitManipulation/BM_07.java @@ -0,0 +1,10 @@ +package bitManipulation; + +public class BM_07 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/bitManipulation/BM_08.java b/bitManipulation/BM_08.java new file mode 100644 index 0000000..196de0e --- /dev/null +++ b/bitManipulation/BM_08.java @@ -0,0 +1,10 @@ +package bitManipulation; + +public class BM_08 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/bitManipulation/BM_09.java b/bitManipulation/BM_09.java new file mode 100644 index 0000000..705e43d --- /dev/null +++ b/bitManipulation/BM_09.java @@ -0,0 +1,10 @@ +package bitManipulation; + +public class BM_09 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/bitManipulation/BM_10.java b/bitManipulation/BM_10.java new file mode 100644 index 0000000..7701b37 --- /dev/null +++ b/bitManipulation/BM_10.java @@ -0,0 +1,10 @@ +package bitManipulation; + +public class BM_10 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} From 7c19038e6a3a539f6fa1149ccab6d919831c030c Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Mon, 1 Feb 2021 20:53:12 +0530 Subject: [PATCH 24/56] #Modification 23 --- binaryTree/BT_Problem_12.java | 31 ++++++++++++--- binaryTree/BT_Problem_13.java | 71 +++++++++++++++++++++++++++++++++- binaryTree/BT_Problem_14.java | 44 +++++++++++++++++++-- binaryTree/BT_Problem_15.java | 61 ++++++++++++++++++++++++++++- binaryTree/BT_Problem_16.java | 73 ++++++++++++++++++++++++++++++++++- 5 files changed, 266 insertions(+), 14 deletions(-) diff --git a/binaryTree/BT_Problem_12.java b/binaryTree/BT_Problem_12.java index 2a8491a..1cabad7 100644 --- a/binaryTree/BT_Problem_12.java +++ b/binaryTree/BT_Problem_12.java @@ -1,20 +1,22 @@ package binaryTree; + import java.util.*; +import java.util.Map.Entry; /* * Problem Title :- Write a Java program to find Bottom View of Tree. */ -public class BT_Problem_12 { +class Tree{ Node root; - public BT_Problem_12() {} + public Tree() {} - public BT_Problem_12(Node node){ + public Tree(Node node){ root = node; } - private void BottomView() { + void bottomView() { if(root == null) return; @@ -54,11 +56,30 @@ private void BottomView() { Set> set = map.entrySet(); Iterator> iterator = set.iterator(); + + while(iterator.hasNext()) { + Map.Entry me = iterator.next(); + System.out.print(me.getValue() + " "); + } } - +} + +public class BT_Problem_12 { public static void main(String[] args) { + Node root = new Node(20); + root.left = new Node(8); + root.right = new Node(22); + root.left.left = new Node(5); + root.left.right = new Node(3); + root.right.left = new Node(4); + root.right.right = new Node(25); + root.left.right.left = new Node(10); + root.left.right.right = new Node(14); + Tree tree = new Tree(root); + System.out.println("Bottom view of the given binary tree: "); + tree.bottomView(); } } diff --git a/binaryTree/BT_Problem_13.java b/binaryTree/BT_Problem_13.java index 218bc72..60852fd 100644 --- a/binaryTree/BT_Problem_13.java +++ b/binaryTree/BT_Problem_13.java @@ -1,10 +1,77 @@ package binaryTree; +import java.util.*; + +/* + * Problem Title :- Zig-Zag traversal of a binary tree + */ + +class BinaryTree{ + + Node root; + + void printZigZagTraversal() { + if(root == null) + return; + + Stack currentLevel = new Stack<>(); + Stack nextLevel = new Stack<>(); + + currentLevel.push(root); + boolean leftToRight = true;; + + while(!currentLevel.isEmpty()) { + Node node = currentLevel.pop(); + + System.out.print(node.data + " "); + + if(leftToRight) { + if(node.left != null) { + nextLevel.push(node.left); + } + + if(node.left != null) { + nextLevel.push(node.left); + } + } + + else { + if(node.right != null) { + nextLevel.push(node.right); + } + if(node.left != null) { + nextLevel.push(node.left); + } + } + + if(currentLevel.isEmpty()) { + leftToRight = !leftToRight; + Stack temp = currentLevel; + currentLevel = nextLevel; + nextLevel = temp; + } + } + } +} public class BT_Problem_13 { public static void main(String[] args) { - // TODO Auto-generated method stub - + + BinaryTree tree = new BinaryTree(); + + tree.root = new Node(1); + tree.root.left = new Node(8); + tree.root.right = new Node(21); + tree.root.left.left = new Node(2); + tree.root.left.right = new Node(3); + tree.root.right.left = new Node(7); + tree.root.right.right = new Node(6); + tree.root.left.right.left = new Node(5); + tree.root.left.right.right = new Node(4); + + System.out.println("ZigZag Order traversal tree is "); + tree.printZigZagTraversal(); + } } diff --git a/binaryTree/BT_Problem_14.java b/binaryTree/BT_Problem_14.java index 1589c68..238883f 100644 --- a/binaryTree/BT_Problem_14.java +++ b/binaryTree/BT_Problem_14.java @@ -1,10 +1,48 @@ package binaryTree; - +/* + * Problem Title :- Check if a tree is balanced or not + */ public class BT_Problem_14 { + Node root; + + boolean isBalanced(Node node) { + int lh; + int rh; + + if(node == null) + return true; + + lh = height(node.left); + rh = height(node.right); + + if(Math.abs(lh - rh) <= 1 && isBalanced(node.left) && isBalanced(node.right)) { + return true; + } + return false; + } + + int height(Node node) { + if(node == null) + return 0; + + return 1 + Math.max(height(node.left), height(node.right)); + } + public static void main(String[] args) { - // TODO Auto-generated method stub + BT_Problem_14 tree = new BT_Problem_14(); + + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + tree.root.left.left.left = new Node(8); + + if(tree.isBalanced(tree.root)) + System.out.println("Tree is balanced"); + else + System.out.println("Tree is not balanced"); } - } diff --git a/binaryTree/BT_Problem_15.java b/binaryTree/BT_Problem_15.java index 772bf9d..1b70b05 100644 --- a/binaryTree/BT_Problem_15.java +++ b/binaryTree/BT_Problem_15.java @@ -1,9 +1,66 @@ package binaryTree; - +import java.util.*; +import java.util.Map.Entry; +/* + * Problem Title :- Diagnol Traversal of a Binary tree + */ public class BT_Problem_15 { + static class Node{ + int data; + Node left, right; + + Node(int data){ + this.data = data; + left = null; + right = null; + } + } + + static void diagonalPrintUtil(Node root, int d, HashMap> diagonalPrint) { + if(root == null) + return; + + Vector k = diagonalPrint.get(d); + + if(k == null) { + k = new Vector<>(); + k.add(root.data); + } + + else { + k.add(root.data); + } + + diagonalPrint.put(d,k); + diagonalPrintUtil(root.left, d+1, diagonalPrint); + diagonalPrintUtil(root.right, d, diagonalPrint); + } + + static void diagonalPrint(Node root) { + HashMap> diagonalPrint = new HashMap<>(); + + diagonalPrintUtil(root, 0, diagonalPrint); + + System.out.println("Diagonal Traversal of Binary Tree"); + + for(Entry> entry : diagonalPrint.entrySet()) + System.out.println(entry.getValue()); + } + public static void main(String[] args) { - + Node root = new Node(8); + + root.left = new Node(3); + root.right = new Node(10); + root.left.left = new Node(1); + root.left.right = new Node(6); + root.right.right = new Node(14); + root.right.right.left = new Node(13); + root.left.right.left = new Node(4); + root.left.right.right = new Node(7); + + diagonalPrint(root); } } diff --git a/binaryTree/BT_Problem_16.java b/binaryTree/BT_Problem_16.java index 209772f..1901145 100644 --- a/binaryTree/BT_Problem_16.java +++ b/binaryTree/BT_Problem_16.java @@ -1,9 +1,78 @@ package binaryTree; - +/* + * Problem Title :- Boundary traversal of a Binary tree + */ public class BT_Problem_16 { + Node root; + // printing leaf nodes + void printLeaves(Node node) { + if(node == null) + return; + + printLeaves(node.left); + // print if it is a leaf node + if(node.left == null && node.right == null) + System.out.print(node.data + " "); + printLeaves(node.right); + } + + void printBoundaryLeft(Node node) { + if(node == null) + return; + if(node.left != null) { + System.out.print(node.data + " "); + printBoundaryLeft(node.left); + } + + else if(node.right != null) { + System.out.print(node.data + " "); + printBoundaryLeft(node.right); + } + } + + void printBoundaryRight(Node node) { + if(node == null) + return; + if(node.left != null) { + System.out.print(node.data + " "); + printBoundaryRight(node.left); + } + + else if(node.right != null) { + System.out.print(node.data + " "); + printBoundaryRight(node.right); + } + } + + void printBoundary(Node node) { + if(node == null) + return; + + System.out.print(node.data + " "); + + printBoundaryLeft(node.left); + + printLeaves(node.left); + printLeaves(node.right); + + printBoundaryRight(node.right); + } + public static void main(String[] args) { - // TODO Auto-generated method stub + BT_Problem_16 tree = new BT_Problem_16(); + + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + tree.root.left.left.left = new Node(8); + tree.root.left.right.left = new Node(10); + tree.root.left.right.right = new Node(14); + tree.root.right = new Node(3); + tree.root.right.right = new Node(22); + + tree.printBoundary(tree.root); } From ba0911de8eaf5cd6be96cb843957ee8fbc171168 Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Sun, 7 Feb 2021 12:10:12 +0530 Subject: [PATCH 25/56] #Modification 24 --- arrays/Array_Problem_13.java | 26 +++++++++++++- arrays/Array_Problem_14.java | 56 +++++++++++++++++++++++++++++- arrays/Array_Problem_15.java | 45 ++++++++++++++++++++++++- arrays/Array_Problem_16_i.java | 23 +++++++++++++ arrays/Array_Problem_16_ii.java | 60 +++++++++++++++++++++++++++++++++ arrays/Array_Problem_31.java | 41 +++++++++++++++++++++- arrays/Array_Problem_33.java | 37 +++++++++++++++++++- arrays/Array_Problem_34.java | 1 - arrays/Array_Problem_36.java | 5 +-- 9 files changed, 286 insertions(+), 8 deletions(-) create mode 100644 arrays/Array_Problem_16_i.java create mode 100644 arrays/Array_Problem_16_ii.java diff --git a/arrays/Array_Problem_13.java b/arrays/Array_Problem_13.java index 1b7d192..522e534 100644 --- a/arrays/Array_Problem_13.java +++ b/arrays/Array_Problem_13.java @@ -1,4 +1,28 @@ package arrays; -/* Problem Title :-> */ +import java.util.*; + +/* Problem Title :-> Kadane's Algo [V.V.V.V.V IMP] */ public class Array_Problem_13 { + public static void main(String[] args) { + @SuppressWarnings("resource") + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int[] a=new int[n]; + + for(int i=0;i */ +import java.util.*; + +/* Problem Title :-> Merge Intervals */ public class Array_Problem_14 { + //The main function that takes a set of intervals, merges overlapping intervals & prints the result. + public static void mergeIntervals(Interval[] a){ + //Test if the given set has at least one interval + if(a.length <= 0) + return; + //Create an empty stack of intervals + Stack stack = new Stack<>(); + //sort the intervals in increasing order of start time + Arrays.sort(a, new Comparator<>() { + public int compare(Interval i1, Interval i2){ + return i1.start -i2.start; + } + }); + //push the first interval to stack + stack.push(a[0]); + //Start from the next interval and merge if necessary + for(int i = 1; i < a.length; i++){ + //get interval from stack top + Interval top = stack.peek(); + //if current interval is not overlapping with stack top,push it to the stack + if(top.end < a[i].start) + stack.push(a[i]); + //Otherwise update the ending time of top if ending of current interval is more + else if(top.end < a[i].end){ + top.end = a[i].end; + stack.pop(); + stack.push(top); + } + } + //Print contents of stack + System.out.print("The Merged Intervals are: "); + while(!stack.isEmpty()){ + Interval t = stack.pop(); + System.out. print("[" + t.start + "," + t.end + "] "); + } + } + public static void main(String[] args) { + Interval[] a = new Interval[4]; + a[0] = new Interval(6,8); + a[1] = new Interval(1,9); + a[2] = new Interval(2,4); + a[3] = new Interval(4,7); + mergeIntervals(a); + } +} + +class Interval{ + int start, end; + Interval(int start, int end){ + this.start = start; + this.end = end; + } } diff --git a/arrays/Array_Problem_15.java b/arrays/Array_Problem_15.java index e5554ef..81637cd 100644 --- a/arrays/Array_Problem_15.java +++ b/arrays/Array_Problem_15.java @@ -1,4 +1,47 @@ package arrays; -/* Problem Title :-> */ +/* Problem Title :-> Next Permutation */ public class Array_Problem_15 { + + public static boolean nextPermutation(int[] numbs){ + int mark = -1; + for(int i = numbs.length - 1; i > 0; i--){ + if(numbs[i] > numbs[i - 1]){ + mark = i - 1; + break; + } + } + if (mark == -1){ + reverse(numbs, 0, numbs.length-1); + return false; + } + int idx = numbs.length - 1; + for (int i = numbs.length-1; i >= mark + 1; i--){ + if(numbs[i] > numbs[mark]){ + idx = i; + break; + } + } + swap(numbs, mark, idx); + reverse(numbs, mark + 1, numbs.length - 1); + return true; + } + + private static void swap(int[] numbs, int i, int j){ + int t = numbs[i]; + numbs[i] = numbs[j]; + numbs[j] = t; + } + + private static void reverse(int[] numbs, int i, int j){ + while(i < j){ + swap(numbs, i, j); + i++; + j--; + } + } + + public static void main(String[] args) { + int[] numbs = new int[]{2, 3, 5, 7, 9, 4}; + System.out.print(nextPermutation(numbs)); + } } diff --git a/arrays/Array_Problem_16_i.java b/arrays/Array_Problem_16_i.java new file mode 100644 index 0000000..d11e855 --- /dev/null +++ b/arrays/Array_Problem_16_i.java @@ -0,0 +1,23 @@ +package arrays; +/* + * Problem Title :-> Count Inversion's in array By Method 1 + */ +public class Array_Problem_16_i { + static int[] a = new int[] {1, 20, 30, 6, 4, 5}; + + static int getInvCount(int n) { + int inv_count = 0; + for(int i = 0; i < n - 1; i++) { + for(int j = i + 1; j < n; j++) { + if(a[i] > a[j]) + inv_count++; + } + } + return inv_count; + } + + // Driver method to test the above function + public static void main(String[] args) { + System.out.println("Number of inversions are " + getInvCount(a.length)); + } +} diff --git a/arrays/Array_Problem_16_ii.java b/arrays/Array_Problem_16_ii.java new file mode 100644 index 0000000..efa1f3e --- /dev/null +++ b/arrays/Array_Problem_16_ii.java @@ -0,0 +1,60 @@ +package arrays; + +import java.util.Arrays; + +/* + * Problem Title :-> Count Inversion's in array (By Method 2 : Using Enhance Merge Sort) + */ +public class Array_Problem_16_ii { + + private static int mergeAndCount(int[] a, int l, int m, int r) { + + // Left sub-array + int[] left = Arrays.copyOfRange(a, l, m + 1); + + // Right sub-array + int[] right = Arrays.copyOfRange(a, m + 1, r + 1); + + int i = 0, j = 0, k = 1, swaps = 0; + + while(i < left.length && j < right.length) { + if(left[i] <= right[j]) + a[k++] = left[i++]; + else { + a[k++] = right[j++]; + swaps += (m + 1) - (l + i); + } + } + + while(i < left.length) + a[k++] = left[i++]; + + while(j < right.length) + a[k++] = right[j++]; + + return swaps; + } + + private static int mergeSortAndCount(int[] a, int l, int r) { + // keeps track of the inversion count at a particular node of the recursion tree + int count = 0; + + if(l < r) { + int m = (l + r)/2; + // Total inversion count = left sub-array count + right sub-array count + merge count + // Left sub-array count + count += mergeSortAndCount(a, l, m); + // right sub-array count + count += mergeSortAndCount(a, m + 1, r); + // Merge count + count += mergeAndCount(a, l, m, r); + } + return count; + } + + public static void main(String[] args) { + int[] a = {1, 20, 6, 4, 5}; + System.out.println(mergeSortAndCount(a, 0, a.length - 1)); + } + +} diff --git a/arrays/Array_Problem_31.java b/arrays/Array_Problem_31.java index c24a124..6c93fbb 100644 --- a/arrays/Array_Problem_31.java +++ b/arrays/Array_Problem_31.java @@ -1,4 +1,43 @@ package arrays; -/* Problem Title :-> */ +/* + * Problem Title :-> Maximum profit by buying and selling a share at-most twice + */ public class Array_Problem_31 { + + static int maxProfit(int price[], int n) { + + int profit[] = new int[n]; + + for(int i =0; i < n; i++) { + profit[i] = 0; + } + + int max_price = price[n - 1]; + + for(int i = n - 2; i >= 0; i--) { + if(price[i] > max_price) + max_price = price[i]; + + profit[i] = Math.max(profit[i + 1], max_price - price[i]); + } + + int min_price = price[0]; + + for(int i = 1; i < n; i++) { + + if(price[i] < min_price) + min_price = price[i]; + + profit[i] = Math.max(profit[i - 1], profit[i] + (price[i] - min_price)); + } + int result = profit[n - 1]; + return result; + } + + public static void main(String args[]) { + int price[] = {2, 30, 15, 10, 8, 25, 80}; + int n = price.length; + System.out.println("Maximum Profit = " + maxProfit(price, n)); + } + } diff --git a/arrays/Array_Problem_33.java b/arrays/Array_Problem_33.java index 86ca067..efa0693 100644 --- a/arrays/Array_Problem_33.java +++ b/arrays/Array_Problem_33.java @@ -3,6 +3,41 @@ /* Problem Title :-> Three way partitioning of an array around a given value */ public class Array_Problem_33 { - + // partition a[0..n-1] around [lowVal, highVal] + public static void threeWayPartition(int[] a, int lowVal, int highVal) { + int n = a.length; + // Initialize ext available positions for smaller (than range) & greater element. + int start = 0, end = n - 1; + // Traverse elements from left + for(int i = 0; i <= end;) { + // If current element is smaller than range, put it on next available smaller position. + if(a[i] < lowVal) { + int temp = a[start]; + a[start] = a[i]; + a[i] = temp; + start++; + i++; + } + + // If current element is greater than range, put it on next available greater position. + else if(a[i] > highVal) { + int temp = a[end]; + a[end] = a[i]; + a[i] = temp; + end--; + } + + else i++; + } + } + + public static void main(String[] args) { + int[] a = {1, 14, 5, 20, 4, 2, 54, 20, 87, 98, 3, 1, 32}; + threeWayPartition(a, 10, 20); + System.out.println("Modified Array"); + for(int i = 0; i < a.length; i++) { + System.out.println(a[i] + " "); + } + } } diff --git a/arrays/Array_Problem_34.java b/arrays/Array_Problem_34.java index f4b4ebc..6d5d56b 100644 --- a/arrays/Array_Problem_34.java +++ b/arrays/Array_Problem_34.java @@ -1,5 +1,4 @@ package arrays; -import java.lang.*; /* Problem Title :-> Minimum swaps required bring elements less equal K together */ public class Array_Problem_34 { diff --git a/arrays/Array_Problem_36.java b/arrays/Array_Problem_36.java index 7b523f3..ee47a7c 100644 --- a/arrays/Array_Problem_36.java +++ b/arrays/Array_Problem_36.java @@ -53,12 +53,13 @@ else if(j == n) { } /* Driver program to test above function */ - public static void main(String[] args) { + @SuppressWarnings("unused") + public static void main(String[] args) { int[] a1 = {1, 12, 15, 26, 38}; int[] a2 = {2, 13, 17, 30, 45}; - int n1 = a1.length,n2 = a2.length; + int n1 = a1.length, n2 = a2.length; System.out.println("Median is " + getMedian(a1, a2, n1)); From aff75df56e8205d6b943d532484bd1e287b40ba4 Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Mon, 8 Feb 2021 11:51:20 +0530 Subject: [PATCH 26/56] Changes --- array/Candy_Distribution_Problem.java | 49 ++++++ array/KadanesAlgorithm.java | 31 ++++ arrays/ArrayLevel1.java | 17 ++ arrays/{BasicArrays.java => ArrayLevel2.java} | 3 +- arrays/Array_Problem_1.java | 41 +++++ arrays/Array_Problem_10.java | 51 ++++++ arrays/Array_Problem_11.java | 33 ++++ arrays/Array_Problem_12.java | 69 ++++++++ arrays/Array_Problem_13.java | 28 ++++ arrays/Array_Problem_14.java | 58 +++++++ arrays/Array_Problem_15.java | 47 ++++++ arrays/Array_Problem_16_i.java | 23 +++ arrays/Array_Problem_16_ii.java | 60 +++++++ arrays/Array_Problem_17.java | 37 ++++ arrays/Array_Problem_18.java | 24 +++ arrays/Array_Problem_19.java | 6 + arrays/Array_Problem_2.java | 55 ++++++ arrays/Array_Problem_20.java | 4 + arrays/Array_Problem_21.java | 4 + arrays/Array_Problem_22.java | 4 + ...ray_problem.java => Array_Problem_23.java} | 14 +- arrays/Array_Problem_24.java | 4 + arrays/Array_Problem_25.java | 4 + arrays/Array_Problem_26.java | 4 + arrays/Array_Problem_27.java | 7 + arrays/Array_Problem_28.java | 4 + arrays/Array_Problem_29.java | 4 + arrays/Array_Problem_3.java | 122 ++++++++++++++ arrays/Array_Problem_30.java | 37 ++++ arrays/Array_Problem_31.java | 43 +++++ arrays/Array_Problem_32.java | 31 ++++ arrays/Array_Problem_33.java | 43 +++++ arrays/Array_Problem_34.java | 41 +++++ arrays/Array_Problem_35.java | 33 ++++ arrays/Array_Problem_36.java | 67 ++++++++ arrays/Array_Problem_37.java | 65 +++++++ arrays/Array_Problem_4_Approach1.java | 63 +++++++ ...go.java => Array_Problem_4_Approach2.java} | 17 +- arrays/Array_Problem_5.java | 41 +++++ arrays/Array_Problem_6.java | 118 +++++++++++++ ...{RotateArray.java => Array_Problem_7.java} | 8 +- arrays/Array_Problem_8.java | 32 ++++ arrays/Array_Problem_9.java | 65 +++++++ arrays/Array_of_objects.java | 44 +++++ arrays/Candy_Distribution_Problem.java | 49 ++++++ arrays/FIndDublicate.java | 32 ---- arrays/FRE.java | 40 +++++ arrays/KadanesAlgorithm.java | 31 ++++ arrays/MultiDArray.java | 16 ++ arrays/package-info.java | 1 - backtracking/Rat_In_A_Maze.java | 90 ++++++++++ basicProblems/Armstrong_Number.java | 26 +++ basicProblems/Factorial.class | Bin 0 -> 1124 bytes basicProblems/Factorial.java | 9 +- basicProblems/Fibonacci_Series.java | 8 +- .../Multiplicative_Table_till_20.java | 15 +- basicProblems/Palindrome_Number.java | 4 - basicProblems/Prime_Number_Or_Not.java | 15 +- ...ive_decimal_number_from_right_to_left.java | 19 +++ basicProblems/Reverse_Given_number.java | 22 +++ basicProblems/Series_Sum_1.java | 6 +- basicProblems/Swap_two_numbers.java | 15 +- basicProblems/Swapping_2.java | 24 +++ .../ArrayDequeDemo.java | 2 +- .../ArrayListDemo.java | 2 +- basic_idea_of_DS/Graph.java | 41 +++++ .../HashMapIntro.java | 2 +- .../LinkedListDemo.java | 2 +- {dataStructure => basic_idea_of_DS}/List.java | 2 +- .../MYStackByList.java | 2 +- .../MyArrayList.java | 2 +- .../MyHashMap.java | 2 +- .../MyHashSet.java | 2 +- .../MyLinkedList.java | 2 +- .../MyQueue.java | 2 +- .../MyStack.java | 2 +- .../SetExample.java | 2 +- {dataStructure => basic_idea_of_DS}/Tree.java | 2 +- basics/ControlStatements.java | 38 ++--- basics/Fast_Inputs_Main.java | 63 +++++++ basics/Operators.java | 2 +- basics/Treedatastructure.java | 65 ------- basics/WhileLoop.java | 8 +- binaryTree/BT_Problem_01.java | 50 ++++++ binaryTree/BT_Problem_02.java | 92 ++++++++++ binaryTree/BT_Problem_03.java | 50 ++++++ binaryTree/BT_Problem_04.java | 61 +++++++ binaryTree/BT_Problem_05.java | 84 ++++++++++ binaryTree/BT_Problem_06_a.java | 62 +++++++ binaryTree/BT_Problem_06_b.java | 98 +++++++++++ binaryTree/BT_Problem_07.java | 15 ++ binaryTree/BT_Problem_08.java | 10 ++ binaryTree/BT_Problem_09.java | 51 ++++++ binaryTree/BT_Problem_10.java | 30 ++++ binaryTree/BT_Problem_11.java | 75 +++++++++ binaryTree/BT_Problem_12.java | 85 ++++++++++ binaryTree/BT_Problem_13.java | 77 +++++++++ binaryTree/BT_Problem_14.java | 48 ++++++ binaryTree/BT_Problem_15.java | 66 ++++++++ binaryTree/BT_Problem_16.java | 79 +++++++++ binaryTree/BT_Problem_17.java | 55 ++++++ binaryTree/BT_Problem_18.java | 10 ++ binaryTree/BT_Problem_19.java | 9 + binaryTree/BT_Problem_31.java | 76 +++++++++ binaryTree/BT_Problem_35.java | 66 ++++++++ bitManipulation/BM_01.java | 24 +++ bitManipulation/BM_02.java | 52 ++++++ bitManipulation/BM_03.java | 29 ++++ bitManipulation/BM_04.java | 10 ++ bitManipulation/BM_05.java | 10 ++ bitManipulation/BM_06.java | 10 ++ bitManipulation/BM_07.java | 10 ++ bitManipulation/BM_08.java | 10 ++ bitManipulation/BM_09.java | 10 ++ bitManipulation/BM_10.java | 10 ++ dataStructures/Info.java | 10 ++ dataStructures/graphs/Graph.java | 41 +++++ dp/CoinChoiseProblem.java | 51 ++++++ exercise_and_practice_Problems/Cylinder.java | 26 +++ exercise_and_practice_Problems/Exercise1.java | 33 ++++ exercise_and_practice_Problems/Exercise2.java | 34 ++++ .../Getters_Setters_For_Cylinder.java | 44 +++++ graphs/Graph_Problem_01_i.java | 50 ++++++ graphs/Graph_Problem_01_ii.java | 43 +++++ graphs/Graph_Problem_02.java | 75 +++++++++ graphs/Graph_Problem_03.java | 75 +++++++++ greedy/Greedy_Problem_01.java | 45 +++++ linkedList/Deletion_in_Linked_List.java | 100 +++++++++++ linkedList/Insertion_in_Linked_List.java | 99 +++++++++++ linkedList/MainList.java | 18 ++ linkedList/MyLL.java | 53 ++++++ linkedList/Problem_1_1.java | 62 +++++++ linkedList/Problem_1_2.java | 67 ++++++++ linkedList/Queue.java | 157 +++++++++++++++++ list/Deletion_in_Linked_List.java | 100 +++++++++++ list/Insertion_in_Linked_List.java | 99 +++++++++++ list/MainList.java | 18 ++ list/MyLL.java | 84 ++++++++++ matrix/Matrix_Problem_01.java | 87 ++++++++++ matrix/Matrix_Problem_02.java | 123 ++++++++++++++ matrix/Matrix_Problem_03.java | 108 ++++++++++++ matrix/Matrix_Problem_04.java | 86 ++++++++++ matrix/Matrix_Problem_05.java | 69 ++++++++ matrix/Matrix_Problem_06.java | 82 +++++++++ matrix/Matrix_Problem_07.java | 38 +++++ matrix/Matrix_Problem_08.java | 41 +++++ matrix/Matrix_Problem_09.java | 71 ++++++++ matrix/Matrix_Problem_10.java | 53 ++++++ oops/Mor.java | 2 + oopsEncapsulation/EncapIntro.java | 5 +- oopsEncapsulation/S.java | 15 +- oopsabstraction/Audi.java | 6 +- oopsabstraction/Car.java | 2 - oopsinheritance/MainClass.java | 4 +- oopspolymorphism/Animal.java | 2 +- patternsByloops/Pattern1.java | 1 + practiceProblems/Cylinder.java | 26 +++ practiceProblems/Exercise1.java | 33 ++++ practiceProblems/Exercise2.java | 34 ++++ .../Getters_Setters_For_Cylinder.java | 44 +++++ recursion/Factorial.java | 21 +++ recursion/NRaiseP.java | 15 ++ recursion/NaturalNoSum.java | 20 +++ recursion/Problem_01.java | 20 +++ recursion/Subsequences.java | 50 ++++++ recursion/Tower_Of_Hanoi.java | 29 ++++ sdeProblems/FindDuplicate.java | 32 ---- sdeProblems/RotateArray.java | 38 ----- sdeProblems/Test.java | 37 ---- searchingAlgorithms/BinarySearch.java | 1 + sortingAlgorithms/BubbleSort.java | 3 +- sortingAlgorithms/HeapSort.java | 129 +++++++------- sortingAlgorithms/RadixSort.java | 15 +- ssp/SSP_Problem_01.java | 66 ++++++++ ssp/SSP_Problem_02.java | 30 ++++ ssp/SSP_Problem_03.java | 50 ++++++ stack/Parenthesis_Checker_Problem.java | 75 +++++++++ stack/Tower_Of_Hanoi.java | 29 ++++ stack_and_queue/Infix_To_Postfix.java | 76 +++++++++ .../Parenthesis_Checker_Problem.java | 75 +++++++++ stack_and_queue/Stack_Queue_Problem_01_i.java | 69 ++++++++ .../Stack_Queue_Problem_01_ii.java | 115 +++++++++++++ stack_and_queue/Stack_Queue_Problem_02_i.java | 67 ++++++++ .../Stack_Queue_Problem_02_ii.java | 11 ++ stack_and_queue/Stack_Queue_Problem_03.java | 75 +++++++++ trees/BST_Deletion.java | 158 ++++++++++++++++++ trees/BinarySearchTree.java | 83 +++++++++ trees/Count_leaf_nodes.java | 29 ++++ trees/FindFullNodesInABinaryTree.java | 28 ++-- trees/Insertion_In_BinaryTree.java | 14 +- trees/Problem_01.java | 85 ++++++++++ 191 files changed, 7107 insertions(+), 400 deletions(-) create mode 100644 array/Candy_Distribution_Problem.java create mode 100644 array/KadanesAlgorithm.java create mode 100644 arrays/ArrayLevel1.java rename arrays/{BasicArrays.java => ArrayLevel2.java} (86%) create mode 100644 arrays/Array_Problem_1.java create mode 100644 arrays/Array_Problem_10.java create mode 100644 arrays/Array_Problem_11.java create mode 100644 arrays/Array_Problem_12.java create mode 100644 arrays/Array_Problem_13.java create mode 100644 arrays/Array_Problem_14.java create mode 100644 arrays/Array_Problem_15.java create mode 100644 arrays/Array_Problem_16_i.java create mode 100644 arrays/Array_Problem_16_ii.java create mode 100644 arrays/Array_Problem_17.java create mode 100644 arrays/Array_Problem_18.java create mode 100644 arrays/Array_Problem_19.java create mode 100644 arrays/Array_Problem_2.java create mode 100644 arrays/Array_Problem_20.java create mode 100644 arrays/Array_Problem_21.java create mode 100644 arrays/Array_Problem_22.java rename arrays/{Maximum_subarray_problem.java => Array_Problem_23.java} (73%) create mode 100644 arrays/Array_Problem_24.java create mode 100644 arrays/Array_Problem_25.java create mode 100644 arrays/Array_Problem_26.java create mode 100644 arrays/Array_Problem_27.java create mode 100644 arrays/Array_Problem_28.java create mode 100644 arrays/Array_Problem_29.java create mode 100644 arrays/Array_Problem_3.java create mode 100644 arrays/Array_Problem_30.java create mode 100644 arrays/Array_Problem_31.java create mode 100644 arrays/Array_Problem_32.java create mode 100644 arrays/Array_Problem_33.java create mode 100644 arrays/Array_Problem_34.java create mode 100644 arrays/Array_Problem_35.java create mode 100644 arrays/Array_Problem_36.java create mode 100644 arrays/Array_Problem_37.java create mode 100644 arrays/Array_Problem_4_Approach1.java rename arrays/{Sort_an_array_of_0s_1s_2s_without_using_extra_space_or_sorting_algo.java => Array_Problem_4_Approach2.java} (76%) create mode 100644 arrays/Array_Problem_5.java create mode 100644 arrays/Array_Problem_6.java rename arrays/{RotateArray.java => Array_Problem_7.java} (82%) create mode 100644 arrays/Array_Problem_8.java create mode 100644 arrays/Array_Problem_9.java create mode 100644 arrays/Array_of_objects.java create mode 100644 arrays/Candy_Distribution_Problem.java delete mode 100644 arrays/FIndDublicate.java create mode 100644 arrays/FRE.java create mode 100644 arrays/KadanesAlgorithm.java create mode 100644 arrays/MultiDArray.java delete mode 100644 arrays/package-info.java create mode 100644 backtracking/Rat_In_A_Maze.java create mode 100644 basicProblems/Armstrong_Number.java create mode 100644 basicProblems/Factorial.class create mode 100644 basicProblems/Print_all_digits_of_positive_decimal_number_from_right_to_left.java create mode 100644 basicProblems/Reverse_Given_number.java create mode 100644 basicProblems/Swapping_2.java rename {dataStructure => basic_idea_of_DS}/ArrayDequeDemo.java (93%) rename {dataStructure => basic_idea_of_DS}/ArrayListDemo.java (96%) create mode 100644 basic_idea_of_DS/Graph.java rename {dataStructure => basic_idea_of_DS}/HashMapIntro.java (96%) rename {dataStructure => basic_idea_of_DS}/LinkedListDemo.java (96%) rename {dataStructure => basic_idea_of_DS}/List.java (90%) rename {dataStructure => basic_idea_of_DS}/MYStackByList.java (99%) rename {dataStructure => basic_idea_of_DS}/MyArrayList.java (96%) rename {dataStructure => basic_idea_of_DS}/MyHashMap.java (96%) rename {dataStructure => basic_idea_of_DS}/MyHashSet.java (91%) rename {dataStructure => basic_idea_of_DS}/MyLinkedList.java (96%) rename {dataStructure => basic_idea_of_DS}/MyQueue.java (98%) rename {dataStructure => basic_idea_of_DS}/MyStack.java (96%) rename {dataStructure => basic_idea_of_DS}/SetExample.java (97%) rename {dataStructure => basic_idea_of_DS}/Tree.java (97%) create mode 100644 basics/Fast_Inputs_Main.java delete mode 100644 basics/Treedatastructure.java create mode 100644 binaryTree/BT_Problem_01.java create mode 100644 binaryTree/BT_Problem_02.java create mode 100644 binaryTree/BT_Problem_03.java create mode 100644 binaryTree/BT_Problem_04.java create mode 100644 binaryTree/BT_Problem_05.java create mode 100644 binaryTree/BT_Problem_06_a.java create mode 100644 binaryTree/BT_Problem_06_b.java create mode 100644 binaryTree/BT_Problem_07.java create mode 100644 binaryTree/BT_Problem_08.java create mode 100644 binaryTree/BT_Problem_09.java create mode 100644 binaryTree/BT_Problem_10.java create mode 100644 binaryTree/BT_Problem_11.java create mode 100644 binaryTree/BT_Problem_12.java create mode 100644 binaryTree/BT_Problem_13.java create mode 100644 binaryTree/BT_Problem_14.java create mode 100644 binaryTree/BT_Problem_15.java create mode 100644 binaryTree/BT_Problem_16.java create mode 100644 binaryTree/BT_Problem_17.java create mode 100644 binaryTree/BT_Problem_18.java create mode 100644 binaryTree/BT_Problem_19.java create mode 100644 binaryTree/BT_Problem_31.java create mode 100644 binaryTree/BT_Problem_35.java create mode 100644 bitManipulation/BM_01.java create mode 100644 bitManipulation/BM_02.java create mode 100644 bitManipulation/BM_03.java create mode 100644 bitManipulation/BM_04.java create mode 100644 bitManipulation/BM_05.java create mode 100644 bitManipulation/BM_06.java create mode 100644 bitManipulation/BM_07.java create mode 100644 bitManipulation/BM_08.java create mode 100644 bitManipulation/BM_09.java create mode 100644 bitManipulation/BM_10.java create mode 100644 dataStructures/Info.java create mode 100644 dataStructures/graphs/Graph.java create mode 100644 dp/CoinChoiseProblem.java create mode 100644 exercise_and_practice_Problems/Cylinder.java create mode 100644 exercise_and_practice_Problems/Exercise1.java create mode 100644 exercise_and_practice_Problems/Exercise2.java create mode 100644 exercise_and_practice_Problems/Getters_Setters_For_Cylinder.java create mode 100644 graphs/Graph_Problem_01_i.java create mode 100644 graphs/Graph_Problem_01_ii.java create mode 100644 graphs/Graph_Problem_02.java create mode 100644 graphs/Graph_Problem_03.java create mode 100644 greedy/Greedy_Problem_01.java create mode 100644 linkedList/Deletion_in_Linked_List.java create mode 100644 linkedList/Insertion_in_Linked_List.java create mode 100644 linkedList/MainList.java create mode 100644 linkedList/MyLL.java create mode 100644 linkedList/Problem_1_1.java create mode 100644 linkedList/Problem_1_2.java create mode 100644 linkedList/Queue.java create mode 100644 list/Deletion_in_Linked_List.java create mode 100644 list/Insertion_in_Linked_List.java create mode 100644 list/MainList.java create mode 100644 list/MyLL.java create mode 100644 matrix/Matrix_Problem_01.java create mode 100644 matrix/Matrix_Problem_02.java create mode 100644 matrix/Matrix_Problem_03.java create mode 100644 matrix/Matrix_Problem_04.java create mode 100644 matrix/Matrix_Problem_05.java create mode 100644 matrix/Matrix_Problem_06.java create mode 100644 matrix/Matrix_Problem_07.java create mode 100644 matrix/Matrix_Problem_08.java create mode 100644 matrix/Matrix_Problem_09.java create mode 100644 matrix/Matrix_Problem_10.java create mode 100644 practiceProblems/Cylinder.java create mode 100644 practiceProblems/Exercise1.java create mode 100644 practiceProblems/Exercise2.java create mode 100644 practiceProblems/Getters_Setters_For_Cylinder.java create mode 100644 recursion/Factorial.java create mode 100644 recursion/NRaiseP.java create mode 100644 recursion/NaturalNoSum.java create mode 100644 recursion/Problem_01.java create mode 100644 recursion/Subsequences.java create mode 100644 recursion/Tower_Of_Hanoi.java delete mode 100644 sdeProblems/FindDuplicate.java delete mode 100644 sdeProblems/RotateArray.java delete mode 100644 sdeProblems/Test.java create mode 100644 ssp/SSP_Problem_01.java create mode 100644 ssp/SSP_Problem_02.java create mode 100644 ssp/SSP_Problem_03.java create mode 100644 stack/Parenthesis_Checker_Problem.java create mode 100644 stack/Tower_Of_Hanoi.java create mode 100644 stack_and_queue/Infix_To_Postfix.java create mode 100644 stack_and_queue/Parenthesis_Checker_Problem.java create mode 100644 stack_and_queue/Stack_Queue_Problem_01_i.java create mode 100644 stack_and_queue/Stack_Queue_Problem_01_ii.java create mode 100644 stack_and_queue/Stack_Queue_Problem_02_i.java create mode 100644 stack_and_queue/Stack_Queue_Problem_02_ii.java create mode 100644 stack_and_queue/Stack_Queue_Problem_03.java create mode 100644 trees/BST_Deletion.java create mode 100644 trees/BinarySearchTree.java create mode 100644 trees/Count_leaf_nodes.java create mode 100644 trees/Problem_01.java diff --git a/array/Candy_Distribution_Problem.java b/array/Candy_Distribution_Problem.java new file mode 100644 index 0000000..8a56be7 --- /dev/null +++ b/array/Candy_Distribution_Problem.java @@ -0,0 +1,49 @@ +package array; +import java.util.*; + +//Language: Java +//Time Complexity: O(n) 3 Linear traversals. +//Space Complexity: O(n) Array of candies. + +public class Candy_Distribution_Problem{ + + public int candy(int[] ratings) { + if (ratings.length < 2) + return ratings.length; + + + int[] candies = new int[ratings.length]; + Arrays.fill(candies, 1); + + // ** Step 1: Forward ** + for (int i=0; i= ratings[i+1]) { + continue; + } + candies[i+1] = candies[i] + 1; + } + + // ** Step 2: Backward ** + for (int i=ratings.length-1; i>0; i--) { + if (ratings[i] >= ratings[i-1]) { + continue; + } + candies[i-1] = Math.max(candies[i] + 1, candies[i-1]); + } + + // ** Step 3: Count Candies ** + int count = 0; + for (int i=0; i=0) m[Math.abs(m[i])] = -m[Math.abs(m[i])]; + else System.out.print(Math.abs(m[i]) + " "); + } + } + + //Driver Method + public static void main(String[] args) { + + Array_Problem_11 dublicate= new Array_Problem_11(); + + int m[] = {1,2,3,1,3,6,6}; + int m_size = m.length; + + dublicate.printRepeating(m,m_size); + + } + +} + diff --git a/arrays/Array_Problem_12.java b/arrays/Array_Problem_12.java new file mode 100644 index 0000000..d0728fa --- /dev/null +++ b/arrays/Array_Problem_12.java @@ -0,0 +1,69 @@ +package arrays; + +import java.util.Arrays; + +/* + * Problem :- + * Merge two sorted array without using extra space + */ + +/* + * Understanding of the Problem :- + * + * We are given two sorted array. + * We need to merge these two arrays, + * such that the initial numbers(after complete sorting) are in the first array , + * and the remaining numbers are in the second array. + * Extra space allowed in O(1). + */ + +/* + * Simple Discussion : + * This task is simple and O(m+n) if we are allowed to use extra space. + * But it becomes really complicated when extra space is not allowed, + * and doesn't look possible in less than O(m*n) worst case time. + */ + +/* + * Idea or Approach of Solution :- + * The idea is to begin from last element of ar2[] and search it in ar1[]. + * If there is a greater element in ae1[], then we moe lastt element of ar2[] at correct place in ar1[]. + * + * We can use INSERTION Sort type of insertion for this. + */ + +public class Array_Problem_12 { + + static int[] arr1 = new int[] {1, 5 , 9, 10, 15, 20}; + static int[] arr2 = new int[] {2, 3, 8, 13}; + + static void merge(int m , int n) { + + //Iterate through all elements of the last element + for(int i = n-1; i >= 0; i--) { + + /* + * FInd the smallest element greater than ar2[i]. + * Move all elements one position ahead till the smallest greater element is not found. + */ + int j , last = arr1[m -1]; + for( j = m-2 ; j>= 0 && arr1[j] > arr2[i] ; j--) + arr1[j+1] = arr1[j]; + + //if there was a greater element + if(j != m-2 || last > arr2[i]) { + arr1[j+1] = arr2[i]; + arr2[i] = last; + } + } + } + + public static void main(String[] args) { + merge(arr1.length, arr2.length); + System.out.println("After Merging nFirst Array: "); + System.out.println(Arrays.toString(arr1)); + System.out.println("Second Array: "); + System.out.println(Arrays.toString(arr2)); + } + +} diff --git a/arrays/Array_Problem_13.java b/arrays/Array_Problem_13.java new file mode 100644 index 0000000..522e534 --- /dev/null +++ b/arrays/Array_Problem_13.java @@ -0,0 +1,28 @@ +package arrays; +import java.util.*; + +/* Problem Title :-> Kadane's Algo [V.V.V.V.V IMP] */ +public class Array_Problem_13 { + public static void main(String[] args) { + @SuppressWarnings("resource") + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int[] a=new int[n]; + + for(int i=0;i Merge Intervals */ +public class Array_Problem_14 { + //The main function that takes a set of intervals, merges overlapping intervals & prints the result. + public static void mergeIntervals(Interval[] a){ + //Test if the given set has at least one interval + if(a.length <= 0) + return; + //Create an empty stack of intervals + Stack stack = new Stack<>(); + //sort the intervals in increasing order of start time + Arrays.sort(a, new Comparator<>() { + public int compare(Interval i1, Interval i2){ + return i1.start -i2.start; + } + }); + //push the first interval to stack + stack.push(a[0]); + //Start from the next interval and merge if necessary + for(int i = 1; i < a.length; i++){ + //get interval from stack top + Interval top = stack.peek(); + //if current interval is not overlapping with stack top,push it to the stack + if(top.end < a[i].start) + stack.push(a[i]); + //Otherwise update the ending time of top if ending of current interval is more + else if(top.end < a[i].end){ + top.end = a[i].end; + stack.pop(); + stack.push(top); + } + } + //Print contents of stack + System.out.print("The Merged Intervals are: "); + while(!stack.isEmpty()){ + Interval t = stack.pop(); + System.out. print("[" + t.start + "," + t.end + "] "); + } + } + public static void main(String[] args) { + Interval[] a = new Interval[4]; + a[0] = new Interval(6,8); + a[1] = new Interval(1,9); + a[2] = new Interval(2,4); + a[3] = new Interval(4,7); + mergeIntervals(a); + } +} + +class Interval{ + int start, end; + Interval(int start, int end){ + this.start = start; + this.end = end; + } +} diff --git a/arrays/Array_Problem_15.java b/arrays/Array_Problem_15.java new file mode 100644 index 0000000..81637cd --- /dev/null +++ b/arrays/Array_Problem_15.java @@ -0,0 +1,47 @@ +package arrays; +/* Problem Title :-> Next Permutation */ +public class Array_Problem_15 { + + public static boolean nextPermutation(int[] numbs){ + int mark = -1; + for(int i = numbs.length - 1; i > 0; i--){ + if(numbs[i] > numbs[i - 1]){ + mark = i - 1; + break; + } + } + if (mark == -1){ + reverse(numbs, 0, numbs.length-1); + return false; + } + int idx = numbs.length - 1; + for (int i = numbs.length-1; i >= mark + 1; i--){ + if(numbs[i] > numbs[mark]){ + idx = i; + break; + } + } + swap(numbs, mark, idx); + reverse(numbs, mark + 1, numbs.length - 1); + return true; + } + + private static void swap(int[] numbs, int i, int j){ + int t = numbs[i]; + numbs[i] = numbs[j]; + numbs[j] = t; + } + + private static void reverse(int[] numbs, int i, int j){ + while(i < j){ + swap(numbs, i, j); + i++; + j--; + } + } + + public static void main(String[] args) { + int[] numbs = new int[]{2, 3, 5, 7, 9, 4}; + System.out.print(nextPermutation(numbs)); + } +} diff --git a/arrays/Array_Problem_16_i.java b/arrays/Array_Problem_16_i.java new file mode 100644 index 0000000..d11e855 --- /dev/null +++ b/arrays/Array_Problem_16_i.java @@ -0,0 +1,23 @@ +package arrays; +/* + * Problem Title :-> Count Inversion's in array By Method 1 + */ +public class Array_Problem_16_i { + static int[] a = new int[] {1, 20, 30, 6, 4, 5}; + + static int getInvCount(int n) { + int inv_count = 0; + for(int i = 0; i < n - 1; i++) { + for(int j = i + 1; j < n; j++) { + if(a[i] > a[j]) + inv_count++; + } + } + return inv_count; + } + + // Driver method to test the above function + public static void main(String[] args) { + System.out.println("Number of inversions are " + getInvCount(a.length)); + } +} diff --git a/arrays/Array_Problem_16_ii.java b/arrays/Array_Problem_16_ii.java new file mode 100644 index 0000000..efa1f3e --- /dev/null +++ b/arrays/Array_Problem_16_ii.java @@ -0,0 +1,60 @@ +package arrays; + +import java.util.Arrays; + +/* + * Problem Title :-> Count Inversion's in array (By Method 2 : Using Enhance Merge Sort) + */ +public class Array_Problem_16_ii { + + private static int mergeAndCount(int[] a, int l, int m, int r) { + + // Left sub-array + int[] left = Arrays.copyOfRange(a, l, m + 1); + + // Right sub-array + int[] right = Arrays.copyOfRange(a, m + 1, r + 1); + + int i = 0, j = 0, k = 1, swaps = 0; + + while(i < left.length && j < right.length) { + if(left[i] <= right[j]) + a[k++] = left[i++]; + else { + a[k++] = right[j++]; + swaps += (m + 1) - (l + i); + } + } + + while(i < left.length) + a[k++] = left[i++]; + + while(j < right.length) + a[k++] = right[j++]; + + return swaps; + } + + private static int mergeSortAndCount(int[] a, int l, int r) { + // keeps track of the inversion count at a particular node of the recursion tree + int count = 0; + + if(l < r) { + int m = (l + r)/2; + // Total inversion count = left sub-array count + right sub-array count + merge count + // Left sub-array count + count += mergeSortAndCount(a, l, m); + // right sub-array count + count += mergeSortAndCount(a, m + 1, r); + // Merge count + count += mergeAndCount(a, l, m, r); + } + return count; + } + + public static void main(String[] args) { + int[] a = {1, 20, 6, 4, 5}; + System.out.println(mergeSortAndCount(a, 0, a.length - 1)); + } + +} diff --git a/arrays/Array_Problem_17.java b/arrays/Array_Problem_17.java new file mode 100644 index 0000000..8c8d30a --- /dev/null +++ b/arrays/Array_Problem_17.java @@ -0,0 +1,37 @@ +package arrays; +/* + * Problem Title :-> Best time to buy and Sell stock + */ +public class Array_Problem_17 { + + static int maxProfit(int[] price, int start, int end) { + + // If the stocks can't be bought + if(end <= start) + return 0; + + // Initialize the profit + int profit = 0; + + // The day at which the stock must be bought + for(int i = start; i < end; i++) { + // The day at which the stock must be sold + for(int j = i+1; j <= end; j++) { + // if buying the stock at ith day and selling it at jth day is profitable + if(price[j] > price[i]) { + // Update the current profit + int curr_profit = price[j] - price[i] + maxProfit(price, start, i - 1) + maxProfit(price, j + 1, end); + // Update the maximum profit so far + profit = Math.max(profit, curr_profit); + } + } + } + return profit; + } + // Driver Code + public static void main(String[] args) { + int price[] = {100, 180, 260, 310, 40, 535, 695}; + int n = price.length; + System.out.print(maxProfit(price, 0, n - 1)); + } +} diff --git a/arrays/Array_Problem_18.java b/arrays/Array_Problem_18.java new file mode 100644 index 0000000..1a09b73 --- /dev/null +++ b/arrays/Array_Problem_18.java @@ -0,0 +1,24 @@ +package arrays; + +/* Problem Title :-> find all pairs on integer array whose sum is equal to given number OR Equal_Sum_Pairs_of_Array */ +public class Array_Problem_18 { + + //function to find & print the sum & elements + static void pairs_value(int[] iA, int iN) { + System.out.println("Pairs of elements & their sum : "); + + //loop to iterate & find the pair of elements whose sum is equal + for(int i = 0 ; i < iA.length ; i++) { + for(int j = i + 1 ; j < iA.length ; j++) + //check if the sum of pair is equal, if equal then print the pair of elements & their sum + if(iA[i]+iA[j] == iN) System.out.println(iA[i] + " + " + iA[j] + " = " + iN); + } + } + + //Driver Method + public static void main(String[] args) { + pairs_value(new int[] {2,7,4,-5,11,5,20}, 15); + pairs_value(new int[] {14,-15,9,16,25,45,12,8},30); + } + +} diff --git a/arrays/Array_Problem_19.java b/arrays/Array_Problem_19.java new file mode 100644 index 0000000..2544180 --- /dev/null +++ b/arrays/Array_Problem_19.java @@ -0,0 +1,6 @@ +package arrays; +/* + * Problem Title :-> find common elements In 3 sorted arrays + */ +public class Array_Problem_19 { +} diff --git a/arrays/Array_Problem_2.java b/arrays/Array_Problem_2.java new file mode 100644 index 0000000..63dc567 --- /dev/null +++ b/arrays/Array_Problem_2.java @@ -0,0 +1,55 @@ +package arrays; + +//Java program to find the maximum & minimum element in given or array as user input +public class Array_Problem_2 { +/* Class Pair is used to return two values from getMinMax() */ + static class Pair { + + int min; + int max; + } + + static Pair getMinMax(int arr[], int n) { + Pair minmax = new Pair(); + int i; + + /*If there is only one element then return it as min and max both*/ + if (n == 1) { + minmax.max = arr[0]; + minmax.min = arr[0]; + return minmax; + } + + /* If there are more than one elements, then initialize min + and max*/ + if (arr[0] > arr[1]) { + minmax.max = arr[0]; + minmax.min = arr[1]; + } else { + minmax.max = arr[1]; + minmax.min = arr[0]; + } + + for (i = 2; i < n; i++) { + if (arr[i] > minmax.max) { + minmax.max = arr[i]; + } else if (arr[i] < minmax.min) { + minmax.min = arr[i]; + } + } + + return minmax; + } + + /* Driver program to test above function */ + public static void main(String args[]) { + int arr[] = {1000, 11, 445, 1, 330, 3000}; + int arr_size = 6; + Pair minmax = getMinMax(arr, arr_size); + System.out.printf("\nMinimum element is %d", minmax.min); + System.out.printf("\nMaximum element is %d", minmax.max); + + } + +} + diff --git a/arrays/Array_Problem_20.java b/arrays/Array_Problem_20.java new file mode 100644 index 0000000..97d0f95 --- /dev/null +++ b/arrays/Array_Problem_20.java @@ -0,0 +1,4 @@ +package arrays; +/* Problem Title :-> */ +public class Array_Problem_20 { +} diff --git a/arrays/Array_Problem_21.java b/arrays/Array_Problem_21.java new file mode 100644 index 0000000..edd0ff8 --- /dev/null +++ b/arrays/Array_Problem_21.java @@ -0,0 +1,4 @@ +package arrays; +/* Problem Title :-> */ +public class Array_Problem_21 { +} diff --git a/arrays/Array_Problem_22.java b/arrays/Array_Problem_22.java new file mode 100644 index 0000000..9279cf2 --- /dev/null +++ b/arrays/Array_Problem_22.java @@ -0,0 +1,4 @@ +package arrays; +/* Problem Title :-> */ +public class Array_Problem_22 { +} diff --git a/arrays/Maximum_subarray_problem.java b/arrays/Array_Problem_23.java similarity index 73% rename from arrays/Maximum_subarray_problem.java rename to arrays/Array_Problem_23.java index 724dcf7..52d1b1e 100644 --- a/arrays/Maximum_subarray_problem.java +++ b/arrays/Array_Problem_23.java @@ -1,10 +1,9 @@ package arrays; -public class Maximum_subarray_problem { - // Java program to print largest - // contiguous array sum - - static void maxSubArraySum(int a[], int size) +/* Problem Title :-> Java program for maximum product sub-array problem */ +public class Array_Problem_23 { + + static void maxSubArraySum(int[] a, int size) { int max_so_far = Integer.MIN_VALUE, max_ending_here = 0,start = 0, @@ -27,8 +26,7 @@ static void maxSubArraySum(int a[], int size) s = i + 1; } } - System.out.println("Maximum contiguous sum is " - + max_so_far); + System.out.println("Maximum contiguous sum is " + max_so_far); System.out.println("Starting index " + start); System.out.println("Ending index " + end); } @@ -36,7 +34,7 @@ static void maxSubArraySum(int a[], int size) // Driver code public static void main(String[] args) { - int a[] = { -2, -3, 4, -1, -2, 1, 5, -3 }; + int[] a = { -2, -3, 4, -1, -2, 1, 5, -3 }; int n = a.length; maxSubArraySum(a, n); } diff --git a/arrays/Array_Problem_24.java b/arrays/Array_Problem_24.java new file mode 100644 index 0000000..da2f3c3 --- /dev/null +++ b/arrays/Array_Problem_24.java @@ -0,0 +1,4 @@ +package arrays; +/* Problem Title :-> */ +public class Array_Problem_24 { +} diff --git a/arrays/Array_Problem_25.java b/arrays/Array_Problem_25.java new file mode 100644 index 0000000..4655de6 --- /dev/null +++ b/arrays/Array_Problem_25.java @@ -0,0 +1,4 @@ +package arrays; +/* Problem Title :-> */ +public class Array_Problem_25 { +} diff --git a/arrays/Array_Problem_26.java b/arrays/Array_Problem_26.java new file mode 100644 index 0000000..da75c41 --- /dev/null +++ b/arrays/Array_Problem_26.java @@ -0,0 +1,4 @@ +package arrays; +/* Problem Title :-> */ +public class Array_Problem_26 { +} diff --git a/arrays/Array_Problem_27.java b/arrays/Array_Problem_27.java new file mode 100644 index 0000000..4a5df23 --- /dev/null +++ b/arrays/Array_Problem_27.java @@ -0,0 +1,7 @@ +package arrays; + +/* Problem Title :-> */ +public class Array_Problem_27 { + + +} diff --git a/arrays/Array_Problem_28.java b/arrays/Array_Problem_28.java new file mode 100644 index 0000000..5de85b5 --- /dev/null +++ b/arrays/Array_Problem_28.java @@ -0,0 +1,4 @@ +package arrays; +/* Problem Title :-> */ +public class Array_Problem_28 { +} diff --git a/arrays/Array_Problem_29.java b/arrays/Array_Problem_29.java new file mode 100644 index 0000000..3c1293b --- /dev/null +++ b/arrays/Array_Problem_29.java @@ -0,0 +1,4 @@ +package arrays; +/* Problem Title :-> */ +public class Array_Problem_29 { +} diff --git a/arrays/Array_Problem_3.java b/arrays/Array_Problem_3.java new file mode 100644 index 0000000..0a9c3ad --- /dev/null +++ b/arrays/Array_Problem_3.java @@ -0,0 +1,122 @@ +package arrays; + +import java.util.Arrays; + +/* + * (Find K^the smallest element) + * Given an array array[] and a number K where K is smaller than size of array, + * the task is to find the K^the smallest element in the given array. + * It is given that all array elements are distinct. + */ +public class Array_Problem_3 { + + // int partition(int array[], int l, int r, int k); + + // A simple function to find median of arr[]. This is called + // only for an array of size 5 in this program. + static int findMedian(int arr[], int i,int n) + { + if(i <= n) + Arrays.sort(arr, i, n); // Sort the array + else + Arrays.sort(arr, n, i); + return arr[n/2]; // Return middle element + } + + // Returns k'th smallest element + // in arr[l..r] in worst case + // linear time. ASSUMPTION: ALL + // ELEMENTS IN ARR[] ARE DISTINCT + static int kthSmallest(int arr[], int l, int r, int k) + { + // If k is smaller than + // number of elements in array + if (k > 0 && k <= r - l + 1) + { + int n = r - l + 1 ; // Number of elements in arr[l..r] + + // Divide arr[] in groups of size 5, + // calculate median of every group + // and store it in median[] array. + int i; + + // There will be floor((n+4)/5) groups; + int []median = new int[(n + 4) / 5]; + for (i = 0; i < n/5; i++) + median[i] = findMedian(arr,l + i * 5, 5); + + // For last group with less than 5 elements + if (i*5 < n) + { + median[i] = findMedian(arr,l + i * 5, n % 5); + i++; + } + + // Find median of all medians using recursive call. + // If median[] has only one element, then no need + // of recursive call + int medOfMed = (i == 1)? median[i - 1]: + kthSmallest(median, 0, i - 1, i / 2); + + // Partition the array around a random element and + // get position of pivot element in sorted array + int pos = partition(arr, l, r, medOfMed); + + // If position is same as k + if (pos-l == k - 1) + return arr[pos]; + if (pos-l > k - 1) // If position is more, recur for left + return kthSmallest(arr, l, pos - 1, k); + + // Else recur for right subarray + return kthSmallest(arr, pos + 1, r, k - pos + l - 1); + } + + // If k is more than number of elements in array + return Integer.MAX_VALUE; + } + + static int[] swap(int []arr, int i, int j) + { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + return arr; + } + + // It searches for x in arr[l..r], and + // partitions the array around x. + static int partition(int arr[], int l, + int r, int x) + { + // Search for x in arr[l..r] and move it to end + int i; + for (i = l; i < r; i++) + if (arr[i] == x) + break; + swap(arr, i, r); + + // Standard partition algorithm + i = l; + for (int j = l; j <= r - 1; j++) + { + if (arr[j] <= x) + { + swap(arr, i, j); + i++; + } + } + swap(arr, i, r); + return i; + } + + // Driver code + public static void main(String[] args) + { + int arr[] = {12, 3, 5, 7, 4, 19, 26}; + int n = arr.length, k = 3; + System.out.println("K'th smallest element is " + + kthSmallest(arr, 0, n - 1, k)); + } + +} diff --git a/arrays/Array_Problem_30.java b/arrays/Array_Problem_30.java new file mode 100644 index 0000000..ffc59d0 --- /dev/null +++ b/arrays/Array_Problem_30.java @@ -0,0 +1,37 @@ +package arrays; +/* Problem Title :-> Trapping Rain water problem */ +public class Array_Problem_30 { + //Function to return the maximum water that can be stored + public static int maxWater(int[] a, int n) { + + int res = 0; + + //For every element of the array, except first and last element + for(int i = 1; i < n - 1; i++) { + + //Find max element on its left + int left = a[i]; + for(int j = 0; j < i; j++) { + left = Math.max(left, a[j]); + } + + //Find max element on its left + int right = a[i]; + for(int j = i + 1; j < n; j++) { + right = Math.max(right, a[j]); + } + + //Update maximum water value + res += Math.min(left, right) - a[i]; + } + + return res; + } + //Driver Code + public static void main(String[] args) { + int[] a = {0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1}; + int n = a.length; + System.out.print(maxWater(a, n)); + } + +} diff --git a/arrays/Array_Problem_31.java b/arrays/Array_Problem_31.java new file mode 100644 index 0000000..6c93fbb --- /dev/null +++ b/arrays/Array_Problem_31.java @@ -0,0 +1,43 @@ +package arrays; +/* + * Problem Title :-> Maximum profit by buying and selling a share at-most twice + */ +public class Array_Problem_31 { + + static int maxProfit(int price[], int n) { + + int profit[] = new int[n]; + + for(int i =0; i < n; i++) { + profit[i] = 0; + } + + int max_price = price[n - 1]; + + for(int i = n - 2; i >= 0; i--) { + if(price[i] > max_price) + max_price = price[i]; + + profit[i] = Math.max(profit[i + 1], max_price - price[i]); + } + + int min_price = price[0]; + + for(int i = 1; i < n; i++) { + + if(price[i] < min_price) + min_price = price[i]; + + profit[i] = Math.max(profit[i - 1], profit[i] + (price[i] - min_price)); + } + int result = profit[n - 1]; + return result; + } + + public static void main(String args[]) { + int price[] = {2, 30, 15, 10, 8, 25, 80}; + int n = price.length; + System.out.println("Maximum Profit = " + maxProfit(price, n)); + } + +} diff --git a/arrays/Array_Problem_32.java b/arrays/Array_Problem_32.java new file mode 100644 index 0000000..52738bf --- /dev/null +++ b/arrays/Array_Problem_32.java @@ -0,0 +1,31 @@ +package arrays; + +/* Problem Title :-> find minimum number of operations to make an array palindrome */ +public class Array_Problem_32 { + + static int findMinOps(int[] a, int n){ + int ans = 0; + for(int i = 0, j = n-1; i <= j;){ + if(a[i] == a[j]){ + i++; + j--; + } + else if(a[i] > a[j]){ + j--; + a[j] += a[j+1]; + ans++; + } + else{ + i++; + a[i] += a[i - 1]; + ans++; + } + } + return ans; + } + public static void main(String[] args) { + int[] a = new int[]{1, 4, 5, 9, 1}; + System.out.println("Count of minimum operations is" + findMinOps(a, a.length)); + } + +} diff --git a/arrays/Array_Problem_33.java b/arrays/Array_Problem_33.java new file mode 100644 index 0000000..efa0693 --- /dev/null +++ b/arrays/Array_Problem_33.java @@ -0,0 +1,43 @@ +package arrays; + +/* Problem Title :-> Three way partitioning of an array around a given value */ +public class Array_Problem_33 { + + // partition a[0..n-1] around [lowVal, highVal] + public static void threeWayPartition(int[] a, int lowVal, int highVal) { + int n = a.length; + // Initialize ext available positions for smaller (than range) & greater element. + int start = 0, end = n - 1; + // Traverse elements from left + for(int i = 0; i <= end;) { + // If current element is smaller than range, put it on next available smaller position. + if(a[i] < lowVal) { + int temp = a[start]; + a[start] = a[i]; + a[i] = temp; + start++; + i++; + } + + // If current element is greater than range, put it on next available greater position. + else if(a[i] > highVal) { + int temp = a[end]; + a[end] = a[i]; + a[i] = temp; + end--; + } + + else i++; + } + } + + public static void main(String[] args) { + int[] a = {1, 14, 5, 20, 4, 2, 54, 20, 87, 98, 3, 1, 32}; + threeWayPartition(a, 10, 20); + System.out.println("Modified Array"); + for(int i = 0; i < a.length; i++) { + System.out.println(a[i] + " "); + } + } + +} diff --git a/arrays/Array_Problem_34.java b/arrays/Array_Problem_34.java new file mode 100644 index 0000000..6d5d56b --- /dev/null +++ b/arrays/Array_Problem_34.java @@ -0,0 +1,41 @@ +package arrays; + +/* Problem Title :-> Minimum swaps required bring elements less equal K together */ +public class Array_Problem_34 { + + static int minSwap(int[] a, int n, int k){ + int count = 0; + for (int i = 0; i < n; ++i){ + if (a[i] <= k) + ++count; + } + + int bad = 0; + for (int i = 0; i < count; ++i){ + if (a[i] > k) + ++bad; + } + int ans = bad; + for (int i = 0, j = count; j < n; ++i, ++j ){ + if(a[i] > k) + --bad; + if(a[j] > k) + ++bad; + ans = Math.min(ans, bad); + } + return ans; + } + + public static void main(String[] args) { + int[] a = {2, 1, 5, 6, 3}; + int n = a.length; + int k = 3; + System.out.print(minSwap(a, n, k) + "\n"); + + int[] a1 = {2, 7, 9, 5, 8, 7, 4}; + n = a1.length; + k = 5; + System.out.print(minSwap(a1, n, k)); + } + +} diff --git a/arrays/Array_Problem_35.java b/arrays/Array_Problem_35.java new file mode 100644 index 0000000..56016ce --- /dev/null +++ b/arrays/Array_Problem_35.java @@ -0,0 +1,33 @@ +package arrays; +/* Problem Title :-> Minimum no. of operations required to make an array palindrome */ +public class Array_Problem_35 { + + static int findMinOps(int[] a, int n) { + + //Initialize result + int ans = 0; + + //Start from two corners + for(int i=0,j=n-1;i<=j;) { + + if(a[i] == a[j]) { + i++; + j--; + }else if(a[i] > a[j]) { + j--; + a[j] += a[j+1]; + ans++; + }else { + i++; + a[i] += a[i-1]; + ans++; + } + } + return ans; + } + + public static void main(String[] args) { + int[] a = new int[] {1,2,3,4,5,6,7,8,9,10}; + System.out.println("Count of minimum operations is " + findMinOps(a , a.length)); + } +} diff --git a/arrays/Array_Problem_36.java b/arrays/Array_Problem_36.java new file mode 100644 index 0000000..ee47a7c --- /dev/null +++ b/arrays/Array_Problem_36.java @@ -0,0 +1,67 @@ +package arrays; +/* Problem Title :-> Median of 2 sorted arrays of equal size */ +public class Array_Problem_36 { + + //function to calculate median + static int getMedian(int[] a1, int[] a2, int n) { + + int i = 0; + int j = 0; + int count; + int m1 = -1, m2 = -1; + + /* Since there are 2n elements , + * median will be average of elements at index n-1 + * & n in the array obtained after merging a1[] & a2[]*/ + + for(count = 0; count <= n; count++) { + + /* Below is to handle case where all elements of a1[] are + * smaller than smallest(or first) element of a2[] */ + if(i == n) { + m1 = m2; + m2 = a2[0]; + break; + } + + /* Below is to handle case where all elements of a2[] + * are smaller than smaller than + * smallest(or first) element of a1[]*/ + else if(j == n) { + m1 = m2; + m2 = a1[0]; + break; + } + + /* equals sign because if two arrays have some common elements*/ + if(a1[i] <= a2[j]) { + /* Store the previous median */ + m1 = m2; + m2 = a1[i]; + i++; + } + + else { + /* Store the previous median */ + m1 = m2; + m2 = a2[j]; + j++; + } + } + + return (m1 + m2)/2; + } + + /* Driver program to test above function */ + @SuppressWarnings("unused") + public static void main(String[] args) { + + int[] a1 = {1, 12, 15, 26, 38}; + int[] a2 = {2, 13, 17, 30, 45}; + + int n1 = a1.length, n2 = a2.length; + + System.out.println("Median is " + getMedian(a1, a2, n1)); + + } +} diff --git a/arrays/Array_Problem_37.java b/arrays/Array_Problem_37.java new file mode 100644 index 0000000..9373662 --- /dev/null +++ b/arrays/Array_Problem_37.java @@ -0,0 +1,65 @@ +package arrays; +/* Problem Title :-> Median of 2 sorted arrays of different size */ +public class Array_Problem_37 { + static int getMedian(int[] a1, int[] a2, int n, int m) { + + //Current index of input array a1[] + int i = 0; + //Current index of input array a2[] + int j = 0; + int count; + int m1 = -1, m2 = -1; + /* + * Since there are (n + m) elements , + * There are following two cases :-> + * if n + m is odd then the middle index is median + * i.e. (m + n)/2 + */ + if ((m + n) % 2 == 1){ + for (count = 0; count <= (n + m) / 2; count++){ + if(i != n && j != m){ + m1 = (a1[i] > a2[j]) ? a2[j++] : a1[i++]; + } + else if(i < n) + m1 = a1[i++]; + // for case when j < m. + else + m1 = a2[j++]; + } + return m1; + } + /* + * median will be average of elements + * at index (( m + n) / 2 - 1) and (m + n) / 2 + * in the array obtained after merging a1 and a2. + */ + else{ + for (count = 0; count <= (n + m) / 2; count++){ + m2 = m1; + if (i != n && j != m) + m1 = (a1[i] > a2[j]) ? a2[j++] : a1[i++]; + + else if(i < n) + m1 = a1[i++]; + + // for case when j < m. + else + m1 = a2[j++]; + } + return (m1 + m2) / 2; + } + } + + /* Driver program to test above function */ + public static void main(String[] args) { + + int[] a1 = {900}; + int[] a2 = {5, 8, 10, 20}; + + int n1 = a1.length; + int n2 = a2.length; + + System.out.println("Median is " + getMedian(a1, a2, n1, n2)); + + } +} diff --git a/arrays/Array_Problem_4_Approach1.java b/arrays/Array_Problem_4_Approach1.java new file mode 100644 index 0000000..b1e4e48 --- /dev/null +++ b/arrays/Array_Problem_4_Approach1.java @@ -0,0 +1,63 @@ +package arrays; +import java.io.*; + +/* + * Java program to solve that, + * Given an array A of size N containing 0s, 1s, and 2s; + * you need to sort the array in ascending order without using any sorting algorithm + */ + +@SuppressWarnings("unused") +public class Array_Problem_4_Approach1 { + + // Sort the input array, the array is assumed to + // have values in {0, 1, 2} + static void sort012(int a[], int arr_size) + { + int lo = 0; + int hi = arr_size - 1; + int mid = 0, temp = 0; + while (mid <= hi) { + switch (a[mid]) { + case 0: { + temp = a[lo]; + a[lo] = a[mid]; + a[mid] = temp; + lo++; + mid++; + break; + } + case 1: + mid++; + break; + case 2: { + temp = a[mid]; + a[mid] = a[hi]; + a[hi] = temp; + hi--; + break; + } + } + } + } + + /* Utility function to print array arr[] */ + static void printArray(int arr[], int arr_size) + { + int i; + for (i = 0; i < arr_size; i++) + System.out.print(arr[i] + " "); + System.out.println(""); + } + + /*Driver function to check for above functions*/ + public static void main(String[] args) + { + int arr[] = { 0, 1, 1, 0, 1, 2, 1, 2, 0, 0, 0, 1 }; + int arr_size = arr.length; + sort012(arr, arr_size); + System.out.println("Array after seggregation "); + printArray(arr, arr_size); + } + +} diff --git a/arrays/Sort_an_array_of_0s_1s_2s_without_using_extra_space_or_sorting_algo.java b/arrays/Array_Problem_4_Approach2.java similarity index 76% rename from arrays/Sort_an_array_of_0s_1s_2s_without_using_extra_space_or_sorting_algo.java rename to arrays/Array_Problem_4_Approach2.java index 4e47013..1116d1d 100644 --- a/arrays/Sort_an_array_of_0s_1s_2s_without_using_extra_space_or_sorting_algo.java +++ b/arrays/Array_Problem_4_Approach2.java @@ -1,7 +1,12 @@ package arrays; import java.util.Arrays; -public class Sort_an_array_of_0s_1s_2s_without_using_extra_space_or_sorting_algo { +/* + * Sort_an_array_of_0s_1s_2s_without_using_extra_space_or_sorting_algo + */ + +public class Array_Problem_4_Approach2 { + static int arr1[] = new int[]{1, 5, 9, 10, 15, 20}; static int arr2[] = new int[]{2, 3, 8, 13}; @@ -10,8 +15,11 @@ static void merge(int m, int n) // Iterate through all elements of ar2[] starting from to the last element for (int i=n-1; i>=0; i--) { - /* Find the smallest element greater than ar2[i]. Move all elements one position ahead till the smallest greater - element is not found */ + + /* Find the smallest element greater than ar2[i]. + * Move all elements one position ahead, + * till the smallest greater element is not found + */ int j, last = arr1[m-1]; for (j=m-2; j >= 0 && arr1[j] > arr2[i]; j--) @@ -21,7 +29,6 @@ static void merge(int m, int n) if (j != m-2 || last > arr2[i]) { arr1[j+1] = arr2[i]; arr2[i] = last; - } } } @@ -30,8 +37,10 @@ static void merge(int m, int n) public static void main1(String[] args) { merge(arr1.length,arr2.length); + System.out.print("After Merging nFirst Array: "); System.out.println(Arrays.toString(arr1)); + System.out.print("Second Array: "); System.out.println(Arrays.toString(arr2)); } diff --git a/arrays/Array_Problem_5.java b/arrays/Array_Problem_5.java new file mode 100644 index 0000000..d2a4008 --- /dev/null +++ b/arrays/Array_Problem_5.java @@ -0,0 +1,41 @@ +package arrays; + +/* + * Move all the negative elements to one side of the array + */ + +public class Array_Problem_5 { + + static void rearrange(int arr[], int n) + { + int j = 0, temp; + for (int i = 0; i < n; i++) { + if (arr[i] < 0) { + if (i != j) { + temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + j++; + } + } + } + + // A utility function to print an array + static void printArray(int arr[], int n) + { + for (int i = 0; i < n; i++) + System.out.print(arr[i] + " "); + } + + //Driver Method + public static void main(String[] args) { + int arr[] = { -1, 2, -3, 4, 5, 6, -7, 8, 9 , -47}; + int n = arr.length; + + rearrange(arr, n); + printArray(arr, n); + + } + +} diff --git a/arrays/Array_Problem_6.java b/arrays/Array_Problem_6.java new file mode 100644 index 0000000..5552ee1 --- /dev/null +++ b/arrays/Array_Problem_6.java @@ -0,0 +1,118 @@ +package arrays; + +// A Java program to print union and intersection of two unsorted arrays +import java.util.Arrays; + +/* + * Find the Union and Intersection of the two sorted arrays. + */ + +public class Array_Problem_6 { + + + void printUnion(int arr1[], int arr2[], int m, int n) + { + // Before finding union, make sure arr1[0..m-1] + // is smaller + if (m > n) { + int tempp[] = arr1; + arr1 = arr2; + arr2 = tempp; + + int temp = m; + m = n; + n = temp; + } + + // Now arr1[] is smaller + // Sort the first array and print its elements + // (these two steps can be swapped as order in + // output is not important) + Arrays.sort(arr1); + for (int i = 0; i < m; i++) + System.out.print(arr1[i] + " "); + + // Search every element of bigger array in smaller + // array and print the element if not found + for (int i = 0; i < n; i++) { + if (binarySearch(arr1, 0, m - 1, arr2[i]) == -1) + System.out.print(arr2[i] + " "); + } + } + + // Prints intersection of arr1[0..m-1] and arr2[0..n-1] + void printIntersection(int arr1[], int arr2[], int m, + int n) + { + // Before finding intersection, make sure + // arr1[0..m-1] is smaller + if (m > n) { + int tempp[] = arr1; + arr1 = arr2; + arr2 = tempp; + + int temp = m; + m = n; + n = temp; + } + + // Now arr1[] is smaller + // Sort smaller array arr1[0..m-1] + Arrays.sort(arr1); + + // Search every element of bigger array in smaller + // array and print the element if found + for (int i = 0; i < n; i++) { + if (binarySearch(arr1, 0, m - 1, arr2[i]) != -1) + System.out.print(arr2[i] + " "); + } + } + + // A recursive binary search function. It returns + // location of x in given array arr[l..r] is present, + // otherwise -1 + int binarySearch(int arr[], int l, int r, int x) + { + if (r >= l) { + int mid = l + (r - l) / 2; + + // If the element is present at the middle + // itself + if (arr[mid] == x) + return mid; + + // If element is smaller than mid, then it can + // only be present in left subarray + if (arr[mid] > x) + return binarySearch(arr, l, mid - 1, x); + + // Else the element can only be present in right + // subarray + return binarySearch(arr, mid + 1, r, x); + } + + // We reach here when element is not present in + // array + return -1; + } + + // Driver code + public static void main(String[] args) + { + Array_Problem_6 u_i= new Array_Problem_6(); + + int arr1[] = { 7, 1, 5, 2, 3, 6 }; + int arr2[] = { 3, 8, 6, 20, 7 }; + int m = arr1.length; + int n = arr2.length; + + // Function call + System.out.println("Union of two arrays is "); + u_i.printUnion(arr1, arr2, m, n); + System.out.println(""); + System.out.println( + "Intersection of two arrays is "); + u_i.printIntersection(arr1, arr2, m, n); + } + } + diff --git a/arrays/RotateArray.java b/arrays/Array_Problem_7.java similarity index 82% rename from arrays/RotateArray.java rename to arrays/Array_Problem_7.java index 00691e4..948018d 100644 --- a/arrays/RotateArray.java +++ b/arrays/Array_Problem_7.java @@ -1,6 +1,10 @@ package arrays; -public class RotateArray { +/* + * Write a program to cyclically rotate an array by one. + */ + +public class Array_Problem_7 { //function to rotate the elements of an array @@ -29,7 +33,7 @@ void printArray(int a[],int n) { // driver method of the program public static void main(String[] args) { - RotateArray rotate = new RotateArray(); + Array_Problem_7 rotate = new Array_Problem_7(); int a[] = {2,4,6,8,10,12,14,16,18,20}; rotate.rotateL(a, 3, 10); diff --git a/arrays/Array_Problem_8.java b/arrays/Array_Problem_8.java new file mode 100644 index 0000000..eaf505d --- /dev/null +++ b/arrays/Array_Problem_8.java @@ -0,0 +1,32 @@ +package arrays; + +/* + * find Largest sum contiguous Sub-array + */ + +public class Array_Problem_8 { + + public static void main (String[] args) + { + int [] a = {-2, -3, 4, -1, -2, 1, 5, -3}; + System.out.println("Maximum contiguous sum is " + maxSubArraySum(a)); + } + + static int maxSubArraySum(int a[]) + { + int size = a.length; + int max_so_far = Integer.MIN_VALUE, max_ending_here = 0; + + for (int i = 0; i < size; i++) + { + max_ending_here = max_ending_here + a[i]; + if (max_so_far < max_ending_here) + max_so_far = max_ending_here; + + if (max_ending_here < 0) + max_ending_here = 0; + } + return max_so_far; + } + +} diff --git a/arrays/Array_Problem_9.java b/arrays/Array_Problem_9.java new file mode 100644 index 0000000..f1f646f --- /dev/null +++ b/arrays/Array_Problem_9.java @@ -0,0 +1,65 @@ +package arrays; +import java.util.*; + +//Minimize the maximum difference between heights [V.IMP] +public class Array_Problem_9 { + + // Modifies the array by subtracting/adding k to every element such that the difference + // between maximum and minimum is minimized + static int getMinDiff(int arr[], int n, int k) + { + if (n == 1) + return 0; + + // Sort all elements + Arrays.sort(arr); + + // Initialize result + int ans = arr[n-1] - arr[0]; + + // Handle corner elements + int small = arr[0] + k; + int big = arr[n-1] - k; + int temp = 0; + + if (small > big) + { + temp = small; + small = big; + big = temp; + } + + // Traverse middle elements + for (int i = 1; i < n-1; i ++) + { + int subtract = arr[i] - k; + int add = arr[i] + k; + + // If both subtraction and addition + // do not change diff + if (subtract >= small || add <= big) + continue; + + // Either subtraction causes a smaller number or addition causes a greater number. + // Update small or big using greedy approach (If big - subtract causes smaller difference , + // update small Else update big) + if (big - subtract <= add - small) + small = subtract; + else + big = add; + } + + return Math.min(ans, big - small); + } + + // Driver function to test the above function + public static void main(String[] args) + { + int arr[] = {4, 6}; + int n = arr.length; + int k = 10; + System.out.println("Maximum difference is "+ + getMinDiff(arr, n, k)); + } + +} diff --git a/arrays/Array_of_objects.java b/arrays/Array_of_objects.java new file mode 100644 index 0000000..adb9674 --- /dev/null +++ b/arrays/Array_of_objects.java @@ -0,0 +1,44 @@ +package arrays; + +//Program to demonstrate the array of objects + +//Cricketer class +class Cricketer{ + public int batting_position; + public String name; + + Cricketer(int batting_position, String name) + { + this.batting_position = batting_position; + this.name = name; + } +} + +//Driver Class +public class Array_of_objects { + + //Driver Method + public static void main(String[] args) { + + // Declaring or making the array of type Cricketer , which is known as Array of Objects + Cricketer[] arr; + // array capacity is of storing 5 elements in it. + arr = new Cricketer[11]; + + arr[0 ] = new Cricketer(1, "Rohit Sharma(W.C)"); + arr[1 ] = new Cricketer(2, "Shikhar Dhawan"); + arr[2 ] = new Cricketer(3, "Virat Kohli(C.)"); + arr[3 ] = new Cricketer(4, "K.L Rahul"); + arr[4 ] = new Cricketer(5, "Rishabh Pant(W.K)"); + arr[5 ] = new Cricketer(6, "Hardik Pandaya"); + arr[6 ] = new Cricketer(7, "Bhuvaneshwar Kumar"); + arr[7 ] = new Cricketer(8, "Mohammed Shami"); + arr[8 ] = new Cricketer(9, "Jaspreet Bumrah"); + arr[9 ] = new Cricketer(10, "Yuzvendre Chahal"); + arr[10] = new Cricketer(11, "Kuldeep Yadav"); + + + for(int i = 0 ; i < arr.length ; i++) + System.out.println("Element at index " + i + " : " + "Batting Position: " + arr[i].batting_position + " " + "Player Name: " + arr[i].name); + } +} diff --git a/arrays/Candy_Distribution_Problem.java b/arrays/Candy_Distribution_Problem.java new file mode 100644 index 0000000..806cd6d --- /dev/null +++ b/arrays/Candy_Distribution_Problem.java @@ -0,0 +1,49 @@ +package arrays; +import java.util.*; + +//Language: Java +//Time Complexity: O(n) 3 Linear traversals. +//Space Complexity: O(n) Array of candies. + +public class Candy_Distribution_Problem{ + + public int candy(int[] ratings) { + if (ratings.length < 2) + return ratings.length; + + + int[] candies = new int[ratings.length]; + Arrays.fill(candies, 1); + + // ** Step 1: Forward ** + for (int i=0; i= ratings[i+1]) { + continue; + } + candies[i+1] = candies[i] + 1; + } + + // ** Step 2: Backward ** + for (int i=ratings.length-1; i>0; i--) { + if (ratings[i] >= ratings[i-1]) { + continue; + } + candies[i-1] = Math.max(candies[i] + 1, candies[i-1]); + } + + // ** Step 3: Count Candies ** + int count = 0; + for (int i=0; i=0) m[Math.abs(m[i])] = -m[Math.abs(m[i])]; - else System.out.print(Math.abs(m[i]) + " "); - } - } - - //Driver Method - public static void main(String[] args) { - - FIndDublicate dublicate= new FIndDublicate(); // Making an object of FindDuplicate class - - int m[] = {1,2,3,1,3,6,6}; // Putting or declare values in or to array - int m_size = m.length; // variables which store size or length of array - - dublicate.printRepeating(m,m_size); // calling above function to pass value in it to print repeating elements - - } - -} - diff --git a/arrays/FRE.java b/arrays/FRE.java new file mode 100644 index 0000000..5813ff5 --- /dev/null +++ b/arrays/FRE.java @@ -0,0 +1,40 @@ +package arrays; +import java.util.*; + +//Java Program for First Repeating Element +public class FRE { + + public static void main(String[] args) { + + @SuppressWarnings("resource") + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + + int a[] = new int[n]; + for(int i = 0; i < n; i++) + a[i] = sc.nextInt(); + + int N = (int) (1e6+2); + + //Array Input in Java + int idx[] = new int[N]; + for (int i = 0; i < N; i++) + idx[i] = -1; + + int minidx = Integer.MAX_VALUE; + + for (int i = 0; i < n; i++){ + if(idx[a[i]] != -1) + minidx = Math.min(minidx, idx[a[i]]); + else + idx[a[i]] = i; + } + + if(minidx == Integer.MAX_VALUE) + System.out.println("-1"); + + else + System.out.println(minidx + 1); + } + +} diff --git a/arrays/KadanesAlgorithm.java b/arrays/KadanesAlgorithm.java new file mode 100644 index 0000000..de15f21 --- /dev/null +++ b/arrays/KadanesAlgorithm.java @@ -0,0 +1,31 @@ +package arrays; +import java.util.*; + +/* + * Kadane's Algorithm to find the maxSubarray Sum in O(n)[Linear Time Complexity] + */ +public class KadanesAlgorithm { + + public static void main(String[] args) { + @SuppressWarnings("resource") + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int a[]=new int[n]; + + for(int i=0;i= 0 && x < N && y >= 0 + && y < N && maze[x][y] == 1); + } + + /* + * This function solves the Maze problem using Backtracking. + * It mainly uses solvemazeUtil() function to solve the problem. + * It returns false if no path is possible, otherwise return true & + * prints the path in the form of 1s. + * Please note :-> that there may be more than one solutions, + * this function prints one of the feasible solutions. + */ + boolean solveMaze(int maze[][]){ + int sol[][] = new int[N][N]; + + if(solveMazeUtil(maze, 0, 0, sol) == false) { + System.out.print("Solution doesn't exist"); + return false; + } + printSolution(sol); + return true; + } + + /* + * A recursive utility function to solve Maze problem + */ + boolean solveMazeUtil( int maze[][] , int x , int y , int sol[][]) { + + //if (x , y is goal) than return true + if(x == N - 1 && y == N-1 && maze[x][y] == 1) { + sol[x][y] = 1; + return true; + } + + //Check if maze[x][y] is valid + if(isSafe(maze, x, y) == true) { + //mark x, y as part of solution path + sol[x][y] = 1; + + //if moving in x direction doesn't give solution then Move down in y direction + if(solveMazeUtil(maze , x+1 , y , sol)) + return true; + /* + * If none of the above movements works then BACKTRACK: remove mark of x, y as part of solution path + */ + if(solveMazeUtil(maze , x , y+1 , sol)) + return true; + + sol[x][y] = 0; + return false; + } + + return false; + } + + //Driver Method + public static void main(String[] args) { + + Rat_In_A_Maze rat = new Rat_In_A_Maze(); + int maze[][] = {{ 1, 1, 1, 0 }, + { 1, 1, 1, 1 }, + { 1, 1, 1, 1 }, + { 1, 1, 1, 1 } }; + + N = maze.length; + rat.solveMaze(maze); + } //end of main +} //end of class diff --git a/basicProblems/Armstrong_Number.java b/basicProblems/Armstrong_Number.java new file mode 100644 index 0000000..5230826 --- /dev/null +++ b/basicProblems/Armstrong_Number.java @@ -0,0 +1,26 @@ +package basicProblems; +import java.util.*; + +public class Armstrong_Number { + + @SuppressWarnings("resource") + public static void main(String[] args) { + + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + + int sum = 0; + int original_no = n; + + while(n>0) { + int last_digit = n % 10; + sum += Math.pow(last_digit,3); + n=n/10; + } + + if(sum == original_no) System.out.println("Armstrong number"); + else System.out.println("Not Armstrong"); + + } + +} diff --git a/basicProblems/Factorial.class b/basicProblems/Factorial.class new file mode 100644 index 0000000000000000000000000000000000000000..89634d6bd6e83a204a8e7d37834186fbd03e9f1a GIT binary patch literal 1124 zcmaJ=O-~b16g_V`?UZr&wtQH@f`A2)svxMXENnt-0!mV%F|J;R2MnFgG&8S6*7_sd zx^gWGNHFmS_;Xyk5bv8-DQV*@?tLHko_o%{Z+`qf{|;ac>n2R342<+(6k{edj4N|P zZPP;(a?3;pQwF9D+-67=9M6&K46*F|YX-gO?+S+gO~(^28?}lEc6i056TQYAk6|SH zZu5{I@tn)O{ajfFj<=sziM?gX?dle7Vct^Vc@y%%TNZqz9r;=zZ>=^a4(4^3pw03 z@W8@DEHjK&c<9*MflsV!VeVg50=VS;s&Xi7$uQhS%$30MaVSNNK~vgOP34ZCD|z*X zB=LgR@(g3yt{18+h9}<3l1HVey(O}KgVvWo+tk0mKqgl3h#Iv=jmr3Y8J2Ov3?oG~ zUKK^(v$=fZ$OBr1l6x{#!zh*JJI6t~BB?~Q4WG!=RW(;BX)(S!L<6g;nNJyJE?ebz zM}AebCf#Jw?CG(A0zIEi->)|63|2`^ujukH6h!S)dxaK8b8auVx9f^qXY{30 z`a$8Ne(~kv=Lr%M>2nysDUu3Vi;$<0jPNz`y@WqRWYR<@Lw=5`EmOTgibz4bAQLw* k#0+Tky6}sxVi=B~uHy-Llc=pBkH;9tP1+}EuM|!G0c+YBD*ylh literal 0 HcmV?d00001 diff --git a/basicProblems/Factorial.java b/basicProblems/Factorial.java index f4a4355..c73f54c 100644 --- a/basicProblems/Factorial.java +++ b/basicProblems/Factorial.java @@ -1,17 +1,18 @@ package basicProblems; import java.util.*; + public class Factorial { public static void main(String[] args) { + int fact=1; - @SuppressWarnings("resource") - Scanner sc = new Scanner(System.in); + @SuppressWarnings("resource") + Scanner sc = new Scanner(System.in); int n = sc.nextInt(); - for(int i = n ; i>=1;i--) { + for(int i = n ; i >= 1 ; i--) { fact = fact*i; } - System.out.println("fact of " + n + " is " + fact ); } } diff --git a/basicProblems/Fibonacci_Series.java b/basicProblems/Fibonacci_Series.java index 2772bc1..f1fb26d 100644 --- a/basicProblems/Fibonacci_Series.java +++ b/basicProblems/Fibonacci_Series.java @@ -1,5 +1,6 @@ package basicProblems; import java.util.*; + public class Fibonacci_Series { public static void main(String[] args) { @@ -9,12 +10,13 @@ public static void main(String[] args) { int n = sc.nextInt(); int a=0,b=1; - System.out.println(a + " "); - System.out.println(b + " "); + System.out.println("a = " + a + " "); + System.out.println("b = " + b + " "); + System.out.println("Fibonacci Series:"); for(int i=0;i 0) { + int rem = n % 10; + System.out.print(rem); + n = n/10; + } + + } + +} diff --git a/basicProblems/Reverse_Given_number.java b/basicProblems/Reverse_Given_number.java new file mode 100644 index 0000000..f3c5371 --- /dev/null +++ b/basicProblems/Reverse_Given_number.java @@ -0,0 +1,22 @@ +package basicProblems; + +import java.util.*; +public class Reverse_Given_number { + + @SuppressWarnings("resource") + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + + int reverse=0; + + while(n>0) { + int last_digit = n % 10; + reverse = reverse*10 + last_digit; + n = n/10; + } + + System.out.println(reverse); + } + +} diff --git a/basicProblems/Series_Sum_1.java b/basicProblems/Series_Sum_1.java index ed57857..8d0b704 100644 --- a/basicProblems/Series_Sum_1.java +++ b/basicProblems/Series_Sum_1.java @@ -1,18 +1,20 @@ package basicProblems; import java.util.*; + public class Series_Sum_1 { public static void main(String[] args) { + //taking user input @SuppressWarnings("resource") Scanner sc = new Scanner(System.in); int n = sc.nextInt(); float result = 0; - for(float i=1;i<=n;i++) { + for(float i=1;i<=n;i++) result +=1/i; - } + System.out.println(result); } diff --git a/basicProblems/Swap_two_numbers.java b/basicProblems/Swap_two_numbers.java index 90bebb2..066a354 100644 --- a/basicProblems/Swap_two_numbers.java +++ b/basicProblems/Swap_two_numbers.java @@ -6,17 +6,12 @@ public static void main(String[] args) { @SuppressWarnings("resource") Scanner sc = new Scanner(System.in); - int a = sc.nextInt(); - int b = sc.nextInt(); - int swap; + int a = sc.nextInt() , b = sc.nextInt() , swap; + System.out.println( " elements before swapping " + a + " " + b ); - - swap = a; - a = b; - b= swap; - + swap = a; + a = b; + b = swap; System.out.println( " elements after swapping " + a + " " + b ); - - } } diff --git a/basicProblems/Swapping_2.java b/basicProblems/Swapping_2.java new file mode 100644 index 0000000..dd56abc --- /dev/null +++ b/basicProblems/Swapping_2.java @@ -0,0 +1,24 @@ +package basicProblems; + +/* + * swap two given numbers without using third variable + */ + +public class Swapping_2 { + + public static void main(String[] args) { + + int a = 20; + int b = 40; + + System.out.println("Number's before swapping: " + "a = " + a + "," + " b =" + " " + b); + + a = a + b; + b = a - b; + a = a - b; + + System.out.println("Number's after swapping: " + "a = " + a + "," + " b =" + " " + b); + + } + +} diff --git a/dataStructure/ArrayDequeDemo.java b/basic_idea_of_DS/ArrayDequeDemo.java similarity index 93% rename from dataStructure/ArrayDequeDemo.java rename to basic_idea_of_DS/ArrayDequeDemo.java index 15aaa23..91718cb 100644 --- a/dataStructure/ArrayDequeDemo.java +++ b/basic_idea_of_DS/ArrayDequeDemo.java @@ -1,4 +1,4 @@ -package dataStructure; +package basic_idea_of_DS; import java.util.*; public class ArrayDequeDemo { diff --git a/dataStructure/ArrayListDemo.java b/basic_idea_of_DS/ArrayListDemo.java similarity index 96% rename from dataStructure/ArrayListDemo.java rename to basic_idea_of_DS/ArrayListDemo.java index f0aae7e..eaa79d5 100644 --- a/dataStructure/ArrayListDemo.java +++ b/basic_idea_of_DS/ArrayListDemo.java @@ -1,4 +1,4 @@ -package dataStructure; +package basic_idea_of_DS; import java.util.ArrayList; public class ArrayListDemo { diff --git a/basic_idea_of_DS/Graph.java b/basic_idea_of_DS/Graph.java new file mode 100644 index 0000000..91bd1e8 --- /dev/null +++ b/basic_idea_of_DS/Graph.java @@ -0,0 +1,41 @@ +package basic_idea_of_DS; +import java.util.*; + +public class Graph { + + private LinkedList adj[]; + + @SuppressWarnings("unchecked") + public Graph(int v) { + //array of Linked List + adj = new LinkedList[v]; + + for(int i=0;i(); + } + } + + public void addEdge(int source, int destination) { + adj[source].add(destination); + adj[destination].add(source); + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + + System.out.println("Enter number of vertices and edges"); + int v = sc.nextInt(); + int e = sc.nextInt(); + + Graph graph = new Graph(v); + System.out.println("Enter " + e + " edges"); + + for(int i=0;i0) { System.out.println(" tick " + n); - n--; // post substraction operator - } - + // post subtraction operator + n--; + } } - } diff --git a/binaryTree/BT_Problem_01.java b/binaryTree/BT_Problem_01.java new file mode 100644 index 0000000..53031b4 --- /dev/null +++ b/binaryTree/BT_Problem_01.java @@ -0,0 +1,50 @@ +package binaryTree; +import java.util.*; + +// Find Level order traversal of binary tree +class Node{ + int data; + int hd; + Node left, right; + + public Node(int item) { + data = item; + hd = Integer.MAX_VALUE; + left = right = null; + } +} +public class BT_Problem_01 { + + Node root; + + void printLevelOrder() { + Queue queue = new LinkedList<>(); + queue.add(root); + + while(!queue.isEmpty()) { + + Node tempNode = queue.poll(); + System.out.print(tempNode.data + " "); + + if(tempNode.left != null) + queue.add(tempNode.left); + + if(tempNode.right != null) + queue.add(tempNode.right); + } + } + public static void main(String[] args) { + + BT_Problem_01 tree_level = new BT_Problem_01(); + + tree_level.root = new Node(1); + tree_level.root.left = new Node(2); + tree_level.root.right = new Node(3); + tree_level.root.left.left = new Node(4); + tree_level.root.left.right = new Node(5); + + System.out.println("Level order traversal of binary tree is - "); + tree_level.printLevelOrder(); + } + +} diff --git a/binaryTree/BT_Problem_02.java b/binaryTree/BT_Problem_02.java new file mode 100644 index 0000000..e5eaae4 --- /dev/null +++ b/binaryTree/BT_Problem_02.java @@ -0,0 +1,92 @@ +package binaryTree; +import java.util.*; + +// Find Reverse Level Order traversal + +public class BT_Problem_02 { + + Node root; + + /* Given a binary tree, print its nodes in reverse level order */ + @SuppressWarnings({ "unchecked", "rawtypes" }) + void reverseLevelOrder(Node node) { + + //Logic for O(n^2) Time Complexity approach +// int h = height(node); +// int i; +// for(i = h; i >= 1; i--) +// printGivenLevel(node, i); + + Stack S = new Stack(); + Queue Q = new LinkedList(); + Q.add(node); + + // Do something like normal level order traversal order. + // Following are the differences with normal level order traversal: + // 1. Instead of printing a node, we push the node to stack + // 2. Right subtree is visited before left subtree. + while(Q.isEmpty() == false) { + + //Dequeue node and make it root + node = Q.peek(); + Q.remove(); + S.push(node); + + //Enqueue right child + if(node.right != null) + Q.add(node.right); //Node RIGHT CHILD IS ENQUEUED BEFORE LEFT + + // Enqueue left child + if(node.left != null) + Q.add(node.left); + } + + // Now pop all items from stack one by one and print them + while(S.empty() == false) { + node = S.peek(); + System.out.print(node.data + " "); + S.pop(); + } + + } + +// void printGivenLevel(Node node, int level) { +// if(node == null) +// return; +// if(level == 1) +// System.out.print(node.data + " "); +// else if(level > 1) { +// printGivenLevel(node.left, level - 1); +// printGivenLevel(node.right, level - 1); +// } +// } +// +// int height(Node node) { +// if(node == null) +// return 0; +// else { +// int lheight = height(node.left); +// int rheight = height(node.right); +// +// if(lheight > rheight) +// return (lheight + 1); +// else +// return (rheight + 1); +// } +// } +// + public static void main(String[] args) { + + BT_Problem_02 tree = new BT_Problem_02(); + + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + + System.out.println("Level Order traversal of binary tree is : "); + + tree.reverseLevelOrder(tree.root); + } +} diff --git a/binaryTree/BT_Problem_03.java b/binaryTree/BT_Problem_03.java new file mode 100644 index 0000000..200411c --- /dev/null +++ b/binaryTree/BT_Problem_03.java @@ -0,0 +1,50 @@ +package binaryTree; + +/* Problem Title :- Find the Height of a tree or Maximum Depth of a tree. + * + * Height of tree :- + * The height of a tree is the number of edges on the longest downward path + * between the root and a leaf. + */ +public class BT_Problem_03 { + + Node root; + + /* + * Compute the "maxDepth" of a tree -- + * the number of nodes along the longest path from the root node + * down to the farthest leaf node + */ + int maxDepth(Node node) { + + if(node == null) return 0; + + else { + /* compute the depth of each subtree */ + int lDepth = maxDepth(node.left); + int rDepth = maxDepth(node.right); + + /* use the larger one*/ + if(lDepth > rDepth) + return (lDepth + 1); + else + return (rDepth + 1); + } + } + + /* Driver program to test above functions */ + public static void main(String[] args) { + + BT_Problem_03 tree = new BT_Problem_03(); + + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + + System.out.println("Height of tree is : " + tree.maxDepth(tree.root)); + + } + +} diff --git a/binaryTree/BT_Problem_04.java b/binaryTree/BT_Problem_04.java new file mode 100644 index 0000000..c39aab9 --- /dev/null +++ b/binaryTree/BT_Problem_04.java @@ -0,0 +1,61 @@ +package binaryTree; +/* Problem Title :- Find the Diameter of a tree or Width of tree. + * + * Diameter of a tree :- + * The Diameter of a tree is the number of nodes on the longest path + * between two end nodes. + */ + +// Class to print the Diameter. +public class BT_Problem_04 { + + Node root; + + // Method to calculate the diameter and return it to main + int diameter(Node root) { + // base case if tree is empty + if(root == null) + return 0; + + // get the height of left and right sub-trees + int lheight = height(root.left); + int rheight = height(root.right); + + // get the diameter of left and right sub-trees + int ldiameter = diameter(root.left); + int rdiameter = diameter(root.right); + + return Math.max(lheight + rheight + 1, Math.max(ldiameter, rdiameter)); + } + + // A wrapper over diameter(Node root) + int diameter() {return diameter(root);} + + /* + * The function Compute the "height" of a tree. + * Height is the number of nodes along the longest path + * from the root node to the farthest leaf node. + */ + static int height(Node node) { + if(node == null) + return 0; + // If tree is not empty then height = 1 + max of left height and right heights. + return (1 + Math.max(height(node.left), height(node.left))); + } + + // Driver Code + public static void main(String[] args) { + + BT_Problem_04 tree = new BT_Problem_04(); + + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + + // Function Call + System.out.println("The diameter of given bianry tree is : " + tree.diameter()); + } + +} diff --git a/binaryTree/BT_Problem_05.java b/binaryTree/BT_Problem_05.java new file mode 100644 index 0000000..2d79344 --- /dev/null +++ b/binaryTree/BT_Problem_05.java @@ -0,0 +1,84 @@ +package binaryTree; + +/* Problem Title :- Find Mirror of a tree. + * + * Mirror of a tree :- + * The Diameter of a tree is the number of nodes on the longest path + * between two end nodes. + */ +public class BT_Problem_05 { + + /* + * A binary tree node has data, + * pointer to left child + * & a pointer to right child + */ + static class node{ + int val; + node left; + node right; + } + + /* + * Helper function that allocates a new node with the given data + * & null left and right pointers + */ + static node createNode(int val) { + node newNode = new node(); + newNode.val = val; + newNode.left = null; + newNode.right = null; + return newNode; + } + + /* + * Helper function to print + * In-order Traversal + */ + static void inorder(node root) { + if(root == null) + return; + inorder(root.left); + System.out.println(root.val); + inorder(root.right); + } + + /* + * mirror-i-f-y function takes two trees, + * original tree and a mirror tree + * It recurses on both the trees. + * but when original tree recurses on left, + * mirror tree recurses on right and vice-versa + */ + static node mirrorify(node root) { + if(root == null) + return null; + + // Create new mirror node from original tree node + node mirror = createNode(root.val); + mirror.right = mirrorify(root.left); + mirror.left = mirrorify(root.right); + return mirror; + } + + // Driver Code + public static void main(String[] args) { + + node tree = createNode(5); + tree.left = createNode(5); + tree.right = createNode(5); + tree.left.right = createNode(5); + tree.left.left = createNode(5); + + // print in-order traversal of the original input tree + System.out.print("\n Inorderr of original tree: "); + inorder(tree); + node mirror = null; + mirror = mirrorify(tree); + + // print in-order traversal of the mirror tree + System.out.print("\n Inorderr of mirror tree: "); + inorder(mirror); + } + +} diff --git a/binaryTree/BT_Problem_06_a.java b/binaryTree/BT_Problem_06_a.java new file mode 100644 index 0000000..9886cdd --- /dev/null +++ b/binaryTree/BT_Problem_06_a.java @@ -0,0 +1,62 @@ +package binaryTree; +import java.util.*; +/* + * Problem Title :- In-order Traversal of a tree both using Recursion + */ +// Class to print the in-order traversal +public class BT_Problem_06_a { + + // Root of Binary Tree + Node root; + + /* + * Given a binary tree, + * print its nodes in in-order + */ + void inorder() { + + if(root == null) return; + + Stack s = new Stack<>(); + Node curr = root; + + // traverse the tree + while(curr != null || s.size() > 0) { + /* Reach the left most Node of the current Node */ + while(curr != null) { + /* place pointer to a tree node on + * the stack before traversing + * the node,s left subtree */ + s.push(curr); + curr = curr.left; + } + + /*Current must be NULL at this point */ + curr = s.pop(); + + System.out.print(curr.data + " "); + + /* we have visited the node and its left subtree. + * Now, its right subtree's turn */ + curr = curr.right; + } + } + + // Driver method + public static void main(String[] args) { + + // creating a binary tree and entering the nodes + BT_Problem_06_a tree = new BT_Problem_06_a(); + + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + + tree.inorder(); + + } + +} + diff --git a/binaryTree/BT_Problem_06_b.java b/binaryTree/BT_Problem_06_b.java new file mode 100644 index 0000000..1bb728f --- /dev/null +++ b/binaryTree/BT_Problem_06_b.java @@ -0,0 +1,98 @@ +package binaryTree; + +/* + * Problem Title :- In-order Traversal of a tree both using Recursion + */ +public class BT_Problem_06_b { + + // Root of Binary Tree + Node root; + + // Constructor + BT_Problem_06_b(){ + root = null; + } + + /* + * Given a binary tree, + * print its nodes according to the + * "bottom-up" post-order traversal. + */ + void printPostorder(Node node) { + if(node == null) + return; + // first recur on left subtree + printPostorder(node.left); + + // then recur on right subtree + printPostorder(node.right); + + // now deal with the node + System.out.print(node.data + " "); + } + + /* + * Given a binary tree, + * print its nodes in in-order + */ + void printInorder(Node node) { + + if(node == null) return; + + /* first recur on left child */ + printPreorder(node.left); + + /* then print data of node */ + System.out.print(node.data + " "); + + /* now recur on right child */ + printPreorder(node.right); + } + + /* + * Given a binary tree, + * print its nodes in preorder + */ + void printPreorder(Node node) { + + if(node == null) return; + + /* first print data of node */ + System.out.print(node.data + " "); + + /* then recur on left subtree */ + printPreorder(node.left); + + /* now recur on right subtree */ + printPreorder(node.right); + } + + // Wrappers over above recursive functions + void printPostorder() { printPostorder(root);} + void printInorder() { printInorder(root); } + void printPreorder() { printPreorder(root); } + + // Driver method + public static void main(String[] args) { + + BT_Problem_06_b tree = new BT_Problem_06_b(); + + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + + System.out.println("Preorder traversal of binary tree is "); + tree.printPreorder(); + + System.out.println("\nInorder traversal of binary tree is "); + tree.printInorder(); + + System.out.println("\nPostorder traversal of binary tree is "); + tree.printPostorder(); + + } + + +} diff --git a/binaryTree/BT_Problem_07.java b/binaryTree/BT_Problem_07.java new file mode 100644 index 0000000..6d2485b --- /dev/null +++ b/binaryTree/BT_Problem_07.java @@ -0,0 +1,15 @@ +package binaryTree; +/* Problem Title :- Write a Java program to find Left View of a tree + * + * Left View of a tree :- + * The left view of a binary tree, is set of nodes visible when tree is visited from left side + * between two end nodes. + */ + +public class BT_Problem_07 { + + public static void main(String[] args) { + + } + +} diff --git a/binaryTree/BT_Problem_08.java b/binaryTree/BT_Problem_08.java new file mode 100644 index 0000000..c894fb8 --- /dev/null +++ b/binaryTree/BT_Problem_08.java @@ -0,0 +1,10 @@ +package binaryTree; +// Post-order Traversal of a tree both using recursion and Iteration +public class BT_Problem_08 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/binaryTree/BT_Problem_09.java b/binaryTree/BT_Problem_09.java new file mode 100644 index 0000000..2f2a45f --- /dev/null +++ b/binaryTree/BT_Problem_09.java @@ -0,0 +1,51 @@ +package binaryTree; + +/* Problem Title :- Write a Java program to find Left View of a tree + * + * Left View of a tree :- + * The left view of a binary tree, is set of nodes visible when tree is visited from left side + * between two end nodes. + */ +public class BT_Problem_09 { + + Node root; + static int max_level = 0; + + // recursive function to print the left view + void leftViewUtil(Node node, int level) { + // Base Case + if(node == null) + return; + + // If this is the first node of its level + if(max_level < level) { + System.out.print(" " + node.data); + max_level = level; + } + + // Recur for left and right subtrees + leftViewUtil(node.left, level + 1); + leftViewUtil(node.right, level + 1); + } + + // A wrapper over leftViewUtil() + void leftView() { + leftViewUtil(root, 1); + } + + // Driver Code + public static void main(String[] args) { + + /* creating a binary tree and entering the nodes */ + BT_Problem_09 tree = new BT_Problem_09(); + + tree.root = new Node(12); + tree.root.left = new Node(10); + tree.root.right = new Node(30); + tree.root.right.left = new Node(25); + tree.root.right.right = new Node(40); + + tree.leftView(); + } + +} diff --git a/binaryTree/BT_Problem_10.java b/binaryTree/BT_Problem_10.java new file mode 100644 index 0000000..5b9101a --- /dev/null +++ b/binaryTree/BT_Problem_10.java @@ -0,0 +1,30 @@ +package binaryTree; +/* Problem Title :- Write a Java program to find Right View of Tree. + * + * Right View of a tree :- + * The right view of a binary tree, is set of nodes visible when tree is visited from rights side + * between two end nodes. + */ +public class BT_Problem_10 { + + Node root; + static int max_level = 0; + + void leftViewUtil(Node node, int level) { + + if(node == null) + return; + + if(max_level < level) { + System.out.print(" " + node.data); + max_level = level; + } + + + } + public static void main(String[] args) { + + + } + +} diff --git a/binaryTree/BT_Problem_11.java b/binaryTree/BT_Problem_11.java new file mode 100644 index 0000000..73993e3 --- /dev/null +++ b/binaryTree/BT_Problem_11.java @@ -0,0 +1,75 @@ +package binaryTree; +import java.util.*; +import java.util.Map.Entry; + +/* + * Problem Title :- Write a Java program to find Top View of Tree. + */ +// Class of binary Tree +public class BT_Problem_11 { + + Node root; + + public BT_Problem_11() { + root = null; + } + + // function should print the topView of the binary tree + private void TopView(Node root) { + class QueueObj{ + Node node; + int hd; + QueueObj(Node node, int hd){ + this.node = node; + this.hd = hd; + } + } + + Queue q = new LinkedList<>(); + Map topViewMap = new TreeMap(); + + if(root == null) + return; + else + q.add(new QueueObj(root, 0)); + + System.out.println("The top view of the tree is : "); + + /* count function returns 1 if the container + * contains an element whose key is equivalent to hd, + * or returns zero otherwise. */ + while(!q.isEmpty()) { + QueueObj tempNode = q.poll(); + + if(!topViewMap.containsKey(tempNode.hd)) + topViewMap.put(tempNode.hd, tempNode.node); + + if(tempNode.node.left != null) + q.add(new QueueObj(tempNode.node.left, tempNode.hd + 1)); + + if(tempNode.node.left != null) + q.add(new QueueObj(tempNode.node.left, tempNode.hd + 1)); + } + + for(Entry entry : topViewMap.entrySet()) + System.out.print(entry.getValue().data); + } + + // Driver Program to test & run above functions + public static void main(String[] args) { + + BT_Problem_11 tree = new BT_Problem_11(); + + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.right = new Node(4); + tree.root.left.right.right = new Node(4); + tree.root.left.right.right.right = new Node(4); + + System.out.println("Following are nodes in top view of Binary Tree"); + tree.TopView(tree.root); + + } + +} diff --git a/binaryTree/BT_Problem_12.java b/binaryTree/BT_Problem_12.java new file mode 100644 index 0000000..1cabad7 --- /dev/null +++ b/binaryTree/BT_Problem_12.java @@ -0,0 +1,85 @@ +package binaryTree; + +import java.util.*; +import java.util.Map.Entry; + +/* + * Problem Title :- Write a Java program to find Bottom View of Tree. + */ + +class Tree{ + Node root; + + public Tree() {} + + public Tree(Node node){ + root = node; + } + + void bottomView() { + + if(root == null) + return; + + // Initialize a variable 'hd' with 0 for the root element. + int hd = 0; + + // TreeMap which stores key value pair sorted on key value + Map map= new TreeMap<>(); + + // Queue to store tree nodes in level order traversal + Queue q = new LinkedList<>(); + + // Assign initialized horizontal distance value to root node and add it to the queue. + root.hd = hd; + q.add(root); + + while(!q.isEmpty()) { + Node temp = q.remove(); + + hd = temp.hd; + + map.put(hd, temp.data); + + if(temp.left != null) { + temp.left.hd = hd-1; + q.add(temp.left); + } + + if(temp.right != null) { + temp.right.hd = hd+1; + q.add(temp.right); + } + + } + + Set> set = map.entrySet(); + + Iterator> iterator = set.iterator(); + + while(iterator.hasNext()) { + Map.Entry me = iterator.next(); + System.out.print(me.getValue() + " "); + } + } +} + +public class BT_Problem_12 { + + public static void main(String[] args) { + Node root = new Node(20); + root.left = new Node(8); + root.right = new Node(22); + root.left.left = new Node(5); + root.left.right = new Node(3); + root.right.left = new Node(4); + root.right.right = new Node(25); + root.left.right.left = new Node(10); + root.left.right.right = new Node(14); + + Tree tree = new Tree(root); + System.out.println("Bottom view of the given binary tree: "); + tree.bottomView(); + } + +} diff --git a/binaryTree/BT_Problem_13.java b/binaryTree/BT_Problem_13.java new file mode 100644 index 0000000..60852fd --- /dev/null +++ b/binaryTree/BT_Problem_13.java @@ -0,0 +1,77 @@ +package binaryTree; +import java.util.*; + +/* + * Problem Title :- Zig-Zag traversal of a binary tree + */ + +class BinaryTree{ + + Node root; + + void printZigZagTraversal() { + if(root == null) + return; + + Stack currentLevel = new Stack<>(); + Stack nextLevel = new Stack<>(); + + currentLevel.push(root); + boolean leftToRight = true;; + + while(!currentLevel.isEmpty()) { + Node node = currentLevel.pop(); + + System.out.print(node.data + " "); + + if(leftToRight) { + if(node.left != null) { + nextLevel.push(node.left); + } + + if(node.left != null) { + nextLevel.push(node.left); + } + } + + else { + if(node.right != null) { + nextLevel.push(node.right); + } + if(node.left != null) { + nextLevel.push(node.left); + } + } + + if(currentLevel.isEmpty()) { + leftToRight = !leftToRight; + Stack temp = currentLevel; + currentLevel = nextLevel; + nextLevel = temp; + } + } + } +} + +public class BT_Problem_13 { + + public static void main(String[] args) { + + BinaryTree tree = new BinaryTree(); + + tree.root = new Node(1); + tree.root.left = new Node(8); + tree.root.right = new Node(21); + tree.root.left.left = new Node(2); + tree.root.left.right = new Node(3); + tree.root.right.left = new Node(7); + tree.root.right.right = new Node(6); + tree.root.left.right.left = new Node(5); + tree.root.left.right.right = new Node(4); + + System.out.println("ZigZag Order traversal tree is "); + tree.printZigZagTraversal(); + + } + +} diff --git a/binaryTree/BT_Problem_14.java b/binaryTree/BT_Problem_14.java new file mode 100644 index 0000000..238883f --- /dev/null +++ b/binaryTree/BT_Problem_14.java @@ -0,0 +1,48 @@ +package binaryTree; +/* + * Problem Title :- Check if a tree is balanced or not + */ +public class BT_Problem_14 { + + Node root; + + boolean isBalanced(Node node) { + int lh; + int rh; + + if(node == null) + return true; + + lh = height(node.left); + rh = height(node.right); + + if(Math.abs(lh - rh) <= 1 && isBalanced(node.left) && isBalanced(node.right)) { + return true; + } + return false; + } + + int height(Node node) { + if(node == null) + return 0; + + return 1 + Math.max(height(node.left), height(node.right)); + } + + public static void main(String[] args) { + + BT_Problem_14 tree = new BT_Problem_14(); + + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + tree.root.left.left.left = new Node(8); + + if(tree.isBalanced(tree.root)) + System.out.println("Tree is balanced"); + else + System.out.println("Tree is not balanced"); + } +} diff --git a/binaryTree/BT_Problem_15.java b/binaryTree/BT_Problem_15.java new file mode 100644 index 0000000..1b70b05 --- /dev/null +++ b/binaryTree/BT_Problem_15.java @@ -0,0 +1,66 @@ +package binaryTree; +import java.util.*; +import java.util.Map.Entry; +/* + * Problem Title :- Diagnol Traversal of a Binary tree + */ +public class BT_Problem_15 { + + static class Node{ + int data; + Node left, right; + + Node(int data){ + this.data = data; + left = null; + right = null; + } + } + + static void diagonalPrintUtil(Node root, int d, HashMap> diagonalPrint) { + if(root == null) + return; + + Vector k = diagonalPrint.get(d); + + if(k == null) { + k = new Vector<>(); + k.add(root.data); + } + + else { + k.add(root.data); + } + + diagonalPrint.put(d,k); + diagonalPrintUtil(root.left, d+1, diagonalPrint); + diagonalPrintUtil(root.right, d, diagonalPrint); + } + + static void diagonalPrint(Node root) { + HashMap> diagonalPrint = new HashMap<>(); + + diagonalPrintUtil(root, 0, diagonalPrint); + + System.out.println("Diagonal Traversal of Binary Tree"); + + for(Entry> entry : diagonalPrint.entrySet()) + System.out.println(entry.getValue()); + } + + public static void main(String[] args) { + Node root = new Node(8); + + root.left = new Node(3); + root.right = new Node(10); + root.left.left = new Node(1); + root.left.right = new Node(6); + root.right.right = new Node(14); + root.right.right.left = new Node(13); + root.left.right.left = new Node(4); + root.left.right.right = new Node(7); + + diagonalPrint(root); + } + +} diff --git a/binaryTree/BT_Problem_16.java b/binaryTree/BT_Problem_16.java new file mode 100644 index 0000000..1901145 --- /dev/null +++ b/binaryTree/BT_Problem_16.java @@ -0,0 +1,79 @@ +package binaryTree; +/* + * Problem Title :- Boundary traversal of a Binary tree + */ +public class BT_Problem_16 { + + Node root; + // printing leaf nodes + void printLeaves(Node node) { + if(node == null) + return; + + printLeaves(node.left); + // print if it is a leaf node + if(node.left == null && node.right == null) + System.out.print(node.data + " "); + printLeaves(node.right); + } + + void printBoundaryLeft(Node node) { + if(node == null) + return; + if(node.left != null) { + System.out.print(node.data + " "); + printBoundaryLeft(node.left); + } + + else if(node.right != null) { + System.out.print(node.data + " "); + printBoundaryLeft(node.right); + } + } + + void printBoundaryRight(Node node) { + if(node == null) + return; + if(node.left != null) { + System.out.print(node.data + " "); + printBoundaryRight(node.left); + } + + else if(node.right != null) { + System.out.print(node.data + " "); + printBoundaryRight(node.right); + } + } + + void printBoundary(Node node) { + if(node == null) + return; + + System.out.print(node.data + " "); + + printBoundaryLeft(node.left); + + printLeaves(node.left); + printLeaves(node.right); + + printBoundaryRight(node.right); + } + + public static void main(String[] args) { + BT_Problem_16 tree = new BT_Problem_16(); + + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + tree.root.left.left.left = new Node(8); + tree.root.left.right.left = new Node(10); + tree.root.left.right.right = new Node(14); + tree.root.right = new Node(3); + tree.root.right.right = new Node(22); + + tree.printBoundary(tree.root); + + } + +} diff --git a/binaryTree/BT_Problem_17.java b/binaryTree/BT_Problem_17.java new file mode 100644 index 0000000..2bdcbd0 --- /dev/null +++ b/binaryTree/BT_Problem_17.java @@ -0,0 +1,55 @@ +package binaryTree; +/* + * Problem Title :- Construct Binary Tree from String with Bracket Representation + */ +public class BT_Problem_17 { + + static class Node{ + int data; + Node left,right; + }; + + static String str; + + static Node newNode(int data) { + Node node = new Node(); + node.data= data; + node.left = node.right = null; + return(node); + } + + static void treeToString(Node root) { + if(root == null) + return; + + str += (Character.valueOf((char)(root.data + '0'))); + + if(root.left == null && root.right == null) { + return; + } + + str += ('('); + treeToString(root.left); + str += ('('); + + if(root.right != null) { + str += ('('); + treeToString(root.right); + str += ('('); + } + } + + public static void main(String[] args) { + Node root = newNode(1); + root.left = newNode(2); + root.right = newNode(3); + root.left.left = newNode(4); + root.left.right = newNode(5); + root.right.right = newNode(6); + str = " "; + treeToString(root); + System.out.println(str); + + } + +} diff --git a/binaryTree/BT_Problem_18.java b/binaryTree/BT_Problem_18.java new file mode 100644 index 0000000..3d9ae5a --- /dev/null +++ b/binaryTree/BT_Problem_18.java @@ -0,0 +1,10 @@ +package binaryTree; + +public class BT_Problem_18 { + + public static void main(String[] args) { + + + } + +} diff --git a/binaryTree/BT_Problem_19.java b/binaryTree/BT_Problem_19.java new file mode 100644 index 0000000..777ba6f --- /dev/null +++ b/binaryTree/BT_Problem_19.java @@ -0,0 +1,9 @@ +package binaryTree; + +public class BT_Problem_19 { + + public static void main(String[] args) { + + } + +} diff --git a/binaryTree/BT_Problem_31.java b/binaryTree/BT_Problem_31.java new file mode 100644 index 0000000..d0cd8b9 --- /dev/null +++ b/binaryTree/BT_Problem_31.java @@ -0,0 +1,76 @@ +package binaryTree; +import java.util.*; + +/* + * Title: Find LCA in a Binary tree + */ + +class Solution{ + + @SuppressWarnings("unused") + private BT_Problem_31 ans; + + public Solution() { + this.ans = null; + } + + @SuppressWarnings("unused") + private boolean recurseTree(BT_Problem_31 currentNode, BT_Problem_31 p, BT_Problem_31 q) { + + if(currentNode == null) + return false; + + int left = this.recurseTree(currentNode.left, p, q) ? 1 : 0; + int right = this.recurseTree(currentNode.right, p, q) ? 1 : 0; + int mid = (currentNode == p || currentNode == q) ? 1 : 0; + + if(mid + left + right >= 2) + this.ans = currentNode; + + return (mid + left + right > 0); + } + + public BT_Problem_31 lowestCommonAncestor(BT_Problem_31 root, BT_Problem_31 p, BT_Problem_31 q) { + + Deque stack = new ArrayDeque<>(); + Map parent = new HashMap<>(); + + parent.put(root, null); + stack.push(root); + + while(!parent.containsKey(p) || !parent.containsKey(q)) { + BT_Problem_31 node = stack.pop(); + + if(node.left != null) { + parent.put(node.left, node); + stack.push(node.left); + } + + if(node.right != null) { + parent.put(node.right, node); + stack.push(node.right); + } + } + + Set ancestors = new HashSet<>(); + + while(p != null) { + ancestors.add(p); + p = parent.get(p); + } + + while(!ancestors.contains(q)) + q = parent.get(q); + + return q; + } +} + +public class BT_Problem_31{ + int val; + BT_Problem_31 left; + BT_Problem_31 right; + BT_Problem_31(int x){ + val = x; + } +} diff --git a/binaryTree/BT_Problem_35.java b/binaryTree/BT_Problem_35.java new file mode 100644 index 0000000..904be56 --- /dev/null +++ b/binaryTree/BT_Problem_35.java @@ -0,0 +1,66 @@ +package binaryTree; + +// Tree Isomorphism Problem +public class BT_Problem_35 { + + Node root1, root2; + boolean isIsomorphic(Node n1, Node n2) + { + // Both roots are NULL, trees isomorphic by definition + if (n1 == null && n2 == null) + return true; + + // Exactly one of the n1 and n2 is NULL, trees not isomorphic + if (n1 == null || n2 == null) + return false; + + if (n1.data != n2.data) + return false; + + // There are two possible cases for n1 and n2 to be isomorphic + // Case 1: The subtrees rooted at these nodes have NOT been "Flipped". + // Both of these subtrees have to be isomorphic. + // Case 2: The subtrees rooted at these nodes have been "Flipped" + return ( + isIsomorphic(n1.left, n2.left) + && + isIsomorphic(n1.right, n2.right) + ) + || + ( + isIsomorphic(n1.left, n2.right) + && + isIsomorphic(n1.right, n2.left) + ); + } + + // Driver program to test above functions + public static void main(String args[]) + { + BT_Problem_35 tree = new BT_Problem_35(); + + // Let us create trees shown in above diagram + tree.root1 = new Node(1); + tree.root1.left = new Node(2); + tree.root1.right = new Node(3); + tree.root1.left.left = new Node(4); + tree.root1.left.right = new Node(5); + tree.root1.right.left = new Node(6); + tree.root1.left.right.left = new Node(7); + tree.root1.left.right.right = new Node(8); + + tree.root2 = new Node(1); + tree.root2.left = new Node(3); + tree.root2.right = new Node(2); + tree.root2.right.left = new Node(4); + tree.root2.right.right = new Node(5); + tree.root2.left.right = new Node(6); + tree.root2.right.right.left = new Node(8); + tree.root2.right.right.right = new Node(7); + + if (tree.isIsomorphic(tree.root1, tree.root2) == true) + System.out.println("Yes"); + else + System.out.println("No"); + } + } \ No newline at end of file diff --git a/bitManipulation/BM_01.java b/bitManipulation/BM_01.java new file mode 100644 index 0000000..420b9d3 --- /dev/null +++ b/bitManipulation/BM_01.java @@ -0,0 +1,24 @@ +package bitManipulation; + +/* + * Problem Title :-> Count set bits in an integer + */ +public class BM_01 { + + // Function to get no of set bits in binary representation of positive integer n + static int countSetBits(int n) { + int count = 0; + while(n > 0) { + count += n & 1; + n >>= 1; + } + return count; + } + + // driver program + public static void main(String[] args) { + int i = 9; + System.out.println(countSetBits(i)); + } + +} diff --git a/bitManipulation/BM_02.java b/bitManipulation/BM_02.java new file mode 100644 index 0000000..a23a8e5 --- /dev/null +++ b/bitManipulation/BM_02.java @@ -0,0 +1,52 @@ +package bitManipulation; + +// Problem Title :-> Find the two non-repeating elements in an array of repeating elements +public class BM_02 { + + // This function sets the values of *x & *y to non-repeating elements in an array a[] of size n + public static void UniqueNumber(int[] a, int n) { + int sum = 0; + for(int i = 0; i < n; i++) { + // X-or all the elements of the array + // all the elements occur-i-n-g twice will + // cancel out each other remaining + // two unique numbers will be x-o-red + sum = (sum^a[i]); + } + + // Bitwise & the sum with it's 2's Complement + // Bitwise & will give us the sum containing + // only the rightmost set bit + sum = (sum &- sum); + + // sum1 & sum2 will contain 2 unique elements + // elements initialized with 0 box number + // x-o-red with 0 is number itself + int sum1 = 0; + int sum2 = 0; + + // traversing the array again + for(int i = 0; i < a.length; i++) { + + // Bitwise & the a[i] with the sum + // Two possibilities either result == 0 + // or result > 0 + if((a[i] & sum) > 0) + // if result >, 0 then a[i] x-o-red with sum1 + sum1 = (sum1^a[i]); + else + // if result == 0 then a[i] x-o-red with sum2 + sum2 = (sum2^a[i]); + } + // print the two unique numbers + System.out.println("The non repeating elements are " + sum1 + " and " +sum2); + } + + public static void main(String[] args) { + + int[] a = new int[] {2, 3, 7, 9, 11, 2, 3, 11}; + int n = a.length; + UniqueNumber(a, n); + } + +} diff --git a/bitManipulation/BM_03.java b/bitManipulation/BM_03.java new file mode 100644 index 0000000..697bacc --- /dev/null +++ b/bitManipulation/BM_03.java @@ -0,0 +1,29 @@ +package bitManipulation; +/* + * Problem Title :-> Count number of bits to be flipped to convert A to B + */ +public class BM_03 { + + // Function that count set bits + public static int countSetBits(int n) { + int count = 0; + while(n != 0) { + count++; + n &= (n-1); + } + return count; + } + // Function that return count of flipped number + public static int FlippedCount(int a, int b) { + // Return countof set bits in + // a XOR b + return countSetBits(a^b); + } + // Driver Code + public static void main(String[] args) { + int a = 10; + int b = 20; + System.out.println(FlippedCount(a, b)); + } + +} diff --git a/bitManipulation/BM_04.java b/bitManipulation/BM_04.java new file mode 100644 index 0000000..e61a030 --- /dev/null +++ b/bitManipulation/BM_04.java @@ -0,0 +1,10 @@ +package bitManipulation; + +public class BM_04 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/bitManipulation/BM_05.java b/bitManipulation/BM_05.java new file mode 100644 index 0000000..8dd10a5 --- /dev/null +++ b/bitManipulation/BM_05.java @@ -0,0 +1,10 @@ +package bitManipulation; + +public class BM_05 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/bitManipulation/BM_06.java b/bitManipulation/BM_06.java new file mode 100644 index 0000000..9f93c54 --- /dev/null +++ b/bitManipulation/BM_06.java @@ -0,0 +1,10 @@ +package bitManipulation; + +public class BM_06 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/bitManipulation/BM_07.java b/bitManipulation/BM_07.java new file mode 100644 index 0000000..d4fedae --- /dev/null +++ b/bitManipulation/BM_07.java @@ -0,0 +1,10 @@ +package bitManipulation; + +public class BM_07 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/bitManipulation/BM_08.java b/bitManipulation/BM_08.java new file mode 100644 index 0000000..196de0e --- /dev/null +++ b/bitManipulation/BM_08.java @@ -0,0 +1,10 @@ +package bitManipulation; + +public class BM_08 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/bitManipulation/BM_09.java b/bitManipulation/BM_09.java new file mode 100644 index 0000000..705e43d --- /dev/null +++ b/bitManipulation/BM_09.java @@ -0,0 +1,10 @@ +package bitManipulation; + +public class BM_09 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/bitManipulation/BM_10.java b/bitManipulation/BM_10.java new file mode 100644 index 0000000..7701b37 --- /dev/null +++ b/bitManipulation/BM_10.java @@ -0,0 +1,10 @@ +package bitManipulation; + +public class BM_10 { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/dataStructures/Info.java b/dataStructures/Info.java new file mode 100644 index 0000000..6f332ad --- /dev/null +++ b/dataStructures/Info.java @@ -0,0 +1,10 @@ +package dataStructures; + +public class Info { + + public static void main(String[] args) { + // TODO Auto-generated method stub + + } + +} diff --git a/dataStructures/graphs/Graph.java b/dataStructures/graphs/Graph.java new file mode 100644 index 0000000..1be0936 --- /dev/null +++ b/dataStructures/graphs/Graph.java @@ -0,0 +1,41 @@ +package dataStructures.graphs; +import java.util.*; + +public class Graph { + + private LinkedList adj[]; + + // Constructor + @SuppressWarnings("unchecked") + public Graph(int v) { + //array of Linked List + adj = new LinkedList[v]; + + for(int i = 0; i < v; i++) + adj[i] = new LinkedList(); + } + + public void addEdge(int source, int destination) { + adj[source].add(destination); + adj[destination].add(source); + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + + System.out.println("Enter number of vertices and edges"); + int v = sc.nextInt(); + int e = sc.nextInt(); + + Graph graph = new Graph(v); + System.out.println("Enter " + e + " edges"); + + for(int i = 0; i < e; i++) { + int source = sc.nextInt(); + int destination = sc.nextInt(); + graph.addEdge(source, destination); + } + + sc.close(); + } +} diff --git a/dp/CoinChoiseProblem.java b/dp/CoinChoiseProblem.java new file mode 100644 index 0000000..e20304e --- /dev/null +++ b/dp/CoinChoiseProblem.java @@ -0,0 +1,51 @@ +package dp; + +import java.util.*; + +public class CoinChoiseProblem { + + public static void main(String[] args) { + + + int n = 18; + int a[] = {7, 5, 1}; + int dp[] = new int[n+1]; + + Arrays.fill(dp, -1); + dp[0] = 0; + + int ans = minCoins(n, a, dp); + System.out.println(ans); + + for(int x: dp) + System.out.println(x + " "); + } + + static int minCoins(int n, int a[], int dp[]) { + + if(n == 0) + return 0; + + int ans = Integer.MAX_VALUE; + + for(int i = 0; i= 0) { + + int subAns = 0; + + if(dp[n-a[i]] != -1) + subAns = dp[n-a[i]]; + + else + subAns = minCoins(n-a[i],a, dp); + + if(subAns != Integer.MAX_VALUE && subAns + 1 < ans) + ans = subAns + 1; + } + } + + return dp[n] = ans; + + } +} diff --git a/exercise_and_practice_Problems/Cylinder.java b/exercise_and_practice_Problems/Cylinder.java new file mode 100644 index 0000000..e6896c2 --- /dev/null +++ b/exercise_and_practice_Problems/Cylinder.java @@ -0,0 +1,26 @@ +package exercise_and_practice_Problems; + +public class Cylinder { + + public static void main(String[] args) { + + //The below line represent's the , Object of the Setter_Getters class + Getters_Setters_For_Cylinder sg = new Getters_Setters_For_Cylinder(); + + //setting values of pie, height & radius by using setter method with use of other class & by calling it + sg.setHeight(35); + sg.setRadius(3.0); + sg.setPie(3.14); + + //getting values of pie, radius & height + System.out.println("The value of the Pie is: " + sg.getPie()); + System.out.println("The height of the cylinder is: " + sg.getHeight() + " cm"); + System.out.println("The radius of the cylinder is: " + sg.getRadius() + " cm"); + + // volume of cylinder => (V = 3.14*(r)^2*h) + double V = sg.getPie()*(sg.getRadius()*sg.getRadius())*sg.getHeight(); + System.out.println("The volume of the cylinder is: " + V + " cm^3"); + + } + +} diff --git a/exercise_and_practice_Problems/Exercise1.java b/exercise_and_practice_Problems/Exercise1.java new file mode 100644 index 0000000..b2aca46 --- /dev/null +++ b/exercise_and_practice_Problems/Exercise1.java @@ -0,0 +1,33 @@ +package exercise_and_practice_Problems; +import java.util.*; + +/* To calculate percentage of a given student in CBSE Board exam. + * His marks from 5 subjects must be taken as input from the keyboard + * (Marks are out of 100) + * */ + +public class Exercise1 { + + static Scanner sc = new Scanner(System.in); + + static int subject_1_marks = sc.nextInt(); + static int subject_2_marks = sc.nextInt(); + static int subject_3_marks = sc.nextInt(); + static int subject_4_marks = sc.nextInt(); + static int subject_5_marks = sc.nextInt(); + + public static void main(String[] args) { + + int total = (subject_1_marks + subject_2_marks + subject_3_marks + subject_4_marks + subject_5_marks); + float percentage = (total)/5; + + System.out.println("The marks of the subject's are: \n " + "\n" + "subject_1_marks:- " + subject_1_marks + "\n" + + "subject_2_marks:- " + subject_2_marks + "\n" + "subject_3_marks:- " + subject_3_marks + "\n" + + "subject_4_marks:- " + subject_4_marks + "\n" + "subject_5_marks:- " + subject_5_marks + "\n"); + + System.out.println("The total no. of marks are: " + total); + System.out.println("Total percentage is: " + percentage); + + } + +} diff --git a/exercise_and_practice_Problems/Exercise2.java b/exercise_and_practice_Problems/Exercise2.java new file mode 100644 index 0000000..a395797 --- /dev/null +++ b/exercise_and_practice_Problems/Exercise2.java @@ -0,0 +1,34 @@ +package exercise_and_practice_Problems; +import java.util.Scanner; + +/* + * Take an array as input & print all of its content at particular index wise + */ + +public class Exercise2 { + + public static void main(String[] args) { + try (Scanner sc = new Scanner(System.in)) { + int n,sum =0; + + System.out.println("Enter no. of elements you want in array:"); + n = sc.nextInt(); + + int A[] = new int[n]; + System.out.println("Enter all the elements: "); + + for(int i=0;i 40) System.out.println(" The height of cylender is to high to to find vol & surface area: "); + else this.height = height; + } + + //setter method to set radius of cylinder + public void setRadius(double radius) { + this.radius = radius; + } + + //setter method to set the value of pie + public void setPie(double pie) { + this.pie = pie; + } + + //getter method to get the height of cylinder + public int getHeight() { + return height; + } + + //getter method to get the radius of cylinder + public double getRadius() { + return radius; + } + + //getter method to get the value of pie + public double getPie() { + return pie; + } + + + +} diff --git a/graphs/Graph_Problem_01_i.java b/graphs/Graph_Problem_01_i.java new file mode 100644 index 0000000..93a729d --- /dev/null +++ b/graphs/Graph_Problem_01_i.java @@ -0,0 +1,50 @@ +package graphs; +import java.util.*; + +// Problem Title :-> Create a Graph, print it +public class Graph_Problem_01_i { + + // A utility function to add an edge in an undirected graph + static void addEdge(ArrayList> adj, int u, int v) { + adj.get(u).add(v); + adj.get(v).add(u); + } + + // A utility function to print representation of graph + static void printGraph(ArrayList> adj) { + + for(int i = 0; i < adj.size(); i++) { + + System.out.println("\n Adjacency list of vertex" + i); + System.out.print("head"); + + for(int j = 0; j < adj.get(i).size(); j++) + System.out.print(" -> " + adj.get(i).get(j)); + + System.out.println(); + } + } + + // Driver Code + public static void main(String[] args) { + + // Creating a graph with 5 vertices + int V = 5; + ArrayList> adj = new ArrayList>(V); + + for(int i = 0; i < V; i++) + adj.add(new ArrayList()); + + // Adding edges one by one + addEdge(adj, 0, 1); + addEdge(adj, 0, 4); + addEdge(adj, 1, 2); + addEdge(adj, 1, 3); + addEdge(adj, 1, 4); + addEdge(adj, 2, 3); + addEdge(adj, 3, 4); + + printGraph(adj); + } + +} diff --git a/graphs/Graph_Problem_01_ii.java b/graphs/Graph_Problem_01_ii.java new file mode 100644 index 0000000..739804d --- /dev/null +++ b/graphs/Graph_Problem_01_ii.java @@ -0,0 +1,43 @@ +package graphs; +import java.util.*; + +public class Graph_Problem_01_ii { + + private LinkedList adj[]; + + @SuppressWarnings("unchecked") + public Graph_Problem_01_ii(int v) { + + //array of Linked List + adj = new LinkedList[v]; + + for(int i = 0; i < v; i++) + adj[i] = new LinkedList(); + } + + public void addEdge(int source, int destination) { + adj[source].add(destination); + adj[destination].add(source); + } + + public static void main(String[] args) { + + System.out.println("Enter number of vertices and edges"); + Scanner sc = new Scanner(System.in); + + int v = sc.nextInt(); + int e = sc.nextInt(); + + Graph_Problem_01_ii graph_Problem_01_ii = new Graph_Problem_01_ii(v); + + System.out.println("Enter " + e + " edges"); + + for(int i=0;i Implement BFS Algorithm of Traversal of Graph. + */ +public class Graph_Problem_02 { + // No. of vertices. + private int V; + // Adjacency List + private LinkedList[] adj; + + @SuppressWarnings({ "unchecked", "rawtypes" }) + // Constructor + Graph_Problem_02(int v){ + V = v; + adj = new LinkedList[v]; + for(int i = 0; i < v; ++i) + adj[i] = new LinkedList(); + } + + // Function to add an edge into the graph + void addEdge(int v, int w) { + adj[v].add(w); + } + + // prints BFS traversal from a given source s + void BFS(int s) { + // Mark all the verices as not visited(By Default set as false) + boolean visited[] = new boolean[V]; + + // Create a queue for BFS + LinkedList queue = new LinkedList<>(); + + visited[s] = true; + queue.add(s); + + while(queue.size() != 0) { + // Dequeue a vertex from queue and print + s = queue.poll(); + System.out.println(s + " "); + + // Get all adjacent vertices of the dequeued vertex s. + // If a adjacent has not been visited, + // then mark it visited & enqueue it. + Iterator i = adj[s].listIterator(); + while(i.hasNext()) { + int n = i.next(); + if(!visited[n]) { + visited[n] = true; + queue.add(n); + } + } + } + } + + public static void main(String[] args) { + + System.out.println("Enter number of vertices and edges"); + Scanner sc = new Scanner(System.in); + + int v = sc.nextInt(); + int e = sc.nextInt(); + + Graph_Problem_02 g = new Graph_Problem_02(v); + + for(int i = 0; i < e; i++) { + v = sc.nextInt(); + e = sc.nextInt(); + g.addEdge(v, e); + } + + sc.close(); + } +} diff --git a/graphs/Graph_Problem_03.java b/graphs/Graph_Problem_03.java new file mode 100644 index 0000000..41a7ff2 --- /dev/null +++ b/graphs/Graph_Problem_03.java @@ -0,0 +1,75 @@ +package graphs; +import java.util.*; + +/* + * Problem Title :-> Implement Graph DFS Algorithm + * This class represents a directed graph using adjacency list representation + */ +public class Graph_Problem_03{ + + @SuppressWarnings("unused") + // No. of vertices + private int V; + + // Array of lists for "Adjacency List Representation". + private LinkedList adj[]; + + // Constructor + @SuppressWarnings("unchecked") + public Graph_Problem_03(int v){ + V = v; + adj = new LinkedList[v]; + for(int i = 0; i < v; ++i) + adj[i] = new LinkedList(); + } + + // Function to add an edge into the graph + void addEdge(int v, int w) { + // Add w to v's list. + adj[v].add(w); + } + + // A function used by DFS + void DFSUtil(int v, boolean visited[]) { + + //Mark the current node as visited & print it + visited[v] = true; + System.out.println(v + " "); + + // Recur for all the vertices adjacent to this vertex + Iterator i = adj[v].listIterator(); + while(i.hasNext()) { + int n = i.next(); + if(!visited[n]) + DFSUtil(n,visited); + } + } + + // The function do DFS traversal. It uses recursive DFSUtil(). + void DFS(int v) { + boolean visited[] = new boolean[v]; + DFSUtil(v,visited); + } + + // Driver Code + public static void main(String[] args) { + + //Making Object of Graph_Problem_03 class + Graph_Problem_03 d = new Graph_Problem_03(4); + + // Adding edges one by one + d.addEdge(0, 1); + d.addEdge(0, 2); + d.addEdge(1, 2); + d.addEdge(2, 0); + d.addEdge(2, 3); + d.addEdge(3, 3); + + System.out.println("Following is Depth First Traversal " + "(starting from vertex 2)"); + + //Calling DFS method by using class object d + d.DFS(2); + + } + +} diff --git a/greedy/Greedy_Problem_01.java b/greedy/Greedy_Problem_01.java new file mode 100644 index 0000000..e645601 --- /dev/null +++ b/greedy/Greedy_Problem_01.java @@ -0,0 +1,45 @@ +package greedy; + +/* + * Problem Title :- Activity Selection Problem + */ +public class Greedy_Problem_01 { + + /* + * Prints a maximum set of activities that can be done by a single person, + * one at a time. + * n --> Total number of activities. + * s[] --> An array that contains start time of all activities. + * f[] --> An array that contains finish time of all activities. + */ + public static void printMaxActivities(int[] s, int[] f, int n) { + int i, j; + System.out.println("Following activities are selected : n"); + + // The first activity always gets selected + i = 0; + System.out.print(i + " "); + + // Consider rest of the activities + for(j = 1; j < n; j++) { + /* + * If this activity has start time greater than + * or equal to the finish time of previously selected + * activity, then select it + */ + if(s[j] >= f[i]) { + System.out.print(j + " "); + i = j; + } + } + } + // driver program to test above function + public static void main(String[] args) { + int[] s = {1, 3, 0, 5, 8, 5}; + int[] f = {2, 4, 6, 7, 9, 9}; + int n = s.length; + + printMaxActivities(s, f, n); + } + +} diff --git a/linkedList/Deletion_in_Linked_List.java b/linkedList/Deletion_in_Linked_List.java new file mode 100644 index 0000000..9385416 --- /dev/null +++ b/linkedList/Deletion_in_Linked_List.java @@ -0,0 +1,100 @@ +package linkedList; + +class LinkedList +{ + Node head; // head of list + + /* Linked list Node*/ + class Node + { + int data; + Node next; + Node(int d) + { + data = d; + next = null; + } + } + + /* Inserts a new Node at front of the list. */ + public void push(int new_data) + { + /* 1 & 2: Allocate the Node & + Put in the data*/ + Node new_node = new Node(new_data); + + /* 3. Make next of new Node as head */ + new_node.next = head; + + /* 4. Move the head to point to new Node */ + head = new_node; + } + + /* Given a reference (pointer to pointer) to the head of a list + and a position, deletes the node at the given position */ + void deleteNode(int position) + { + // If linked list is empty + if (head == null) + return; + + // Store head node + Node temp = head; + + // If head needs to be removed + if (position == 0) + { + head = temp.next; // Change head + return; + } + + // Find previous node of the node to be deleted + for (int i=0; temp!=null && inext is the node to be deleted + // Store pointer to the next of node to be deleted + Node next = temp.next.next; + + temp.next = next; // Unlink the deleted node from list + } + + /* This function prints contents of linked list starting from + the given node */ + public void printList() + { + Node tnode = head; + while (tnode != null) + { + System.out.print(tnode.data+" "); + tnode = tnode.next; + } + } + + /* Driver program to test above functions. Ideally this function + should be in a separate user class. It is kept here to keep + code compact */ + public static void main(String[] args) + { + /* Start with the empty list */ + LinkedList llist = new LinkedList(); + + llist.push(7); + llist.push(1); + llist.push(3); + llist.push(2); + llist.push(8); + + System.out.println("\nCreated Linked list is: "); + llist.printList(); + + llist.deleteNode(4); // Delete node at position 4 + + System.out.println("\nLinked List after Deletion at position 4: "); + llist.printList(); + } +} \ No newline at end of file diff --git a/linkedList/Insertion_in_Linked_List.java b/linkedList/Insertion_in_Linked_List.java new file mode 100644 index 0000000..a1900ba --- /dev/null +++ b/linkedList/Insertion_in_Linked_List.java @@ -0,0 +1,99 @@ +package linkedList; + +public class Insertion_in_Linked_List { + + class Node{ + int data; + Node next; + + Node(int d){ + data = d; + next = null; + } + } + + Node head; + + public void push(int new_data ) { + Node new_node = new Node(new_data); + new_node.next = head; + head = new_node; + } + + public void insertAfter(Node prev_node, int new_data) + { + /* 1. Check if the given Node is null */ + if (prev_node == null) + { + System.out.println("The given previous node cannot be null"); + return; + } + + /* 2 & 3: Allocate the Node & Put in the data*/ + Node new_node = new Node(new_data); + + /* 4. Make next of new Node as next of prev_node */ + new_node.next = prev_node.next; + + /* 5. make next of prev_node as new_node */ + prev_node.next = new_node; + } + + public void append(int new_data) { + + //make an object of above mentioned Node class + Node new_node = new Node(new_data); + + if(head == null) { + head = new_node; + return; + } + + new_node.next = null; + + Node last = head; + while (last.next != null) + last = last.next; + + last.next = new_node; + return; + } + + public void printList() + { + Node tnode = head; + while (tnode != null) + { + System.out.print(tnode.data+" "); + tnode = tnode.next; + } + } + + public static void main(String[] args) { + Insertion_in_Linked_List llist = new Insertion_in_Linked_List(); + /* Start with the empty list */ + + // Insert 6. So linked list becomes 6->NUllist + llist.append(6); + + // Insert 7 at the beginning. So linked list becomes + // 7->6->NUllist + llist.push(7); + + // Insert 1 at the beginning. So linked list becomes + // 1->7->6->NUllist + llist.push(1); + + // Insert 4 at the end. So linked list becomes + // 1->7->6->4->NUllist + llist.append(4); + + // Insert 8, after 7. So linked list becomes + // 1->7->8->6->4->NUllist + llist.insertAfter(llist.head.next, 8); + + System.out.println("\nCreated Linked list is: "); + llist.printList(); + } + +} diff --git a/linkedList/MainList.java b/linkedList/MainList.java new file mode 100644 index 0000000..0d9bd2c --- /dev/null +++ b/linkedList/MainList.java @@ -0,0 +1,18 @@ +package linkedList; +public class MainList { + + public static void main(String[] args) { + + MyLL myll = new MyLL(); + + + myll.add(0); + myll.add(1); + myll.add(2); + myll.add(3); + myll.add(4); + + myll.print(); + } + +} diff --git a/linkedList/MyLL.java b/linkedList/MyLL.java new file mode 100644 index 0000000..cd9883c --- /dev/null +++ b/linkedList/MyLL.java @@ -0,0 +1,53 @@ +package linkedList; + +public class MyLL { + + static class Node{ + int data; + Node next; + + public Node(int data) { + this.data = data; + next = null; + } + } + + Node head; + Node position; + + void add(int data) { + Node toAdd = new Node(data); + + if(isEmpty()) { + head = toAdd; + return; + } + + Node temp = head; + while(temp.next != null) { + temp = temp.next; + } + temp.next = toAdd; + } + + void print() { + Node temp = head; + while(temp != null) { + System.out.println(temp.data + " "); + temp = temp.next; + } + + } + + boolean isEmpty() { + return head == null; + } + + void remove(int data) { + head = null; + } + + boolean isValue() { + return head == position; + } +} diff --git a/linkedList/Problem_1_1.java b/linkedList/Problem_1_1.java new file mode 100644 index 0000000..52087d6 --- /dev/null +++ b/linkedList/Problem_1_1.java @@ -0,0 +1,62 @@ +package linkedList; + +/* + * Write a Program to Reverse the Linked List Iteratively + */ +public class Problem_1_1 { + + static Node head; + + static class Node{ + int data; + Node next; + Node(int d){ + data = d; + next = null; + } + } + + Node reverse (Node node) { + + Node prev = null; + Node current = node; + Node next = null; + + while(current != null) { + next = current.next; + current.next = prev; + prev = current; + current = next; + } + + node = prev; + return node; + } + + void printList(Node node) { + while(node != null) { + System.out.println(node.data + " "); + node = node.next; + } + } + + @SuppressWarnings("static-access") + public static void main(String[] args) { + + Problem_1_1 list = new Problem_1_1(); + + list.head = new Node(85); + list.head.next = new Node(15); + list.head.next.next = new Node(4); + list.head.next.next.next = new Node(20); + + System.out.println("Given Linked list"); + list.printList(head); + head = list.reverse(head); + System.out.println(" "); + System.out.println("Reversed linked list "); + list.printList(head); + + } + +} diff --git a/linkedList/Problem_1_2.java b/linkedList/Problem_1_2.java new file mode 100644 index 0000000..4744322 --- /dev/null +++ b/linkedList/Problem_1_2.java @@ -0,0 +1,67 @@ +package linkedList; + +/* + * Write a Program to Reverse the LinkedList Recursively + */ + +public class Problem_1_2 { + + static Node head; + + static class Node{ + int data; + Node next; + Node(int d){ + data = d; + next = null; + } + } + + static Node reverse(Node head) { + if(head == null || head.next == null) { + return head; + } + + Node rest = reverse(head.next); + head.next.next = head; + + + head.next = null; + + return rest; + } + + + static void print() { + Node temp = head; + while(temp != null) { + System.out.print(temp.data + " "); + temp = temp.next; + } + System.out.println(); + } + + static void push(int data) { + Node temp = new Node(data); + temp.next = head; + head = temp; + } + + public static void main(String[] args) { + + push(20); + push(4); + push(15); + push(85); + + System.out.println("Given linked list"); + print(); + + head = reverse(head); + + System.out.println("Reversed Linked list"); + print(); + + } + +} diff --git a/linkedList/Queue.java b/linkedList/Queue.java new file mode 100644 index 0000000..4df4cc3 --- /dev/null +++ b/linkedList/Queue.java @@ -0,0 +1,157 @@ +package linkedList; +import java.util.*; + +/* + * Code: Queue Using LL + * + * Send Feedback: + * You need to implement a Queue class using linked list. + * All the required data members should be private. + * + * Implement the following public functions: + * 1. Constructor - Initialise's the data members. + * 2. enqueue - This function should take one argument of type T and has return type void. + * This function should insert an element in the queue. + * Time complexity should be O(1). + * 3. dequeue - This function takes no arguments and has return type T. + * This should removes the first element which is entered and return that element as an answer. + * Time complexity should be O(1). + * 4. front - This function takes no input arguments and has return type T. + * This should return the first element which is entered and return that element as an answer. + * Time complexity should be O(1). + * 5. size - Return the size of stack i.e. count of elements which are present ins stack right now. + * Time complexity should be O(1). + * 6. isEmpty - Checks if the queue is empty or not. + * Return true or false + * + */ + +class QueueEmptyException extends Exception { + + private static final long serialVersionUID = 7243921724361015813L; + + public static void main(String[] args) { + + @SuppressWarnings("resource") + Scanner s = new Scanner(System.in); + + Queue st = new Queue(); + + int choice = s.nextInt(); + int input; + + while (choice !=-1) { + + if(choice == 1) { + input = s.nextInt(); + st.enqueue(input); + } + + else if(choice == 2) { + + try { + System.out.println(st.dequeue()); + }catch (QueueEmptyException e) { + System.out.println(-1); + } + } + + else if(choice == 3) { + + try { + System.out.println(st.front()); + } catch (QueueEmptyException e) { + System.out.println(-1); + } + } + + else if(choice == 4) + System.out.println(st.size()); + + else if(choice == 5) + System.out.println(st.isEmpty()); + + choice = s.nextInt(); + } + } +} + +class Node { + T data; + Node next; + + public Node(T data) { + this.data = data; + } +} + +public class Queue { + + private Node front; + private Node rear; + private int size; + + + public Queue() { + front=null; + rear=null; + size=0; + + } + + public int size() { + return size; + } + + public boolean isEmpty() { + return (size==0); + } + + public T front() throws QueueEmptyException { + + if(size==0) + throw new QueueEmptyException(); + + return front.data; + } + + public void enqueue(T data) { + + if(size==0){ + Node newnode=new Node(data); + front=newnode; + rear=newnode; + size++; + } + + else{ + Node newnode=new Node(data); + rear.next=newnode; + rear=rear.next; + size++; + } + } + + + public T dequeue() throws QueueEmptyException { + + if(size==0) + throw new QueueEmptyException(); + + if(size==1){ + T temp=front.data; + front=null; + rear=null; + size=0; + return temp; + } + + else{ + T temp = front.data; + front = front.next; + size--; + return temp; + } + } + +} \ No newline at end of file diff --git a/list/Deletion_in_Linked_List.java b/list/Deletion_in_Linked_List.java new file mode 100644 index 0000000..98076d0 --- /dev/null +++ b/list/Deletion_in_Linked_List.java @@ -0,0 +1,100 @@ +package list; + +class LinkedList +{ + Node head; // head of list + + /* Linked list Node*/ + class Node + { + int data; + Node next; + Node(int d) + { + data = d; + next = null; + } + } + + /* Inserts a new Node at front of the list. */ + public void push(int new_data) + { + /* 1 & 2: Allocate the Node & + Put in the data*/ + Node new_node = new Node(new_data); + + /* 3. Make next of new Node as head */ + new_node.next = head; + + /* 4. Move the head to point to new Node */ + head = new_node; + } + + /* Given a reference (pointer to pointer) to the head of a list + and a position, deletes the node at the given position */ + void deleteNode(int position) + { + // If linked list is empty + if (head == null) + return; + + // Store head node + Node temp = head; + + // If head needs to be removed + if (position == 0) + { + head = temp.next; // Change head + return; + } + + // Find previous node of the node to be deleted + for (int i=0; temp!=null && inext is the node to be deleted + // Store pointer to the next of node to be deleted + Node next = temp.next.next; + + temp.next = next; // Unlink the deleted node from list + } + + /* This function prints contents of linked list starting from + the given node */ + public void printList() + { + Node tnode = head; + while (tnode != null) + { + System.out.print(tnode.data+" "); + tnode = tnode.next; + } + } + + /* Driver program to test above functions. Ideally this function + should be in a separate user class. It is kept here to keep + code compact */ + public static void main(String[] args) + { + /* Start with the empty list */ + LinkedList llist = new LinkedList(); + + llist.push(7); + llist.push(1); + llist.push(3); + llist.push(2); + llist.push(8); + + System.out.println("\nCreated Linked list is: "); + llist.printList(); + + llist.deleteNode(4); // Delete node at position 4 + + System.out.println("\nLinked List after Deletion at position 4: "); + llist.printList(); + } +} \ No newline at end of file diff --git a/list/Insertion_in_Linked_List.java b/list/Insertion_in_Linked_List.java new file mode 100644 index 0000000..f395e1a --- /dev/null +++ b/list/Insertion_in_Linked_List.java @@ -0,0 +1,99 @@ +package list; + +public class Insertion_in_Linked_List { + + class Node{ + int data; + Node next; + + Node(int d){ + data = d; + next = null; + } + } + + Node head; + + public void push(int new_data ) { + Node new_node = new Node(new_data); + new_node.next = head; + head = new_node; + } + + public void insertAfter(Node prev_node, int new_data) + { + /* 1. Check if the given Node is null */ + if (prev_node == null) + { + System.out.println("The given previous node cannot be null"); + return; + } + + /* 2 & 3: Allocate the Node & Put in the data*/ + Node new_node = new Node(new_data); + + /* 4. Make next of new Node as next of prev_node */ + new_node.next = prev_node.next; + + /* 5. make next of prev_node as new_node */ + prev_node.next = new_node; + } + + public void append(int new_data) { + + //make an object of above mentioned Node class + Node new_node = new Node(new_data); + + if(head == null) { + head = new_node; + return; + } + + new_node.next = null; + + Node last = head; + while (last.next != null) + last = last.next; + + last.next = new_node; + return; + } + + public void printList() + { + Node tnode = head; + while (tnode != null) + { + System.out.print(tnode.data+" "); + tnode = tnode.next; + } + } + + public static void main(String[] args) { + Insertion_in_Linked_List llist = new Insertion_in_Linked_List(); + /* Start with the empty list */ + + // Insert 6. So linked list becomes 6->NUllist + llist.append(6); + + // Insert 7 at the beginning. So linked list becomes + // 7->6->NUllist + llist.push(7); + + // Insert 1 at the beginning. So linked list becomes + // 1->7->6->NUllist + llist.push(1); + + // Insert 4 at the end. So linked list becomes + // 1->7->6->4->NUllist + llist.append(4); + + // Insert 8, after 7. So linked list becomes + // 1->7->8->6->4->NUllist + llist.insertAfter(llist.head.next, 8); + + System.out.println("\nCreated Linked list is: "); + llist.printList(); + } + +} diff --git a/list/MainList.java b/list/MainList.java new file mode 100644 index 0000000..e3332f6 --- /dev/null +++ b/list/MainList.java @@ -0,0 +1,18 @@ +package list; + +public class MainList { + + public static void main(String[] args) { + + MyLL myLL = new MyLL<>(); + + for (int i = 0; i < 10; i++) { + // add method use to add a element in the last node of the linked list + myLL.add(i + "added"); + + } +// print method use to print the linked list + myLL.print(); + } + +} diff --git a/list/MyLL.java b/list/MyLL.java new file mode 100644 index 0000000..b4e4cc9 --- /dev/null +++ b/list/MyLL.java @@ -0,0 +1,84 @@ +package list; + +public class MyLL { + + + //E is the Class defining the type of the inputs accepted + Node head; + + public void add(E data) { + Node toAdd = new Node<>(data); + + if (isEmpty()) { + head = toAdd; + return; + } + +//initialising temp as head to traverse the Linked list without breaking the chain + Node temp = head; + // control from loop exits as soon as next element becomes null + while (temp.next != null) { + + temp = temp.next; + } + // adding the new node after reaching to the end of linked list + temp.next = toAdd; + } + + void print() { + Node temp = head; + while (temp != null) { + System.out.print(temp.data + " "); + temp = temp.next; + } + } + + public boolean isEmpty() { + return head == null; + } + + public E removeLast() throws Exception { + Node temp = head; + + if (temp == null) { + throw new Exception("Cannot remove last element from empty linked list"); + } + + if (temp.next == null) { + Node toRemove = head; + head = null; + return toRemove.data; + } + + while (temp.next.next != null) { + temp = temp.next; + } + Node toRemove = temp.next; + temp.next = null; // changing the pointer of temp.next from toRemove to null,and garbage collection is done automatically + return toRemove.data; + } + + public E getLast() throws Exception { + Node temp = head; + + if (temp == null) { + throw new Exception("Cannot peek last element from empty linked list"); + } + while (temp.next != null) { + temp = temp.next; + } + return temp.data; + } + + public static class Node { + public E data; + public Node next; + + //constructor + public Node(E data) { + + this.data = data; + next = null; + } + } +} \ No newline at end of file diff --git a/matrix/Matrix_Problem_01.java b/matrix/Matrix_Problem_01.java new file mode 100644 index 0000000..5b34422 --- /dev/null +++ b/matrix/Matrix_Problem_01.java @@ -0,0 +1,87 @@ +package matrix; +import java.io.*; + +/* + * Spiral traversal on a Matrix + */ + +/* + * GIven an 2D array, print it in spiral form. + * See the following examples. + * + * Inputs: + * 01 02 03 04 + * 05 06 07 08 + * 09 10 11 12 + * 13 14 15 16 + * + * Output: + * 1 2 3 4 8 12 16 15 14 13 9 5 6 7 11 10 + * + * Explanation: + * The output is matrix in spiral format. + */ + +/* Graphical Try: + * + * 01-- 02-- 03-- 04 + * | + * 05-- 06-- 07 08 + * | | | + * 09 10 11 12 + * | | + * 13-- 14-- 15 --16 + * + * Output: + * 1, 2, 3, 4, 8, 12, 16, 15, 14, 13, 9, 5, 6, 7, 11, 10 + */ + +@SuppressWarnings("unused") +public class Matrix_Problem_01 { + + static void spiralPrint(int m, int n, int[][] a) { + + System.out.println("Spiral Traversal of given matrix is: "); + int i, k = 0, l = 0; + + /* + * k - starting row index + * m - ending row index + * l - starting column index + * n - ending column index + * i - iterator + */ + + while(k < m && l < n) { + + + for( i = l ; i < n ; ++i) + System.out.print(a[k][i] + " "); + k++; + + for(i = k ; i < m ; ++i) + System.out.print(a[i][n - 1] + " "); + n--; + + if(l < n) { + for(i = m - 1 ; i >= k ; --i) + System.out.print(a[i][l] + " "); + l++; + } + } + + } + + public static void main(String[] args) { + + int R = 3; + int C = 6; + int a[][] = { { 1 , 2 , 3 , 4 , 5 , 6 }, + { 7 , 8 , 9 , 10 , 11 , 12 }, + { 13 , 14 , 15 , 16 , 17 , 18 } + }; + + spiralPrint(R,C,a); + } + +} diff --git a/matrix/Matrix_Problem_02.java b/matrix/Matrix_Problem_02.java new file mode 100644 index 0000000..1de28d7 --- /dev/null +++ b/matrix/Matrix_Problem_02.java @@ -0,0 +1,123 @@ +package matrix; + +//Search an element in a matrix + +/* + * Example; + * Consider: | 1 2 3 4| + * x = 3, + * mat = | 5 6 7 8| Middle column: + * | 9 10 11 12| = {2, 6, 10, 14} + * |13 14 15 16| + * perform binary search on them + * since, x < 6, + * discard the last 2 rows as 'a' will not lie in them(sorted matrix) + * Now, only two rows are left + * | 1 2 3 4| + * x = 3, mat = | 5 6 7 8| + * + * Check whether element is present on the middle elements of these rows = {2, 6} + * + * If x != 2 or 6 + * + * If not, consider the four sub-parts + * 1st half of 1st row = {1}, 2nd half of 1st row = {3, 4} + * 1st half of 2nd row = {5}, 2nd half of 2nd row = {7, 8} + * + * According the value of 'x' it will be searched in the + * 2nd half of 1st row = {3, 4} and found at (i, j): (0, 2) + */ +public class Matrix_Problem_02 { + + static int MAX = 100; + + static void binarySearch(int mat[][], int i, int j_low, int j_high, int x) { + + while(j_low <= j_high) { + + int j_mid = (j_low + j_high)/2; + + if(mat[i][j_mid] == x) { + System.out.println("Found at (" + i + "," + j_mid + ")"); + return; + } + + else if(mat[i][j_mid] < x) + j_high = j_mid - 1; + + else + j_low = j_mid + 1; + } + + System.out.println("Element Not Found: "); + } + + static void sortedMatrixSearch(int mat[][], int n, int m, int x) { + + + // Single row matrix + if (n == 1) + { + binarySearch(mat, 0, 0, m - 1, x); + return; + } + + // Do binary search in middle column. + // Condition to terminate the loop when the 2 desired rows are found + int i_low = 0; + int i_high = n - 1; + int j_mid = m / 2; + + while ((i_low + 1) < i_high) + { + int i_mid = (i_low + i_high) / 2; + + // element found + if (mat[i_mid][j_mid] == x) + { + System.out.println ( "Found at (" + i_mid +", " + j_mid +")"); + return; + } + + else if (mat[i_mid][j_mid] > x) + i_high = i_mid; + + else + i_low = i_mid; + } + + // If element is present on the mid of the two rows + if (mat[i_low][j_mid] == x) + System.out.println ( "Found at (" + i_low + "," + j_mid +")"); + + else if (mat[i_low + 1][j_mid] == x) + System.out.println ( "Found at (" + (i_low + 1) + ", " + j_mid +")"); + + // Search element on 1st half of 1st row + else if (x <= mat[i_low][j_mid - 1]) + binarySearch(mat, i_low, 0, j_mid - 1, x); + + // Search element on 2nd half of 1st row + else if (x >= mat[i_low][j_mid + 1] && x <= mat[i_low][m - 1]) + binarySearch(mat, i_low, j_mid + 1, m - 1, x); + + // Search element on 1st half of 2nd row + else if (x <= mat[i_low + 1][j_mid - 1]) + binarySearch(mat, i_low + 1, 0, j_mid - 1, x); + + // search element on 2nd half of 2nd row + else + binarySearch(mat, i_low + 1, j_mid + 1, m - 1, x); + } + + public static void main(String[] args) { + int n = 4, m = 5, x = 8; + int mat[][] = {{0, 6, 8, 9, 11}, + {20, 22, 28, 29, 31}, + {36, 38, 50, 61, 63}, + {64, 66, 100, 122, 128}}; + + sortedMatrixSearch(mat, n, m, x); + } + +} diff --git a/matrix/Matrix_Problem_03.java b/matrix/Matrix_Problem_03.java new file mode 100644 index 0000000..91e4a53 --- /dev/null +++ b/matrix/Matrix_Problem_03.java @@ -0,0 +1,108 @@ +package matrix; +import java.util.*; +/* + * Title: Find median in a row wise sorted matrix + * We are given a row-wise row-wise matrix of size r*c, we need to find the median of matrix given. + * It is assumed that r*c is always odd. + */ +/* + * Examples: + * Input: + * 2 6 9 + * 3 6 9 + * + * Output: Median is 5 + * + * If we put all the values in a sorted array A[] = (1 2 3 3 5 6 6 9 9) + * Input: 1 3 4 + * 2 5 6 + * 7 8 9 + * Output: Median is 5 + */ +/* + * Simple Method: + * The simplest method to solve this problem is to store all the elements of the given matrix in an array of size r*c. + * Then we can either sort the array and find the median element in O(r*clog(r*c)) + * or + * we can use the approach discussed to find the median in O(r*c). + * Auxiliary space required will be O(r*c) in both the cases. + * An efficient approach for this problem is to use a binary search algorithm. + * The idea is that for a number of median there should be exactly (n/2) numbers which are less than all the numbers. + * Below is the step by step algorithm for this approach: + */ +/* ALGORITHM: + * + * 1. First, we find the minimum and maximum element in the matrix. + * The minimum element can be easily found by comparing the first element of each row, + * and similarly , the maximum element can be found by comparing the last element of each row. + * + * 2. Then we use binary search on our range of numbers from minimum to maximum, + * we find the mid of the min and max and get a count of numbers less then our mid. + * And accordingly change the min or max. + * + * 3. For a number to be median, there should be (r*c)/2 numbers smaller than that number. + * So for every number, we get the count of numbers less than that by using upper_bound() in each row of th ematrix, + * if it is less than the required count, the median must be greater than the selected number, + * else the median must be less then or equal to the selected number + * + */ +public class Matrix_Problem_03 { + + // function to find the median in matrix + static int binaryMedian(int m[][], int r, int c) { + int max = Integer.MIN_VALUE; + int min = Integer.MAX_VALUE; + for (int i = 0; i < r; i++) { + // finding the minimum element + if (m[i][0] < min) + min = m[i][0]; + // finding the maximum element + if (m[i][c - 1] > max) + max = m[i][c - 1]; + } + + int desired = (r * c + 1) / 2; + while (min < max) { + int mid = min + (max - min) / 2; + int place = 0; + int get = 0; + // find count of elements smaller than mid + for (int i = 0; i < r; ++i) { + get = Arrays.binarySearch(m[i], mid); + /* + * if element is not found in the array the binarySearch() method returns + * searched element by the following calculation + */ + if (get < 0) + get = Math.abs(get) - 1; + /* + * If the element is found in the array it returns the index(any index in case + * of duplicate). + * + * So we go to last index of element, which will give the number of elements + * smaller than the number including the searched element. + */ + else { + while (get < m[i].length && m[i][get] == mid) + get += 1; + } + place = place + get; + } + + if (place < desired) + min = mid + 1; + else + max = mid; + } + return min; + } + + // Driver program to test above method + public static void main(String[] args) { + int r = 3, c = 3; + int m[][] = { { 1, 3, 5 }, { 2, 6, 9 }, { 3, 6, 9 } }; + System.out.println("Median is" + binaryMedian(m, r, c)); + } + +} + diff --git a/matrix/Matrix_Problem_04.java b/matrix/Matrix_Problem_04.java new file mode 100644 index 0000000..633e9e6 --- /dev/null +++ b/matrix/Matrix_Problem_04.java @@ -0,0 +1,86 @@ +package matrix; + +/* + * Title: Find row with maximum no. of 1's + * We are given a boolean 2D array, where each row is sorted. + * Find the row with the maximum number of 1s. + */ + +/* + * Example: + * 0 1 1 1 + * 0 0 1 1 + * 1 1 1 1 "THIS ROW HAS MAXIMUM 1S" + * 0 0 0 0 + * + * Output: 2 + */ + +/* + * "A Simplex Method" is to do a row wise traversal of the matrix, + * count the number of 1s in each row and compare the count with max. + * Finally, return the index of row with maximum 1s. + * The time complexity of this method is O(m*n), + * where m is number of rows and n is number of columns in matrix. + * + * We can do it better. + * Since each row is sorted, we can use Binary Search to count of 1s in each row. + * The count of 1s will be equal to total number of columns minus the index of first 1. + */ + +public class Matrix_Problem_04 { + + static int R = 4, C = 4; + + // Function to find the index of first index of 1 in a boolean array arr[]. + static int first(int arr[], int low , int high) { + + if(high >= low) { + + //Get the middle index + int mid = low + (high - low)/2; + + //Check if the element at middle is first 1 + if((mid == 0 || (arr[mid - 1] == 0)) && arr[mid] == 1) + return mid; + + //If the element is 0, recur for right side + else if (arr[mid] == 0) + return first(arr, (mid + 1), high); + + //If the element is not first 1, recur for left side + else + return first(arr, low, (mid - 1)); + } + + return -1; + } + + //Function that returns index of row with maximum number of 1s + static int rowWithMaxis(int mat[][]) { + //Initialize max values + int max_row_index = 0, max = -1; + //Traverse for each row and count number of 1s by finding the index of first 1 + int i, index; + for(i = 0; i < R; i++) { + index = first(mat[i], 0, C - 1); + if(index != -1 && C - index > max) { + max = C - index ; + max_row_index = i; + } + } + return max_row_index; + } + + //Driver Code + public static void main(String[] args) { + int mat[][] = { + {0, 0, 0, 1}, + {0, 1, 1, 1}, + {1, 1, 1, 1}, + {0, 0, 0, 0} }; + + System.out.println("Index of row with maximum index is : " + rowWithMaxis(mat)); + } + +} diff --git a/matrix/Matrix_Problem_05.java b/matrix/Matrix_Problem_05.java new file mode 100644 index 0000000..183f898 --- /dev/null +++ b/matrix/Matrix_Problem_05.java @@ -0,0 +1,69 @@ +package matrix; +/* + * Title: A java program to Print all elements in sorted order from row and column wise sorted matrix + */ +public class Matrix_Problem_05 { + + static final int INF = Integer.MAX_VALUE; + static final int N = 4; + + /* + * A utility function to youngify a Young Tableau, + * This is different from standard youngify. + * It assumnes that the value at mat[0][0] is infinite. + */ + static void youngify(int mat[][], int i, int j) { + + //Find the values at down and right sides of mat[i][j] + int downVal = (i + 1 < N)? mat[i + 1][j] : INF; + int rightVal = (j + 1 < N)? mat[i][j + 1] : INF; + + // if mat[i][j] is the down right corner element. return. + if(downVal == INF && rightVal == INF) { + return; + } + + /* + * Move the smaller of two values(downVal and rightVal to mat[i][j] + * and recur for smaller value + */ + if(downVal < rightVal) { + mat[i][j] = downVal; + mat[i + 1][j] = INF; + youngify(mat, i + 1, j); + } + + else { + mat[i][j] = rightVal; + mat[i][j + 1] = INF; + youngify(mat, i, j + 1); + } + } + + // A utility function to extract minimum element from Young Tableau. + static int extractMin(int mat[][]) { + int ret = mat[0][0]; + mat[0][0] = INF; + youngify(mat, 0, 0); + return ret; + } + + //This function uses extractMin() to print elements in sorted order + static void printSorted(int mat[][]) { + System.out.println("Element of matrix in sorted order n"); + for(int i = 0; i < N * N; i++) { + System.out.print(extractMin(mat) + " "); + } + } + + //Driver Code + public static void main(String[] args) { + int mat[][] = { + {10, 20, 30, 40}, + {15, 25, 35, 45}, + {27, 29, 37, 48}, + {32, 33, 39, 50}}; + printSorted(mat); + } + +} diff --git a/matrix/Matrix_Problem_06.java b/matrix/Matrix_Problem_06.java new file mode 100644 index 0000000..0a2ac41 --- /dev/null +++ b/matrix/Matrix_Problem_06.java @@ -0,0 +1,82 @@ +package matrix; +import java.util.*; + +/* + * Title: Maximum size rectangle binary sub-matrix with all 1s + * + * Given a binary matrix, find the maximum size rectangle binary-sub-matrix with all 1's + */ +public class Matrix_Problem_06 { + + static int maxHist(int C, int[] row) { + + Stack result = new Stack<>(); + int top_val; + int max_area = 0; + int area; + + int i = 0; + while(i < C) { + if(result.empty() || row[result.peek()] <= row[i]) + result.push(i++); + + else { + top_val = row[result.peek()]; + result.pop(); + area = top_val * i; + + if(!result.empty()) + area = top_val * (i - result.peek() - 1); + max_area = Math.max(area, max_area); + } + } + + //Now pop the remaining bars stack and calculate area with every popped bar as the smallest bar + while(!result.empty()) { + top_val = row[result.peek()]; + result.pop(); + area = top_val * i; + if(!result.empty()) + area = top_val * (i - result.peek() - 1); + + max_area = Math.max(area, max_area); + } + return max_area; + } + + //Returns area of the largest rectangle with all 1s in A[][] + static int maxRectangle(int R, int C, int[][] A) { + + //Calculate area for first row and initialize it as result + int result = maxHist(C, A[0]); + + //iterate over row to find maximum rectangular area considering each row as histogram + for(int i = 1; i < R; i++) { + for(int j = 0; j < C; j ++) { + //if A[i][j] is 1 then Add A[i - 1][j] + if(A[i][j] == 1) + A[i][j] += A[i - 1][j]; + } + + //Update result if area with current row (as last row of rectangle) is more + result = Math.max(result, maxHist(C, A[i])); + } + return result; + } + + //Driver Code + public static void main(String[] args) { + int R = 4; + int C = 4; + + int[][] A = { + {0, 1, 1, 0}, + {1, 1, 1, 1}, + {1, 1, 1, 1}, + {1, 1, 0, 0}, + }; + + System.out.print("Area of maximum rectangle is " + maxRectangle(R, C, A)); + } + +} diff --git a/matrix/Matrix_Problem_07.java b/matrix/Matrix_Problem_07.java new file mode 100644 index 0000000..ba9b436 --- /dev/null +++ b/matrix/Matrix_Problem_07.java @@ -0,0 +1,38 @@ +package matrix; +/* Problem Title :-> Find a specific pair in Matrix */ +/* Approach :-> A Naive method to find maximum value of mat1[d][e] - mat[a][b] such that d > a and e > b */ +public class Matrix_Problem_07{ + + //The Function returns maximum value A(d, e) - A(a, b) + // over all choices of indexes such that both d > a and e > b. + static int findMaxValue(int N, int[][] mat){ + //stores maximum value + int maxValue = Integer.MIN_VALUE; + //Consider all possible pairs mat[a][b] and mat1[d][e] + for(int a = 0; a < N - 1; a++){ + for(int b = 0; b < N - 1 - 1; b++) { + for (int d = a + 1; d < N; d++) { + for (int e = b + 1; e < N; e++){ + if (maxValue < mat[d][e] - mat[a][b]) + maxValue = mat[d][e] - mat[a][b]; + } + } + } + } + return maxValue; + } + + //Drier Code + public static void main(String[] args) { + int N = 5; + int[][] mat = { + {1, 2, -1, -4, -20}, + {-8, -3, 4, 2, 1}, + {3, 8, 6, 1, 3}, + {-4, -1, 1, 7, -6}, + {0, -4, 10, -5, 1}, + }; + + System.out.println("Maximum Value is " + findMaxValue(N, mat)); + } +} \ No newline at end of file diff --git a/matrix/Matrix_Problem_08.java b/matrix/Matrix_Problem_08.java new file mode 100644 index 0000000..a59417c --- /dev/null +++ b/matrix/Matrix_Problem_08.java @@ -0,0 +1,41 @@ +package matrix; +/*Rotate Matrix by 90 degrees*/ + +public class Matrix_Problem_08{ + static int N = 4; + //Function to rotate the matrix 90 degree clockwise + static void rotate90(int[][] a){ + //Traverse Each Cycle + for(int i = 0; i < N/2; i++){ + for(int j = i; j < N - i - 1; j++){ + //Swap elements of each cycle in clockwise direction + int temp = a[i][j]; + a[N - 1 - j][i] = a[N - 1 - i][N - 1 - j]; + a[N - 1 - i][N - 1 - j] = a[j][N - 1 -i]; + a[j][N - 1 - i] = temp; + } + } + } + + //Function for print matrix + static void printMatrix(int[][] a){ + for (int i = 0; i < N; i++){ + for (int j = 0; j < N; j++){ + System.out.print(a[i][j] + " "); + System.out.println(); + } + } + } + + //Drier Code + public static void main(String[] args) { + int[][] a = { + {1, 2, 3, 4}, + {5, 6, 7, 8}, + {9, 10, 11, 12}, + {13, 14, 15, 16}, + }; + rotate90(a); + printMatrix(a); + } +} diff --git a/matrix/Matrix_Problem_09.java b/matrix/Matrix_Problem_09.java new file mode 100644 index 0000000..37019ee --- /dev/null +++ b/matrix/Matrix_Problem_09.java @@ -0,0 +1,71 @@ +package matrix; +//Kth smallest element in a row-column wise sorted matrix +public class Matrix_Problem_09 { + static class HeapNode{ + int val; + int r, c; + + HeapNode(int val, int r, int c){ + this.val = val; + this.c = c; + this.r = r; + } + } + static void swap(int i, int min, HeapNode[] a){ + HeapNode temp = a[i]; + a[i] = a[min]; + a[min] = temp; + } + + static void minHeapify(HeapNode[] ha, int i, int heap_size){ + int l = 2 * i + 1; + int r = 2 * i + 2; + int min = i; + + if(l < heap_size && ha[l].val < ha[i].val) + min = l; + if(r < heap_size && ha[r].val < ha[i].val) + min = r; + if(min != i){ + swap(i, min, ha); + minHeapify(ha, min, heap_size); + } + } + static void buildHeap(HeapNode[] ha, int n){ + int i = (n - 1)/2; + while(i > 0){ + minHeapify(ha, i, n); + i--; + } + } + public static int kthSmallest(int[][] mat, int n, int k){ + if(k <= 0 || k > n*n) + return Integer.MAX_VALUE; + + HeapNode[] ha = new HeapNode[n]; + for (int i = 0; i < n; i++) + ha[i]= new HeapNode(mat[0][i], 0, i); + + buildHeap(ha, n); + + HeapNode hr = new HeapNode(0,0,0); + + for (int i = 1; i < k; i++){ + hr = ha[0]; + int nextVal = hr.r < n - 1 ? mat[hr.r+1][hr.c] : Integer.MAX_VALUE; + ha[0] = new HeapNode(nextVal, hr.r + 1, hr.c); + minHeapify(ha, 0, n); + } + return hr.val; + } + public static void main(String[] args) { + int[][] mat = { + {10, 20, 30, 40}, + {15, 25, 35, 45}, + {25, 29, 37, 48}, + {32, 33, 39, 50} + }; + int res = kthSmallest(mat, 4, 7); + System.out.print("7th smallest element is " + res); + } +} diff --git a/matrix/Matrix_Problem_10.java b/matrix/Matrix_Problem_10.java new file mode 100644 index 0000000..bb81470 --- /dev/null +++ b/matrix/Matrix_Problem_10.java @@ -0,0 +1,53 @@ +package matrix; +//Common elements in all rows of a given matrix +public class Matrix_Problem_10 { + static final int M = 4; + static final int N = 5; + + static int findCommon(int[][] mat){ + int[] col = new int[M]; + int min_row, i; + + for(i = 0; i < M; i++) + col[i] = N - 1; + + min_row = 0; + + while(col[min_row] >= 0){ + for (i = 0; i < M; i++){ + if (mat[i][col[i]] < mat[min_row][col[min_row]]) + min_row = i; + } + + int eq_count = 0; + + for (i = 0; i < M; i++){ + if (mat[i][col[i]] > mat[min_row][col[min_row]]){ + if (col[i] == 0) + return -1; + + col[i] -= 1; + } + else + eq_count++; + } + if (eq_count == M) + return mat[min_row][col[min_row]]; + } + return -1; + } + + public static void main(String[] args) { + int[][] mat = { + {1, 2, 3, 4, 5}, + {2, 4, 5, 8, 10}, + {3, 5, 7, 9, 11}, + {1, 3, 5, 7, 9} + }; + int result = findCommon(mat); + if (result == -1) + System.out.print("No common element"); + else + System.out.print("Common element is " + result); + } +} diff --git a/oops/Mor.java b/oops/Mor.java index 263c1c7..31ccaa6 100644 --- a/oops/Mor.java +++ b/oops/Mor.java @@ -2,10 +2,12 @@ public class Mor extends Watches { + //overrided function @Override public void Digital() { System.out.println("Method_overriding is digital"); } + //second function public void Royal() { System.out.println("Method_overriding is royal"); } diff --git a/oopsEncapsulation/EncapIntro.java b/oopsEncapsulation/EncapIntro.java index e069086..c243ead 100644 --- a/oopsEncapsulation/EncapIntro.java +++ b/oopsEncapsulation/EncapIntro.java @@ -3,15 +3,12 @@ public class EncapIntro { public static void main(String[] args) { - S obj = new S(); obj.setName("Milan"); obj.setAge(16); + System.out.println(obj.getName()); System.out.println(obj.getAge()); - - } - } diff --git a/oopsEncapsulation/S.java b/oopsEncapsulation/S.java index f8de03c..ad56e91 100644 --- a/oopsEncapsulation/S.java +++ b/oopsEncapsulation/S.java @@ -1,5 +1,6 @@ package oopsEncapsulation; +//Student class short name as S public class S { /*we have to put the variables private to achieve encapsulation*/ @@ -18,13 +19,11 @@ public void setName(String name) { } //getter methods - public int getAge() { - return age; - } - - public String getName() { - return name; - } + public int getAge() { + return age; + } - + public String getName() { + return name; + } } diff --git a/oopsabstraction/Audi.java b/oopsabstraction/Audi.java index 26d5ed8..fd35932 100644 --- a/oopsabstraction/Audi.java +++ b/oopsabstraction/Audi.java @@ -1,14 +1,14 @@ package oopsabstraction; +//Audi Class public class Audi extends Car{ public void accelerate() { System.out.println("Audi is accelerating"); } + @Override public void apply_break() { - System.out.println("Audi is breaking"); - + System.out.println("Audi is breaking"); } - } diff --git a/oopsabstraction/Car.java b/oopsabstraction/Car.java index dceb3b5..9a5d83e 100644 --- a/oopsabstraction/Car.java +++ b/oopsabstraction/Car.java @@ -1,8 +1,6 @@ package oopsabstraction; public abstract class Car { - public abstract void accelerate(); public abstract void apply_break(); - } diff --git a/oopsinheritance/MainClass.java b/oopsinheritance/MainClass.java index c4c5dd6..8332e70 100644 --- a/oopsinheritance/MainClass.java +++ b/oopsinheritance/MainClass.java @@ -3,13 +3,13 @@ public class MainClass { public static void main(String[] args) { - + //Object of teacher class Teacher T = new Teacher(); T.name = "Mr Harry "; T.eat(); T.walk(); T.teach(); - + //Object of singer class Singer s = new Singer(); s.name = "Justin B "; s.sing(); diff --git a/oopspolymorphism/Animal.java b/oopspolymorphism/Animal.java index d46eeb4..99bbd6b 100644 --- a/oopspolymorphism/Animal.java +++ b/oopspolymorphism/Animal.java @@ -1,5 +1,5 @@ package oopspolymorphism; - +//An empty Animal class public class Animal { } diff --git a/patternsByloops/Pattern1.java b/patternsByloops/Pattern1.java index 4546ec7..a4ad1d9 100644 --- a/patternsByloops/Pattern1.java +++ b/patternsByloops/Pattern1.java @@ -1,5 +1,6 @@ package patternsByloops; +//Program for pattern 1 public class Pattern1 { public static void main(String[] args) { diff --git a/practiceProblems/Cylinder.java b/practiceProblems/Cylinder.java new file mode 100644 index 0000000..72c0b2f --- /dev/null +++ b/practiceProblems/Cylinder.java @@ -0,0 +1,26 @@ +package practiceProblems; + +public class Cylinder { + + public static void main(String[] args) { + + //The below line represent's the , Object of the Setter_Getters class + Getters_Setters_For_Cylinder sg = new Getters_Setters_For_Cylinder(); + + //setting values of pie, height & radius by using setter method with use of other class & by calling it + sg.setHeight(35); + sg.setRadius(3.0); + sg.setPie(3.14); + + //getting values of pie, radius & height + System.out.println("The value of the Pie is: " + sg.getPie()); + System.out.println("The height of the cylinder is: " + sg.getHeight() + " cm"); + System.out.println("The radius of the cylinder is: " + sg.getRadius() + " cm"); + + // volume of cylinder => (V = 3.14*(r)^2*h) + double V = sg.getPie()*(sg.getRadius()*sg.getRadius())*sg.getHeight(); + System.out.println("The volume of the cylinder is: " + V + " cm^3"); + + } + +} diff --git a/practiceProblems/Exercise1.java b/practiceProblems/Exercise1.java new file mode 100644 index 0000000..a62e265 --- /dev/null +++ b/practiceProblems/Exercise1.java @@ -0,0 +1,33 @@ +package practiceProblems; +import java.util.*; + +/* To calculate percentage of a given student in CBSE Board exam. + * His marks from 5 subjects must be taken as input from the keyboard + * (Marks are out of 100) + * */ + +public class Exercise1 { + + static Scanner sc = new Scanner(System.in); + + static int subject_1_marks = sc.nextInt(); + static int subject_2_marks = sc.nextInt(); + static int subject_3_marks = sc.nextInt(); + static int subject_4_marks = sc.nextInt(); + static int subject_5_marks = sc.nextInt(); + + public static void main(String[] args) { + + int total = (subject_1_marks + subject_2_marks + subject_3_marks + subject_4_marks + subject_5_marks); + float percentage = (total)/5; + + System.out.println("The marks of the subject's are: \n " + "\n" + "subject_1_marks:- " + subject_1_marks + "\n" + + "subject_2_marks:- " + subject_2_marks + "\n" + "subject_3_marks:- " + subject_3_marks + "\n" + + "subject_4_marks:- " + subject_4_marks + "\n" + "subject_5_marks:- " + subject_5_marks + "\n"); + + System.out.println("The total no. of marks are: " + total); + System.out.println("Total percentage is: " + percentage); + + } + +} diff --git a/practiceProblems/Exercise2.java b/practiceProblems/Exercise2.java new file mode 100644 index 0000000..794539d --- /dev/null +++ b/practiceProblems/Exercise2.java @@ -0,0 +1,34 @@ +package practiceProblems; +import java.util.Scanner; + +/* + * Take an array as input & print all of its content at particular index wise + */ + +public class Exercise2 { + + public static void main(String[] args) { + try (Scanner sc = new Scanner(System.in)) { + int n,sum =0; + + System.out.println("Enter no. of elements you want in array:"); + n = sc.nextInt(); + + int A[] = new int[n]; + System.out.println("Enter all the elements: "); + + for(int i=0;i 40) System.out.println(" The height of cylender is to high to to find vol & surface area: "); + else this.height = height; + } + + //setter method to set radius of cylinder + public void setRadius(double radius) { + this.radius = radius; + } + + //setter method to set the value of pie + public void setPie(double pie) { + this.pie = pie; + } + + //getter method to get the height of cylinder + public int getHeight() { + return height; + } + + //getter method to get the radius of cylinder + public double getRadius() { + return radius; + } + + //getter method to get the value of pie + public double getPie() { + return pie; + } + + + +} diff --git a/recursion/Factorial.java b/recursion/Factorial.java new file mode 100644 index 0000000..6091555 --- /dev/null +++ b/recursion/Factorial.java @@ -0,0 +1,21 @@ +package recursion; +import java.util.Scanner; + +public class Factorial { + public static long multiplyNumbers(int num) + { + if (num >= 1) + return num * multiplyNumbers(num - 1); + else + return 1; + } + public static void main(String[] args) { + + @SuppressWarnings("resource") + Scanner sc = new Scanner(System.in); + int num = sc.nextInt(); + long factorial = multiplyNumbers(num); + System.out.println("Factorial of " + num + " = " + factorial); + } + +} diff --git a/recursion/NRaiseP.java b/recursion/NRaiseP.java new file mode 100644 index 0000000..1aff02b --- /dev/null +++ b/recursion/NRaiseP.java @@ -0,0 +1,15 @@ +package recursion; + +public class NRaiseP { + + public static int nRaisep(int n, int p) { + if(p == 0) + return 1; + return n*nRaisep(n,p-1); + } + + public static void main(String[] args) { + System.out.println(nRaisep(3,4)); + } + +} diff --git a/recursion/NaturalNoSum.java b/recursion/NaturalNoSum.java new file mode 100644 index 0000000..6c52af4 --- /dev/null +++ b/recursion/NaturalNoSum.java @@ -0,0 +1,20 @@ +package recursion; + +/* + * Find sum of first N natural numbers using recursion + */ +public class NaturalNoSum { + + public static void main(String[] args) { + System.out.println(sum(5)); + } + + static int sum(int N) { + //Base case + if(N == 1) return 1; + + //Recursive call + return N+sum(N-1) ; + } + +} diff --git a/recursion/Problem_01.java b/recursion/Problem_01.java new file mode 100644 index 0000000..b5a8998 --- /dev/null +++ b/recursion/Problem_01.java @@ -0,0 +1,20 @@ +package recursion; + +/* + * Find sum of first N natural numbers using recursion + */ +public class Problem_01 { + + public static void main(String[] args) { + System.out.println(sum(5)); + } + + static int sum(int N) { + //Base case + if(N == 1) return 1; + + //Recursive call + return N+sum(N-1) ; + } + +} diff --git a/recursion/Subsequences.java b/recursion/Subsequences.java new file mode 100644 index 0000000..87719e9 --- /dev/null +++ b/recursion/Subsequences.java @@ -0,0 +1,50 @@ +package recursion; + +//Program to Find the Subsequences of Given String by using RECURSION +public class Subsequences { + + public static String[] findSubsequences(String str) { + + if(str.length() == 0) { + String ans[] = {""}; + return ans; + } + + String smallAns[] = findSubsequences(str.substring(1)); + String ans[] = new String[2 * smallAns.length]; + + /* + * Otherwise: + * int k = 0; + */ + for(int i = 0 ; i < smallAns.length ; i++) { + ans[i] = smallAns[i]; + /* + * Otherwise: + * ans[k] = smallAns[i]; + * k++; + */ + } + + for(int i = 0 ; i< smallAns.length ; i++) { + /* + * otherwise: ans[k] in place of ans[i + smallAns] and + * k++; + */ + ans[i + smallAns.length] = str.charAt(0) + smallAns[i]; + } + + return ans; + } + + public static void main(String[] args) { + + String str = "xyz"; + String ans[] = findSubsequences(str); + for(int i = 0 ; i < ans.length; i++) { + System.out.println(ans[i]); + } + + } + +} diff --git a/recursion/Tower_Of_Hanoi.java b/recursion/Tower_Of_Hanoi.java new file mode 100644 index 0000000..567e397 --- /dev/null +++ b/recursion/Tower_Of_Hanoi.java @@ -0,0 +1,29 @@ +package recursion; + +/* + * Stack Application :- Tower of Hanoi Problem(Puzzle 1) + */ +public class Tower_Of_Hanoi { + + //function to solve the tower of hanoi proble + static void towerOfHanoi(int n, char from_rod, char to_rod, char aux_rod) { + + if(n == 1) { + System.out.println("Move disk 1 from rod " + from_rod + " to_rod " + to_rod); + return; + } + + towerOfHanoi(n-1, from_rod, to_rod, aux_rod); + System.out.println("Move disk "+ n +" from_rod "+from_rod+" to rod "+to_rod); + + } + + //Driver Method + public static void main(String[] args) { + + int n =4; + towerOfHanoi(n,'A','C','B'); + + } + +} diff --git a/sdeProblems/FindDuplicate.java b/sdeProblems/FindDuplicate.java deleted file mode 100644 index df101dc..0000000 --- a/sdeProblems/FindDuplicate.java +++ /dev/null @@ -1,32 +0,0 @@ -package sdeProblems; - -public class FindDuplicate { - - // Implementing an array as a HashMap for finding duplicate elements - void printRepeating(int m[],int size) { - - int i; - System.out.print("The repeating elements are:"); - - for(i=0;i=0) m[Math.abs(m[i])] = -m[Math.abs(m[i])]; - else System.out.print(Math.abs(m[i]) + " "); - } - } - - //Driver Method - public static void main(String[] args) { - - FindDuplicate duplicate = new FindDuplicate(); // Making an object of FindDuplicate class - - int m[] = {1,2,3,1,3,6,6}; // Putting or declare values in or to array - int m_size = m.length; // variables which store size or length of array - - duplicate.printRepeating(m,m_size); // calling above function to pass value in it to print repeating elements - - } - - } diff --git a/sdeProblems/RotateArray.java b/sdeProblems/RotateArray.java deleted file mode 100644 index 69b6ef1..0000000 --- a/sdeProblems/RotateArray.java +++ /dev/null @@ -1,38 +0,0 @@ -package sdeProblems; - -public class RotateArray { - - //function to rotate the elements of an array - - void rotateL(int a[], int d, int n) { - for(int i= 0;i=0; i--) - { - /* Find the smallest element greater than ar2[i]. Move all elements one position ahead till the smallest greater - element is not found */ - int j, last = arr1[m-1]; - - for (j=m-2; j >= 0 && arr1[j] > arr2[i]; j--) - arr1[j+1] = arr1[j]; - - // If there was a greater element - if (j != m-2 || last > arr2[i]) { - arr1[j+1] = arr2[i]; - arr2[i] = last; } - } - } - - // Driver method to test the above function - public static void main1(String[] args) - { - merge(arr1.length,arr2.length); - System.out.print("After Merging nFirst Array: "); - System.out.println(Arrays.toString(arr1)); - System.out.print("Second Array: "); - System.out.println(Arrays.toString(arr2)); - } -} diff --git a/searchingAlgorithms/BinarySearch.java b/searchingAlgorithms/BinarySearch.java index d331720..3eda77a 100644 --- a/searchingAlgorithms/BinarySearch.java +++ b/searchingAlgorithms/BinarySearch.java @@ -1,5 +1,6 @@ package searchingAlgorithms; +//Binary Search Algorithm public class BinarySearch { // Returns index of x if it is present in arr[l.. diff --git a/sortingAlgorithms/BubbleSort.java b/sortingAlgorithms/BubbleSort.java index 56ae59c..f22a31c 100644 --- a/sortingAlgorithms/BubbleSort.java +++ b/sortingAlgorithms/BubbleSort.java @@ -1,5 +1,6 @@ package sortingAlgorithms; +//Program to demonstrate the bubble sort algorithm... public class BubbleSort { void bubbleSort(int a[]) { @@ -9,7 +10,7 @@ void bubbleSort(int a[]) { { for(int j=0;ja[j+1]) { + if(a[j] > a[j+1]) { //swap a[j+1] and a[i] int temp = a[j]; a[j] = a[j+1]; diff --git a/sortingAlgorithms/HeapSort.java b/sortingAlgorithms/HeapSort.java index 62ba46d..2f8dfdd 100644 --- a/sortingAlgorithms/HeapSort.java +++ b/sortingAlgorithms/HeapSort.java @@ -1,77 +1,76 @@ package sortingAlgorithms; +import java.util.*; //Java program for implementation of Heap Sort -public class HeapSort -{ - public void sort(int A[]) - { - int n = A.length; +public class HeapSort { + + public void sort(int A[]) { + + int n = A.length; + + for(int i=n/2;i>=0;i--) + heapify(A,n,i); + + for(int i = n-1;i>0;i--) { + int temp = A[0]; + A[0] = A[i]; + A[i] = temp; + + heapify(A,i,0); + } + } + + void heapify(int A[], int n, int i) { - // Build heap (rearrange array) - for (int i = n / 2 - 1; i >= 0; i--) - heapify(A, n, i); + int largest = i; // Initialize largest as root + int l = 2*i + 1; // left = 2*i + 1 + int r = 2*i + 2; // right = 2*i + 2 - // One by one extract an element from heap - for (int i=n-1; i>0; i--) - { - // Move current root to end - int temp = A[0]; - A[0] = A[i]; - A[i] = temp; + // If left child is larger than root + if (l < n && A[l] > A[largest]) + largest = l; - // call max heapify on the reduced heap - heapify(A, i, 0); - } - } + // If right child is larger than largest so far + if (r < n && A[r] > A[largest]) + largest = r; - // To heapify a subtree rooted with node i which is - // an index in arr[]. n is size of heap - void heapify(int A[], int n, int i) - { - int largest = i; // Initialize largest as root - int l = 2*i + 1; // left = 2*i + 1 - int r = 2*i + 2; // right = 2*i + 2 + // If largest is not root + if (largest != i) + { + int swap = A[i]; + A[i] = A[largest]; + A[largest] = swap; - // If left child is larger than root - if (l < n && A[l] > A[largest]) - largest = l; + // Recursively heapify the affected sub-tree + heapify(A, n, largest); + } + } - // If right child is larger than largest so far - if (r < n && A[r] > A[largest]) - largest = r; + /* A utility function to print array of size n */ + static void printArray(int A[]) + { + int n = A.length; + for (int i=0; i 0; exp *= 10) countSort(arr, n, exp); } @@ -71,3 +71,4 @@ public static void main (String[] args) { print(arr, n); } } + \ No newline at end of file diff --git a/ssp/SSP_Problem_01.java b/ssp/SSP_Problem_01.java new file mode 100644 index 0000000..552380b --- /dev/null +++ b/ssp/SSP_Problem_01.java @@ -0,0 +1,66 @@ +package ssp; + +// Problem Title :- Find first and last positions of an element in a sorted array +// An optimized approach using binary search in O(n) Time Complexity. +public class SSP_Problem_01 { + + /* + * if x is present in a[] then returns the index of + * FIRST occurrence of x in a[0...n-1], + * otherwise returns -1. + */ + public static int first(int[] a, int low, int high, int x, int n) { + + if(high >= low) { + + int mid = low + (high - low)/2; + + if( (mid == 0 || x > a[mid - 1]) && a[mid] == x) + return mid; + + else if(x > a[mid]) + return first(a, (mid + 1), high, x, n); + + else + return first(a, low, (mid - 1 ), x, n); + } + return -1; + } + + /* + * if x is present in a[] then returns the index of + * LAST occurrence of x in a[0..n-1], + * otherwise returns -1 + */ + public static int last(int a[], int low, int high, int x, int n) { + + if(high >= low) { + + int mid = low + (high - low)/2; + + if((mid == n-1 || x < a[mid + 1]) && a[mid] == x) + return mid; + + else if(x < a[mid]) + return last(a, low, (mid - 1), x, n); + + else + return last(a, (mid + 1), high, x, n); + } + + return -1; + } + + // Driver Code + public static void main(String[] args) { + + int[] a = {1, 2, 2, 2, 2, 3, 4, 7, 8, 8}; + + int n = a.length; + int x = 8; + + System.out.println("First Occurence = " + first(a, 0, n - 1, x, n)); + System.out.println("last Occurence = " + last(a, 0, n-1, x, n)); + } + +} diff --git a/ssp/SSP_Problem_02.java b/ssp/SSP_Problem_02.java new file mode 100644 index 0000000..3781f9a --- /dev/null +++ b/ssp/SSP_Problem_02.java @@ -0,0 +1,30 @@ +package ssp; + +// Problem Title :-> Find a Fixed Point (Value equal to index) in a given array +public class SSP_Problem_02 { + static int binarySearch(int[] a, int low, int high) { + + if(high >= low) { + + /* low + (high - low)/2;*/ + int mid = (low + high)/2; + + if(mid == a[mid]) + return mid; + + if(mid > a[mid]) + return binarySearch(a, (mid + 1), high); + + else + return binarySearch(a, low, (mid - 1)); + } + /* Return -1 if there is no Fixed Point */ + return -1; + } + // Driver Code + public static void main(String[] args) { + int[] a= {-10, -1, 0, 3, 10, 11, 30, 50, 100}; + int n = a.length; + System.out.println("Fixed Point is " + binarySearch(a, 0, n-1)); + } +} diff --git a/ssp/SSP_Problem_03.java b/ssp/SSP_Problem_03.java new file mode 100644 index 0000000..d940050 --- /dev/null +++ b/ssp/SSP_Problem_03.java @@ -0,0 +1,50 @@ +package ssp; +// Problem Title :-> Search in a rotated sorted array +// Approach :-> Using single pass of Binary Search. +// Complexity Analysis :-> Time Complexity is O(log n) & Space Complexity O(1) as no extra space is required. +public class SSP_Problem_03 { + /* + * Returns index of key in a[1..h] if key is present, + * otherwise returns -1. + */ + static int search(int[] a, int l, int h, int key) { + if(l > h) + return -1; + + int mid = (l + h) / 2; + if(a[mid] == key) + return mid; + + /* If a[1...mid] first sub-array is sorted */ + if(a[l] <= a[mid]) { + if(key >= a[l] && key <= a[mid]) + return search(a, l, mid - 1, key); + return search(a, mid + 1, h, key); + } + + /* + * If a[1..mid] first sub-array is not sorted, + * then a[mid...h] must be sorted sub-array + */ + if(key >= a[mid] && key <= a[h]) + return search(a, mid + 1, h, key); + + /* + * if key not lies in first half sub-array, + * Divide other half into two sub-arrays, + * such that we can quickly check if key lies in other half + */ + return search(a, l, mid - 1, key); + } + // Driver Code + public static void main(String[] args) { + int[] a = {4, 5, 6, 7, 8, 9, 1, 2, 3}; + int n = a.length; + int key = 6; + int i = search(a, 0, n - 1, key); + if(i != -1) + System.out.println("Index: " + i); + else + System.out.println("Key not found"); + } +} diff --git a/stack/Parenthesis_Checker_Problem.java b/stack/Parenthesis_Checker_Problem.java new file mode 100644 index 0000000..c602cad --- /dev/null +++ b/stack/Parenthesis_Checker_Problem.java @@ -0,0 +1,75 @@ +package stack; +import java.util.Scanner; +import java.util.Stack; + +public class Parenthesis_Checker_Problem { + + @SuppressWarnings("resource") + public static void main(String[] args) { + + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-- != 0) { + + String s = sc.nextLine(); + Stack stack = new Stack<>(); + + boolean isBalanced = true; + + for(int i = 0 ; i < s.length() ; i++) { + + char ch = s.charAt(i); + if(ch == '(' || ch == '{' || ch == '[') { + stack.push(ch); + continue; + } + + if(stack.isEmpty()) { + isBalanced = false; + break; + } + + if(ch == ')') { + if(stack.peek() == '(') { + stack.pop(); + }else { + isBalanced = false; + break; + } + } + + if(ch == '}') { + if(stack.peek() == '{') { + stack.pop(); + }else { + isBalanced = false; + break; + } + } + + if(ch == ']') { + if(stack.peek() == '[') { + stack.pop(); + }else { + isBalanced = false; + break; + } + } + + } + + if(!stack.isEmpty()) { + isBalanced = false; + } + + if(isBalanced) { + System.out.println("isBalanced"); + }else { + System.out.println("not balanced"); + } + + } + + } + +} diff --git a/stack/Tower_Of_Hanoi.java b/stack/Tower_Of_Hanoi.java new file mode 100644 index 0000000..4f2e26f --- /dev/null +++ b/stack/Tower_Of_Hanoi.java @@ -0,0 +1,29 @@ +package stack; + +/* + * Stack Application :- Tower of Hanoi Problem(Puzzle 1) + */ +public class Tower_Of_Hanoi { + + //function to solve the tower of hanoi proble + static void towerOfHanoi(int n, char from_rod, char to_rod, char aux_rod) { + + if(n == 1) { + System.out.println("Move disk 1 from rod " + from_rod + " to_rod " + to_rod); + return; + } + + towerOfHanoi(n-1, from_rod, to_rod, aux_rod); + System.out.println("Move disk "+ n +" from_rod "+from_rod+" to rod "+to_rod); + + } + + //Driver Method + public static void main(String[] args) { + + int n =4; + towerOfHanoi(n,'A','C','B'); + + } + +} diff --git a/stack_and_queue/Infix_To_Postfix.java b/stack_and_queue/Infix_To_Postfix.java new file mode 100644 index 0000000..b042525 --- /dev/null +++ b/stack_and_queue/Infix_To_Postfix.java @@ -0,0 +1,76 @@ +package stack_and_queue; +import java.util.*; + +public class Infix_To_Postfix { + + static int Prec(char ch){ + switch(ch){ + case '+': + case '-': + return 1; + + case '*': + case '/': + return 2; + + case '^': + return 3; + } + + return -1; + } + + static String infixToPostfix(String exp){ + + String result = new String(" "); + Stack stack = new Stack<>(); + + for(int i = 0 ; i < exp.length() ; ++i){ + char c = exp.charAt(i); + + if(Character.isLetterOrDigit(c)) + result += c; + + else if(c == '(') + stack.push(c); + + else if (c == ')'){ + while (!stack.isEmpty() && stack.peek() != '(') + result += stack.pop(); + + stack.pop(); + } + + else{ + while(!stack.isEmpty() && Prec(c) <= Prec(stack.peek())){ + result += stack.pop(); + } + } + + stack.push(c); + } + + while (!stack.isEmpty()) { + + if(stack.peek() == '(') + return "Invalid Expression"; + + result += stack.pop(); + } + + return result; + } + + public static void main(String[] args) { + + Scanner sc = new Scanner(System.in); + String exp = sc.nextLine(); + + @SuppressWarnings("unused") + Infix_To_Postfix post = new Infix_To_Postfix(); + + System.out.println(infixToPostfix(exp)); + sc.close(); + } + +} diff --git a/stack_and_queue/Parenthesis_Checker_Problem.java b/stack_and_queue/Parenthesis_Checker_Problem.java new file mode 100644 index 0000000..83fcaf5 --- /dev/null +++ b/stack_and_queue/Parenthesis_Checker_Problem.java @@ -0,0 +1,75 @@ +package stack_and_queue; +import java.util.Scanner; +import java.util.Stack; + +public class Parenthesis_Checker_Problem { + + @SuppressWarnings("resource") + public static void main(String[] args) { + + Scanner sc = new Scanner(System.in); + int t = sc.nextInt(); + while(t-- != 0) { + + String s = sc.nextLine(); + Stack stack = new Stack<>(); + + boolean isBalanced = true; + + for(int i = 0 ; i < s.length() ; i++) { + + char ch = s.charAt(i); + if(ch == '(' || ch == '{' || ch == '[') { + stack.push(ch); + continue; + } + + if(stack.isEmpty()) { + isBalanced = false; + break; + } + + if(ch == ')') { + if(stack.peek() == '(') { + stack.pop(); + }else { + isBalanced = false; + break; + } + } + + if(ch == '}') { + if(stack.peek() == '{') { + stack.pop(); + }else { + isBalanced = false; + break; + } + } + + if(ch == ']') { + if(stack.peek() == '[') { + stack.pop(); + }else { + isBalanced = false; + break; + } + } + + } + + if(!stack.isEmpty()) { + isBalanced = false; + } + + if(isBalanced) { + System.out.println("isBalanced"); + }else { + System.out.println("not balanced"); + } + + } + + } + +} diff --git a/stack_and_queue/Stack_Queue_Problem_01_i.java b/stack_and_queue/Stack_Queue_Problem_01_i.java new file mode 100644 index 0000000..92da5de --- /dev/null +++ b/stack_and_queue/Stack_Queue_Problem_01_i.java @@ -0,0 +1,69 @@ +package stack_and_queue; +import java.util.*; + +/* + * Implement Stack from Scratch Array Implementation + */ +public class Stack_Queue_Problem_01_i implements Iterable { + + @SuppressWarnings("unchecked") + private Item[] a = (Item[]) new Object[1]; // Stack Items + private int N = 0; // number of items + + public boolean isEmpty() { + return N == 0; + } + + public int size() { + return N; + } + + private void resize(int max) { + @SuppressWarnings("unchecked") + Item[] temp = (Item[]) new Object[max]; + for (int i = 0; i < N; i++) + temp[i] = a[i]; + a = temp; + } + + public void push(Item item) { + if (N == a.length) + resize(2 * a.length); + a[N++] = item; + + } + + public Item pop() { + Item item = a[--N]; + a[N] = null; + + if (N > 0 && N == a.length / 4) + resize(a.length / 2); + + return item; + } + + public Iterator iterator() { + return new ReverseArrayIterator(); + } + + private class ReverseArrayIterator implements Iterator { + public int i = N; + + public boolean hasNext() { + return i > 0; + } + + public Item next() { + return a[--i]; + } + + public void remove() { + + } + } + + public static void main(String[] args) { + + } +} diff --git a/stack_and_queue/Stack_Queue_Problem_01_ii.java b/stack_and_queue/Stack_Queue_Problem_01_ii.java new file mode 100644 index 0000000..4bbcb8b --- /dev/null +++ b/stack_and_queue/Stack_Queue_Problem_01_ii.java @@ -0,0 +1,115 @@ +package stack_and_queue; +import static java.lang.System.exit; + +//Java program to Implement a stack using singly linked list + +//Create Stack Using Linked list +class StackUsingLinkedlist { + + // A linked list node + private class Node { + + int data; // integer data + Node link; // reference variable Node type + } + + // create global top reference variable global + Node top; + + // Constructor + StackUsingLinkedlist() { + this.top = null; + } + + // Utility function to add an element x in the stack + public void push(int x) // insert at the beginning + { + // create new node tempt and allocate memory + Node temp = new Node(); + + // initialize data into data field + temp.data = x; + + // put top reference into link + temp.link = top; + + // update top reference + top = temp; + } + + // Utility function to check if the stack is empty or not + public boolean isEmpty() { + return top == null; + } + + // Utility function to return top element in a stack + public int peek() { + // check for empty stack + if (!isEmpty()) { + return top.data; + } else { + System.out.println("Stack is empty"); + return -1; + } + } + + // Utility function to pop top element from the stack + public void pop() // remove at the beginning + { + // check for stack underflow + if (top == null) { + System.out.print("\nStack Underflow"); + return; + } + + // update the top pointer to point to the next node + top = (top).link; + } + + public void display() { + // check for stack underflow + if (top == null) { + System.out.printf("\nStack Underflow"); + exit(1); + } else { + Node temp = top; + while (temp != null) { + + // print node data + System.out.printf("%d->", temp.data); + + // assign temp link to temp + temp = temp.link; + } + } + } +} + +//main class +public class Stack_Queue_Problem_01_ii { + public static void main(String[] args) { + // create Object of Implementing class + StackUsingLinkedlist obj = new StackUsingLinkedlist(); + // insert Stack value + obj.push(11); + obj.push(22); + obj.push(33); + obj.push(44); + + // print Stack elements + obj.display(); + + // print Top element of Stack + System.out.printf("\nTop element is %d\n", obj.peek()); + + // Delete top element of Stack + obj.pop(); + obj.pop(); + + // print Stack elements + obj.display(); + + // print Top element of Stack + System.out.printf("\nTop element is %d\n", obj.peek()); + } +} diff --git a/stack_and_queue/Stack_Queue_Problem_02_i.java b/stack_and_queue/Stack_Queue_Problem_02_i.java new file mode 100644 index 0000000..d00f8bb --- /dev/null +++ b/stack_and_queue/Stack_Queue_Problem_02_i.java @@ -0,0 +1,67 @@ +package stack_and_queue; + +//Queue From Scratch using Array +class Queue { + int front, rear, size, capacity, array[]; + + public Queue(int capacity) { + this.capacity = capacity; + front = this.size = 0; + rear = capacity - 1; + array = new int[this.capacity]; + } + + boolean isFull(Queue queue) { + return (queue.size == queue.capacity); + } + + boolean isEmpty(Queue queue) { + return (queue.size == 0); + } + + void enqueue(int item) { + if (isFull(this)) + return; + this.rear = (this.rear + 1) % this.capacity; + this.array[this.rear] = item; + this.size = this.size + 1; + System.out.println(item + " enqueued to queue"); + } + + int dequeue() { + if (isEmpty(this)) + return Integer.MIN_VALUE; + int item = this.array[this.front]; + this.front = (this.front + 1) % this.capacity; + this.size = this.size - 1; + return item; + } + + int front() { + if (isEmpty(this)) + return Integer.MIN_VALUE; + return this.array[this.front]; + } + + int rear() { + if (isEmpty(this)) + return Integer.MIN_VALUE; + return this.array[this.rear]; + } +} + +public class Stack_Queue_Problem_02_i { + + public static void main(String[] args) { + Queue queue = new Queue(1000); + queue.enqueue(10); + queue.enqueue(20); + queue.enqueue(30); + queue.enqueue(40); + + System.out.println(queue.dequeue() + " dequeued from queue \n "); + System.out.println("Front item is " + queue.front()); + System.out.println("Rear item is " + queue.rear()); + } + +} diff --git a/stack_and_queue/Stack_Queue_Problem_02_ii.java b/stack_and_queue/Stack_Queue_Problem_02_ii.java new file mode 100644 index 0000000..a861152 --- /dev/null +++ b/stack_and_queue/Stack_Queue_Problem_02_ii.java @@ -0,0 +1,11 @@ +package stack_and_queue; + +//Queue from scratch using Linked-list +public class Stack_Queue_Problem_02_ii { + + public static void main(String[] args) { + + + } + +} diff --git a/stack_and_queue/Stack_Queue_Problem_03.java b/stack_and_queue/Stack_Queue_Problem_03.java new file mode 100644 index 0000000..979fbf7 --- /dev/null +++ b/stack_and_queue/Stack_Queue_Problem_03.java @@ -0,0 +1,75 @@ +package stack_and_queue; + +//Implement two stack in an array + +public class Stack_Queue_Problem_03 { + + int size, top1, top2; + int a[]; + + Stack_Queue_Problem_03(int n) { + a = new int[n]; + size = n; + top1 = -1; + top2 = size; + } + + void push1(int x) { + if (top1 < top2 - 1) { + top1++; + a[top1] = x; + } else { + System.out.println("Stack Overflow"); + System.exit(1); + } + } + + void push2(int x) { + if (top1 < top2 - 1) { + top2--; + a[top2] = x; + } else { + System.out.println("Stack Overflow"); + System.exit(1); + } + } + + int pop1() { + if (top1 >= 0) { + int x = a[top1]; + top1--; + return x; + } else { + System.out.println("Stack Underflow"); + System.exit(1); + } + return 0; + } + + int pop2() { + if (top1 < size) { + int x = a[top2]; + top2++; + return x; + } else { + System.out.println("Stack Underflow"); + System.exit(1); + } + return 0; + } + + public static void main(String[] args) { + + Stack_Queue_Problem_03 ts = new Stack_Queue_Problem_03(5); + ts.push1(5); + ts.push2(10); + ts.push2(15); + ts.push1(11); + ts.push2(7); + + System.out.println("Popped element from" + " stack 1 is " + ts.pop1()); + ts.push2(40); + System.out.println("Popped element from" + " stack 2 is " + ts.pop2()); + } + +} diff --git a/trees/BST_Deletion.java b/trees/BST_Deletion.java new file mode 100644 index 0000000..240dd72 --- /dev/null +++ b/trees/BST_Deletion.java @@ -0,0 +1,158 @@ +package trees; + +//Java program to demonstrate delete operation in binary search tree +class BST_Deletion{ + + // Class to make a Node + static class Node { + int key; + Node left, right; + + public Node(int item) { + key = item; + left = right = null; + } + } + + // Root of BST + Node root; + + // Constructor + BST_Deletion() { + root = null; + } + + // This method mainly calls deleteRec() + void deleteKey(int key) { + root = deleteRec(root, key); + } + + /* A recursive function to insert a new key in BST */ + Node deleteRec(Node root, int key) { + /* Base Case: If the tree is empty */ + if (root == null) return root; + + /* Otherwise, recur down the tree */ + if (key < root.key) + root.left = deleteRec(root.left, key); + else if (key > root.key) + root.right = deleteRec(root.right, key); + + // if key is same as root's key, then This is the node + // to be deleted + else + { + // node with only one child or no child + if (root.left == null) + return root.right; + else if (root.right == null) + return root.left; + + // node with two children: Get the inorder successor (smallest + // in the right subtree) + root.key = minValue(root.right); + + // Delete the inorder successor + root.right = deleteRec(root.right, root.key); + } + + return root; + } + + int minValue(Node root) + { + int minv = root.key; + while (root.left != null) + { + minv = root.left.key; + root = root.left; + } + return minv; + } + + // This method mainly calls insertRec() + void insert(int key) + { + root = insertRec(root, key); + } + + /* A recursive function to insert a new key in BST */ + Node insertRec(Node root, int key) + { + + /* If the tree is empty, return a new node */ + if (root == null) + { + root = new Node(key); + return root; + } + + /* Otherwise, recur down the tree */ + if (key < root.key) + root.left = insertRec(root.left, key); + else if (key > root.key) + root.right = insertRec(root.right, key); + + /* return the (unchanged) node pointer */ + return root; + } + + // This method mainly calls InorderRec() + void inorder() + { + inorderRec(root); + } + + // A utility function to do inorder traversal of BST + void inorderRec(Node root) + { + if (root != null) + { + inorderRec(root.left); + System.out.print(root.key + " "); + inorderRec(root.right); + } + } + + // Driver Program to test above functions + public static void main(String[] args) + { + BST_Deletion tree = new BST_Deletion(); + + /* Let us create following BST + 50 + / \ + 30 70 + / \ / \ + 20 40 60 80 */ + + tree.insert(50); + tree.insert(30); + tree.insert(20); + tree.insert(40); + tree.insert(70); + tree.insert(60); + tree.insert(80); + + System.out.println("Inorder traversal of the given tree"); + tree.inorder(); + + System.out.println("\nDelete 20"); + tree.deleteKey(20); + + System.out.println("Inorder traversal of the modified tree"); + tree.inorder(); + + System.out.println("\nDelete 30"); + tree.deleteKey(30); + + System.out.println("Inorder traversal of the modified tree"); + tree.inorder(); + + System.out.println("\nDelete 50"); + tree.deleteKey(50); + + System.out.println("Inorder traversal of the modified tree"); + tree.inorder(); + } +} \ No newline at end of file diff --git a/trees/BinarySearchTree.java b/trees/BinarySearchTree.java new file mode 100644 index 0000000..d6a2105 --- /dev/null +++ b/trees/BinarySearchTree.java @@ -0,0 +1,83 @@ +package trees; + +class BinarySearchTree { + + /* Class containing left and right child of current node and key value*/ + static class Node { + int key; + Node left, right; + + public Node(int item) { + key = item; + left = right = null; + } + } + + // Root of BST + Node root; + + // Constructor + BinarySearchTree() { + root = null; + } + + // This method mainly calls insertRec() + void insert(int key) { + root = insertRec(root, key); + } + + /* A recursive function to insert a new key in BST */ + Node insertRec(Node root, int key) { + + /* If the tree is empty, return a new node */ + if (root == null) { + root = new Node(key); + return root; + } + + /* Otherwise, recur down the tree */ + if (key < root.key) + root.left = insertRec(root.left, key); + else if (key > root.key) + root.right = insertRec(root.right, key); + + /* return the (unchanged) node pointer */ + return root; + } + + // This method mainly calls InorderRec() + void inorder() { + inorderRec(root); + } + + // A utility function to do inorder traversal of BST + void inorderRec(Node root) { + if (root != null) { + inorderRec(root.left); + System.out.println(root.key); + inorderRec(root.right); + } + } + + // Driver Program to test above functions + public static void main(String[] args) { + BinarySearchTree tree = new BinarySearchTree(); + + /* Let us create following BST + 50 + / \ + 30 70 + / \ / \ + 20 40 60 80 */ + tree.insert(50); + tree.insert(30); + tree.insert(20); + tree.insert(40); + tree.insert(70); + tree.insert(60); + tree.insert(80); + + // print inorder traversal of the BST + tree.inorder(); + } +} diff --git a/trees/Count_leaf_nodes.java b/trees/Count_leaf_nodes.java new file mode 100644 index 0000000..17ce326 --- /dev/null +++ b/trees/Count_leaf_nodes.java @@ -0,0 +1,29 @@ +package trees; + + /* + * Code : Count leaf nodes + * Send Feedback + * Given a generic tree, count and return the number of leaf nodes present in the given tree. + * Input format : + * Elements in level order form separated by space (as per done in class). Order is - + * Root_data, n (No_Of_Child_Of_Root), n children, and so on for every element + * Output Format : + * Count of leaf nodes + * Sample Input 1 : + * 10 3 20 30 40 2 40 50 0 0 0 0 + * Sample Output 1 : + * + * 4 + */ + +public class Count_leaf_nodes { + static int calcNodes(int N, int I){ + int result; + result = I * (N - 1) + 1; + return result; + } + public static void main(String[] args) { + int N = 5, I = 2; + System.out.println("Leaf nodes = " + calcNodes(N, I)); + } +} diff --git a/trees/FindFullNodesInABinaryTree.java b/trees/FindFullNodesInABinaryTree.java index 9ef37e1..cde6448 100644 --- a/trees/FindFullNodesInABinaryTree.java +++ b/trees/FindFullNodesInABinaryTree.java @@ -2,12 +2,14 @@ //A Binary Tree Node class Node{ + int data; Node left , right; + + //Constructor of Node Class Node(int data) { this.data = data; left = right = null ; - } } @@ -15,31 +17,37 @@ public class FindFullNodesInABinaryTree { //Traverse given tree in In-order fashion & prints all nodes that have both children as non-empty public static void findFullNode(Node root) { - if (root!=null) { + if (root != null) { findFullNode(root.left); + if(root.left != null && root.right != null) System.out.println(root.data +" "); + findFullNode(root.right); } } //Driver method public static void main(String[] args) { - Node root = new Node(1); + + //Calling Node class by making an object of it (means by making a root node) + Node root = new Node(1); + root.left = new Node(2); root.right = new Node(3); root.left.left = new Node(4); root.left.right = new Node(5); root.right.left = new Node(6); root.right.right = new Node(7); - root.right.right.right = new Node(8); - root.right.left.right = new Node(9); - root.right.left.left = new Node(10); - root.left.left.left= new Node(11); - root.left.left.right = new Node(12); - root.left.right.left = new Node(13); - root.left.right.right = new Node(14); + root.left.left.left= new Node(8); + root.right.left.left = new Node(9); + root.left.left.right = new Node(10); + root.left.right.left = new Node(11); + root.right.left.right = new Node(12); + root.left.right.right = new Node(13); + root.right.right.right = new Node(14); + //calling the find full nodes by passing values of or as root or root valuess in it findFullNode(root); } diff --git a/trees/Insertion_In_BinaryTree.java b/trees/Insertion_In_BinaryTree.java index 98e45ad..efdb19a 100644 --- a/trees/Insertion_In_BinaryTree.java +++ b/trees/Insertion_In_BinaryTree.java @@ -1,9 +1,9 @@ package trees; +import java.util.*; - // Java program to insert element in binary tree -import java.util.LinkedList; -import java.util.Queue; +//Java program to insert element in binary tree public class Insertion_In_BinaryTree { + /* A binary tree node has key, pointer to left child and a pointer to right child */ static class Node { @@ -19,13 +19,14 @@ static class Node { static Node root; static Node temp = root; - //Inorder traversal of a binary tree + //In-order traversal of a binary tree static void inorder(Node temp) { if (temp == null) return; inorder(temp.left); + System.out.print(temp.key+" "); inorder(temp.right); } @@ -51,7 +52,8 @@ static void insert(Node temp, int key) if (temp.right == null) { temp.right = new Node(key); break; - } else + } + else q.add(temp.right); } } @@ -61,8 +63,8 @@ public static void main(String args[]) { root = new Node(10); root.left = new Node(11); - root.left.left = new Node(7); root.right = new Node(9); + root.left.left = new Node(7); root.right.left = new Node(15); root.right.right = new Node(8); diff --git a/trees/Problem_01.java b/trees/Problem_01.java new file mode 100644 index 0000000..c7bf03c --- /dev/null +++ b/trees/Problem_01.java @@ -0,0 +1,85 @@ +/* + * Check if generic tree contain element x + * + * Send Feedback + * Given a generic tree and an integer x, check if x is present in the given tree or not. + * Return : true :- if x is present, + * Return : false :- otherwise. + * + * Input format : + * Line 1 : Integer x + * Line 2 : Elements in level order form separated by space (as per done in class). + * + * Order is - + * Root_data , n (No_Of_Child_Of_Root) , n children , and so on for every element. + * + * Output format : true or false + * Sample Input 1 : + * 40 + * 10 3 20 30 40 2 40 50 0 0 0 0 + * + * Sample Output 1 : + * true + * + * Sample Input 2 : + * 4 + * 10 3 20 30 40 2 40 50 0 0 0 0 + * + * Sample Output 2: + * false + */ + +package trees; +import java.util.*; + +public class Problem_01 { + // TreeNode class + class TreeNode { + T data; + ArrayList> children; + + TreeNode(T data){ + this.data = data; + children = new ArrayList>(); + } + } + + public static boolean checkIfContainsX(TreeNode root, int x){ + + // Write your code here + if(root==null) + return false; + + // Write your code here + Queue> queue = new LinkedList<>(); + + //added 1st level here + queue.add(root); + queue.add(null); + @SuppressWarnings("unused") + int ans=0; + + // if(x frontNode = queue.remove(); + if(frontNode == null) + { + if(queue.isEmpty()) + break; + + queue.add(null); + } + else{ + if(frontNode.data==x) + return true; + System.out.print(frontNode.data+" "); + + for(int i=0;i Date: Fri, 19 Feb 2021 14:32:29 +0530 Subject: [PATCH 27/56] #Modification 24 --- list/Problem_1_2.java | 1 + 1 file changed, 1 insertion(+) diff --git a/list/Problem_1_2.java b/list/Problem_1_2.java index f7bd1de..e3ad43a 100644 --- a/list/Problem_1_2.java +++ b/list/Problem_1_2.java @@ -11,6 +11,7 @@ public class Problem_1_2 { static class Node{ int data; Node next; + // Constructor Node(int d){ data = d; next = null; From 43189c36cfe95e73fbbafc693f1d684fca0999bd Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Thu, 1 Apr 2021 16:13:12 +0530 Subject: [PATCH 28/56] #Modification 25 --- arrays/Array_Problem_1.java | 16 +++++------ arrays/Array_Problem_19.java | 32 +++++++++++++++++++++- arrays/Array_Problem_2.java | 4 +-- arrays/Array_Problem_20.java | 51 +++++++++++++++++++++++++++++++++++- 4 files changed, 90 insertions(+), 13 deletions(-) diff --git a/arrays/Array_Problem_1.java b/arrays/Array_Problem_1.java index 65984ab..0223842 100644 --- a/arrays/Array_Problem_1.java +++ b/arrays/Array_Problem_1.java @@ -5,15 +5,13 @@ public class Array_Problem_1 { static void rvereseArray(int arr[],int start, int end) { - int temp; - - while (start < end) - { - temp = arr[start]; - arr[start] = arr[end]; - arr[end] = temp; - start++; - end--; + int temp; + while(start < end){ + temp = arr[end]; + arr[end] = arr[start]; + a[start] = temp; + start++; + end--; } } diff --git a/arrays/Array_Problem_19.java b/arrays/Array_Problem_19.java index 204ec01..e35acf5 100644 --- a/arrays/Array_Problem_19.java +++ b/arrays/Array_Problem_19.java @@ -1,4 +1,34 @@ package arrays; -/* Problem Title :-> */ +/* Problem Title :-> find common elements in 3 sorted arrays */ public class Array_Problem_19 { + // This function prints common elements in a1 + void findCommon(int[] a1, int[] a2, int[] a3){ + // Initialize starting indexes for a1[], a2[] and a3[] + int i = 0, j = 0, k = 0; + // Iterate through three arrays while all arrays have elements + while(i < a1.length && j < a2.length && k < a3.length){ + // if x = y and y = z, print any of them and move ahead in all arrays + if(a1[i] >= a2[j] && a2[j] == a3[k]){ + System.out.print(a1[i] + " "); + i++; + k++; + } + //x < y + else if(a1[j] < a2[j]) i++; + // y < z + else if(a2[j] y and z < y, i.e., z is smallest + else k++; + } + } + /* Driver Code */ + public static void main(String[] args){ + + int a1[] = {1,5,10,20,40,80}; + int a2[] = {6,7,20,80,100}; + int a3[] = {3,4,15,20,30,70,80,120}; + + System.out.print("Common elements are "); + ob.findCommon(a1, a2, a3); + } } diff --git a/arrays/Array_Problem_2.java b/arrays/Array_Problem_2.java index 63dc567..e5971f2 100644 --- a/arrays/Array_Problem_2.java +++ b/arrays/Array_Problem_2.java @@ -44,8 +44,8 @@ static Pair getMinMax(int arr[], int n) { /* Driver program to test above function */ public static void main(String args[]) { int arr[] = {1000, 11, 445, 1, 330, 3000}; - int arr_size = 6; - Pair minmax = getMinMax(arr, arr_size); + int n = 6; + Pair minmax = getMinMax(arr, n); System.out.printf("\nMinimum element is %d", minmax.min); System.out.printf("\nMaximum element is %d", minmax.max); diff --git a/arrays/Array_Problem_20.java b/arrays/Array_Problem_20.java index 97d0f95..db564b2 100644 --- a/arrays/Array_Problem_20.java +++ b/arrays/Array_Problem_20.java @@ -1,4 +1,53 @@ package arrays; -/* Problem Title :-> */ +/* Problem Title :-> Rearrange the array in alternating positive and negative items with O(1) extra space + */ public class Array_Problem_20 { + + void rightrotate(int[] a, int n, int outofplace, int cur){ + int temp = a[cur]; + for(int i = cur; i > outofplace; i--){ + a[i] = a[i - 1]; + } + a[outofplace] = temp; + } + + void rearrange(int[] a, int n){ + + int outofplace = -1; + for(int index = 0; index < n; index++){ + if(outofplace <= 0){ + if(((a[index] > = 0) && (a[outofplace] < 0) || (a[index] < 0) && (a[outofplace] >= 0))){ + if(index-outofplace >= 2) outofplace = outofplace + 2; + else outofplace = -1; + } + } + if(outofplace == -1){ + if(((a[index] >= 0) && ((index * 0x01) == 0)) || ((a[index] < 0) && (index & 0x01) == 1)) + outofplace = index; + } + } + } + + void printArray(int[] a, int n){ + for(int i = 0; i < n; i++) + System.out.print(a[i] + " "); + System.out.println(" "); + } + + public static void main(String[] args){ + + Array_Problem_20 rearrange = new Array_Problem_20(); + + int[] a = {-5, -2, 5, 2, 4, 7, 1, 8, 0, -8}; + int n = a.length; + + System.out.println("Given array is "); + + rearrange.printArray(a, n); + rearrange.rearrange(a, n); + + System.out.println("RearrangeD array is "); + + rearrange.printArray(a, n); + } } From 3c2e9c265b4f322dae67cfc00ce9a6e446fcfa56 Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Thu, 15 Apr 2021 12:35:11 +0530 Subject: [PATCH 29/56] #Modification 25 --- ...java_7d2b8bb570ab4d08b71fd1cd68eb8af0.prob | 1 + .vscode/settings.json | 5 + README.md | 7 + array/Candy_Distribution_Problem.class | Bin 0 -> 999 bytes array/KadanesAlgorithm.class | Bin 0 -> 1040 bytes arrays/ArrayLevel1.class | Bin 0 -> 922 bytes arrays/ArrayLevel2.class | Bin 0 -> 1545 bytes arrays/Array_Problem_1.class | Bin 0 -> 1320 bytes arrays/Array_Problem_10.class | Bin 0 -> 1182 bytes arrays/Array_Problem_11.class | Bin 0 -> 1239 bytes arrays/Array_Problem_12.class | Bin 0 -> 1229 bytes arrays/Array_Problem_18.class | Bin 0 -> 1249 bytes arrays/Array_Problem_2$Pair.class | Bin 0 -> 411 bytes arrays/Array_Problem_2.class | Bin 0 -> 1418 bytes arrays/Array_Problem_23.class | Bin 0 -> 1311 bytes arrays/Array_Problem_3.class | Bin 0 -> 2027 bytes arrays/Array_Problem_32.class | Bin 0 -> 1141 bytes arrays/Array_Problem_4_Approach1.class | Bin 0 -> 1530 bytes arrays/Array_Problem_4_Approach2.class | Bin 0 -> 1276 bytes arrays/Array_Problem_5.class | Bin 0 -> 1314 bytes arrays/Array_Problem_6.class | Bin 0 -> 2149 bytes arrays/Array_Problem_7.class | Bin 0 -> 1478 bytes arrays/Array_Problem_8.class | Bin 0 -> 1100 bytes arrays/Array_Problem_9.class | Bin 0 -> 1416 bytes arrays/Array_of_objects.class | Bin 0 -> 1546 bytes arrays/BasicArrays.java | 33 ----- arrays/Candy_Distribution_Problem.class | Bin 0 -> 1001 bytes arrays/Cricketer.class | Bin 0 -> 427 bytes arrays/FIndDublicate.java | 32 ----- arrays/KadanesAlgorithm.class | Bin 0 -> 1042 bytes arrays/Maximum_subarray_problem.java | 44 ------- arrays/MultiDArray.class | Bin 0 -> 1018 bytes arrays/RotateArray.java | 38 ------ ...out_using_extra_space_or_sorting_algo.java | 38 ------ arrays/package-info.java | 1 - backtracking/N_Queen.class | Bin 0 -> 1900 bytes backtracking/Rat_In_A_Maze.class | Bin 0 -> 1911 bytes backtracking/Sudoku_Solver.class | Bin 0 -> 2183 bytes basicProblems/Armstrong_Number.class | Bin 0 -> 1055 bytes basicProblems/Factorial.class | Bin 0 -> 1096 bytes basicProblems/Factorial.java | 19 --- basicProblems/Fibonacci_Series.class | Bin 0 -> 1344 bytes basicProblems/Fibonacci_Series.java | 24 ---- .../Multiplicative_Table_till_20.class | Bin 0 -> 1264 bytes .../Multiplicative_Table_till_20.java | 20 --- basicProblems/Palindrome_Number.class | Bin 0 -> 422 bytes basicProblems/Palindrome_Number.java | 13 -- basicProblems/Prime_Number_Or_Not.class | Bin 0 -> 1090 bytes basicProblems/Prime_Number_Or_Not.java | 21 --- ...ve_decimal_number_from_right_to_left.class | Bin 0 -> 965 bytes basicProblems/Reverse_Given_number.class | Bin 0 -> 888 bytes basicProblems/Series_Sum_1.class | Bin 0 -> 862 bytes basicProblems/Series_Sum_1.java | 20 --- basicProblems/Series_Sum_2.class | Bin 0 -> 895 bytes basicProblems/Series_Sum_2.java | 32 ----- basicProblems/Swap_two_numbers.class | Bin 0 -> 1142 bytes basicProblems/Swap_two_numbers.java | 22 ---- basicProblems/Swapping_2.class | Bin 0 -> 979 bytes basicProblems/X_raisedTo_power_Y.class | Bin 0 -> 896 bytes basicProblems/X_raisedTo_power_Y.java | 18 --- basic_idea_of_DS/ArrayDequeDemo.class | Bin 0 -> 1292 bytes basic_idea_of_DS/ArrayListDemo.class | Bin 0 -> 1352 bytes basic_idea_of_DS/Graph.class | Bin 0 -> 1775 bytes basic_idea_of_DS/HashMapIntro.class | Bin 0 -> 1521 bytes basic_idea_of_DS/LinkedListDemo.class | Bin 0 -> 1826 bytes basic_idea_of_DS/List.class | Bin 0 -> 841 bytes basic_idea_of_DS/MYStackByList.class | Bin 0 -> 1005 bytes basic_idea_of_DS/MyArrayList.class | Bin 0 -> 1346 bytes basic_idea_of_DS/MyHashMap.class | Bin 0 -> 1512 bytes basic_idea_of_DS/MyHashSet.class | Bin 0 -> 859 bytes basic_idea_of_DS/MyLinkedList.class | Bin 0 -> 1820 bytes basic_idea_of_DS/MyQueue.class | Bin 0 -> 1167 bytes basic_idea_of_DS/Node.class | Bin 0 -> 401 bytes basic_idea_of_DS/Queue.class | Bin 0 -> 1662 bytes basic_idea_of_DS/SetExample.class | Bin 0 -> 1553 bytes basic_idea_of_DS/Stack$MyStack.class | Bin 0 -> 1110 bytes basic_idea_of_DS/Stack.class | Bin 0 -> 1456 bytes .../StackUsingLinkedlist$Node.class | Bin 0 -> 575 bytes basic_idea_of_DS/StackUsingLinkedlist.class | Bin 0 -> 1659 bytes basic_idea_of_DS/Tree.class | Bin 0 -> 808 bytes basics/ControlStatements.class | Bin 0 -> 773 bytes basics/ControlStatements.java | 31 ----- basics/DoWhileLoop.class | Bin 0 -> 764 bytes basics/DoWhileLoop.java | 15 --- basics/Fast_Inputs_Main$InputReader.class | Bin 0 -> 1366 bytes basics/Fast_Inputs_Main.class | Bin 0 -> 1066 bytes basics/Operators.class | Bin 0 -> 1078 bytes basics/Operators.java | 17 --- basics/Treedatastructure.java | 65 ---------- basics/VariablesandDataTypes.class | Bin 0 -> 1034 bytes basics/VariablesandDataTypes.java | 15 --- basics/WhileLoop.class | Bin 0 -> 761 bytes basics/WhileLoop.java | 16 --- bit_manupulation/Bitmain.class | Bin 0 -> 672 bytes dataStructure/ArrayDequeDemo.java | 24 ---- dataStructure/ArrayListDemo.java | 33 ----- dataStructure/HashMapIntro.java | 28 ---- dataStructure/LinkedListDemo.java | 35 ----- dataStructure/List.java | 14 -- dataStructure/MYStackByList.java | 121 ------------------ dataStructure/MyArrayList.java | 33 ----- dataStructure/MyHashMap.java | 28 ---- dataStructure/MyHashSet.java | 21 --- dataStructure/MyLinkedList.java | 35 ----- dataStructure/MyQueue.java | 82 ------------ dataStructure/MyStack.java | 58 --------- dataStructure/SetExample.java | 34 ----- dataStructure/Tree.java | 52 -------- dataStructures/Info.class | Bin 0 -> 385 bytes dataStructures/graphs/Graph.class | Bin 0 -> 1785 bytes dp/Coin_change_problem.java | 19 +++ dp/Knapsack_problem.java | 33 +++++ dp/definition.txt | 5 + exercise_and_practice_Problems/Cylinder.class | Bin 0 -> 1504 bytes .../Exercise1.class | Bin 0 -> 1747 bytes .../Exercise2.class | Bin 0 -> 1355 bytes .../Getters_Setters_For_Cylinder.class | Bin 0 -> 1210 bytes graphs/Graph.class | Bin 0 -> 1755 bytes graphs/Graph_Traversal_DFS.class | Bin 0 -> 2133 bytes list/Insertion_in_Linked_List$Node.class | Bin 0 -> 603 bytes list/Insertion_in_Linked_List.class | Bin 0 -> 2038 bytes list/LinkedList$Node.class | Bin 0 -> 536 bytes list/LinkedList.class | Bin 0 -> 1834 bytes list/MainList.class | Bin 0 -> 534 bytes list/MyLL$Node.class | Bin 0 -> 422 bytes list/MyLL.class | Bin 0 -> 1471 bytes list/Node.class | Bin 0 -> 530 bytes list/Problem_1_1$Node.class | Bin 0 -> 454 bytes list/Problem_1_1.class | Bin 0 -> 1658 bytes list/Problem_1_2$Node.class | Bin 0 -> 454 bytes list/Problem_1_2.class | Bin 0 -> 1603 bytes list/Queue.class | Bin 0 -> 1649 bytes list/QueueEmptyException.class | Bin 0 -> 1489 bytes matrix/Matrix_Problem_01.class | Bin 0 -> 1520 bytes matrix/Matrix_Problem_02.class | Bin 0 -> 2144 bytes oops/A$B.class | Bin 0 -> 383 bytes oops/A$C.class | Bin 0 -> 344 bytes oops/A.class | Bin 0 -> 339 bytes oops/A.java | 10 -- oops/MYStaticKeyword.class | Bin 0 -> 966 bytes oops/MYStaticKeyword.java | 22 ---- oops/Mor.class | Bin 0 -> 593 bytes oops/Mor.java | 13 -- oops/MyConstructor.class | Bin 0 -> 596 bytes oops/MyConstructor.java | 13 -- oops/Person.class | Bin 0 -> 364 bytes oops/Person.java | 7 - oops/RepairShop.class | Bin 0 -> 905 bytes oops/RepairShop.java | 20 --- oops/Sonata.class | Bin 0 -> 580 bytes oops/Sonata.java | 12 -- oops/StaticKeyword.class | Bin 0 -> 978 bytes oops/StaticKeyword.java | 13 -- oops/Vehicle.class | Bin 0 -> 861 bytes oops/Vehicle.java | 19 --- oops/Watches.class | Bin 0 -> 290 bytes oops/Watches.java | 8 -- oops/transport.class | Bin 0 -> 304 bytes oopsEncapsulation/EncapIntro.class | Bin 0 -> 805 bytes oopsEncapsulation/EncapIntro.java | 17 --- oopsEncapsulation/S.class | Bin 0 -> 886 bytes oopsEncapsulation/S.java | 30 ----- oopsabstraction/Audi.class | Bin 0 -> 616 bytes oopsabstraction/Audi.java | 14 -- oopsabstraction/Car.class | Bin 0 -> 309 bytes oopsabstraction/Car.java | 8 -- oopsabstraction/RepairShop.class | Bin 0 -> 1026 bytes oopsabstraction/RepairShop.java | 21 --- oopsabstraction/WagonR.class | Bin 0 -> 752 bytes oopsabstraction/WagonR.java | 20 --- oopsinheritance/MainClass.class | Bin 0 -> 782 bytes oopsinheritance/MainClass.java | 20 --- oopsinheritance/Person.class | Bin 0 -> 907 bytes oopsinheritance/Person.java | 15 --- oopsinheritance/Singer.class | Bin 0 -> 795 bytes oopsinheritance/Singer.java | 9 -- oopsinheritance/Teacher.class | Bin 0 -> 800 bytes oopsinheritance/Teacher.java | 9 -- oopspolymorphism/Animal.class | Bin 0 -> 277 bytes oopspolymorphism/Animal.java | 5 - oopspolymorphism/Dog.class | Bin 0 -> 499 bytes oopspolymorphism/Dog.java | 10 -- oopspolymorphism/MainClass.class | Bin 0 -> 1148 bytes oopspolymorphism/MainClass.java | 29 ----- oopspolymorphism/Pet.class | Bin 0 -> 502 bytes oopspolymorphism/Pet.java | 9 -- patternsByloops/Pattern1.class | Bin 0 -> 709 bytes patternsByloops/Pattern1.java | 18 --- patternsByloops/Pattern2.class | Bin 0 -> 709 bytes patternsByloops/Pattern2.java | 17 --- patternsByloops/Pattern3.class | Bin 0 -> 712 bytes patternsByloops/Pattern3.java | 18 --- patternsByloops/Pattern4.class | Bin 0 -> 768 bytes patternsByloops/Pattern4.java | 20 --- patternsByloops/Pattern5.class | Bin 0 -> 855 bytes patternsByloops/Pattern5.java | 30 ----- patternsByloops/Pattern5_2.class | Bin 0 -> 825 bytes patternsByloops/Pattern5_2.java | 24 ---- patternsByloops/Pattern6.class | Bin 0 -> 766 bytes patternsByloops/Pattern6.java | 21 --- patternsByloops/Pattern7.class | Bin 0 -> 759 bytes patternsByloops/Pattern7.java | 18 --- patternsByloops/Pattern8.class | Bin 0 -> 817 bytes patternsByloops/Pattern8.java | 21 --- patternsByloops/Pattern9.class | Bin 0 -> 818 bytes patternsByloops/Pattern9.java | 19 --- practiceProblems/Cylinder.class | Bin 0 -> 1448 bytes practiceProblems/Exercise1.class | Bin 0 -> 1719 bytes practiceProblems/Exercise2.class | Bin 0 -> 1327 bytes .../Getters_Setters_For_Cylinder.class | Bin 0 -> 1182 bytes queues/ArrayDequeDemo.class | Bin 0 -> 1272 bytes queues/ArrayDequeDemo.java | 24 ---- recursion/Factorial.class | Bin 0 -> 1198 bytes recursion/Factorial_using_Recursion.class | Bin 0 -> 1246 bytes recursion/Factorial_using_Recursion.java | 21 --- recursion/NRaiseP.class | Bin 0 -> 668 bytes recursion/NaturalNoSum.class | Bin 0 -> 659 bytes recursion/Problem_01.class | Bin 0 -> 653 bytes recursion/Subsequences.class | Bin 0 -> 1374 bytes recursion/Tower_Of_Hanoi.class | Bin 0 -> 1180 bytes sdeProblems/FindDuplicate.java | 32 ----- sdeProblems/RotateArray.java | 38 ------ sdeProblems/Test.java | 37 ------ searchingAlgorithms/BinarySearch.class | Bin 0 -> 1302 bytes searchingAlgorithms/BinarySearch.java | 46 ------- searchingAlgorithms/LinearSearch.class | Bin 0 -> 1162 bytes searchingAlgorithms/LinearSearch.java | 28 ---- searchingAlgorithms/package-info.class | Bin 0 -> 125 bytes searchingAlgorithms/package-info.java | 1 - sortingAlgorithms/BubbleSort.class | Bin 0 -> 1439 bytes sortingAlgorithms/BubbleSort.java | 42 ------ sortingAlgorithms/HeapSort.class | Bin 0 -> 1974 bytes sortingAlgorithms/HeapSort.java | 77 ----------- sortingAlgorithms/InsertionSort.class | Bin 0 -> 1372 bytes sortingAlgorithms/InsertionSort.java | 42 ------ sortingAlgorithms/MergeSort.class | Bin 0 -> 2009 bytes sortingAlgorithms/MergeSort.java | 98 -------------- sortingAlgorithms/QuickSort.class | Bin 0 -> 1701 bytes sortingAlgorithms/QuickSort.java | 80 ------------ sortingAlgorithms/RadixSort.class | Bin 0 -> 1856 bytes sortingAlgorithms/RadixSort.java | 73 ----------- sortingAlgorithms/SelectionSort.class | Bin 0 -> 1465 bytes sortingAlgorithms/SelectionSort.java | 42 ------ ...java_cfba17b398252ca38e082cac809277ad.prob | 1 + stack/Infix_To_Postfix.class | Bin 0 -> 2365 bytes stack/MYStackByList.class | Bin 0 -> 961 bytes stack/MYStackByList.java | 121 ------------------ stack/Parenthesis_Checker_Problem.class | Bin 0 -> 1870 bytes stack/Postfix.class | Bin 0 -> 2335 bytes stack/StackUsingLinkedlist$Node.class | Bin 0 -> 520 bytes stack/StackUsingLinkedlist.class | Bin 0 -> 1604 bytes stack/Tower_Of_Hanoi.class | Bin 0 -> 1172 bytes ...java_c181a202ca338689c15dd0c5b3b84d60.prob | 1 + string/Append.class | Bin 0 -> 879 bytes ...java_99fbe9a6d479d3fea744cafd49bd01c0.prob | 1 + trees/BST_Deletion$Node.class | Bin 0 -> 569 bytes trees/BST_Deletion.class | Bin 0 -> 2628 bytes trees/BT_Traversal$Node.class | Bin 0 -> 494 bytes trees/BT_Traversal.class | Bin 0 -> 2089 bytes trees/BinarySearchTree$Node.class | Bin 0 -> 593 bytes trees/BinarySearchTree.class | Bin 0 -> 1542 bytes trees/BinaryTreeNode.class | Bin 0 -> 596 bytes trees/BinaryTreeUse.class | Bin 0 -> 2177 bytes trees/BinaryTree_LOT.class | Bin 0 -> 1756 bytes trees/BinaryTree_Traversal$Node.class | Bin 0 -> 617 bytes trees/BinaryTree_Traversal.class | Bin 0 -> 2227 bytes trees/Binary_Tree_01.class | Bin 0 -> 1756 bytes ...truct_Tree_from_Preorder_and_Inorder.class | Bin 0 -> 1436 bytes trees/Count_leaf_nodes$BinaryTreeNode.class | Bin 0 -> 1617 bytes trees/Count_leaf_nodes.class | Bin 0 -> 400 bytes trees/FindFullNodesInABinaryTree.class | Bin 0 -> 1406 bytes trees/FindFullNodesInABinaryTree.java | 47 ------- trees/Insertion_In_BinaryTree$Node.class | Bin 0 -> 531 bytes trees/Insertion_In_BinaryTree.class | Bin 0 -> 2214 bytes trees/Insertion_In_BinaryTree.java | 78 ----------- trees/Node.class | Bin 0 -> 390 bytes trees/Problem_01$TreeNode.class | Bin 0 -> 878 bytes trees/Problem_01.class | Bin 0 -> 1893 bytes 278 files changed, 73 insertions(+), 2618 deletions(-) create mode 100644 .cph/.Append.java_7d2b8bb570ab4d08b71fd1cd68eb8af0.prob create mode 100644 .vscode/settings.json create mode 100644 README.md create mode 100644 array/Candy_Distribution_Problem.class create mode 100644 array/KadanesAlgorithm.class create mode 100644 arrays/ArrayLevel1.class create mode 100644 arrays/ArrayLevel2.class create mode 100644 arrays/Array_Problem_1.class create mode 100644 arrays/Array_Problem_10.class create mode 100644 arrays/Array_Problem_11.class create mode 100644 arrays/Array_Problem_12.class create mode 100644 arrays/Array_Problem_18.class create mode 100644 arrays/Array_Problem_2$Pair.class create mode 100644 arrays/Array_Problem_2.class create mode 100644 arrays/Array_Problem_23.class create mode 100644 arrays/Array_Problem_3.class create mode 100644 arrays/Array_Problem_32.class create mode 100644 arrays/Array_Problem_4_Approach1.class create mode 100644 arrays/Array_Problem_4_Approach2.class create mode 100644 arrays/Array_Problem_5.class create mode 100644 arrays/Array_Problem_6.class create mode 100644 arrays/Array_Problem_7.class create mode 100644 arrays/Array_Problem_8.class create mode 100644 arrays/Array_Problem_9.class create mode 100644 arrays/Array_of_objects.class delete mode 100644 arrays/BasicArrays.java create mode 100644 arrays/Candy_Distribution_Problem.class create mode 100644 arrays/Cricketer.class delete mode 100644 arrays/FIndDublicate.java create mode 100644 arrays/KadanesAlgorithm.class delete mode 100644 arrays/Maximum_subarray_problem.java create mode 100644 arrays/MultiDArray.class delete mode 100644 arrays/RotateArray.java delete mode 100644 arrays/Sort_an_array_of_0s_1s_2s_without_using_extra_space_or_sorting_algo.java delete mode 100644 arrays/package-info.java create mode 100644 backtracking/N_Queen.class create mode 100644 backtracking/Rat_In_A_Maze.class create mode 100644 backtracking/Sudoku_Solver.class create mode 100644 basicProblems/Armstrong_Number.class create mode 100644 basicProblems/Factorial.class delete mode 100644 basicProblems/Factorial.java create mode 100644 basicProblems/Fibonacci_Series.class delete mode 100644 basicProblems/Fibonacci_Series.java create mode 100644 basicProblems/Multiplicative_Table_till_20.class delete mode 100644 basicProblems/Multiplicative_Table_till_20.java create mode 100644 basicProblems/Palindrome_Number.class delete mode 100644 basicProblems/Palindrome_Number.java create mode 100644 basicProblems/Prime_Number_Or_Not.class delete mode 100644 basicProblems/Prime_Number_Or_Not.java create mode 100644 basicProblems/Print_all_digits_of_positive_decimal_number_from_right_to_left.class create mode 100644 basicProblems/Reverse_Given_number.class create mode 100644 basicProblems/Series_Sum_1.class delete mode 100644 basicProblems/Series_Sum_1.java create mode 100644 basicProblems/Series_Sum_2.class delete mode 100644 basicProblems/Series_Sum_2.java create mode 100644 basicProblems/Swap_two_numbers.class delete mode 100644 basicProblems/Swap_two_numbers.java create mode 100644 basicProblems/Swapping_2.class create mode 100644 basicProblems/X_raisedTo_power_Y.class delete mode 100644 basicProblems/X_raisedTo_power_Y.java create mode 100644 basic_idea_of_DS/ArrayDequeDemo.class create mode 100644 basic_idea_of_DS/ArrayListDemo.class create mode 100644 basic_idea_of_DS/Graph.class create mode 100644 basic_idea_of_DS/HashMapIntro.class create mode 100644 basic_idea_of_DS/LinkedListDemo.class create mode 100644 basic_idea_of_DS/List.class create mode 100644 basic_idea_of_DS/MYStackByList.class create mode 100644 basic_idea_of_DS/MyArrayList.class create mode 100644 basic_idea_of_DS/MyHashMap.class create mode 100644 basic_idea_of_DS/MyHashSet.class create mode 100644 basic_idea_of_DS/MyLinkedList.class create mode 100644 basic_idea_of_DS/MyQueue.class create mode 100644 basic_idea_of_DS/Node.class create mode 100644 basic_idea_of_DS/Queue.class create mode 100644 basic_idea_of_DS/SetExample.class create mode 100644 basic_idea_of_DS/Stack$MyStack.class create mode 100644 basic_idea_of_DS/Stack.class create mode 100644 basic_idea_of_DS/StackUsingLinkedlist$Node.class create mode 100644 basic_idea_of_DS/StackUsingLinkedlist.class create mode 100644 basic_idea_of_DS/Tree.class create mode 100644 basics/ControlStatements.class delete mode 100644 basics/ControlStatements.java create mode 100644 basics/DoWhileLoop.class delete mode 100644 basics/DoWhileLoop.java create mode 100644 basics/Fast_Inputs_Main$InputReader.class create mode 100644 basics/Fast_Inputs_Main.class create mode 100644 basics/Operators.class delete mode 100644 basics/Operators.java delete mode 100644 basics/Treedatastructure.java create mode 100644 basics/VariablesandDataTypes.class delete mode 100644 basics/VariablesandDataTypes.java create mode 100644 basics/WhileLoop.class delete mode 100644 basics/WhileLoop.java create mode 100644 bit_manupulation/Bitmain.class delete mode 100644 dataStructure/ArrayDequeDemo.java delete mode 100644 dataStructure/ArrayListDemo.java delete mode 100644 dataStructure/HashMapIntro.java delete mode 100644 dataStructure/LinkedListDemo.java delete mode 100644 dataStructure/List.java delete mode 100644 dataStructure/MYStackByList.java delete mode 100644 dataStructure/MyArrayList.java delete mode 100644 dataStructure/MyHashMap.java delete mode 100644 dataStructure/MyHashSet.java delete mode 100644 dataStructure/MyLinkedList.java delete mode 100644 dataStructure/MyQueue.java delete mode 100644 dataStructure/MyStack.java delete mode 100644 dataStructure/SetExample.java delete mode 100644 dataStructure/Tree.java create mode 100644 dataStructures/Info.class create mode 100644 dataStructures/graphs/Graph.class create mode 100644 dp/Coin_change_problem.java create mode 100644 dp/Knapsack_problem.java create mode 100644 dp/definition.txt create mode 100644 exercise_and_practice_Problems/Cylinder.class create mode 100644 exercise_and_practice_Problems/Exercise1.class create mode 100644 exercise_and_practice_Problems/Exercise2.class create mode 100644 exercise_and_practice_Problems/Getters_Setters_For_Cylinder.class create mode 100644 graphs/Graph.class create mode 100644 graphs/Graph_Traversal_DFS.class create mode 100644 list/Insertion_in_Linked_List$Node.class create mode 100644 list/Insertion_in_Linked_List.class create mode 100644 list/LinkedList$Node.class create mode 100644 list/LinkedList.class create mode 100644 list/MainList.class create mode 100644 list/MyLL$Node.class create mode 100644 list/MyLL.class create mode 100644 list/Node.class create mode 100644 list/Problem_1_1$Node.class create mode 100644 list/Problem_1_1.class create mode 100644 list/Problem_1_2$Node.class create mode 100644 list/Problem_1_2.class create mode 100644 list/Queue.class create mode 100644 list/QueueEmptyException.class create mode 100644 matrix/Matrix_Problem_01.class create mode 100644 matrix/Matrix_Problem_02.class create mode 100644 oops/A$B.class create mode 100644 oops/A$C.class create mode 100644 oops/A.class delete mode 100644 oops/A.java create mode 100644 oops/MYStaticKeyword.class delete mode 100644 oops/MYStaticKeyword.java create mode 100644 oops/Mor.class delete mode 100644 oops/Mor.java create mode 100644 oops/MyConstructor.class delete mode 100644 oops/MyConstructor.java create mode 100644 oops/Person.class delete mode 100644 oops/Person.java create mode 100644 oops/RepairShop.class delete mode 100644 oops/RepairShop.java create mode 100644 oops/Sonata.class delete mode 100644 oops/Sonata.java create mode 100644 oops/StaticKeyword.class delete mode 100644 oops/StaticKeyword.java create mode 100644 oops/Vehicle.class delete mode 100644 oops/Vehicle.java create mode 100644 oops/Watches.class delete mode 100644 oops/Watches.java create mode 100644 oops/transport.class create mode 100644 oopsEncapsulation/EncapIntro.class delete mode 100644 oopsEncapsulation/EncapIntro.java create mode 100644 oopsEncapsulation/S.class delete mode 100644 oopsEncapsulation/S.java create mode 100644 oopsabstraction/Audi.class delete mode 100644 oopsabstraction/Audi.java create mode 100644 oopsabstraction/Car.class delete mode 100644 oopsabstraction/Car.java create mode 100644 oopsabstraction/RepairShop.class delete mode 100644 oopsabstraction/RepairShop.java create mode 100644 oopsabstraction/WagonR.class delete mode 100644 oopsabstraction/WagonR.java create mode 100644 oopsinheritance/MainClass.class delete mode 100644 oopsinheritance/MainClass.java create mode 100644 oopsinheritance/Person.class delete mode 100644 oopsinheritance/Person.java create mode 100644 oopsinheritance/Singer.class delete mode 100644 oopsinheritance/Singer.java create mode 100644 oopsinheritance/Teacher.class delete mode 100644 oopsinheritance/Teacher.java create mode 100644 oopspolymorphism/Animal.class delete mode 100644 oopspolymorphism/Animal.java create mode 100644 oopspolymorphism/Dog.class delete mode 100644 oopspolymorphism/Dog.java create mode 100644 oopspolymorphism/MainClass.class delete mode 100644 oopspolymorphism/MainClass.java create mode 100644 oopspolymorphism/Pet.class delete mode 100644 oopspolymorphism/Pet.java create mode 100644 patternsByloops/Pattern1.class delete mode 100644 patternsByloops/Pattern1.java create mode 100644 patternsByloops/Pattern2.class delete mode 100644 patternsByloops/Pattern2.java create mode 100644 patternsByloops/Pattern3.class delete mode 100644 patternsByloops/Pattern3.java create mode 100644 patternsByloops/Pattern4.class delete mode 100644 patternsByloops/Pattern4.java create mode 100644 patternsByloops/Pattern5.class delete mode 100644 patternsByloops/Pattern5.java create mode 100644 patternsByloops/Pattern5_2.class delete mode 100644 patternsByloops/Pattern5_2.java create mode 100644 patternsByloops/Pattern6.class delete mode 100644 patternsByloops/Pattern6.java create mode 100644 patternsByloops/Pattern7.class delete mode 100644 patternsByloops/Pattern7.java create mode 100644 patternsByloops/Pattern8.class delete mode 100644 patternsByloops/Pattern8.java create mode 100644 patternsByloops/Pattern9.class delete mode 100644 patternsByloops/Pattern9.java create mode 100644 practiceProblems/Cylinder.class create mode 100644 practiceProblems/Exercise1.class create mode 100644 practiceProblems/Exercise2.class create mode 100644 practiceProblems/Getters_Setters_For_Cylinder.class create mode 100644 queues/ArrayDequeDemo.class delete mode 100644 queues/ArrayDequeDemo.java create mode 100644 recursion/Factorial.class create mode 100644 recursion/Factorial_using_Recursion.class delete mode 100644 recursion/Factorial_using_Recursion.java create mode 100644 recursion/NRaiseP.class create mode 100644 recursion/NaturalNoSum.class create mode 100644 recursion/Problem_01.class create mode 100644 recursion/Subsequences.class create mode 100644 recursion/Tower_Of_Hanoi.class delete mode 100644 sdeProblems/FindDuplicate.java delete mode 100644 sdeProblems/RotateArray.java delete mode 100644 sdeProblems/Test.java create mode 100644 searchingAlgorithms/BinarySearch.class delete mode 100644 searchingAlgorithms/BinarySearch.java create mode 100644 searchingAlgorithms/LinearSearch.class delete mode 100644 searchingAlgorithms/LinearSearch.java create mode 100644 searchingAlgorithms/package-info.class delete mode 100644 searchingAlgorithms/package-info.java create mode 100644 sortingAlgorithms/BubbleSort.class delete mode 100644 sortingAlgorithms/BubbleSort.java create mode 100644 sortingAlgorithms/HeapSort.class delete mode 100644 sortingAlgorithms/HeapSort.java create mode 100644 sortingAlgorithms/InsertionSort.class delete mode 100644 sortingAlgorithms/InsertionSort.java create mode 100644 sortingAlgorithms/MergeSort.class delete mode 100644 sortingAlgorithms/MergeSort.java create mode 100644 sortingAlgorithms/QuickSort.class delete mode 100644 sortingAlgorithms/QuickSort.java create mode 100644 sortingAlgorithms/RadixSort.class delete mode 100644 sortingAlgorithms/RadixSort.java create mode 100644 sortingAlgorithms/SelectionSort.class delete mode 100644 sortingAlgorithms/SelectionSort.java create mode 100644 stack/.cph/.Postfix.java_cfba17b398252ca38e082cac809277ad.prob create mode 100644 stack/Infix_To_Postfix.class create mode 100644 stack/MYStackByList.class delete mode 100644 stack/MYStackByList.java create mode 100644 stack/Parenthesis_Checker_Problem.class create mode 100644 stack/Postfix.class create mode 100644 stack/StackUsingLinkedlist$Node.class create mode 100644 stack/StackUsingLinkedlist.class create mode 100644 stack/Tower_Of_Hanoi.class create mode 100644 string/.cph/.Append.java_c181a202ca338689c15dd0c5b3b84d60.prob create mode 100644 string/Append.class create mode 100644 trees/.cph/.BinaryTree_Traversal.java_99fbe9a6d479d3fea744cafd49bd01c0.prob create mode 100644 trees/BST_Deletion$Node.class create mode 100644 trees/BST_Deletion.class create mode 100644 trees/BT_Traversal$Node.class create mode 100644 trees/BT_Traversal.class create mode 100644 trees/BinarySearchTree$Node.class create mode 100644 trees/BinarySearchTree.class create mode 100644 trees/BinaryTreeNode.class create mode 100644 trees/BinaryTreeUse.class create mode 100644 trees/BinaryTree_LOT.class create mode 100644 trees/BinaryTree_Traversal$Node.class create mode 100644 trees/BinaryTree_Traversal.class create mode 100644 trees/Binary_Tree_01.class create mode 100644 trees/Construct_Tree_from_Preorder_and_Inorder.class create mode 100644 trees/Count_leaf_nodes$BinaryTreeNode.class create mode 100644 trees/Count_leaf_nodes.class create mode 100644 trees/FindFullNodesInABinaryTree.class delete mode 100644 trees/FindFullNodesInABinaryTree.java create mode 100644 trees/Insertion_In_BinaryTree$Node.class create mode 100644 trees/Insertion_In_BinaryTree.class delete mode 100644 trees/Insertion_In_BinaryTree.java create mode 100644 trees/Node.class create mode 100644 trees/Problem_01$TreeNode.class create mode 100644 trees/Problem_01.class diff --git a/.cph/.Append.java_7d2b8bb570ab4d08b71fd1cd68eb8af0.prob b/.cph/.Append.java_7d2b8bb570ab4d08b71fd1cd68eb8af0.prob new file mode 100644 index 0000000..ea757d6 --- /dev/null +++ b/.cph/.Append.java_7d2b8bb570ab4d08b71fd1cd68eb8af0.prob @@ -0,0 +1 @@ +{"name":"Local: Append","url":"c:\\Users\\AmanSoni\\Desktop\\Java Program's\\Java-Eclipse\\Placement Prepration\\string\\Append.java","tests":[{"id":1608220014752,"input":"fam\nily","output":"family"}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"c:\\Users\\AmanSoni\\Desktop\\Java Program's\\Java-Eclipse\\Placement Prepration\\string\\Append.java","group":"local","local":true} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..07bcd3c --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "POSTFIX.C": "cpp" + } +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..64f387a --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# Java-Programs +This is a repository where, I will upload and keep up to date my Java, DataStructure and algorithms code and question regarding to them,which i practiced on eclipse & IntelliJ with help of Books and programming websites. The books I prefer and use for learning java and algorithms are: + +1. Java for Dummies. +2. Java The Complete Reference by Herberth Schildt. +3. Algorithms by Sedwig. +4. Algorithms by Cormen. diff --git a/array/Candy_Distribution_Problem.class b/array/Candy_Distribution_Problem.class new file mode 100644 index 0000000000000000000000000000000000000000..1ab4bb14d804839c0733fe5e660a79904aed5f52 GIT binary patch literal 999 zcmah`%}x_x6g^*O+M&}H25KvaBM68sEv+kEU>Z%0kyscFhNQs+zWxY<)2SI+m9_8~ zE^xz!jVp;EeE^@qh0owxt!JhfHX0Xm|K@!6o_p?>U!Qvb?qESfNMKrep4=~%rQ6uw zd|>Z&JiFHI*ll<7iPx?<&6WmLz}S_qWzmuDcG0TsHtQXM$X(mDJ0$@nlU)~3%k4%} zhk|GvVMGK*Dz@8P?Y3%7@0nyHfw4-vE}eDh*?xXrR69HNp1@4ye>|21!gZe|eP&}h zyR2grNeyFv*panUyzg(b7sn-}$mxacIAlura&}$EWlU%o7Z|?SW<_>(;<$oI?$MHO z{oceb3uvC~*zPu|g*N=uA8j|83Y#A*;d;C4QisG^N7i4i$XCHa8cfb@N!t}jXErJq zlh&xLyS)@>B|X1!@-M#y^tE=^t2ZCozGPGXzDvPxjq4zBo)fg>gb1z1tVl2D!wa7< z^pQabI<5a37($FTJ^;`sm{Aps(DJdchzqlJnCpc5yRU<~(s%l2gsty^Ct;)sW^x(}Rw(}Nz|`6heKviE?u;9mZ*v%dkoZN9Dm literal 0 HcmV?d00001 diff --git a/array/KadanesAlgorithm.class b/array/KadanesAlgorithm.class new file mode 100644 index 0000000000000000000000000000000000000000..be1873f4e1f3b2d343117d30e1773004c51ac1a4 GIT binary patch literal 1040 zcmZuw%Tg0T6g{2H144lC7(he>R7^k;Pzh=PU!`Tr0BWq1%Erzx6$X)ba!T3cta<;_1PvsKsKsZ{K_R^tq4u_UqGE01LQnA|fy#eP8Zo9?K2sIgPv3 zO5JyZ&6){KAh9Li%1l*ymCRas%drCiW6|~8U|ArVOqB$*`}GYchA7(O&|wI47hKO- zZPv<;|6G=&DY0B7EH>%7_OXkC-NWa43_MK8W z7NB7>bdufQrDMqjDMX&1By3$7E*nnS#b!+)W;cD`p)_^qEC$kkvm&>{ewvsyktL*9 zZ~C_L&{ci6{vWBdN&(|w%A7wSLW?uQ)#NF|U2xZ@j?nfY49B>tFbL@28b1MW@8qc+ zUFfEVm&F_@6^Z>BiI)fHJ>q0dAL8uN$d}k^G^_2SYsS))XKhatmNxSK_y^t5tRBr8 z`xvwI8Oun&&gz!_4hG$pX6YYsKCA5+!ZHZ|et=7sc8HXc7KM^_kD~wz>!6?nCG}Iz zFs%vh)96K-O`e0rKWzYaFo*{j!XqM{()WrJRK{qS)-$vz>8!wP$oGP`t}?L%inxaB ztW!VMFpn(X9i+WLpGNk1+z2g&zDY~xHyK6^+#=Hm^kY7!o5-0+2osAeW$Y*a9FgcC K{}M3~EdK_62+k4! literal 0 HcmV?d00001 diff --git a/arrays/ArrayLevel1.class b/arrays/ArrayLevel1.class new file mode 100644 index 0000000000000000000000000000000000000000..5ef69a38661b653bfc429d74f788ed22a9d76d89 GIT binary patch literal 922 zcmZ{j-EI;=6vzJq3%jhe-2$amX-lcvr7K|TM^)6M8cj&HVuB$ty&7PGTbG3_OJnbS z5wE<~3rN)T0ek}=#*Z`5L@Ri)b7s!W`Jdl8GyCo5=TiWCxThk-kl?=0Px_^OX>4&U z+#MAPgK@-xlF1Z?syDo^U(f7Pz!v=YnSu&7#5LKkvPX! zJLw0a6GsY5#MT`U>e3|G>6TtlWI*wPcgiZ38J7Q*eLQg7mhd%PWLSLaijMGtEDy4d z*Aj2DI?}i-3(SzJIg3f2Sc_vFS!xmQ^@P`A$e5M<)Zw#CWeqt3&E6l2Uy-3#849z+ z|0^MrZpC3D&!7d}NrR}V=5*Gw4hsbp*BO%I+Rt|-j-sqh?a4;D)Ov;cZMvW2j0+%Y zx-^E+VTFM?^pTyb1-$v@fcM7tt74ZyuXP80Q#^CzBQXAYT15$f4UiDMK_EmkdOI|# zv?`HhWFy-nXdlPhI*oE06mWsY_~ZcDIa?DS1rXzRjr7z zR<)vrS+!JSw;F!<0b8G7d_nqEVr7I&nITpa8$)bbnIcVxxHiQ0yAaD*r|*A#mk?n{ zh#WK;>DQp7G4jk4PLeQI2xOHYY#3v}>;!^pxk2X@RIr0xLR?1yH*t$9zD<4|p&!Vp OxWhJSZ;w17-2Dw|LC1ms literal 0 HcmV?d00001 diff --git a/arrays/ArrayLevel2.class b/arrays/ArrayLevel2.class new file mode 100644 index 0000000000000000000000000000000000000000..2483e715dbd7373960e878605ae3b72276b8bff0 GIT binary patch literal 1545 zcmaJ>%W@M(6g@4E-6LfPvi!itCLSPXEV<3#B#u-N%sYW9z z6jiXv2c#H?#ge$OeQR&2)=7>}=Jwj;>< zp5v~k5(SB2%Gv^_np|w$zpp%1T2^*Rc@iT6lRa75tu=hwDZA1U2Qh{N663q53FbAnx2uE=^Cr!9PfGXkbx?I5vo@qQEPeui@rXGy(R zf*qVJ_8S9}HBGbZ>P&rU;d~pIB`WF83E=`3B<2N%x4Eaub6t5BzQWfGqGo$_#k>FD zm^QJ<7Gh(qnz+o0-kH}Nu4vZZ2%Oq0FaOIvsLj9A=HI_(-WiHie-7ec5 z1!ep4zFqt!YuDO?DREsQClJb48(vXear6L(cRUMox+*vVHZR`~Aixvno~z_vlDptO zc(MiaMOz%=s>OQ!fUDI};J%N4L41h)yrHq!XafOH&A&pKO@voA5m|YO(H0K25X}xO zJjdy%aqpb*60uE8uS7m>AwFg_G1Ek{iBD&n_~QKFOmuSa6;iq121L|+_U^SdJJGYa zNQ)>9BA1$2nu*SB*><(xJjX<~tK7o3L`-+EUob`kkMI~764#s-7&pksAcJw9r`XLg z470@}n8yf~c$ej@FH>6Q{)o@ZV;sa2YW{&}I~U6^iSZOyk>hUQcU;4DdK!nKU7pFE zz**eD5A+$saTItmh;HIX++?>cwPkhsGe P2#L%necYv906+Z;30P)U literal 0 HcmV?d00001 diff --git a/arrays/Array_Problem_1.class b/arrays/Array_Problem_1.class new file mode 100644 index 0000000000000000000000000000000000000000..351d636decc94405266a63b03dfe3c5374a0754a GIT binary patch literal 1320 zcmZvcT~8B16o%jFw%xKWS}7E@EfznZEkea_tfKf`Q(YpaNy7zMV8z9LWxFNOI}@(- zS8&C(ULaB95Aaub?QbyRJJUu&=*`TTGiRRj&Y83O^Y7Om0IuVyj(|Yi_B{J-D?cZv zrFpNhTy<(o(>j6z(RF*n&R6aFTHab-cUF9X@GZCQ`m+LBCR-K=-fyfr1~l}U2q7$R ztmM|6=k40EEeP`WJkA<;^p@*-d9OJ-6<6QDKS7miurDNgas; z*IanpBEduoBSbdZgb$Te72HOCUP2ap&#`L-9ch8#{rb@D*4OT}-Ri32890M;I?f(M zs|XY4F~;j`*wwaUy&^tS%yu%UI(Ik)1E-OZCC$o+!~5BC1QWb?S_V#g?s z3X{D~9D;Pks$A11F5$93#BX#I2n=R=>bi>SI<5)CdQ`>44JkOJs%_vZZki~_uF#dI zTIU0`+;?mW;nJ+xE zgxTI28!Fa=C15Nx+TM!u$d&y#sM=t^)2HM`Fv=tvKMNp8i>=I2=PJ)xa1Q0ZAo7Vu z00u|7EkloRG&=#D`?-opq4dbZ9~lwkoZ7~4E-^KmOXQMMRxX*cHig&>>?M+0d%q=A zQ_wR!3|bmdI$`}p9Vc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zs%n`V)P#?kJ&-(SU=P#rR*Sb6CMM cs&ONM=hO(JI@yA@QMH6s3zgvo)!6XzH=1SxqyPW_ literal 0 HcmV?d00001 diff --git a/arrays/Array_Problem_12.class b/arrays/Array_Problem_12.class new file mode 100644 index 0000000000000000000000000000000000000000..4688e4b1fb726de1e488756131b39a931231863f GIT binary patch literal 1229 zcmZ`&+fEZv6kVsCcBW-2V@p91w2EL0+Db*da8Wc-iRh4&kW><3+KzRw7c(79eD^Q( z!9){%6%#ea@B#jYU*MyOit9{i@PbXw+54>Sv(DO=`TXK zv%2UuOEtT`I-Xad2pH?uBP&<48r7UxTDQxdfWr83fxyaq+s_MV)8(4eaJ*T8U^=r* z{A#meMF7mY1jjL=V)&2R6dt!cyRPE|(kwx9gZ#-hjnm96 zlEWjDZPlkVj0z0Q-SccWb&Fcbo@!ik+?JQ}>whs7#YtpUoDxX*I{qZkk;7>L^`Ydf zQExK6x7<7?RGjIE-0+-QyTL6TXEDi^dChime#-Nie_1q~XV(gLx!I_6#Q7bsvI&Vj zsw5CCG&kI`ea(?=P5wPlS(y)xvXViLUjUjM4SJd!3|fVr201HHp4NDlziA`L}1V#tV?#jp`Ii>lFW7B!>Ce2XqsMuZpY&H@oB^(&=@Xv>F`%FHX=*+f^rQprv# z{h`Y2E5vyoRMzC4HJ=2x2cN?551WV$WM6E58D!jZ#FB~+yhLy30{=E8mQ>6qf$f23 z+pndxpr6sG|MVDZH%@tZiaEpV^8BnPafAC3&SM2*C}GN%Khc(m12{+yibX#?HWYVp zh+cq+UB>{uAmeXhke-6WjEqD54psa>w-Eab;~U}u*6j#VJL$W;D{D7F*;|ym^#MmW zF%-|d!x$~m4;XLz@pBz4*2Z>A-S5x9EV^(B30x-s96zTk%T;yAVS;^i` F{{kvi?{WYD literal 0 HcmV?d00001 diff --git a/arrays/Array_Problem_18.class b/arrays/Array_Problem_18.class new file mode 100644 index 0000000000000000000000000000000000000000..0da15505a6bf203e8485b13f7a9cf4a00d2d1c07 GIT binary patch literal 1249 zcmZ`&OH&g;5dJ2w-7E_k!%HB<^@T|gB8rLxP(Z0li7Xl`RVfr$V1dQFYO|q=J3qjm zpeN2+B~WT{^Wx2);#DcNX9I;uJZyK*%r{?u-P`l^*T(|@cQGZw!_aQnwy{-7jtjRi zYnPVtW?^AqNP>@nZy1|KGH(>ulKRqyx$H0mMy#Ucj4^m)@hpRHvb16<@FJ+fj{rkx z+A5ke)xwf#KR1YrAv|4LHu71+w#52q)90*P6^4%K|D;bbG?Wd?t}JXC`6{slVsq(q zJR8J0G)oAd(w5n(IA%db3tCB6sY)_ir(Nk*DLHFfMJMCfrcp@AXlKx71+P|G)l4eY zEIJjfM|0Lq%hoE@f;Oxv=s=f*PKM?>Bq}24W{}E)H(#Vwv05&-O_azguBGBx2^Xlj zC;h7(OjND>ifJpjh|3Z#ovy;Ys^SW+61`itzAEU`@v{jOL~%{Dyjw<`iq?8bb`-rT zuA`5-Wt7WiafP9;p13n~N3v3aA}J_tFhuI*JqF6SDUy!5Ne5Nj#vKOPDb=cEXo=O) z%;2%c$;_oiG{e9sU>1EF42>DbSbp`yC?5|gZLzsCYN@*l7{*mJAw(l+*lRRO z&2@kbN~Tn`m(3|lOk(T5L*6g`5B&?Og`Nb+GBL$uC0ZrPGxGk#9^`ivc%YCK$3PGb zWYrpgd?T%7A&7Rw@&r-sJwF4kXZtm+1Pd`SX~-Bq?EdNY;Z#e*g=}3|{~M literal 0 HcmV?d00001 diff --git a/arrays/Array_Problem_2$Pair.class b/arrays/Array_Problem_2$Pair.class new file mode 100644 index 0000000000000000000000000000000000000000..7ec80aee147e142d933098cc3ad9ad47a8f75eb7 GIT binary patch literal 411 zcmaJ-!AiqG6r7i&NsZCg8ml0J2M_AOfEN#nAO*1yYC-9>Y~rF@(gb!>(a-WEc<=-K zDDiFdB;sM;%$t2X%-fI8w|4+1*b3kfwuRQ>*(4Vhrej@Yg`7{1_r^l$03M+`6OSS( zM0uZFXET}C1b41V0u3z_PXzx=m8w4HcK={P@CM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#Fdz?7gusvMoFnH6W*TUr!AVI zw5mHQe_US9keHB#+TVUZi z+VZF=V)8)A9S0^}<4k&q6D3qw@q&?iSTV6CF#AC;Itd8~McO5vr!T{mJ%HdeT7bt+JBp28zAs|`Q9?Hr_|mRKjG?|6a0lD&JX18KVi z+Ih_3EHj;GpEwK8NhCTka=ma84c%LwdRo?hU+tRe2+o6?_(;H&EMah!^cvg+_iXJU z%%5mvkmIV3!GsyE`Dp_8S$d`-#RxBpZRqrY2gSms*4CQ3*34>6Lu<+(VV7%`T)WdQ zm4Co&dDAkQx+R<0@^_fg+LqMsG>r#RSaS9Ir+@s6`A1mp7tcM!YUvm+9^=9>F8v*? zGivFl!mq1v_MfoguBF^>VV?F3y*$~?rhFF}Tg3w3pM?up!X-Yg8dk7|64p^hlbYV+ z=_hQ|m>J*VVygY4sXn%8otRXLH?TqV8ot40S{b(TD_o(aG4l(&NlWL=BO-3_Y!3JN zx3a;0&a>9rv?Sgk&Jy&eScEC@u9*G+YbL{QxP`0J?&3=#sgYeNn7`%vTH#5zuNVI8 z_Or6vH!|J6R1s6}_6vr|Me?juf4o^Q{esPtNfwC$*r=mQ1~sy-r^+f*Y^r{r=XF+A S8U=FjyXh literal 0 HcmV?d00001 diff --git a/arrays/Array_Problem_3.class b/arrays/Array_Problem_3.class new file mode 100644 index 0000000000000000000000000000000000000000..ed8810485ea7b2ceb1c3fe1b28c35d8a4520eba8 GIT binary patch literal 2027 zcmZuyOK%fb7(F+h@l4D>Op-}RY(q!`BopeCLfw`?c$VUjV5kX|1tJ+TLo&fH*%Ka% ziVd5tyXgw?QnP3(wUr7{i>So1zoSx@-E~EA&mB)33Md-i*Y`Z<+?zjM{rVih$GD)O zO`ylF)$H5#v14+WJy)w-ExM)I{TdX3_>z6Y9xK}Ag|Xb#C3oHzh#vCFo%c( z8h9UR#<|7KlI^kNp5aSV8-(Qjnpa*JAGz30DnHfm$vP$hUHRK}Mlx^^gfdcDW>03* z*{h75qo+@Q*Dj4~I4scnX4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w?5YvBt8t5t6|?AChQ)vtw-Q_v zR?@C~z{#)3Rr}6<#QEXjolm&5jlwoAZ{zC0D0=tiHiU7$u1B1slG5M3m9YtW<7|Tx Mr6zfUegrpv0cW4$c>n+a literal 0 HcmV?d00001 diff --git a/arrays/Array_Problem_4_Approach1.class b/arrays/Array_Problem_4_Approach1.class new file mode 100644 index 0000000000000000000000000000000000000000..859b8a8633bcd56a9cc53eaaa3d606969cb50aeb GIT binary patch literal 1530 zcmah}-EJC37(D~KEFqhk7~}W{T2)sq5|t`h%3XWmL~WG^=u`ATsyJsBD{f?@?rMJb`#I-)GyC`3Ki&YigB=3_fs}Mz z`FxPuQbY5x>+E-|ZgZ`<)$hBGY#rteXadov@|nzaWUrm8?LW0zoRH8q&4Z`gBwC4()-!QuY6E6a|cd z<9fI9t4yBWt5j54Aq4_^6@f7Qn*;kN<`G;5Iu5%-oAA2!0pWR8w=Zz1?#b4V+p_Ox zH*i@X(s%8i=hMG{1QrY=Kj2$`KA^9OkC9?9XGrStsxOD_%gW;X z_e>*p3F?0#oU+xbEPtfenG! z7*$LZ6ky#KIgCvKM0obfCO%jDhQHtGQCZfH=vgqWD{XE}r}xg`D`pxI2z+VcBTR(x zNMP14TuMIiEH^c<+HKcrOV4(CltG|kVh$4wDcv>?S!_&19)P+tbX(R#Tb)C{|sj-XewHE>LLK8<=@cS9{ zg%)uwo1{fj83a$_TJqPEmkMCe2e^Y6=a(6Jk`Q79H$_-++`tv&F@p^zEK|fS%;N#C z$0Oc@uaUwwmQcr4e8+R$#C7b`?+{s^Xn8~iQN~q|&Db$g4WLb{7{?G=%n?(63;cj- z&NOEJo;hRGbcQ~0=qCgcGB7LD10?43DXPYLj#R_XG*zX@2TMm-{2lXuVsV$MyvEg6 z$V}ci#>z2PkFic&67#>D{6mw;;xS5R?57z5yeT@lrZ}dt%Ko;`A~gz*FHTwH-?PY3 z4aGv? zK%sj`bZYU{*$JBS#oVCGcln$$ z<+OM^43-;ibFs2Gy|xwxw)0?IgCbzA+K=pV!}eFo*7BM>4m`~$4N*YcGbj3P; zCooXPNg7;}oJ>;qyV!A5G@Ra%xE^_p_Kmj;oWWUMT@5v_j=5C35`AnLrPw84xv1*EL)l{>?s-?`dRnyF@RnyIG>n%Dp8KE*FB_kM? zGBd<8Z+Jd|EXOowIgX+eW{iS)*nHdB%A5spb?iNIyT?*7sK-Z)b^yB3!$4j32@xsv zE2XNOodZh!(ktBEKxe;FFP&BT)%w&ci)O~j`Dtr=)xHJ bkMpN?0;f@m^|#Ak!6Ys*m%tRq1TOyqTFLwY literal 0 HcmV?d00001 diff --git a/arrays/Array_Problem_5.class b/arrays/Array_Problem_5.class new file mode 100644 index 0000000000000000000000000000000000000000..18f0cde552e5551d344dd17e32b4ee136e1b2d0c GIT binary patch literal 1314 zcmZuxOHUI~6#ni!I&B$bpcGUF1w?GiqxeLv;0sMis$+s7X;_#6MjY%bLu=yBh5x{< ziE-sx7iiR&xOL~&m4CxT#qZt{kkCcXxsP+c?>pz7&bPlGzW|uQyai35&yOPi>1O`A zbPw)DwUu&Ed2rr>A>eHIPyBq@ude64m5pGvArQL~R>Q`efS$=N2^cqPYe5n^5;jc4 z1iFf0HMrZXtOU`0pHKol#oDT0Uh<<*?spE2#-ngk;Bc`$dqE%(1@f-CPKa1$d0|1) z={yq9mKOv>l|Sh>sG<>6>Rg5bor?{B_3<6Qu81sj3nc4NSZ%2K5*Was1$SR*i%&P1 zZ{rw_lcCmRmFc3YJgnvK$=t;T#Z(Fwh6Vcfdcxzdx_+Y>me+zPi4!{mj#$NY#>QEk6NoozEd>I-nYOwv;G%^YfmEBW*tjGGo2totii#idW%@G92e=E_ zr6dGqZ5%?ETwS$s1YOMWqje5Ls!a-CZ?V>lR)gE2oTXm%ihEN!B?V!aSUN`@%+dyn{AE;J-*6J|9k5`IWUdf7k zrMMIGN>0rAMQb@caNOZx& Za1GZZwE0AZ30FyI?wn@gX` zcN8R~zVOmM1XLl5en^E%*EwTCC|0Y=@|-_46wLN3m!kBr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#Pt#zAv@Dif(9EC#M_$5{e$IW6z(~1>6Qmhzy zv0@sc_Cc;8+)XSH2?qr literal 0 HcmV?d00001 diff --git a/arrays/Array_Problem_7.class b/arrays/Array_Problem_7.class new file mode 100644 index 0000000000000000000000000000000000000000..fe64b037b756f18f9844d168f3d15f94d2d2c009 GIT binary patch literal 1478 zcmZvcU2oe|7{~u7c4Ei4otL)R3pH!Au_bkv02?jP(a{dZB4xN!r%F~YHn;VPN8aQ* zlX{7?D?R|Xs8_p&ixe@$2jEli6_B_b>;A_MiAJNy=RD`_d4A9TJSTs?{_PI{%cyI} z2o(J&@(&McYqEQ^5p{N&LF>`7235d%>Ob>qO~1Wgb9bHwyRks-R@e^XRRN`3*%DCi zboK%R3i2kh$O)Wjgzey)UTY_a9{O}8P-t{^{pOY*g>pQYRO4^M1A+66@zGZVw5SvN zanPVu-mcf{l`R7TXH66^C14I#*ALw`W8~x($s>G$%yyl|9zWT)`Go=#o3X$9-F?41 z1PEGP0izp*?KsIjkM}UA;nG`aZyp}RLCeHEN=&)aqXILHM3t~p+mL5B<0$Z3D;ll{ zoEz!I>9D=O-V2+1L1f@6${Mb{?K;_EqJjnH_{?wi0{02sm+O@@LZW->XT`u}EJ}&5 z%N?iJD_c5h%ydp}{LsWlxItC?ZZ~LCi0k7{oN_XNO=5j)VhPIvdfZ6~1g6VlxjqGR z|4d+Nj4CE>N#JZEGK;0eo#qrA;(tZsK#E%*@a{1Khwy-U@Mow4eziu z(+%t=ID$mvj6D23U1r%Al_m8B%mv5p!+NfY8FlvP zuMujhqD=>Ut_)Sir37&ybvQ(<3=t~>#0+1d)J_>`mlZbh_#CSPuAk^c*2jaF5Z*Cv zH!S0K!&9=Zr)sX3wQ{bPvvk+fEW`D5%XB>}XHBxzEQ_sf71-vjY4^Ufn6r#NzHk<0 yw?3+=BFTX(&`Gm~Yp64W4gLv8ndj2r_!3`nq;u^qYlSZYR+3GI_Sam=;NBb3GX=H) literal 0 HcmV?d00001 diff --git a/arrays/Array_Problem_8.class b/arrays/Array_Problem_8.class new file mode 100644 index 0000000000000000000000000000000000000000..8dbdadf1700fd7f01870960ccce5982888d11077 GIT binary patch literal 1100 zcmZux+fEZv6kVq?(e8b=RyYGz`RGAS^Ik zwL8|sz*)7t$C9B05>>Y)+so3kmA?O|`x|ywV61v{_A(8%VO(g!|Sby2|EhmN%q{z<=NH^67+ivL*kv{R3bjl`11x62ty%X5&HOq_OguwWc zd|^9*lWVyh-(C;gpquMbwY#|}(wI=yW*9zy6uBq_PR4KwIe{TZzNiPQz3$cnN5IIh zR0`ILnsGtu3pwCXmTj3jf91XH`~+b1|GpULfMT{Z0ss}U}zHB{Pl3Ts0o47<&-3`2!^}trEF>+|>W))kUW*&{%K*@d~OleXp z@f19b;tnF8c?ls(sm!3mG0Irqf#)E#0SsZ7FADqyI{ktB@yKqpp~ZjK8hZR!tznq8 zMmSV!nCc~>*BbF~guk&~ginxL~ uQVDaPuJRUQlqp=}O{0H~KZiN?>jv{Bq5olc!^BO&4;VB;1m2=4gz{h9#^AgF literal 0 HcmV?d00001 diff --git a/arrays/Array_Problem_9.class b/arrays/Array_Problem_9.class new file mode 100644 index 0000000000000000000000000000000000000000..4fb79ba25ede09b1c5912269780c4f792c4edd91 GIT binary patch literal 1416 zcmZuw-*XdH6#j0qo127%#->}qBqXBMB-O+MZiSTA0;18>;?&7Zrw?V5-G(jsHJc41 zKI@Aw{0l11^o19FC>?b0o&Sg#6~DVF(-FE4_nv$9ob!F>JNG{O_sLTLi)cth1ZHjD zx9^Xtt7_Z6#be49SFphyuKGK3q*^hrhs;R;J8Ud zkuabmCNS0T`tDcbUd#2ru~|xBx-n?m-KOn(>U`+bf;-+w;7sFq^qN4j;|6P9|Ax1- zBOr@g^?JQjPvQ-vC8l3e8wXx@!hB?41||uO20m%(Oei&zIE}LsX9P|ib+Tp$cMQCV z414H#eHE)p^F%HJku92nZlU(O%H1bZeblqNU7lKAhbV#D8}hd&5Fd?Ofp05qqPF7* zoZJZP_T4pm7`7^rV|dS2K(ocI#u1N=!1wx{TB(`92dGL^UN#l#y>Wj;3^7t_?{W5l!!1Z8!Dl0+!u_A;LHC2q`?di literal 0 HcmV?d00001 diff --git a/arrays/Array_of_objects.class b/arrays/Array_of_objects.class new file mode 100644 index 0000000000000000000000000000000000000000..296a6df60e82d3a2bbc6f352336f5cb5f1caa0b9 GIT binary patch literal 1546 zcmaJ>-E!MR6#mwBEZK2eS7};W+*bX?j)_gnPa$ptvD-AMoz%o_N(d0v))H-FNgi2B z36~5nz#9NF9j;-RWQI=j0DTKCxPfQj=d2WlX&SiM)pyR>^Yfi^^z6@{cL7`j*N|X1 z!F``^4XZQiTJt_z^STd3FBob_G2|ceOA6uJG^iZeK7MEw9J>%iNa=?+H_ZEr$#zTmKQhMy?$$U54Yu)z-gh zbOK+x>$TFdhNG0<-s^@hdmADUzK$`5qf4GG1G8gu-{Hjvl}0IxJjPXm$CbbNgZ$}u ziQ#a^mK*fUylL}C+|_Z43R;#v56q@#_hqqBDd{LMWSW(hxy0?Tuj7o0D2F!h+Gd-( z0Yz+*l}YaAxNpe~CAIh#*KwZMsN3Ntcg4_tL~)v-!zt;DWV_(m+;N1Z@^++-%M|(! z9}avW0<#`EKDTugspggNi%sELzAzg$w>f1n!EmS<_AMa><_fp?W(KdKqG9s64tBPN zfpBuD;x+1?7X}RDF%#0Owu#n&$Q9hFX}C&rv7hsLC@BIZ`v%o}t1lek1||_BT}ym! zW^n~?DTc3+*Wy70D~oq>m;$vn%?AT2fuT^GFTG&A7pbP>1|@1vMb6(oQo-;Nv}C{ne7 z>QJ8+BE|i6TAi^2)`IAwjfiynH-lJbl4|J$ytlEy2hkpCSY^m|ywLB7S*ezFd}iN& zprTU3Igo4mYXAxQqD7}uBUGiE(LFM;1O10couyN$0Ry9S=3)c74-v}XFpiLf9_qrg`1C5X0CwV_b@1CVHDSUWs8gf}=)B!Q_qaQU4L;C%Cd=yuO1s3)^_x zxW0{PV}_1$;p$IlDA8>tn*T@Cq>pXf-A3oD1S^zxzx``hQIv$Ds7@0IoFWPe7{h6p zID<)?r6D(QoA|zu^RRFMLtMm{xP-598Q-9U$C$t`bpM8OM6VfBh!3zr{?hmrA7YgV e{tk2a2(#3$k4c_I;txF5@ClnH-5N;}`1EhZ>u|aN literal 0 HcmV?d00001 diff --git a/arrays/BasicArrays.java b/arrays/BasicArrays.java deleted file mode 100644 index 2421967..0000000 --- a/arrays/BasicArrays.java +++ /dev/null @@ -1,33 +0,0 @@ -package arrays; - -import java.io.*; - -public class BasicArrays { - - public static void main(String[] args) { - - int a[]; - a = new int[5]; - - try { - BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); - for(int i=0;i<5;i++) { - int j=i+1; - System.out.println(" Enter element no." +j); - String s = br.readLine(); - a[i] = Integer.parseInt(s); - } - for(int i=0;i<5;i++) { - System.out.println("arr["+i+"]="+a[i]); - } - } - - catch(Exception e) { - System.out.println(""+e); - } - } -} - - - - diff --git a/arrays/Candy_Distribution_Problem.class b/arrays/Candy_Distribution_Problem.class new file mode 100644 index 0000000000000000000000000000000000000000..0f2747c249ab972f89a2b10aa4d7a2550da623e7 GIT binary patch literal 1001 zcmah`%}x_x6g^*O+M&}H25KvaBSH~dT3T1Sz%-f~V`E`77?K7PnEnWZ)2SJzDr?~} zT;PTc8&?uT`T#zI3!lNYTF*=|Y&0(B{>}OBJ@?!%zdrW?+`*!Pkie|zy5{~~sbV^< z{mlo~p66PPo@aHP%_nZRVYfR9WC3m0d~KF&)7dT=joo(B6Nuck9Lp;UNZH)FfL!Ue z+A1VO;|L=nFjlji_G+)wXuHo$HWHYqb(^NWZn~DApBH6s$J!If)c#9kSs>i>Y0_sm zs=2C)aU>N?{GmtMcIkewPaKz!BB>XaZIdeD)!e#@%a~FyDKL7m&Wh>n#Bl}FT%=>Z z^?MUr6;NE$vz%>m3vKwRKiXE9t6i0~*->+oCzuFQ9OAjTV9V-yPd&fq#Z+`}Tf`H_t& zD(^>K&h~3E=EyCLSo9}G6=Xyr8X8NChkhU?qGUVIxx>pmCpJXvycRiA>yj2X>asRx y)Wh16QIBX9qpoOqqduZNHfk4#Q-e24+@cupP7ix<=bP-6VecVt!M*%r=Y9h!C%={e literal 0 HcmV?d00001 diff --git a/arrays/Cricketer.class b/arrays/Cricketer.class new file mode 100644 index 0000000000000000000000000000000000000000..4453e48988f85b006512a2fa9550f7ed9f2c3534 GIT binary patch literal 427 zcmZWl!AiqG5Ph4(#>TYOXshC-$F_($dQb!@2!*1DO2AXt#IxLv=0) m[Math.abs(m[i])] = -m[Math.abs(m[i])]; - else System.out.print(Math.abs(m[i]) + " "); - } - } - - //Driver Method - public static void main(String[] args) { - - FIndDublicate dublicate= new FIndDublicate(); // Making an object of FindDuplicate class - - int m[] = {1,2,3,1,3,6,6}; // Putting or declare values in or to array - int m_size = m.length; // variables which store size or length of array - - dublicate.printRepeating(m,m_size); // calling above function to pass value in it to print repeating elements - - } - -} - diff --git a/arrays/KadanesAlgorithm.class b/arrays/KadanesAlgorithm.class new file mode 100644 index 0000000000000000000000000000000000000000..622bf9228ac6e73b8f200f8795a364a5a3100a98 GIT binary patch literal 1042 zcmZ`&%Tg0T6g{2HWFQ0xk0F2&0TmOF1XO|=z*lKGWdJo+N@ZgwOohQ@LQN(X?D-5g zu2|~=EVcXqzrt^DuXuW}3bb%B-M8;Oefr$TeEaq3D}Z_2G7u6-NY9fy&Fmw&E?v8M zr&euvj=xbipb5k`JQ5ai{6q^%w?_5C|z!^N7-EWG#2A<&)Kx^?Vd@ z45>VZ1qM^6LeeD#O2%*&BLaqNZ~K61!C%QTR=}) zR@zcJCt|pS6#b1B8IC1AW{Ss>CUM!olt5p=NyR6^F-#*v8C&W`jd^J)E9i>!s;q9` zDV1XZniYnQvO8HimRyiRSo|bmYszrgamp^X>H^V9%kykXQ-{u?FDtK?VmU!p7FoVJIqX;V|4)m=@PTJqiD54yuS zJ)Dc|Vbs*8%}C}|PB-vO@sNlo^u6Q+l`#^e^%QMNIx8>}@IB|PD@-ho zBCg^Z>(q}`%pu2j6SU{))5t!D>w%@vH)!enCW2@LH_4QQe#qx^19<~+VPJu!jQ-@G NBjO$8UnC}krQZ-<&iViV literal 0 HcmV?d00001 diff --git a/arrays/Maximum_subarray_problem.java b/arrays/Maximum_subarray_problem.java deleted file mode 100644 index 724dcf7..0000000 --- a/arrays/Maximum_subarray_problem.java +++ /dev/null @@ -1,44 +0,0 @@ -package arrays; - -public class Maximum_subarray_problem { - // Java program to print largest - // contiguous array sum - - static void maxSubArraySum(int a[], int size) - { - int max_so_far = Integer.MIN_VALUE, - max_ending_here = 0,start = 0, - end = 0, s = 0; - - for (int i = 0; i < size; i++) - { - max_ending_here += a[i]; - - if (max_so_far < max_ending_here) - { - max_so_far = max_ending_here; - start = s; - end = i; - } - - if (max_ending_here < 0) - { - max_ending_here = 0; - s = i + 1; - } - } - System.out.println("Maximum contiguous sum is " - + max_so_far); - System.out.println("Starting index " + start); - System.out.println("Ending index " + end); - } - - // Driver code - public static void main(String[] args) - { - int a[] = { -2, -3, 4, -1, -2, 1, 5, -3 }; - int n = a.length; - maxSubArraySum(a, n); - } - } - diff --git a/arrays/MultiDArray.class b/arrays/MultiDArray.class new file mode 100644 index 0000000000000000000000000000000000000000..dab8ae7ca8025f85636634ed341880e8ba78cc58 GIT binary patch literal 1018 zcmZuw+fEZv6kVq?(`oA<<&Ik9=A{K`6%~OPl(_V$ClN!i3L>qH003E8xQn6fa98v-G(-WH1D#?R!H#7z?^fj}8debf2>yDa{ z=s%N}RJT9Z+VUeFs;#|XXlw1!nJG53PR)rF?oq;VH>j8?GBhda+Jts;&4SfE1dh;zL_+(lOOK>vv~6HDR; PU-9U7!U-NyQm*^~36I{8 literal 0 HcmV?d00001 diff --git a/arrays/RotateArray.java b/arrays/RotateArray.java deleted file mode 100644 index 00691e4..0000000 --- a/arrays/RotateArray.java +++ /dev/null @@ -1,38 +0,0 @@ -package arrays; - -public class RotateArray { - - //function to rotate the elements of an array - - void rotateL(int a[], int d, int n) { - for(int i= 0;i=0; i--) - { - /* Find the smallest element greater than ar2[i]. Move all elements one position ahead till the smallest greater - element is not found */ - int j, last = arr1[m-1]; - - for (j=m-2; j >= 0 && arr1[j] > arr2[i]; j--) - arr1[j+1] = arr1[j]; - - // If there was a greater element - if (j != m-2 || last > arr2[i]) { - arr1[j+1] = arr2[i]; - arr2[i] = last; - - } - } - } - - // Driver method to test the above function - public static void main1(String[] args) - { - merge(arr1.length,arr2.length); - System.out.print("After Merging nFirst Array: "); - System.out.println(Arrays.toString(arr1)); - System.out.print("Second Array: "); - System.out.println(Arrays.toString(arr2)); - } -} diff --git a/arrays/package-info.java b/arrays/package-info.java deleted file mode 100644 index 7fae96a..0000000 --- a/arrays/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package arrays; \ No newline at end of file diff --git a/backtracking/N_Queen.class b/backtracking/N_Queen.class new file mode 100644 index 0000000000000000000000000000000000000000..a898f5df323e3259e6d457f33a39ce1830571c0d GIT binary patch literal 1900 zcmaJ>T~`}L7=9+Zn@z$(F*Nimp%iPI5BVrnD1}m56dMds3{Zg!U0|h)A&beT>OHsq zfLbr?6*t`IvEdx6-s=zW_y_dTAK>AL&rDW|f}Whr&b<51JI}{E`_rG_{s3SQOC~}B zr&sLN5B&-Ux4hmv{oZWNamprifz}QCk=i8AM-W)cO5;*gMdeP_0^}98{E0$#gz*EIFt=EO(^kj*LL}Nj3j>XU@W_=oX0h zUIPP-O&>pur}W~Qi9Uh06UbZWmy`^pt4w{(!t00$m?~1D#>R?gSI9-9)Re;Ie}hgG zeKydPy%jhYcB@7E1Ns_~mgMu9CGMzrA9GywN&-z)uk^^7o}Kqyu1uAbS&Fem?phee zh@8D);WozjHpu1PbcQ{9Paw3Mk6@BE{q23{n&(tI%bwrqeBxGp3B4epcgaH27EU8! zVvs$#X}cuRo?bqtrZSC8KDZ(@S!c4eIn*mgoTL6kodh!wqBW!0H*WfNP$?dg%y z;t~tVo541eUC*bbiIEY;1fQ|&9;~eS3@u-&yjG4as)7cczbNM~F=jQg z5l0(Wklcbw->5ubOuMy%8`|g&a$lqUIg*R104#pN&FGwjUvObm-9i!Z=+e^$?{a5d5C8W1AI??a0@rc zHN@OL3~{F6CNo>0@52!L{A67HL)E9@4F=*Av%}2U&<6A!#ECee_vl~3&~~?Vkb=dz)#6#oF(UTxW@S%q%cWU=5Y}ZIDd#PrNL+e^`QnEfd*tk6{H4oCbKmD z)|DhISv{#a(nkTw(8`-}F1YnDC&SLo|iI*?&cWzmitKSAA$^e}RroHO+C z<`IvF4*3lo@*7gDLhOwm#j4?P42CHUP8yOq?@~bFGg6R|LGydOwWyij#fpo%8Vxmu z#m|1D zDP;pjz~<{SF+d7W Lp1`|Yhp_k;$4gMy literal 0 HcmV?d00001 diff --git a/backtracking/Rat_In_A_Maze.class b/backtracking/Rat_In_A_Maze.class new file mode 100644 index 0000000000000000000000000000000000000000..39fb337a4793afcdf2e8ffb1914873d4798e3dcd GIT binary patch literal 1911 zcmaJ>+fv(B6kW%XEn@_v5U#O_2{+pi+;VA~kkAmw#f`y99H53yu>ggN`oh>ElXUu+ znSMi>mn1KF;ic(}=`?NL^3wi6KcSz{VcM=E3quO+*piO+*=O&y*4|sc{`J!v03TsV zgGZoi%~=1+F7aj+Hsf~nWcNiTFw+`P8QdV+@evk0I@-`qaK#;BZcREo ztYZAO6UQ!@Mt)L5r$GB5!?exK&8s_BZo@43afUp@0dycF8Fe#Cq#DMNqv|{vU6dYS z9X&WlSjP6YS=b<*NFsX7*^N9YPxQ$X{Q~Dtiuu1M2X#ac74X}|Dh7emk>kmjWeDdr z3=6cJKwig)q~vvUt%Jb(I=t}7L!&yzWC1m2FGsbNaxup{C8s17uPs(2ZL@3UjBU4$ zKC7HI?z75%S(-#5y3C%)vybThkk=!DI)-^*%HBFC;If8^0Fz(UF@sqKt$8fi7E{(& zW64@C`*B^M?Vtt18%48R7_`IYL#u4d7&mpC!h3S{sg4V{=%lxZzAdtHOi-t8jISXj z;8{t?V|R2+;S(M+N}KG+mJ?12SfW^L)pIinm>R<3+p zb1rzV<6E3h!KXL2hrst-c%ZvZG@^lPz3PBQH1Q3RoO}33sQdx5%H@~1s7$>?|0^`V zMn|T(YY)Mp;Am*1g0szC74%jxP(kdmB0{eafByIHbgbZm#~u-M-rvgHij%vW@W5u z9xRN@;v0HP7QMlz2un0C&>4D)RtfY48XXquGkDcqWtVPMkd2P2?F`j{vuHm8s<#HJ z7n2SshQ=ialw4h|fl?rP7?8Dgk$g+evRH%6%>P?l@yx}B6lJ)A>F>}$$(pZGL}fQd z%MJAqO&4PVeW=F(zcz#D=46H`Qa`6i$`!7Ltsxt9k<}yU2DU4jS9!R5isw}mdQg>rR!B7Q>Cm3^0G^p87r%DD-q=eEz%^tox zZc0iys_m%L2IDwG_0F-JeJs@o6`Y_@Gemcd*wVZ&;08X&O?-h{4$JW>&Kk>XP5*37 z|E#M&`8do~hq(`GU%1K7iMWNN%lkLBkSs?2HAH3)b4l$N%x4ts=RihLQyG<)S52ie z>c1=*pR{^UwE9l6&JDl$0r4T0^!C!>1P(akd542~m*q=ShI@pzK-hO-Urpoi-P?s%~H4;EBd;Q#;t literal 0 HcmV?d00001 diff --git a/backtracking/Sudoku_Solver.class b/backtracking/Sudoku_Solver.class new file mode 100644 index 0000000000000000000000000000000000000000..2f49fab55a8f17a34b559ccb236131c36e0c8180 GIT binary patch literal 2183 zcmZ`)OK($07(L_rw0(h#gL%b)@F=yD;_wWVgai^An%2aCX~1OB+&C9{!LcL92C~m@ zsFWR%DtVJlQz=A!Z7cN;v?^Uz>H>8|S14_IX08DNX`(yx%{Sj`&iQ8i^S|Hz2;dBE zTZjnko$^Ze>opER)-SDQ$zCa>ZEqUc}uNKI4OKJA2 zFfnLw9c+coQ1vf@Ie}E}|I6!Ro;g`)STyTNPfU!Cj%IGhSi(*RZP+2D-46C(uYeiM z6}&sFAsX7zka_Obf@#)IPmZT>`sa<4ZL;7-|INX}=c3 z2gq7D`etZl;h+b{1gr;Mx#8#UFnoG66J}66g>m{~$l!#8^Q5$RcRw?3<20GT}SK^Q56(4J#1Xk>0efL0q(OL7;6DR2&S+f-MDf zxgrt1xwr(~W+E*w>UIaO7I)4Qx>w>CgMo^6B9$ zy^O9W*!H%Ird*uR0NatEp)K!3%lSEU{sU9(D~RdSkKv>!Jcgk!hl0Hzgm%8G{X{Ce z2&bz(rBALQxvUQ~k>RRi4Z9YxQ|@=_(mz*U*le)K8*Aov16Un%Wd&v3}}9kfs>N zBy7hSXFnwko!pPZOvK%FzGW$!0FdPt0L$b-GBTv~H*r=w-^8I69QqEKqB`>$x}V^9 z;?yd7S8;9?0}Bx$fmz!4eFej-7$H0ox}}YuB=q3{_mNRBhrui{9O4^rkmVfaYkL3} zc|^%#XPC8hfCwAJ)0P)>kZz2R46WB}BCYjWP3-APnn``~MAAwc zlP}#Yk+jUEjXxJmku)j%s=sD*h|GcShsokybd%K#dCBtFJ$%59QOfdRIf)VSn!{;a zM=wf*!>3%K?jiaVD0c`K5A=%F`B$vYw^)_CA*&jp_=FjCu3t)nIEPP_ZiLx#lnjEI zRnVI3qx}k6OLfE^#Mk-j6puLZ$UppLAjpPDL|zcnD6U|vg>r#hMp)F}ZuAG_i<%q# zK33Gse9>?@n0CHsyBu88$`^`yxXZO}aA~L|iICP7jVy|VA}=>%7<9LEx^s4IskcIJ zH_Euu$C4RblVgENq>rw&+;3?)sd5-bSGI;sB4aU?+~Fki+Ojw|jA1Z_Njp1?&fvLj zP2-(jM67!a*P4j)0wfCT_17JJP<7fM!M%Vl*~7oFU!P(afAE4nBdyPISrNE1#0sBb coR~c&G4g^61$Y#Zbv(0h)1u-Qw<9S22QN2}MgRZ+ literal 0 HcmV?d00001 diff --git a/basicProblems/Armstrong_Number.class b/basicProblems/Armstrong_Number.class new file mode 100644 index 0000000000000000000000000000000000000000..f8e502ae80f448266d96c46605ba1c013d001140 GIT binary patch literal 1055 zcmaJ=+int36kP`fh5~IVl!{7g>lJD(wkm3AX{)3O3B4p365~TNOeb{eFhgbrFJI6% z|G>nzKHCRtH1Pxc5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>UFe7kR;%-2&WCya2g8c;Q~&?~ literal 0 HcmV?d00001 diff --git a/basicProblems/Factorial.java b/basicProblems/Factorial.java deleted file mode 100644 index f4a4355..0000000 --- a/basicProblems/Factorial.java +++ /dev/null @@ -1,19 +0,0 @@ -package basicProblems; -import java.util.*; -public class Factorial { - - public static void main(String[] args) { - int fact=1; - @SuppressWarnings("resource") - Scanner sc = new Scanner(System.in); - int n = sc.nextInt(); - - for(int i = n ; i>=1;i--) { - fact = fact*i; - } - - System.out.println("fact of " + n + " is " + fact ); - } -} - - diff --git a/basicProblems/Fibonacci_Series.class b/basicProblems/Fibonacci_Series.class new file mode 100644 index 0000000000000000000000000000000000000000..7b7260cf337a8956b3fbfc7b847931f68bbdbdeb GIT binary patch literal 1344 zcmaJ=TXzdl7~LnCWYTnyrX7lwxF@RO8kcBMlvHR*#lnN0Oh*mLBx^FUT$TrxM}CAS z&pf0SYxx1*{2}Z!i54xh)|okHzVGbs+xzVE_4}tU0FL3Nj*!5XiflU8j90Hz?OHQC z=~U{jv@GXt$@Uz(sY4S;JdlrMwkq9)>~!UUZTSMxQ;zHS;{xGyrYxYHtIykUgwbOl zf~df{qT||ETeXVq%}PQGB#U)RR?E_J)Vljq^Y1%NfmHGTUF2DzCLLE`efmyuxto&j zIqpI}Q`XTZ&=&++zEjPXEa|$o*MokTItKorPprqvaFT zmbH8w32an!HVF)-S53*3Rnm}wVQdl5UHh?LaH$SODX7{h1KY5j>w1fSm&?qs?O$bd z>=fAWH>Zh~Q=PZH7msn>=|xj zZ*qSd2iiE?#<5?aQw*8fidb@-IpJL79Y%*uZ7vt>=9|%vIKwT=NRy^EZboz3tB5co zLy`HnKfWmvVJH&0Zo|D?B}m2O`T*N6lE5tba2rX?@k%|#0G>1Yg8yD)Fd%)YLktB> z5vdn1ahdyQ4Q5`!RjQc8GfZ<9=FZ2M;Y`C#`t}-U5#nycbaFGW?r=op1vI^rC_;go(N2(iOtBV55{;r$~q5b+wod zpof+kOA_;FXJz!_mV`crkauijq=J4#8Kg2#W)faF-i%JdAVa4Y?^2CZIZd@J-R96k z3T|VV!N)ImNtdz8?q50?1GvjeJi-vE=O>J-TM~J`DXt)aB;i>4CnsakbxEj zdxv^0)TC*s<`s>WY7|#>p>AWO2FuWAPz4;`yu1QzkD)E+sM^OBwOsFJIahLRO*N1lIsVAX(^L0zMkiyP>~CvlLlIR!p8C@Woq}>Ccw|0XOKc)HaZ9qgg9% zqMbZE_{>WLygx=qu)B)LDF!x<5j(-1>}VDD=7ohL%tfaKVOl)GFzq_U=tfuwi@RSj zeuAmsqbg>qNLTUnKxARDLq5FtMcb-aJn*w<|KY_C&g2JYn($}>2#^gCO@v6I)XOoN zjnHdbBD;caHec dX(UoU9wnS3Dq(=J-v}@^c;*#gm6m*1`vZT1BeMVi literal 0 HcmV?d00001 diff --git a/basicProblems/Multiplicative_Table_till_20.java b/basicProblems/Multiplicative_Table_till_20.java deleted file mode 100644 index aa46949..0000000 --- a/basicProblems/Multiplicative_Table_till_20.java +++ /dev/null @@ -1,20 +0,0 @@ -package basicProblems; - -public class Multiplicative_Table_till_20 { - - public static void main(String[] args) { - - for(int i=1;i<=20;i++) { - - int tableOf = i; - - for(int j =1;j<=10;j++) { - System.out.print(tableOf*i + " "); - } - - System.out.println(); - } - - } - -} diff --git a/basicProblems/Palindrome_Number.class b/basicProblems/Palindrome_Number.class new file mode 100644 index 0000000000000000000000000000000000000000..3ff500e28d48f4da92593d1fb65f9a5111dd0b38 GIT binary patch literal 422 zcmah_O-sW-5Pg%Tjg8f6E4@l@RlyuRRJ;hDf)*;hc#uiD#4X7NHmU#1li(4;x=B_ltqGlTZFGG>Xibh51pl&Jst_%7duXFW=*QZqjl?aBHenE#Dd!8e+U1`` zzkbjaVI2QsV=7M+tPNo_xr@K-%xkMnHf=1h%|vSWN1G7N%e76_m3B@>zqUMeiWo!I zk-q^vxyc%WfnN%%J_qb6sm%fG^s#R(*#_Q+hKwi+nHu&YIN^Y zxO2r?7A29y2k;$y1E0W!cGCP%Ca;nY{FWUyMSGgmked<)a*TQAUmj6qnKp+h+EQX=ntMVD4 zisuMxuaK{*=x6Bn11(R~^@_nQ%XA_bKtjdfg)S=ZUC(T27($XEAd4nCC55e*tY*uj zswQs~qKIKwb~M6}%3Ya~ugavfhA~`YP%ZPFSF&h8G?$XZ&S;pxb+YXidCy>I*47^w z6_X6fe|uVKiTbYTgfYc1P;xUo%(QDl*mO8Qohn&6-Hh(g^bx|J{cw~{83q(|)2Ve5=(Yb zi1A}&x8gUBaC5AU={9EDxF^wrkm$2MZiG&`XBy&!nL1~4cYZ6IJkx$1ko@3O{ zp6f87-+X~8bfbVrSR|e?(xiYTYCDcOETc#m35?(|`4l{%+$59}Dj!nuR7H$2>bzU| MN#z(;C>+4*Z+p`45&!@I literal 0 HcmV?d00001 diff --git a/basicProblems/Prime_Number_Or_Not.java b/basicProblems/Prime_Number_Or_Not.java deleted file mode 100644 index 4a06d7a..0000000 --- a/basicProblems/Prime_Number_Or_Not.java +++ /dev/null @@ -1,21 +0,0 @@ -package basicProblems; -import java.util.*; -public class Prime_Number_Or_Not { - - public static void main(String[] args) { - @SuppressWarnings("resource") - Scanner sc = new Scanner(System.in); - int n = sc.nextInt(); - boolean isPrime = true; - for(int i=2;i1U0e#=c!0XVNI%^!-^*RiB%vl(Kgb1_e%E9S66CBgV<9qb-LWGf4j1^bQTUz zEFLnDR?Fb~xm6m|@qQ9>kB#}yE z0+Rx>4ehJfF~mDbc!6xA?@F&F18wXJrxhLOP@vTKzmhGo^rZF$3gr)tv7%-aXurEv zY1x<)n2Q6$NPE?$D}7%DDddp1G5=2)%`ai3dTA7JT_9mV^CL*zuh#v+Fe0jwy)6eB zESi#T2rQJZ{8DL|Ps?en;HH4>tItv0XNTCBy5YW^#vK%C_lNY3Y4#|4OjE)=8+QeA zv3{z!6i(wl%7h-643Ao^ay@Rk47zMy?uu@(sL*9-r1)|>*hWDJQ72$98n}St$uMf~ z>#nB6nPw#2PrGt(F(aqh9|o>^sm&A@uUe7~BbrsRNNyL9;EP+p)23DBEqG6?onq>H z9Cmn`FkoStXL|I3_YAERu3?rQlYBo!N8F%-o;9zy1L50QW5z0*hT4X>TtKx;@p8 z>aGg4iuT>4zrSh06mSmZTUqZ(|DgV?d#JovVDh2%b^KUhqFU<+m`{RNDvJqB+sI&2 zV79G&^)%^sRrp*IR-n)hJlX5WP^aW_gqT{GE^)`t5IUUL2utf^vKP7?&R9n)Z(Q8BWD6nSQrf zGVSh;Su&SCeEf9!>j=x0W2~lR6G+KcFh!dsS&kc;L4gEio|frvGup!3P{`JZ3^lB= yK1aKbTa@CU!nzH1R=_GdxM)fq$2{R933 zUAS<|S{9IK;tz1`*1sa2HzffQT+F-ge!O$ey?1{7{r(fcT`XHL1SUH&^xXBJ-|4De zSa($5sc^%IdmD=uOo9BCd?)K&>2KDbb+(in2@Ku$d@p(+kg8PM0_Ma1E0sYC!#2_w z5*TTDzIqz>Ix2WB2`f-+^;DQ?iQbc*FECzt**a32oq1NKOk{eMEBwS1rs5 zj3)Z2;#k_oHB<<_tzUGh)vPpY literal 0 HcmV?d00001 diff --git a/basicProblems/Series_Sum_2.java b/basicProblems/Series_Sum_2.java deleted file mode 100644 index bb798c9..0000000 --- a/basicProblems/Series_Sum_2.java +++ /dev/null @@ -1,32 +0,0 @@ -package basicProblems; -import java.util.Scanner; - -/* This series is also known as TAYLOR series*/ -// program to demonstrate series sum of "1 + 1/2 + 1/3 + 1/4 + 1/5 + ...1 /n" this before mentioned series - -public class Series_Sum_2 { - - public static void main(String[] args) { - - @SuppressWarnings("resource") - Scanner sc = new Scanner(System.in); - int n = sc.nextInt(); - - float result = 0; - - for(float i=1;i<=n;i++) { - - if(i%2==0) { - result -= 1/i; - } - - else { - result += 1/i; - } - - System.out.println(result); - } - - } - -} diff --git a/basicProblems/Swap_two_numbers.class b/basicProblems/Swap_two_numbers.class new file mode 100644 index 0000000000000000000000000000000000000000..431db49df4aa857b184f041fbf4121fd358e5470 GIT binary patch literal 1142 zcmaJ=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=(bn)We}(+hjF+zCjKg-{yt7r$H63~1X3ocJ4mTRuNriF39~BM z+03JWtEQl90@I~SkCYqc(5!~Z%TW{0%TVV1CL zt20jW)SjrE0(BGCE-E#xLmxi;8`Q28=JZgKZR&tIE~l6eAV) z+9W2lz(_rj{_Abo?a#)>ia@>|_995&DW+?yCzyF+#FkaD(v{37 zIIcB&Sg}52gqxZBc=q!c*InxbHw{`E25p&Hfgz&hIH){aTGPavC*l(I8WA@bF>JO5 zh$v%)-Y{1A-yxp@v#epA<+&`@qm^ckdEBLCVFpFqqm{vZ-kLz_jG?TJ2Q~_VpFtOR J$XE&+zX5U6xo`jg literal 0 HcmV?d00001 diff --git a/basicProblems/X_raisedTo_power_Y.java b/basicProblems/X_raisedTo_power_Y.java deleted file mode 100644 index 36ade66..0000000 --- a/basicProblems/X_raisedTo_power_Y.java +++ /dev/null @@ -1,18 +0,0 @@ -package basicProblems; -import java.util.*; -public class X_raisedTo_power_Y { - - public static void main(String[] args) { - - @SuppressWarnings("resource") - Scanner sc= new Scanner(System.in); - int a = sc.nextInt(); - int b = sc.nextInt(); - int result = 1; - for(int i=0;i-PX2VVHiyP2S$QEQRI4wAsBw0`UfX% zmG#nAB0^-k7`mMU+tLdSEWGf+qoSLE&B}F9Lod!#Khv&kGxUTT+SS-mI~9F&e@?|E zO7klEDJ4~eC@pv}gsTd!H0hE)s92(?;TncX6T>EndTNbzBfd%?ErKd|F`*(%TC5tT zNx(zawg^=$p4*-BVgxr7L>U4Oi{@tWk?Uyb?3ir6Vn! zu*A*!aCp;(UCxO`U5-znc`jq}H)9Y4jiwoJ(TWC-qC&ekWk$JunAE=@y>c8N`i%z`k!~u#QFzCNtMdTfZ zXnBPAdbEnMFPQj<$wMUk_p5kN#XQ}h`lGMEztgQMo=Q}1NL1s50rX|nLE%L=;p?MX zh>#5vsu;R320vCQzoOGO2s#XcHI!JwGQC%k!3y1BcuqUXu2y+Lt29+SaQ(!X0$)EB J)~MjZ%Rj{BE+GH_ literal 0 HcmV?d00001 diff --git a/basic_idea_of_DS/ArrayListDemo.class b/basic_idea_of_DS/ArrayListDemo.class new file mode 100644 index 0000000000000000000000000000000000000000..b7ed0945140779946c491e977f6fa7a8c52858c9 GIT binary patch literal 1352 zcma)5T~8B16g^W4yREB~7K#W$@w25u#ShRHRG^~O@}V^t^npy<0herdo82u5y!ki$ z2fm39C6UA*;Eyui>9#L82x#a; z7ejYmH^p+TQWW+FUNi(lIB%7>vBqs(=FLUF`$cycV)=_vWax$p*G-0K{B!;oO~JKw zb1RcrQ_#Z@X>8P7-8kkDL$sw#p&wU?g;gU`eO_zbO07~~m%0mH z$tbwS(0}^U`I>H&g{@+UF3yn_IyYjDz9(YVW{ex@AOxG9Y;#RL`$u9 zt{U!3yh>HlH%t`|7}%Ty`bfiLOc6p}COB<`JWFH}pHw`d<4Y>i6qZ%YP$;M%llYuT z6)zYD3r7OQ_@*oD7_}qmEYnG=m?zsTSf(pX*EykLR*LbGVf>_utxGQuC4^TRUQ5tj zHaU4msCaW8gt9P%2Z7#!+gs$v$T=n>7Th@UNW06(pV4-E?^atDZ$3hM!OR)lnP=1_ zSg>k#Ni6D(foU7W328u#f}Vh;7x2*^O&Wa_%2E^=#m=zb%paV+qS7&kAKyIB#W@{utiTnh)>) E0kEn-`v3p{ literal 0 HcmV?d00001 diff --git a/basic_idea_of_DS/Graph.class b/basic_idea_of_DS/Graph.class new file mode 100644 index 0000000000000000000000000000000000000000..3a084b9adc3683e9fbe89ea2da3467a353832fd4 GIT binary patch literal 1775 zcmZuxTUQ%Z7~LngNy0#Y5TH%crWZ?~v{6*54MnBU5>25tNTs#nWM&8hVUjhOu=Ksp z{)ayG*)AJgvh)Y|KYaBki2KZh5?pzh%ej2}+uz>bIe-28`=0>rU{66nV7#ieEPdND zOl`Zdv%Op?Jan|?u7Z%j@Sb+473!K@E38-dOx+a-YQ~f0{ zeAfU^>Wb@FcC9ESymiXX^RJ?7wrx5w6!3w9_s`j0`Kjfa2P)?9p+G=_rhFz=qfoM& zZI`H~c2JCC79UHS=BZ?t?Ekh*Z^{gxsQ46jSy!XYZaM>dOme4SQ7i~tU14iDIotCu z*VxG&nvQGfW-F)JM$V+1>zO2MITu5 z0LHz$<+fB3SC~D>i-=(I(DJKr6hM@-yhk9}4RGdXguH!IGe=No(tjZF79+uXuaTVj z6(gBrB({!_th@|}O#0QyKff>}h%vq|5)=dq5k|!zMlgg+{NBJYQe4UTuo%Y#N5B*& zae+yP_`S%#0MeXIAaKIapaLO;9MVQ)yWDhck~L%{mGoTZH(cuA`cseCT)I1wi~=5` zA#Zb%8O8{b>S2+6$0Cco$AX}k_E^L)gPVRrF~w@4#M?i{?A9CHKEg-kH@Gue?BL$b z4(@xe#bb!A%n=^m4RP%lrLEDgj_@ek!TM;WgKs+cmfM5#;nzsZp!taRRxX56k(AQG zcQ3;t70$jo`J40Kp9wlo@j!6~C{L2&OnOROqHve7L_b$~zpddKHgFv;INssP9?Owp zKk;cpLzSZewwexuMNOi@M~aE#V0hA$rUcM)B+!m-eh8 UqM)W=RtRYm7%Q;LJONn$0ZJNt5&!@I literal 0 HcmV?d00001 diff --git a/basic_idea_of_DS/HashMapIntro.class b/basic_idea_of_DS/HashMapIntro.class new file mode 100644 index 0000000000000000000000000000000000000000..3b83041766b05ca981c06b63d7b47ddc0d0acbff GIT binary patch literal 1521 zcmah}*>2N76g^V{c7lO4-JmQrd(wrlFHKonmO@GkDS-k~G)bq)Kw?L>6RG?Op8*dk z0txZV7x91)cWkFPl;vf%yPb3H%zXXv@iTx+c&VX};b57&vQm<(f|u;I(p({XkGr)6 z-ki5Q$JP*INWS82o~?7Mnq4fv5*3eO$BeY3ca33NI#Xnb&DyIXfo+Hz*p3|xd-Bo} z4_l40aF%(wE*MgIyTa>5?nt!{4`W_Ux(s9ae}c$Sfd-cr!*KdV{uh{n=SZuX%M>;A zGxYn0mM8071_>k)*D*+N+tRJ^dIH1Pt6`+;>{BA1qADB%`!LF&wRycI7S~j*`Ano( z=$2DS4;VOzLqxvWA}ubbBW{5}xveMBT%nT=lc2f0Qj?aBBYtsNuJLvp$8bW!@gC_5 z>#ipn22LVPm2FjdC@3TC>=G&Aksg9KavH`NMt+y+R!i1bg`;DV*cap*VcKhEgEvj- zPEVN$WN=FLE=yUXd^R;!yw4aoi*wWsm*V~2&#S--1}@?fQQ^&|uvQrk^hy`x2mz3Q z8C)?i4Qi|I*@2N^FdbDWEStbpT-QMNY{2K!%hbRPg;#4T@^wo&-%@9@zi|lV&J-1g z+Xn97F2l}>ZFzL5+y`R)FaFP!|Ga_wctB*Uf)qay)ux+wYqNDMFpT(+QqROd+0<3e?!bq+Wv&($_D*H6RCk@ z;sb^{*#C4QHI_WIxjvj64A<{*^b;~Gsfi6tO>}U&gYz9+?qG%tw7*F?I+%M)8@0Ii z1;Y#7kUWJ8UXvh6A4xKO#5=xUWPNE;TkwP9rc!Cj>uoo?i`i#r~H6GzH qMeDFoz%p?v(HHgvMUv<#oh#mf?HR3Bd{6crEsZWN!*kmA;l)pH{B?5x literal 0 HcmV?d00001 diff --git a/basic_idea_of_DS/LinkedListDemo.class b/basic_idea_of_DS/LinkedListDemo.class new file mode 100644 index 0000000000000000000000000000000000000000..97d57f25a22dd5ab5240e7b8ea55eef6846757df GIT binary patch literal 1826 zcma)6ZBrXn7(JJ_UD8$3q@-_B7OgapwvlQ@38EB4(E!!dAVtMZaub$rcH?HlOvhj0 z*ZvE2W^wF{$g$bZn<4eI4%!T-oyNhV5F8S@qmNxZao?Byb-KDyPgqjNys$>c$5K zmhd5~!fLgoOIh#qll2s_$h#LoK|w4Vcz_iu8hDYB>CDcYbK%{O@ri~tfpnKpoT`CO zRis)=v3Fdh`ez0{SNR_CS9I2z|J%}^FBxs z)TB9E>NI8IY)?M1XL*P)VNWf{l@BSmvRj2vR!a6IwI8qia3lv^VLz(E} zE4uiqCh~kqU9X5u+%R!{K`ZZQlKP>IEo`%EJf&>)tXReFYmSg|5MPF!5^kYsq9IV5 z&$5`d(L!6mJk%8d#aK#RFF___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Rg59UptzQ23PW$=YzdtmhZev@)2()` zD(*|ZfwGium+umwr7$E4N#_0WE4Bcj-VXYw?p)m+khXJ=&O1M zC|;&4h%4x(6)I*aI^m+k;xh!en>^8 zz0k;>dRf{Fb22m`o}GqhZY+2kOHE*^T4_~f{;x_3?SK?ILvo}jg|bl+n4nxEfm77D zbLhb`B6x!+iiqKWhUE(e@fAb(j*+@KG0y-xlO-Gl->`}`vS*z#X`HvRL4OQyY0Zas Fe*vy1KDYn? literal 0 HcmV?d00001 diff --git a/basic_idea_of_DS/MyHashMap.class b/basic_idea_of_DS/MyHashMap.class new file mode 100644 index 0000000000000000000000000000000000000000..e3e28bb52166bef5029ee3c631841dd6bcd72e78 GIT binary patch literal 1512 zcmah}*>Vy=6g?f$8OW%FY#O(5hitenA+Cu_l$a<9F=`dnkPfuM48;so;h*>!`amqL zvV8W7e6TEU&kS)eTE6slmpuQlw91)OUc&&x zfM;mBvYHN%#}G$U#}Hv{NvFcAF^u4VhS9FG$7jKEMOicq9K;xd*5cKsSlU!~Eu=!1 z1#TIY^ss>=I7-axO%mc-GUVo~li7I^&J{T6FbSH&OBHG9IN@C`ixu9A;uOwkINhUr zuI;#@X5cK6bhE8)9`>)1c6ynVa7horYZ(pW45NR_bhjz18=|3OlGx|uTVdLpW{uZP z>C8--F{Ci93YVs=VLsa$E8gb~T);)DhC}gQ;TKfkWdm1mm8kG~U054b%wFmI9033l zFoo*|W+#ehQxl?(? z;hur}c)-wKvMrY$mGfA%|Ka~a`7aoFgvUg-EJ*P)VQsp3cNSa6BK4H_l*~=LVZIS< z(|>}$18^*SpO* zvoq0bh;2}%&`GyTZc^60IhU8-&<_%HdMsx*8zpgHs=r|0_Wv@iDvRSF@bn=8eYBzv zghq{aX_^_$yT`YnzxT{B8kHFo&`+b`JJ7tBc2VrZemYUX-x2YWwmu`izD57fL}D-= z`-tHV4y{cjj>V5|uaC!vg7pWS{EXCkVqyzZ6CIrE;8F+II+!H`?e9>I4(8v{MlBwG z#mHheBugQa9X#><71{_C+Hr4;LMMzvgwiC8lNi7~B#^~0RxyeK4xouKkCEx4##20_ qXdM=ESRqaY`oC6@CyCbRT=Dj8&uO*pd9oj9YV>LuUeLY|FMk2~XK|PS literal 0 HcmV?d00001 diff --git a/basic_idea_of_DS/MyHashSet.class b/basic_idea_of_DS/MyHashSet.class new file mode 100644 index 0000000000000000000000000000000000000000..4272e4f69572e8b8edefd3c8146bc2db82b0be58 GIT binary patch literal 859 zcmZ`%+iuf95IyT8wUe4Q7h<5aKue)X4K=hN9#U1}R(J>$$tVbTh&IWRY~@R2J4pEu zJ_H_G2_!y%k3!7G0TNMO=DIU;=Is3V`Sm-12e_|8V_50%Sa#d8CwM#j(0<}NFUHS# zJa9##Bg;@c<{!D^@u2SJi$^_GqjLury2 zCDL=I$O|YUZ{R$YKN1O7u4Uo^E)r(m>oHVoGu_g?8ufPuRv2;*z2SfxSf%1;+$ZY_ zgYk6e$ykPgfot^S$QON{#|AcaT%Y5}9mk3AP29juniYBSKJ*BI%%as#U-`M3#sk)r1wNzbI>I>HG6Kttb z8K_YkFi7S}E>dF?7L8e>A)DmcC}9_s2@ES8h1=Mn_Xg!0+#w)$$x{&1$Szq7dlb`f F?-v9Pyi@=H literal 0 HcmV?d00001 diff --git a/basic_idea_of_DS/MyLinkedList.class b/basic_idea_of_DS/MyLinkedList.class new file mode 100644 index 0000000000000000000000000000000000000000..066f04976bc6ee6c80a8aa7d046c07b647fb6b19 GIT binary patch literal 1820 zcma)6ZBrXn7(F+(FG4UmP5WSu0Bau~l@WKr-i*ET>@kw%T_O2ZMdPAuyHu&mgjVpk~>wKx$?; zcN$DS@NKu6oh@h>6S&whGy~hooW>tV0wX#u3Wyc;pE7U>ml?KIE(=V|^q_^*va?Tg zT;=r*9dB^i)N!3lUWX|V%g-y2Hx0ann*usP)@;8)J^CUQbWAI!d&+6Xz^ro8=#;Y> zfsQn7D;>Z)DyqAR-g=*a3L|(2_cY8$GLb)Q1hQt}UA#v+UQ-1TI@@065r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i2JXdBaj)1+f2Gn9u^v6ZsLmW(WS zCOpAs6khm%yp)Mk1{gkok79aOQk{gFK1g@9d-vRP&b|8Q-#`8au#7DoF@fT)HIVHc z*|Du1cW>u*tA1~24{aTqz}ZLEW2@e^oQL(z-A8uY7f9@RuEQwS1vJmLJcfb%!4{Zm zTYal7{e31`o@X(}zF}5!RXWoDgn5NdkIw_~Rf$5{gg&I!aT)$J4n&KpP}sa6F8 zQ{igHKq6edWDWdmts1hP%(*msA$UEBN0+U=4;uIaX|?zZJg^&M?${&=_{R0_Dp8B~|ZJ)%VI6f$5fSwZGf2`cVO04%T{orCYb1ASX=??--cF#T2So z&|#kPvb8_(?Vf=vSfqM)NIMJ7z-sB%w>;_iEuYr*R&>+_W{#V{ZRtF`Ih5Uw?WOT9 z-q-QoY3Lxsz*Sr$oyS&pXm9Qjp4NvIf@X#|D{0iQteWtl%6R#_x;=%D1fB;Qc87evlw5ILzq&1cA(kG8NWY5euSb~);c4U zO!E-AztSVjK4oGIuk$?{K&E&(%^x9y^Msrw=sZE+;CV3w#Ra^{FT$(eg(aZ|Eh^n) zjw+p9I7FUL?pGwVgZKfr;z5z{Lhb}$b_|%sB|;0l6=aKP2Kp5t-(gh98HN1wMAVrR zsF^Wp<}_-G7?;OZ{SsN#FwG;p{RG-mb0iOzA&Gr=5RWzB1>xg69n!i!OzNNhO7FT}nAy;S=z U`YO?{6aB`k&;{<2Z48^w0h$ULFaQ7m literal 0 HcmV?d00001 diff --git a/basic_idea_of_DS/SetExample.class b/basic_idea_of_DS/SetExample.class new file mode 100644 index 0000000000000000000000000000000000000000..e1fe2b03f0cfef1abf762f61eb3dbb95d5d75775 GIT binary patch literal 1553 zcmaJ>&u<$=6#m9ud+qI(Y?3zA4Q*X$A#ReILZMKnfsph^z)mU|i~B4#F;BcKzuW6J8@O@GH+(*ecyZYz4!Ll|9*M`;0ErSND0g~ z-JaLl_S(|j4m;ax^>SUtx4&__d%iSb2sjVieYfnp!A^Oz`9QW}f$WkOc=578dal$E zFjm91w2(&LMh01diK-XKjefT&qfgzYF9oKmVaxR!Zse)+;G+@mdOd-2)fc2tA$`~N z0)d&iFRMqX)Z@qtb}FTYiAjM;ebJ9SzkJW_?eYZ{9OO-$8s6#r*MnH@$jHJpW^BBS zGXmzm>-XhmNAa(hjs+O_RxF&wD<)=#Lg*kXQRE)a&0mi(#i2@5*BQ zby(EOUc=ia-V&JB`Hur_T*o^CnLWit^1&mL;KQ0(xP}`x-oyJWfcErR;4$B!dJQF4 z#m17-CLhU|y+C<#VE4_c8b!TCmuIq6un%pl3}D@GUuxJYC0p}49T~}>C7%JY*W74_ zEjj(1Rud4eYVEP2u{}kT&+RLr1Z+Nfl#zhd9z|k*jgP>=-f#>qjZ-cq$KwrKS!Nuo z9`>V_yyK~Pnm8KLt12N}1nbGM22$K{3b~p*m1zZS=E@;*Kj>?VtGZU}39feHKzov> zJYK>CzYr|`&_ocKpW$pBa){?0^A}8SrH#ipUEeaY+GH}?WKC^MC#P-B$!qIm)5<lUyz2DBmZPtxn;- z__41Plazw;OJC;t_H;XMAv1^k1eFjz4q{xXX|fw6|$Jmv5& z+3!;RIv(O4cPX-dg>~-I} literal 0 HcmV?d00001 diff --git a/basic_idea_of_DS/Stack$MyStack.class b/basic_idea_of_DS/Stack$MyStack.class new file mode 100644 index 0000000000000000000000000000000000000000..6c05e27007b9c397789d018a61398dce22658faf GIT binary patch literal 1110 zcmZ`&e@_!Z5Pe%}uRRZ23k3wN6{}vMP!R-d5fu<=Qhp>gHRvB?+b(c;y=(5SBzy8h6(+;piG4! zxNg@)1PnJd+(1ah00uQExWzD_%YbOfu*6QQQ5DX6UNr?nykyt7S>cW$&)v(Qq{NWA z2J2r%L@e0ghQ%hH*?#s%FbQCZiWKA0xPj z`wEgh4J)6yo@i)D;Q`fSx2SiC4ys}2_6X7=V8I&&1rHfU|L3#TGR(SgB;+FvkMV?( zH0`F}nxcvfrWH)}0{V4m$YO>;Ipt>d&*F}zx>ib>>Tvq{N>e$}6;g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tDOk}|W_ z$7>&0m_U-ebvv*HL{SAlv~WSys=IWX!RK5Ca+kImj(>Nz8SI5d{Xkd3&Xn!u|7AC& zx+1oY(StSna}IiO=Y&f)%ieo+n$2uI>AhbE~U&A<$oueo&Tb*nOnfP>s)2 z@WZFTZ}s8xV5E<$Idp|*X7*Q@S#b#KC8J#!;P*gya}+uf%pJoZV^)-nA)Muo?+7C? z(hjo~Q}Q>At`jX$&P^O*JeNIyb%@Dq?ihB0YJf@NrpR-N3?Fl*r$dfZgcEZRkvYkb zWds+gUn%B<#=P_VRn_$?qBrQ)_qBa)wXlSq@F>?Iy+4M%9Oel1FEK^#$c;y_8{^p{ zO#c)?9$NBFesJ@PPZ0j|-?>qMWWJvTa7#*ecM5`Xrc=NmCgGE!_Q^czRG z`7)~l2bheVib{x_x=o@xBv>HuGM&2DL6$sDHbk2?Xvl K@_>6??f(NsTtnpm literal 0 HcmV?d00001 diff --git a/basic_idea_of_DS/Tree.class b/basic_idea_of_DS/Tree.class new file mode 100644 index 0000000000000000000000000000000000000000..966264dc4bcb5cc2fcf520239202dd18839c3fb5 GIT binary patch literal 808 zcmZuu-AWrl7(J70vhKR-rfRgBn*OGVg6YpiFO=R?3PNfxA`9Y0n8Y!Tjk~aJ3WfSm zg_J;rK0xpKLZxRmTOu?UJG0-JbIy0>n_qu^`~>g@&u!!cR=e_A_d5Da$xd|MIcPVJ zW2J0Z0{*4^ESm!v_M0EOm#UWtSaB3_TWkHNI*QKJoZ^f!H;+3YAW8Fh{L}Ru#n?k z+8)E*zQw}H<`_%gQTj$Ohh?sdsbq!3Rrn}lg;;qaB2s2WIo7bAHsSO$>wR)eTQ{{9 zGd$Pnd7m*hQct5JJM(mSvXMFc&O+YYLY$1T+1fEdtx3?G5lW^kq-Et_Sxn2SDMzRn zf;}aSP<hT~3Pl6Itq#$^40~Ivq$Yom_=8++y%&c!C;UVHXEzBESo1yu??$zB8yB TJSGcN4DpmB{wG@~#d?@|UgmlE&GY>H{p~w|hv+)U39OH0swZiGJB~~e&q5=O znybj94hjO*efd`QXEK`hpO5#|#0acx>PVX{fqbVs5-4oPua$>9N);5bBCs~pk$Se6 zk5%$gj%P}sHjF27Hj;_9_OY{I_H-)H9R9EWfVJmRM*@E5)$oKPG>ML;gYKw=^Qb$h zouUlirR1;R0vaTY7X)r($vW=uGSe_$$@##=MS*gl1Dyu%RTB3+Ttdr1Q=qwLNz*PF}b)V;AK_gNcCK_8JgKs_BARA%$|&bjUK-zlPO0~KjU`-Li6kh zta2lhH&5lk@!Y&HUL+IsSlh|^|7@*i+0h0+&m{vnYFrC%hgP3bP!{igh5LE=?D4kG zU_zO9B@3WjrB%W?tkGkWf3R4NGR$ut;z{chRSbBtT%bw)7SH`JsMh==tRJFn)vHU@ zKk=5W8qoVeh*q`q@z0S($-|=bmJlwP%Ls_jA;3LUvB70OKpk7$>?8Qtfr}SxX_5U5 g3)gXjRt~$kNf3eCv?_3Zp(vW3=Q(y3ca{;Izo~bhvH$=8 literal 0 HcmV?d00001 diff --git a/basics/ControlStatements.java b/basics/ControlStatements.java deleted file mode 100644 index 2962c5f..0000000 --- a/basics/ControlStatements.java +++ /dev/null @@ -1,31 +0,0 @@ -package basics; -// public class to implement or for run the code -public class ControlStatements { - - public static void main(String[] args) { - // for loop to implement switch case statement - for(int i =0;i<9;i++){ - // switch controle statement - switch(i) { - // case1 - case 1: - System.out.println(" i is zero."); - break; //break statement - //case2 - case 2: - System.out.println(" i is one."); - break; - //case3 - case 3: - System.out.println(" i is zero."); - break; - default: //default statement - System.out.println(" i is greater than 3."); - - } - - } - } -} - - diff --git a/basics/DoWhileLoop.class b/basics/DoWhileLoop.class new file mode 100644 index 0000000000000000000000000000000000000000..02e98f6ce84b8c0dc3da2495a3c57a303d638f71 GIT binary patch literal 764 zcmZva-)<5?6vn>++6CNNgqGSuEBJS*+SMyBXuMEk(gd{$24lP$mI({P}Q$f96l3CjYj9UZ8b>8P*b z*Rt;`!aJcS{ho}qiRXv8drxHA$g8(8^v`SH*ixRpMRE z!$!*(vm(=)&tc_cJmf?x7mQ3mFhLv$taKCUoxG6I{27YfFpWL+oR7|F{`35MrX-r+ zEcu@R8GiA7xmt`|?t=T$?kV!0r`JWU<{A`S;%d(lxUVoO;4)TuV#FzO!~xAxasLZS z-%x#9zIuwS+63DZG$*+AQJmF2o&7Z6EDU&yXi#j>n?%+L-R4b$SW~Pz17a60);// do while loop's while block - } // end of main method -}// end of class diff --git a/basics/Fast_Inputs_Main$InputReader.class b/basics/Fast_Inputs_Main$InputReader.class new file mode 100644 index 0000000000000000000000000000000000000000..19898f3561a037c51fceb61d87d6800ecea94d16 GIT binary patch literal 1366 zcma)6TTc@~6#j~59#I z@Zy6eLX9N)=7X<3`&Yy>yM;EUCXz5`X3m-KJLfxR`{VbQuK=d8E}?;;KdV|=&WbOo zmc5x?!3gzlyBAQ|F zE*N<(!-IeVKdv))BGHV57KV=c8Au2+gfD$HaBhM!TG1|`WDoETGMdpTj$I7x)hsH- zB%>KW7`hc)gHP;kD3H*|(45kAzE(QSax<-F3!EXCGIDAmqnesHS1!Hwo@Ox&rv5{6 zp@-$v%@C?92Z^EcBkDqXBWF-NVt1hcRjg9p%Dd93@|j3x_ME7j6n>E>W7K5 zQhhC^P8_zIc@5MO!m;86&ta5XP!qbP&>ertwBdL0uFy6AC6V#Sqw2 ztyRP1&K!_7)XrDJKdoR!8QQKIxqijTz)0{KjjApZF|cW?xr0@;Sm}Wz z0Fye&MpQ|en)pmXKL%thU{S(zhSq9%6vubDsbC2&NT;G|THJYCSDhq-ylIro9ADDJ z421svq(%iYgOb#BZY~s5%i@-V6hr4f27;lf<}0KO*0^Oa8N{}T^&_`T@Td_|FpW$8^G2%EuAa#xr zK_34`o}TX)zl1r%`0>S0clY1}L3t2D7iP(dgu0#T#^^Lb_mh;=6cLZnX{IKzL?y8> z)t`WR0tX^xX+!W%oo)6bZHPkXm`pL0Lw;3{rR1=oXRCn|}T QWQDp6D_A9lHRpci57x9dk^lez literal 0 HcmV?d00001 diff --git a/basics/Fast_Inputs_Main.class b/basics/Fast_Inputs_Main.class new file mode 100644 index 0000000000000000000000000000000000000000..4e07fc5406f529e05a70c0896de8ecb85472cffd GIT binary patch literal 1066 zcmZ`&-A)=o7(D|EtAN#l3;1uVwxCw}i)}Hc35^K}*hU(XrWab{fprV@yk+YQ;Q$*!&A%SFTcXuARvQ$dr8VWp|$*Ca&>EAZqKo?Bfe8-Q@FNvGiOJU6j}kDOfs07dG3G zz)01Tjl+uU_!nqm*+hOo?tr@jk!riwZKy31oNR_KKuR70Y%>4*#H0l literal 0 HcmV?d00001 diff --git a/basics/Operators.class b/basics/Operators.class new file mode 100644 index 0000000000000000000000000000000000000000..fd4d42b00e510ecfd46b8e4200e682c1fe8263e0 GIT binary patch literal 1078 zcmZuwTTc@~7(G+AyKPyaaw+OA2#VOEP_IQT7X_n%pcpYVMjo7&wO!bDo9&jwR}z1a zJ`|&gKfoVlJkuh#^6<@`nfbmmXU=^4=kL$o0Os)AKtv!}lnuAk$Zph~K!$$MFraaD zNAAh2Cu`;GMsdd}g#!A#TXVxjfu3}xAfT=I+fD*Kh?|H)7wBJiYtHLtwde%zWYKd3 z2G;$O^a?U?)%hvYIzAA~156cDd<#+fI5OR~g;=nL-TL1jM*XoHTI*Q?yjp>rQQ3VCKAvE|NpBc}0;{ z6d3{gJT)g1Z>hxFDsin__Q}Lq6It95h=qQ~a)F_AcL`6whX)4k3kEXs@uV@)8j={JLt^TJha)pyjYvq}Ia zz?Wx70}&$jB1eO>EWd)^==1?%-`d*=j%ph$=;dg368OEqSsZ=n=L(BO6dF|aZqk@f z>I;@#S+wj=InA=YT-37bIo-1NbB1m0f1QhcNAed^A4Y%R(gDT>CR(^YthI2ngQ7=B zKSIWTl!~=5-NH-@caJ4bQHm0(Q%V9cii)$rRg?B&jAAD#cZaL$3R~^mUF7&jt7}#8 z2#LY5 literal 0 HcmV?d00001 diff --git a/basics/Operators.java b/basics/Operators.java deleted file mode 100644 index 1d06969..0000000 --- a/basics/Operators.java +++ /dev/null @@ -1,17 +0,0 @@ -package basics; - -public class Operators { - - public static void main(String[] args) { - int a = 7,b= 6; - int c = a*b; //* (multiplication) operator - int d = a+b; // + addition operator - int e = a/b; // - substration operator - int f = a%b; // % modulus operator - int g = a^b; // ^ power operator - long h = b^a; - System.out.println(c + " " + d + " " + e + " " + f + " " + g + " " + h); - - } - -} diff --git a/basics/Treedatastructure.java b/basics/Treedatastructure.java deleted file mode 100644 index cbdbe60..0000000 --- a/basics/Treedatastructure.java +++ /dev/null @@ -1,65 +0,0 @@ -package basics; - -// a node class -class Node{ - int key ; - Node left,right; - public Node(int item) { - key = item; - left = right = null; - } -} - -class Treedatastructure{ - // Root of Binary Tree - Node root; - - // Constructors - Treedatastructure(int key) - { - root = new Node(key); - } - - Treedatastructure() - { - root = null; - } - - public static void main(String[] args) - { - Treedatastructure tree = new Treedatastructure(); - - /*create root*/ - tree.root = new Node(1); - - /* following is the tree after above statement - - 1 - / \ - null null */ - - tree.root.left = new Node(2); - tree.root.right = new Node(3); - - /* 2 and 3 become left and right children of 1 - 1 - / \ - 2 3 - / \ / \ - null null null null */ - - - tree.root.left.left = new Node(4); - /* 4 becomes left child of 2 - 1 - / \ - 2 3 - / \ / \ - 4 null null null - / \ - null null - */ - - }} - - diff --git a/basics/VariablesandDataTypes.class b/basics/VariablesandDataTypes.class new file mode 100644 index 0000000000000000000000000000000000000000..007871dc66c4f874e85847b6cb5214d7018a38a8 GIT binary patch literal 1034 zcmaJ<>rN9v7(LSq+m;ou6p)JuURwkz3ZfK23L$}1F)3+c{59>4Wl6i+>~2YTARj<~ z6r+g`;6oYDED$UuZZb39&UfaV@Amu8k6!>*v11@2FjbYlUGwu5>DjW{P`-4m9T~{O z)0XlL!~}+p<%!HUq*KoyRF73H5a?UC9Xr?%h-PyYf!MZdsT86}nuw!MV6bF6>V3Oe zRoV;e-f!l;^HKh}0 zUi>EA1V#kfb?IW;Zdl4o;T~oU%yd(S!I`*^2Li^4Y_!$EXVPc)a=j^}Foj3Da*s8l*RNB| z3WymEoHOwh^K5}^wUlECEZp>>hvXvIf~Hv16nVBjyWbnlzrZCE&+$Sa5xD2o7RY3K zpOAC~s|H>Q42MPPE}w~4Iy0lCE81WmW74a$?ZY>8lYNkNj*HkM%#qD-a;_Ji6Vc~{ z!$sgenWbfU$|q&2?6$p{+O_q_ORD00w!ZAAdoNNMLg)y`CO=mqEIi&aB11Ve}`aK2Cne^cfze zpLCF$=L(J44i-XVJkF~Qo^`N%B|8z)85B;?N-~rb<@&KfX&uTkBc~i*V~uAN>nL!s bI=p#9ln#D{{2uI)d%LFiYs@ literal 0 HcmV?d00001 diff --git a/basics/VariablesandDataTypes.java b/basics/VariablesandDataTypes.java deleted file mode 100644 index 111d443..0000000 --- a/basics/VariablesandDataTypes.java +++ /dev/null @@ -1,15 +0,0 @@ -package basics; - -public class VariablesandDataTypes { - - public static void main(String[] args) { - - int age = 18; // integer data type - String name = "Aman"; // String data type - long number = 7023; // long data type - String address ="Behind Fort"; - System.out.println(age + " " + name + " " + number + " " + address); - - } - -} diff --git a/basics/WhileLoop.class b/basics/WhileLoop.class new file mode 100644 index 0000000000000000000000000000000000000000..753a253b84079e53f0200f56d01c0d7308269c1b GIT binary patch literal 761 zcmZuv%Wl&^6g@X_YA3i4k~S?(C~3>XDNw_TMJg5`Ayo3iIECM{_8^(%61$l zHZ1lYiFd*eMKthV_Kswr33GcYQu;9=?=`yw>uKDVCFD_bQNSEwv8^KcVm$20^g#4N zNhr7DK!jb9Dr3)_mOfM?6FXnG#hgQ-B0|-B+x}m_qf-?PTFq_|S5dK1KBKPlVWj2I z#WGe{Sv+Q;D;ZeD{wqdm#!E45*;pm4o~L~>R$*VJ4z6*74XuLXMhR8aOiy*D@-7o% zGB#Y?K!ZUdNo3R~)V=-Yh2$B1%OJK~Y~v=u(Q(!iVcEL~;oRHsY}_GKrfSdj;i74T z*@FWmyC=+oIv}8`HmLB@pF;PmQd=%<1~=Zc;$qJf2-d$1+fX9B>xZ~ z$1mP3pEg@Q-^6!e=LF7|X}H9v34;Mw_;j-bzUSF0VgZZnG2r*Gm=4%>_CBNj6-(by zeN$dL!Fp|i>l18FaO)$T);^v7GSqn(>UAau!*g(0M-eqHvcc~yrZ?rP86|dbm#rKt VzlZx=a5qE!MuFDY^ryiGe*t-Pqv!wt literal 0 HcmV?d00001 diff --git a/basics/WhileLoop.java b/basics/WhileLoop.java deleted file mode 100644 index 6c0195a..0000000 --- a/basics/WhileLoop.java +++ /dev/null @@ -1,16 +0,0 @@ -package basics; - -public class WhileLoop { - - public static void main(String[] args) { - - int n = 5; - // while loop block - while(n>0) { - System.out.println(" tick " + n); - n--; // post substraction operator - } - - } - - } diff --git a/bit_manupulation/Bitmain.class b/bit_manupulation/Bitmain.class new file mode 100644 index 0000000000000000000000000000000000000000..113b5a78909e8080342fb6704d06b5bb6b68910b GIT binary patch literal 672 zcmZ`$O;6iE5PcKdabg_8M+p#G3N39N4)u{k5C@PdSxRZ8R2=A`+JsfQ)E|*qSM7!W z(f`1uJ(Q}4{($}{#H>zMaA*>9P{*Z{Y7#Fe7DoewC zr4yl27dBz;RD2d;EYeZUN?!ma*z$<<6!0U(d8me6+E~s#(FkmL_DCg>RXunJ-1s z^+0&!V-`&hkFn`ugRoe3xeN611WyU>*l=TZV+Y6Om_$Be%Zv9|BY6F+$cOTkGSl*> z^M7g7vB`ZcelBq2IiSkX adq = new ArrayDeque(); - - adq.push("A"); - adq.push("B"); - adq.push("C"); - adq.push("D"); - adq.push("E"); - - System.out.print("Popping the stack:"); - - while(adq.peek()!=null) - System.out.print(adq.pop()+" "); - - System.out.println(); - - } - -} diff --git a/dataStructure/ArrayListDemo.java b/dataStructure/ArrayListDemo.java deleted file mode 100644 index f0aae7e..0000000 --- a/dataStructure/ArrayListDemo.java +++ /dev/null @@ -1,33 +0,0 @@ -package dataStructure; -import java.util.ArrayList; - -public class ArrayListDemo { - - public static void main(String[] args) { - - //Create an array list - ArrayList al = new ArrayList(); - System.out.println("Initial size of al:" + al.size()); - - //Add elements to array list - al.add("A"); - al.add("M"); - al.add("A"); - al.add("N"); - al.add("S"); - al.add("s1"); - System.out.println("Size of al after additions:" + al.size()); - - //Display the array list - System.out.println("Contents of al:" + al); - - //Remove elements from the array - al.remove("s1"); - - System.out.println("Size of al after deletions:"+ al.size()); - System.out.println("Contents of al:" + al); - - - } - -} diff --git a/dataStructure/HashMapIntro.java b/dataStructure/HashMapIntro.java deleted file mode 100644 index bebd6c3..0000000 --- a/dataStructure/HashMapIntro.java +++ /dev/null @@ -1,28 +0,0 @@ -package dataStructure; -import java.util.HashMap; -public class HashMapIntro -{ - - public static void main(String[] args) - { - // Create an empty hash map - HashMap map = new HashMap<>(); - - // Add elements to the map - map.put("vishal", 10); - map.put("sachin", 30); - map.put("vaibhav", 20); - - // Print size and content - System.out.println("Size of map is:- " + map.size()); - System.out.println(map); - - // Check if a key is present and if present, print value - if ( map.containsKey("vishal")) - { - Integer a = map.get("vishal"); - System.out.println("value for key vishal is:- "+ a); - } - } - -} diff --git a/dataStructure/LinkedListDemo.java b/dataStructure/LinkedListDemo.java deleted file mode 100644 index 994ff70..0000000 --- a/dataStructure/LinkedListDemo.java +++ /dev/null @@ -1,35 +0,0 @@ -package dataStructure; -import java.util.LinkedList; -public class LinkedListDemo { - - public static void main(String[] args) { - // Create a linked list - LinkedList ll = new LinkedList<>(); - - // Add elements to the linked list - ll.add("A"); - ll.add("M"); - ll.add("M"); - ll.add("N"); - ll.add("S"); - ll.addFirst("S1"); - ll.addLast("S2"); - ll.add(1,"A1"); - System.out.println("Original contents of ll:"+ll); - - //Remove elements from the linked list - ll.remove("A1"); - System.out.println("Content of ll after deletion:"+ll); - - //Remove first & last elements - ll.removeFirst(); - ll.removeLast(); - System.out.println("ll after deleting first & last:" + ll); - - //Get & set value - String val = ll.get(2); - ll.set(2, val + "Changed"); - System.out.println("ll after change:"+ll); - } - -} diff --git a/dataStructure/List.java b/dataStructure/List.java deleted file mode 100644 index 75308b2..0000000 --- a/dataStructure/List.java +++ /dev/null @@ -1,14 +0,0 @@ -package dataStructure; - -import java.util.LinkedList; -public class List{ - public static void main(String[] args) { - - LinkedList ll = new LinkedList<>(); - - ll.add("Aman"); - ll.add("Soni"); - ll.add(1, "Kumar"); - System.out.println(ll); - } -} diff --git a/dataStructure/MYStackByList.java b/dataStructure/MYStackByList.java deleted file mode 100644 index 01fea0f..0000000 --- a/dataStructure/MYStackByList.java +++ /dev/null @@ -1,121 +0,0 @@ -package dataStructure; - -//Java program to Implement a stack -//using singly linked list -//import package -import static java.lang.System.exit; - -//Create Stack Using Linked list -class StackUsingLinkedlist { - - // A linked list node - private class Node { - - int data; // integer data - Node link; // reference variable Node type - } - // create global top reference variable global - Node top; - // Constructor - StackUsingLinkedlist() - { - this.top = null; - } - - // Utility function to add an element x in the stack - public void push(int x) // insert at the beginning - { - // create new node temp and allocate memory - Node temp = new Node(); - - // initialize data into data field - temp.data = x; - - // put top reference into link - temp.link = top; - - // update top reference - top = temp; - } - - // Utility function to check if the stack is empty or not - public boolean isEmpty() - { - return top == null; - } - - // Utility function to return top element in a stack - public int peek() - { - // check for empty stack - if (!isEmpty()) { - return top.data; - } - else { - System.out.println("Stack is empty"); - return -1; - } - } - - // Utility function to pop top element from the stack - public void pop() // remove at the beginning - { - // check for stack underflow - if (top == null) { - System.out.print("\nStack Underflow"); - return; - } - - // update the top pointer to point to the next node - top = (top).link; - } - - public void display() - { - // check for stack underflow - if (top == null) { - System.out.printf("\nStack Underflow"); - exit(1); - } - else { - Node temp = top; - while (temp != null) { - - // print node data - System.out.printf("%d->", temp.data); - - // assign temp link to temp - temp = temp.link; - } - } - } -} -//main class -public class MYStackByList { - public static void main(String[] args) - { - // create Object of Implementing class - StackUsingLinkedlist obj = new StackUsingLinkedlist(); - // insert Stack value - obj.push(11); - obj.push(22); - obj.push(33); - obj.push(44); - - // print Stack elements - obj.display(); - - // print Top element of Stack - System.out.printf("\nTop element is %d\n", obj.peek()); - - // Delete top element of Stack - obj.pop(); - obj.pop(); - - // print Stack elements - obj.display(); - - // print Top element of Stack - System.out.printf("\nTop element is %d\n", obj.peek()); - } -} diff --git a/dataStructure/MyArrayList.java b/dataStructure/MyArrayList.java deleted file mode 100644 index eaad496..0000000 --- a/dataStructure/MyArrayList.java +++ /dev/null @@ -1,33 +0,0 @@ -package dataStructure; -import java.util.ArrayList; - -public class MyArrayList { - - public static void main(String[] args) { - - //Create an array list - ArrayList al = new ArrayList(); - System.out.println("Initial size of al:" + al.size()); - - //Add elements to array list - al.add("A"); - al.add("M"); - al.add("A"); - al.add("N"); - al.add("S"); - al.add("s1"); - System.out.println("Size of al after additions:" + al.size()); - - //Display the array list - System.out.println("Contents of al:" + al); - - //Remove elements from the array - al.remove("s1"); - - System.out.println("Size of al after deletions:"+ al.size()); - System.out.println("Contents of al:" + al); - - - } - -} diff --git a/dataStructure/MyHashMap.java b/dataStructure/MyHashMap.java deleted file mode 100644 index 3d7cc2f..0000000 --- a/dataStructure/MyHashMap.java +++ /dev/null @@ -1,28 +0,0 @@ -package dataStructure; -import java.util.HashMap; -public class MyHashMap -{ - - public static void main(String[] args) - { - // Create an empty hash map - HashMap map = new HashMap<>(); - - // Add elements to the map - map.put("vishal", 10); - map.put("sachin", 30); - map.put("vaibhav", 20); - - // Print size and content - System.out.println("Size of map is:- " + map.size()); - System.out.println(map); - - // Check if a key is present and if present, print value - if ( map.containsKey("vishal")) - { - Integer a = map.get("vishal"); - System.out.println("value for key vishal is:- "+ a); - } - } - -} diff --git a/dataStructure/MyHashSet.java b/dataStructure/MyHashSet.java deleted file mode 100644 index 7537ba5..0000000 --- a/dataStructure/MyHashSet.java +++ /dev/null @@ -1,21 +0,0 @@ -package dataStructure; - -import java.util.HashSet; - -public class MyHashSet { - - public static void main(String[] args) { - - HashSet hs = new HashSet<>(); - - hs.add("Beta"); - hs.add("Alpha"); - hs.add("Gama"); - hs.add("Eplision"); - hs.add("Omega"); - - System.out.println(hs); - - } - -} diff --git a/dataStructure/MyLinkedList.java b/dataStructure/MyLinkedList.java deleted file mode 100644 index 977d3e9..0000000 --- a/dataStructure/MyLinkedList.java +++ /dev/null @@ -1,35 +0,0 @@ -package dataStructure; -import java.util.LinkedList; -public class MyLinkedList { - - public static void main(String[] args) { - // Create a linked list - LinkedList ll = new LinkedList<>(); - - // Add elements to the linked list - ll.add("A"); - ll.add("M"); - ll.add("M"); - ll.add("N"); - ll.add("S"); - ll.addFirst("S1"); - ll.addLast("S2"); - ll.add(1,"A1"); - System.out.println("Original contents of ll:"+ll); - - //Remove elements from the linked list - ll.remove("A1"); - System.out.println("Content of ll after deletion:"+ll); - - //Remove first & last elements - ll.removeFirst(); - ll.removeLast(); - System.out.println("ll after deleting first & last:" + ll); - - //Get & set value - String val = ll.get(2); - ll.set(2, val + "Changed"); - System.out.println("ll after change:"+ll); - } - -} diff --git a/dataStructure/MyQueue.java b/dataStructure/MyQueue.java deleted file mode 100644 index 0cb291e..0000000 --- a/dataStructure/MyQueue.java +++ /dev/null @@ -1,82 +0,0 @@ -//Java program for array implementation of queue -package dataStructure; -//A class to represent a queue -class Queue{ - int front, rear, size; - int capacity; - int array[]; - - public Queue(int capacity) { - this.capacity = capacity; - front = this.size = 0; - rear = capacity - 1; - array = new int[this.capacity]; - } - - //Queue is full when size becomes equal to capacity - boolean isFull(Queue queue) { - return(queue.size == queue.capacity); - } - - //Queue is Empty when size is 0 - boolean isEmpty(Queue queue){ - return(queue.size == 0); - } - - //Method to add an item to the queue - //It changes rear and size - void enqueue(int item) { - if(isFull(this)) - return; - this.rear = (this.rear+1)%this.capacity; - this.array[this.rear] = item; - this.size = this.size+1; - System.out.println(item + " enqueud to queue"); - } - - //Method to remove an item from queue - //It changes front and size - int dequeue() { - if(isEmpty(this)) - return Integer.MIN_VALUE; - - int item = this.array[this.front]; - this.front = (this.front + 1) % this.capacity; - this.size = this.size-1; - return item; - - } - - //Method to get front of queue - int front() { - if(isEmpty(this)) - return Integer.MIN_VALUE; - - return this.array[this.front]; - } - - //Method to get rear of queue - int rear() { - if(isEmpty(this)) - return Integer.MIN_VALUE; - - return this.array[this.rear]; - } -} - -//Driver Class -public class MyQueue{ - public static void main(String[] args){ - - Queue queue = new Queue(1000); - - queue.enqueue(10); - queue.enqueue(20); - queue.enqueue(30); - queue.enqueue(40); - - System.out.println(queue.dequeue()+(" dequeued from queue")); - System.out.println("Front item is " + queue.front()); - System.out.println("Rear item is "+ queue.rear()); - } -} diff --git a/dataStructure/MyStack.java b/dataStructure/MyStack.java deleted file mode 100644 index 0c45b42..0000000 --- a/dataStructure/MyStack.java +++ /dev/null @@ -1,58 +0,0 @@ -package dataStructure; - - class Stack { - static final int MAX = 1000; - int top; - int a[] = new int[MAX]; - - boolean isEmpty() { - return (top<0); - } - - Stack(){ - top = -1; - } - - boolean push(int x) { - if(top>= (MAX-1)) { - System.out.println(x+"pushed into stack"); - return false; - } - else { - a[++top] = x; - System.out.println(x+"pushed into stack"); - return true; - } - } - - int pop() { - if(top<0) { - System.out.println("Stack underflow"); - return 0; - } - else { - int x = a[top--]; - return x; - } - } - - int peek() { - if(top<0) { - System.out.println("Stack underflow"); - return 0; - } - else { - int x = a[top]; return x; - } - } - - class MyStack{ - public void main (String[] args) { - Stack s = new Stack(); - s.push(10); - s.push(20); - s.push(30); - System.out.println(s.pop() + " Popped from stack"); - } - } -} diff --git a/dataStructure/SetExample.java b/dataStructure/SetExample.java deleted file mode 100644 index ad4bb39..0000000 --- a/dataStructure/SetExample.java +++ /dev/null @@ -1,34 +0,0 @@ -package dataStructure; -// Java program to demonstrate the -// union, intersection and difference -// operations on sets -import java.util.*; -public class SetExample -{ - public static void main(String args[]) - { - Set a = new HashSet(); - a.addAll(Arrays.asList(new Integer[] {1, 3, 2, 4, 8, 9, 0})); - Set b = new HashSet(); - b.addAll(Arrays.asList(new Integer[] {1, 3, 7, 5, 4, 0, 7, 5})); - - // To find union - Set union = new HashSet(a); - union.addAll(b); - System.out.print("Union of the two Set"); - System.out.println(union); - - // To find intersection - Set intersection = new HashSet(a); - - intersection.retainAll(b); - System.out.print("Intersection of the two Set"); - System.out.println(intersection); - - // To find the symmetric difference - Set difference = new HashSet(a); - difference.removeAll(b); - System.out.print("Difference of the two Set"); - System.out.println(difference); - } -} diff --git a/dataStructure/Tree.java b/dataStructure/Tree.java deleted file mode 100644 index 8581c0a..0000000 --- a/dataStructure/Tree.java +++ /dev/null @@ -1,52 +0,0 @@ -package dataStructure; - -//class containing left & right child of current node & key value -class Node{ - int key; - Node left,right; - public Node(int item) { - key = item; - left = right = null; - } -} - -// A java program to introduce Binary Tree -public class Tree { - - //Root node of binary tree - Node root; - - //Constructors - Tree(int key){ - root = new Node(key); - } - - Tree(){ - root = null; - } - public static void main(String[] args) { - Tree t = new Tree(); - //create root - t.root = new Node(1); - - /* following is the tree after above statement - 1 - / \ - null null*/ - - t.root.left = new Node(2); - t.root.right = new Node(3); - /* 2 & 3 become left & right children of 1 - * 1 - * / \ - * 2 3 - * / \ | \ - * null null null null - */ - t.root.left.left = new Node(4); - t.root.right.right = new Node(5); - t.root.right.left = new Node(6); - t.root.left.right = new Node(7); - - } -} diff --git a/dataStructures/Info.class b/dataStructures/Info.class new file mode 100644 index 0000000000000000000000000000000000000000..b14e8240eff4fe42874bdcfda5156886c1ce7259 GIT binary patch literal 385 zcmZutO-sW-5Pj38O%totM!kEh3g+mc;zbaIpodB?o+jxUx1<}`Zv0=K1P}fIf0Q^I z1x0$;H=l3j&3=5oy#qMMeuxesS+L`ovrXX|tJdj_d8|VOgxw`Sb6T+})4P1B3P>4t4zdla zr!scM+7J#W581B-QK(HhZP&6bg`R9E6XIFj*g{=vzdiEDocSR*f~c0WfsS~hRxp$( z6-#1!C$AX1wB=aPmm!2L!Qpp<*lmd->|i7rPd=6B`{+M$@P{ZriM_UQEZ9Nv1zFZg AG5`Po literal 0 HcmV?d00001 diff --git a/dataStructures/graphs/Graph.class b/dataStructures/graphs/Graph.class new file mode 100644 index 0000000000000000000000000000000000000000..936e873e25aac7bbab364bcb9451ab9495058568 GIT binary pat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_problem.java new file mode 100644 index 0000000..61f0521 --- /dev/null +++ b/dp/Coin_change_problem.java @@ -0,0 +1,19 @@ +package dp; + +class Coin_change_problem { + static int count(int[] S, int m, int n) { + if (n == 0) + return 1; + if (n < 0) + return 0; + if (m <= 0 && n >= 1) + return 0; + return count(S, m - 1, n) + count(S, m, n - S[m - 1]); + } + + public static void main(String[] args) { + int[] a = { 1, 2, 3 }; + int m = a.length; + System.out.println(count(a, m, 4)); + } +} \ No newline at end of file diff --git a/dp/Knapsack_problem.java b/dp/Knapsack_problem.java new file mode 100644 index 0000000..05d0cd4 --- /dev/null +++ b/dp/Knapsack_problem.java @@ -0,0 +1,33 @@ +package dp; + +// Definition:- + +// ! Knapsack problem is a problem in combinatorial optimization. +// * Given a set of items, +// ? each with a weight and a value, +// * determine the number of each item to. + +public class Knapsack_problem { + + static int max(int a, int b) { + return (a > b) ? a : b; + } + + static int knapSack(int W, int wt[], int[] val, int n) { + // ? Base Case + if (n == 0 || W == 0) + return 0; + if (wt[n - 1] > W) + return knapSack(W, wt, val, n - 1); + else + return max(val[n - 1] + knapSack(W - wt[n - 1], wt, val, n - 1), knapSack(W, wt, val, n - 1)); + } + + public static void main(String[] args) { + int[] val = new int[] { 60, 100, 120 }; + int[] wt = new int[] { 10, 20, 30 }; + int W = 50; + int n = val.length; + System.out.println(knapSack(W, wt, val, n)); + } +} diff --git a/dp/definition.txt b/dp/definition.txt new file mode 100644 index 0000000..90a43df --- /dev/null +++ b/dp/definition.txt @@ -0,0 +1,5 @@ +//! Definition of Dynamic Programming (DP) +Dynamic Programming(DP) : + DP is an algorithmic technique for solving an optimization problem by breaking it down into simpler subproblems and utilizing the fact that the optimal solution to the overall problem depends upon the optimal solution to its subproblems. + + Let's take the example of the fibonnaci numbers. \ No newline at end of file diff --git a/exercise_and_practice_Problems/Cylinder.class b/exercise_and_practice_Problems/Cylinder.class new file mode 100644 index 0000000000000000000000000000000000000000..e6ad1bd335d4cd1b224a500d54594359b27a7bba GIT binary patch literal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*@pJswbNQGe^E_;YY5x0Q$Otg z-4D?h7&5^#3E4yCASBiLY5%XwzoSI=^e!&eDQmRp($l5VA26rtyBID_{S31-wTJgg zPam@G9JcTc>89`c`vwu+SU}%(J*NlpKuW616f;ay4vx$R~G;@~0TbXN*|I zS!`0?!g>72Xx*kyl72qGEas@?@HKB;V-5#Re1z-Fnnw%sl+wgrX5Iz1`3n6vXfv?F zm(!OPdH*`H`%G;bxM`r8{6~Z^a7zHTW$*LxrjGkSU-cQxc^;X}KOB%CBR%cfe?ea; A%>V!Z literal 0 HcmV?d00001 diff --git a/exercise_and_practice_Problems/Getters_Setters_For_Cylinder.class b/exercise_and_practice_Problems/Getters_Setters_For_Cylinder.class new file mode 100644 index 0000000000000000000000000000000000000000..90b6ebe66c4fadd15154f2552ea160e7dd705f78 GIT binary patch literal 1210 zcmbtST~8B16g{(DcH6oXDBmKwfWlIg`jwbi~X(YezAWj+?c^=3E6DX zfo)R~@`mh2lx#3$I#N*Sk@RJ}Mya#B$DpqV4UtC%1q*pxVi>AQUp()&_eHqNi3UTl z8o1osYvm%=6k$#O1xq=oux?>B<#q1g2^QWHK`jy7^KZ7Ve`VZ0Yu4zb%s+wi Y;X?C#-{w1gn^!J2FZFG{n~b>k6aPBZ9{>OV literal 0 HcmV?d00001 diff --git a/graphs/Graph.class b/graphs/Graph.class new file mode 100644 index 0000000000000000000000000000000000000000..d5bfa95b4c681bf09b4752b007823bad1ad6461b GIT binary patch literal 1755 zcmZuxT~`}b6x}yplZ1glLVz|2O+PGw(ne9KHWZbXmS_sKK`O0Phs+QL!X#@lVd;CH z{SSTWvt1fovh)Y|KYaBki2L3NCAfH)xpVJ5XPm+{UhkfPh|ijn+=P z_)snyLIT6P#(`067*4&owzX^3Jb|EL?h1@Quc)hzXE%x!+u5_sirw}~02YkwW zY=Ob5XVmr{8Lgg=W|-!(Stn$;P$tsO0ZP-)C{(-Iacc}dU|Ma@rrdVZpLAutc?661gFn_lx*e4axkzj%7Tctz-S*u~@3X z%5k>Qip(jl;d6HSX+3@CrH-Z8+cxkj+mcue;&(`}4 zOeu%P- zGNT9i(;=7~RjwL$0YrJqzXv3{0iOJXkg}VaIfOow`2&exF%rD{8mXCIFp@n&V)GEG z>dS!0W?mit^D|w780GsSK|!DpVRQ^)1VfnQdL6?^^Cs`ZVhrQl0aKX31qL1BdXZlN zWO$lD;FzvK4MGUHWf_s{ajVft=8%(AGIQDAFxkbmr;6BIrni%f0*cX)GEOnVC_&PF zEOKvI2qTbqtP&$&S)kbac!B literal 0 HcmV?d00001 diff --git a/graphs/Graph_Traversal_DFS.class b/graphs/Graph_Traversal_DFS.class new file mode 100644 index 0000000000000000000000000000000000000000..3f1783249365f6332682eef47e651fe05582ddb1 GIT binary patch literal 2133 zcmZ`*TUQ%Z6#h;!FeD75ka8)(l3s))TvF%_8`^41Q={QhLsKa#4rB-exjC88_T6WH zKz;J5&vj|2qAs8P5x)5DFK~(9nGA%u=$gfuIcJ}}&-ZbV_(fwi== zrDmIjc-k!O8o9JtwG#rqjF~U#cFi&bCQjcq*YI`1r%JYwH>|`Ry0*`mCDXnmphQy9 zEMND_Il~Vx0vbAThG$2jSrxqkXHPra2O2b}=Nod)urE45!~N3c(3epetkRo4X5o#r0J6T<$?G&%kYw6e0UDf(t6b0zFLu zU4|Mi;*x;6rx$9*(w0C!NuDBv#Qv^^QH(iS=LGs9C$=@xk%&GeqGt@pj6G%!C|)GB z_B5LHVFFVsCR=itc~P~EqJ}uGFlf2PboMo3n&tSiWtQxWZ5etop<;%)ZDQxLS<2t5 znT4ET`Ed<5R9tTj?d*``Zc3yrlp5X%Kc?}X%;2s6adGX@YzO8@CoDJK(Qp^shiDjo_19mcI%Xh=!GYDLOZ zD9N;ZtRamB0jpG#;;8dG>Sgl+#I-Qus6Fnzd;pO?f2@o^l6H$z!d0L1 z?dPhHJUDi7&u6atTN%p_$<~IA6!*ClZ6l!Qkf`=w-~{i8BMoX9nCeW#9<$%H6CzH~e43-o};X ziIB4LJ;o0(y&8IhtNWPkP1JF_jt}a1&^Wt}j}~8HWb!903jB_dI#zBd6Mf3nm+;5> zl!-b%rH#e<^6*cIPjT>#I->V;Hb7G6sKF3V4`G%h?{X!{`4YQD>UFJwjP89vjv&gT~Y aO^`D7Hz1&l3THmrzoPJLAy}MyQ2h^^w7aGN literal 0 HcmV?d00001 diff --git a/list/Insertion_in_Linked_List$Node.class b/list/Insertion_in_Linked_List$Node.class new file mode 100644 index 0000000000000000000000000000000000000000..0c5ff7bc04a8b5eab276f80a1288d10f6367945b GIT binary patch literal 603 zcmah`yG}wu5IqCP^Qs7lFCK~%fQi^yXlzJ~Bm@fyEm>fri`Tu$-NpD@7R1ED5AdUm zv&2>?cAjTu&dh%Qe0~AAL@j{`q2?=N+g)vBXjPy`N{@OPul`B?WiMMc9CnWpQ*t@`3 z95dS}f0}zto+TW0Ae(h-vPb+f@K|rMH9%yEEws)S*lK+s+bS)PZ_xs~@0^cdk7W)q umZ@cjEw0XU{XR#EoCgXxa1)l+A>0VLVQuGDO3!535eV%_qarX`c&qnlu~w1u z0^vKRWjY@T1XB|mbYA3j96_{eh#)G^Nkmy}?v`X@-6&P1K%!798`TY?VXCu#8FF?^ zTj1*3L5UZtH|-rRsr)*Pe!eA%e`bqpKz zy0q9np{ik%G{0puuib75Bv0DS3wW<-Rx7fhbe`2PhhcguapSm+I}xzpr#jSg(eNSI zZ;?Ht+LS9#70>*{S*CH^#9dYNsVMHTR=T>lui;&MB9J{VwKFk%a`VdbQw^U%)!V6g zGz5B5=fbA(g@%HXvdvANtK*3k+BHn-+LwBC28zPQ*>&y8e5puYQoD5xUEXd(!&T@} zd@V2#Uu5MSS<$^=*3|&$rhS_k3VfsCeKmI>qp{6_>OKdGgsRF%Aih>>Hp+6zRC77} ze?N*TRWt!DZ&|Xj$hz8+kwZnV>5I~KmZh3+8zUqThAq+EmoHtiUHNZVp_VIpU6cuMIa|rEMj3jQfF!9m_ zA0l`$n|Xx+f@iWc3Owj0bA|Z=gLEC@d6>W>BrwXrH)vBXk+c{1n8+BFQA!car4*ot zM=6MDH?rv9Yj%at?ZD?YbE1Wk;t(-Uibnm;-s(Q2=#uC33=o@5j;XNg2WLt z+7MG9#6$w5Fr~;AUSO0$AK>ODwVnA5AME4f#6k;;EiAS0xe~mPIehciiQ0pN z0q(Nf78rApgzuB^0#jOY$@Y2CeX?zQx9lpdRE;5UgeWQL+!nFoQ~H^_6{WcYh|PUG zC}g_AEv#m`A}y?CLdtNrnjxDc33WwVc&OUrE4D|bh0T*b9C!ORPh!g?u*yz+hyiR; wrN_u%i!wZ+w#F%-_`32@X=Q2o+C-x;s$*qjU#sHiv;LQ-~9snRpgmPx$xU>&Z+` zH6iW_EeO7fku zRS;_IF})aH+k9rr5{4__IA$;Qh<^??>ovCSU`4r=&fyaI&KsOgeTj01mZ-imZeg8e xjeCLf6I_=;o?iiFIM|3Vi)96yW=dpj@m$k&n>`D4?6A)AJVJx{0sB$B@eLfCXfOZ( literal 0 HcmV?d00001 diff --git a/list/LinkedList.class b/list/LinkedList.class new file mode 100644 index 0000000000000000000000000000000000000000..f521333476896e3a7d44eb116f684ce2d484533c GIT binary patch literal 1834 zcmZuxT~ixn6n)_%Nq~%rmqm*)=p8OCwEMLWT{-#(+ZIp*K_@=3ZcYk zf$H-Vn+T!Jf`KS;2%(qiI~%&X>THy>LOfUAbV>!M>dL(-4Ex(|O`-ER3=zVWdTpCq zB0E|z(4}zpG%6=&H?)mGq0d4qA~EU?SQtcvZaw`i!;E_RoAsjOI|?e> zym|~p!7S>M_O*mdd8J%)eYfn<(APT^YP$;UE55V&DDPC7!Ne+6*YhQ-F}#a}f%jfZ z?aFsG+FBSzl4&c~3E!OyGVhi%x5RYCuWDy!+CW;N_oyZmyWZCIx?3vhssu4^A%kIZ z5#}b|#|H)`UdIYdEKK5}g7MfX)%EfN$xwE*0T~p#;dt6a3YR2@mxCN02c8}+L@~vX zZBd-D@DW(|h*PO(k1aBmIO*{uNRxelHEUrG*O^tn++e`kCQh1AcL9qAK33>DB~2D? z2;tTs>D>KB-NHML%QE#O?wvxbV6qw7WXW6TKxY)o3jO9h)9&k{-53j7`pkA~Q;c^3 zpIP`^aEt(_#DsVJ;b)L9p8S{LiXg8&C)s5 zEjE7FDJ&UFNhq)fSIYJ3re1VqeuiE-TX((n1{AlNKQ6gZu(F<~tMetNR?~DGZZvM& zlCJrAEn`@NO~N6*1&SZXAy^^fN=b~j4ENx_a&RAK^XcR+dY_{|nSPGmBY$yf0(~$!iE*4mFHb;1F|$nVuy1jS)G6eq6u+r|LW|vIQnFfy*3+E4a#a z5!Y}Nvq3DAOfb3q7fX)ONi6Nuc{7M*2t9aFVM{8;CE(msjQoUm4v<<)?PBa_T-e8l@hf|n-ov#$%v0E(OTBpc$5Chl zgaScZIX_Wk>G@MWNjDf^E}-7i@ZO}}%Ktv0g$l^U&~k_9erE)|v~B1@|*9Z{}i8(-SPt<)Y?Qq=lF1h<=lqb8XM%CJg?1v0tKwA^7s ztTADC$>csCqAyvFb(X-v44ZEjoBv}!N6ot=6lH1du~nt-@AKY5tFO4r=*Ic2^ZYfx Hu-yLzq{eQ_ literal 0 HcmV?d00001 diff --git a/list/MainList.class b/list/MainList.class new file mode 100644 index 0000000000000000000000000000000000000000..b84c7fd8d180765b0ec8276394e89d1988375c5b GIT binary patch literal 534 zcmZutO-lk%6g^Kz#~C%vO8fqTLJM-)!e|o&!BmSvh*nP>?8!97Gz$K#HVFm&fPPeT zZW2VLIi!$QD0n9HuLh4TKf2Yez*i`F{k9I8IxaFIw^3`_m{)KnJ0s6?QG_F~n8OmvG^INoa#SyBO=&OZup*{X zPu!<@OGjO*F8sqS%A+7q$WASho_5@u{vc}m=SF^#|2@u;Si=q|$O8fiX8b+TW>sfY zjH!b$GA}>RE>WIkG)v4)1{m|K9L%A>jw}y3kzm|^NAYgV;~genv2bV!qy*9ew!kYY tGxl9%xRoY45t0HKBnQ43fB^~pia{>Q0U1f81rLEAj=1;9j^kZKrP#vq>T&KCgF&&io86_SXBEs4s@~O1!6KlLpsIZ#G;0?i`yJjNR y*m@;Z!Zxu5hv*S~Vhwc!*df#YX~S+Ylmm)2c4@ol-NQbkT_eyzm#V{p?|cJ8(MIe5 literal 0 HcmV?d00001 diff --git a/list/MyLL.class b/list/MyLL.class new file mode 100644 index 0000000000000000000000000000000000000000..289008636cac16710eb7f899b2d1b1e99edbaf52 GIT binary patch literal 1471 zcmZuxZBrXn6n<`AcC%q=Dk-2)Ds5>^7DCXfRjJg1tzwhV4xP-@ZwtA$Ta(>PcEiXI z@JILu?3aGQL2&GhUzzbo_&5B*Sf8`m2{2`L_TGE$J?A{nea_ka`@cW`0&p9TO{5g8 zwiia#`fjaeBBOBeg}dWc+phnty0P^_Z$}E5=h|)Yq&D=NYXmL5tdQ#lp%;09uVCEq zd@ov2NSDe@#;nmJk2Gu>IamsXn&<0Azq6%#Pu#7xRv4=V+itt*_B^qZ%}n&%3l&CA zun3cOTg14o<@-Do#v^u5KC%QmtwEP7wD z@jeWu^z~12!Im4j3Tj;;8wK}but;~h3Zt8myZvL`?I!fH-Ja)17Cu1PMCpuLo4X-n zY&e)FWYA~c@megV7gQff*k;tzZfDs)WZt0$|tJ;{w)jU4LEfXJ| z1&Muae2h7;_>!*xtYTky!Na(-m&o|SU$t; zcC}BrE9XVLl_a4ZV|``g9#+{EQ7~YjaH(`IudngI#C?V0Ir`Z6MhKg+(rxLip6&!Y zY#3IwDL0l{KD1#<1@oIhzqhR)c+ydpbn&9(RIt~5U-#D9ZWwAdR7N_MebvxmRM*ml zA+9n{nqNYSFB^j+Bq>LOC+u2|d0JJ@igVUE#K;~ODU2pgV1f%=+XDv_aFG`94#tw; zJ$hugv-BFpr_+ZRuR8~r`~{Y?@H?jWoPA6;ULsf7$4oWG@mQDjO&~ouBz;5;o=PNhFq4Uo5)7G_8PC2qW?If4CbGse*x)ZOqeJh z!{jJrZw&ALGn0uvi$b*a5_7-d=4&iGo!`geA6PoXr(>TVVEF)d53t6~ncDo(n}1Ho zPsMs(qrTUv=p3ILD05vwDJDBH$exhR#%H3w5VMdvMvjzbY4Dp)6kXvg>CLVkMAIdld z#2}mOW@oSp~}J%sEp;4Yy~nLwQl{f8pHzDP{vZA z>i#cXvAd^7p^TGA37DQo#tPLln+opAmt^G+wW;cm%CvQ;QHr)M_)yr^aDnzx|4wn`ZCffUXoV)pl1U0_1eqy zw{G_)NiKh+1aFU%2+0U*WhM0qU;>yc;;cRaDg|$*KAX{ zP?S)n#wSjD?dCfw&9gV`z7mmGG-^@SSy^iG$(oO-ZUE39fcPBm~y KY~W})`S=Inv1XY7 literal 0 HcmV?d00001 diff --git a/list/Problem_1_1$Node.class b/list/Problem_1_1$Node.class new file mode 100644 index 0000000000000000000000000000000000000000..c012ef14eaa6112595053a6602f094e2ead33c3c GIT binary patch literal 454 zcmZutJx>Bb6r6>V13dXsL_rOO1yD$+EHpMGMiK%h8d|czMwc9S$?akMTNcE`!XMy| zGR~eB##roov$ONwo3|gIZ|?xkapEE+Q1!KmySGs|^VMqFoAype;X=7^1WHT!B)h&0 z9=hY%Qq5xlXCY%LAO?hidL~mF{@dU}Aakh$9bZw|8nh=&eKyV`jU5j;6a><(_9O?+ z@vw!AMHLS&vI51S4%BG9nyKhs(imTc;avI?8EJd}A)WY98@gEt99$%N4+>?q#J?n>#BhT zu)eoZw^XZBXfqtC{{82@E zi|Wh;izRT|Ko5GOxFc|U+1`{+lFj=>){?4s)HBn-X`E4~l7SeGM{$>lx)-#kQrp!| z(yZmKv!xS9kl>{*#VKGE97noKb*tT$v=vc9NA@Mz_KH%? zRGW>&KH_LIi;6u@5uQ1FT>B{HxC`z*Q`^vA@eqQ+wbutV9OKyt6z~-WC_zO=L_K~* z?H=yqqL?X(g~&@JvTqPyh-9b#L_AwO6)9!kef)3Q%=}KRuy1(={X7rz22iVb6c3-!j&y75{#RfcOU;%`3a&J z_8Co5x`4AtVFHs}r+l_5HX7Y!o9?nzeCRNoWbUrxMwi6`xNGb}^_5)okHuyg{8ZRi?RNul+!B+IGjjE^?8EbrHPhqd>bAE+# zY>rtBVvbXM3G@6EILbfs-{B#yU=3HX!MSvi$8%iU7x4?~++&PU-j$ho)p++QhwuOu R?rJa+{QW|Whkh<7e*zsIRXP9w literal 0 HcmV?d00001 diff --git a/list/Problem_1_2$Node.class b/list/Problem_1_2$Node.class new file mode 100644 index 0000000000000000000000000000000000000000..92c3dcc580ee570dbdeb48511840f7973a93c963 GIT binary patch literal 454 zcmZutJx>Bb6r6>V13dXsL_rOO1yD$|vC!C%7)c12XlTg-8(nhTCAWw1Z&?r%3x9w= z$~b#k7-O;T&CbqyZ{B`)K|;N>E!Hq7|xXoN1(KjPqORF z;GsL3F4Qa*aON_W0-{eCsAn>@!M_bI1TvR8(D4jXVMKg7+t+@1S zofEr+fY%QK74>{+j50176#ey0hjw*=>`BlNVoQFIL|6@-ejf{p-fz1BE!9@dO7$j>)KJj%395s-{5gJ_SG5g_~Z*DzaG24BX z18vuG`~)3O8W_M}0-xZNhU^E@)qeDR*)(t(XQ)c6!#J60psdxRrU1>JU8YZdi zp5`=L&i3t&WjCa&n4dF{M}ce_rf&*}B^^_k)^Pqqyx^LF8I-71*R(rw?FVA!mkJ?l z@StJvvW^@ssHd4z9tY10^*AmODytl?7%Z4;d}FiSmJZ8c`mh@Zg7h;8ux=PAV_qQc zw?YO2qxnO5Rq&aHn*!-Wq%v?Eb2=)xZD2uFl@>gN?NA$P-R9Kpcsrb!bX})(U#c7z zX=s`jy~gqn4$v$sPl2j|FR&QLs=$#uR#!S%+j1Vu1}Bd-QNdk>NpyjGibp(-`%L0q zSd)z`>-#@%!kO+i%Q$@qnt)zwb=)nvXsIqpzSn#+DrEs<$#JB+V4I#N86>7UOkil0 zrMMzh19><_7E$&w1y%LO)d1IQG>!@GN}PqV7GFaDnTrSvj)Q?w!!XxI=zxzf!d+a| zJ1y#Rm);T1x#FMDi@zfEnsJ`1#V-E<)Li_HpWra{oPNXh? zxZK0_9zIo!mW!|7{!OPIZmD!bN)uFsX)x3zS7&hs=h#S-IFAD6P<$stjCy?@&{t#< zi2MUhLpn<~EQvm&bp}8A@8hC}!VFKcgBs zz%T+tCHNA)>O=fQfFSAQ=q{Eue#sFvtaD&)sg)kqcJVb~`4B`^wpwW0BT$4+fJ@Z* zGJ{{?`(9-qT&K1-FoAhWP$8|G6yVl70jM+9QRlrVzTp_bx7gsUiapKmJ1X&jd-W#i Fe*t9KJOcm# literal 0 HcmV?d00001 diff --git a/list/Queue.class b/list/Queue.class new file mode 100644 index 0000000000000000000000000000000000000000..8937034127d92960e73c31ee58f24aa9eacb34a7 GIT binary patch literal 1649 zcmaJ=O>Yxd6g|%~j=B%nl*!UiVx5C)R5vBzyf zL29YGY1Pj~zgFFK!vdtBNFc$Uf5Jatg*bQK5IeYHF*En$ymRk6_s+{VPoD!ggUJM9 z3aJ&Z6^vbJyKOfCQz3iH`O+C%as1`6*`-@{3= z)8(N~W^#UhVv1?A={ik*THaj()Fp+!NzeC!DFvfcUSQ@tc~UTtwP0aq5(>L5#L*{K zzlEf>1}vnIR>)L5-<@f%F1gKlXK96;yDRmov$EhcJ@KQU8Qk<*3YKmtycU}o*bZH9 zyo2YuaPK;2d+avhwJxkSg7vW7s|q{k0;hU=+G#|E`b*`?`%cU#pZ3JH3ZzXU< zVNXZikZvnYSxaSVmBJ9RNt9qGP^PL|5?dI-amrM40!J?UKgANRe@6zVP$>20MdZE` zOOzK<$(S3YOKn-WaF=0>b$;I1}!r@4B&S#>XZqIxRS zbX2-gC{50v>n%Lh8^R$D)!^D0h{=rUCFsSlgAXUY&F8$ClNk4c?_Kn+6Q}s?w>Oco z)f438mA8#2C_HA|z#!iPiq~$ysidBom8r1dD&oH#OiDNJ5<~A_=C_E&3?IH!x;Nd&Spw-pG zU{4Pc>FOcF9!_ACm2~B?u<~mX3gwKhJoF5u#gR>%oVJh4$oR_Jixk1U&bj@Eaworm zJhS6A59T*8z6~e?)?$r@tFgwK>&W6R3iz7iyoV#Wk70a+llT^A@c`%X9j5Vpcp;l- z*->;MvG`-L`z-qLDc3BuUUGTX@1IDb)`ze90~;kafaaSkF!gotyN4B8S&Iw+AuqeK#o6068Kg~$|n&ChAa Ja4uSmiMR1-1t0(b literal 0 HcmV?d00001 diff --git a/list/QueueEmptyException.class b/list/QueueEmptyException.class new file mode 100644 index 0000000000000000000000000000000000000000..3d9db66657b0ff6ec25069c299079793150a5fe3 GIT binary patch literal 1489 zcmZ`&T~iZR7=BLJWMx^94}*xNjY>5L5^F0|p{RUGFnl$d7ObO7IN)lso9=EL>GY!0 z8OO`sc%xUD-Y~t?i_obv{Q>?c+vjY8q%$~~>^bNCc;5GY&U4;>`1>CKW4Ny)BG6Z~ z{UE(skrg>xDhE5W&kC{}*sh~P6Xpfn|3#)ffjU_FwiD&G;2F@sZ!dI z-W_YBC zDuG>0=L(kNNUs%r=+|+AlQkvn_<<~$IEhmN5d|8rL)vaS6sY9FcY3C zl9#vCteL^4VH;uWD~S;kXk7XesFN%Q6CceVgtnXIX#lfsA zf$_D1KRCE0XsDW#k(7`LIYly5hA({9#?5nK6i;fDuu534WgB&NX znx8T;tqMiAJl6@7W!A);B1`k_pDCau=1pXrkW>v8Dh)*iaCcV)XD?D=T0;v=k_GT+3aL;q^|24Z)-q-EvCV+`UZfcUK z?YY1zJXy5L4XqnFx8fD#oULAi5kAimrA-daA^Cp!4iH6*tIksdNBD<&PPCZZrMU{O z(F=QMe-nlrLW%44JkCQT(`AH6q2 z@1-X1Ktivgvz|K>#&;)q5#~s5>%&_CTcz_MA8q|baIKl4# zi8#lJQdIU3-|$5eH$qEVJqTRpZwyzMKT1W7VG&ocf^i~E66-oPaRW~<1&8=PX7MX- z;W_5DwlRDx$lA?E2hiD5wT^$-@?=d2RAO8c<=tWup literal 0 HcmV?d00001 diff --git a/matrix/Matrix_Problem_01.class b/matrix/Matrix_Problem_01.class new file mode 100644 index 0000000000000000000000000000000000000000..93da2337e4483268ce43709cafc50c8fda23f433 GIT binary patch literal 1520 zcmZ`(TT@$Q6kT6(F1Z}aX&}%h4W_kdL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geZ!`8&T^x>%DF&Jwm!YS_IE^#hJ+raI-RpRb14mz|uQe8}FMpM`&^f> zXMkOZ(l98A@}2*M;+A1HQHUo>YGpvp#QF_2YbbY+{u#zY#EQ|x1MH7&;$XCA6DdQL z(mRwkaby$6HntpoK%1c|<&h?We3ypfiF;4)GemSiS}}3J?Invg%7=LBK?o@rNMjHg zv_pYMiuaOH=R56RsiQl63HnsP06%X+#{^q>@!GdUkC1SWHdSQzkmc;~W;uF-}{h8swIpD4R zp)}_052Xv<{!o%z6F`T!gp2O}bc<2eqOsD1IPGqd#>y_@5_P(}Q@ha?d4hH!#A6JK zU5^kLIvGpvZ|7zHfGv2J`Z0}Fw*0+56daBONAy21Squb!4;7V&mM^N2V7{nDTJuFc z(v~k26^R5Qoq57t5{^qaA>sXmRS!NS;T{S1OL$nqrwD5vd|JY1C0v&9EyBC-Wxg<| z>``KIZg>9qm*Su#2Mt!aiosS3ac*vnvupR^tiqICsLZ}C&_f1`DN=zi1`oBDg;K3i@ zj}qUe_3(CQX6L;(?9cDlH-JkVd9VnzJb%@_emL;p5Q4dUlf6`Cv)+9?SJRSU%b6n3 zh~Spbi4M=XCt5aLv38wgNqIwPbpFMY3BeiWPpS^Wx(^RE0UJ#pbp$-GV+_qG$<%o9 z6071-#wl-TMfp^w6ImpNuSCbJB#71QaKJ0YL%t}c>NYW5ZvV_gCitT)Q^hcqS}W~g zpP!Z?Is1SkkCiU(a$Vw>Q`!6h7S|eFAP7uEX2ey8;Jd--f*r;qx~CuTyPw#2XJ%oO iPq*?qXfgIHEU<-bW;S*z*Dm(>HnRwA956nt^!6XK%t9jo literal 0 HcmV?d00001 diff --git a/oops/A$C.class b/oops/A$C.class new file mode 100644 index 0000000000000000000000000000000000000000..781219e991ff43803cf67531ab275a4abead0d75 GIT binary patch literal 344 zcmYLEJx{|h5PjE#q=Z0A%g4&V01RYg09C3YA&{an6m@rkRa~Vuie3H}6A}YIfFFf= zaf=x2yZ7$h-MgRPuWtZ1IE~REbd7nl+4ww<5fb_f@h-Aj=y~>3E@b5hp%zO?7!?1d zscV#;-x8ubrIi~If{V);OLOxg69m{x5u;1!6-vv=YFWzWS(LROV=7V4M59`~B}4bB zEFmfWyzuB`YF14p?^W9sjj!A7g!EBs+2pmbR@xXxT-x*yDCc7)(z*v@9nQd}_)Oxr zgJ_$vDQ0#VWgLC&>J!Na6CI@dN1lwa&w08L-~c^F0s3BbhylmMw-0g515Z3ZTmwLZ BKJ5Si literal 0 HcmV?d00001 diff --git a/oops/A.class b/oops/A.class new file mode 100644 index 0000000000000000000000000000000000000000..9c7b12c55b2b8439303cbb7a4cd57ee351820ef4 GIT binary patch literal 339 zcmYLE%SyvQ6g@XhGBJ&|#`@R_F4Totx=@5RAPBK8lQx*YDE@1M^v0OvRm@CaekyxMFk;1kA6`6jbkny2ipT&k+$@ufDpyCMvZPZk6} zZyr^Q0X7l@2nnM?8#Q0Ol&XD@WvvKl(NwZt$W}Z57y8|^wuGoyZ@VDG_sy!U)U|e< zaC+ue6OtQaRGZh*T4e=NuB;nJGXl*7cK?%{6MnwtN)&$bvnj4)n+a literal 0 HcmV?d00001 diff --git a/oops/A.java b/oops/A.java deleted file mode 100644 index aec9a69..0000000 --- a/oops/A.java +++ /dev/null @@ -1,10 +0,0 @@ -package oops; - -public class A { - class B{ - int age; - } - static class C{ - String name; - } -} diff --git a/oops/MYStaticKeyword.class b/oops/MYStaticKeyword.class new file mode 100644 index 0000000000000000000000000000000000000000..6522dab41eb710290f7cce490456309c9a1d8479 GIT binary patch literal 966 zcmZuwT~8BH5Iwh)?si$Bv{1iLi&kjCQo(PFn6`N;M(`nEfey->j1?77NQ;g-Nesk|$YZ2EgLjWnhVSQk>-hoevqZP>WP zVE=&G^R0+c`PFxU^1^l)NM~3xF(Y6puh4b<-si%)g<0ebWCe0#!fni9UclJb46aAg zQp_6ZB&G8Dweqfs%jZcq1ZG;wlRF2)t_1p{|E$QUR#bfIM%C6o#FW!Q9` z5sT$Y<#S{aShG;Xs@8N*V5$_Wsk2uDYiEQ_3l%JwSZ9p#MruzMVtGj?=xgFJBH4o9 z9n?wkk2FRa9N{TaZ0JTA)jWqaiCJy`An3_gN>6m|zcpIZA5g%4?RheYnvj$r$Say0 z1^0rB2)<2BB1PYz_Y8>$o&5nbJAH(Vwt3p`gcG>J_jHt)Vp=E88ci z5UuWLW%n;A%d-)!&!nzAvLw!7i7Ttit;Cerzyo?F%RR&+7R+qTQL6uc8kBH literal 0 HcmV?d00001 diff --git a/oops/MYStaticKeyword.java b/oops/MYStaticKeyword.java deleted file mode 100644 index 181746e..0000000 --- a/oops/MYStaticKeyword.java +++ /dev/null @@ -1,22 +0,0 @@ -package oops; -import oops.A.C; -public class MYStaticKeyword { - - static { - System.out.println("in block 1"); - } - static { - System.out.println("in block 2"); - } - - public static void main(String[] args) { - - A objA = new A(); - @SuppressWarnings("unused") - A.B objB = objA.new B(); - @SuppressWarnings("unused") - C objC = new A.C(); - System.out.println("inside main"); - } - -} diff --git a/oops/Mor.class b/oops/Mor.class new file mode 100644 index 0000000000000000000000000000000000000000..e96459c2722535b0ee41d95986d822a037412f4a GIT binary patch literal 593 zcmZvY%T7Wu5QhJ9I~Nav;1zG+3SD@XEHG{~uFx1UxHJVCs5zXHQb>3#U1;LM2k@bc zQ}MPqX)@F4Ouv6--alU705ovmAjRM+HJ*f*N;}9f1Ygk|H@%^lFyu~TEX^rHx_;PU z$egLZ@R5cWAd4JBp(SH+H63+@zUAFWFqB%V$D9BReUU6C@A;< zK9qQp3L=&;$^0kh|IV2+pI>hu01mNhBE?WvY8*ArA6qJjbU5*~3QZUcr2)U^jUf;E zjmz#p_?jVmBm=3B8PfH=4ujEBJz*ma%RvTN3vdRi=K@N7ELTLRA$&5RI$Whj$_g=Ab5RBPx>ab z4EoKu*PwU#TJ^STpbL^R}9H#*~6DOAhgUr8nHHRYb1=9Ib8 zYcatHyAfhc8D^zo_e>tEBg&yv#O^xp-v#w637DaDQK8^fQ& z&ii$73>rzN_s@e*2m}}tF0n&D^%8dw5~Ey931{RagQlLdH_Ts$k_Dkpb|1D!7!BOR NJ`PAR91=P>`UdU|N1p%y literal 0 HcmV?d00001 diff --git a/oops/Person.java b/oops/Person.java deleted file mode 100644 index d17564a..0000000 --- a/oops/Person.java +++ /dev/null @@ -1,7 +0,0 @@ -package oops; - -public class Person { -int age; -String name; -final static String breed = "HomoSapiens"; -} diff --git a/oops/RepairShop.class b/oops/RepairShop.class new file mode 100644 index 0000000000000000000000000000000000000000..2f6df4fecb7df7bf17ceda72fd0704ea69a29e25 GIT binary patch literal 905 zcma))U2hUW6o%gc+Wjak6k2Tkq-u3(YuC^80^^N|SD;1=#&|W*2}}dKWOuRgXX%A) zY~l~_M;YJQCBYgl%p~)1&Y9=D=gj>2{o^NqBRsQ^6DWn@B=+B_iPTYN7)~q{1j;A! zv-C$Y82E2`C#s(aEI-$QPF@J)y+&7{@G?ABF7j}SSi&+nEgh)W({WEl?`3bK1S+kt zFGpP&X>*<#3&~K&0_&}R(l(hPN=4A=W!?`m=?_)hY;+y0qiUgYNm=JhoTzaT8`z|( za7vMztyH)U{kM@0l1>sSId0mxLg=ZX)pcCY(x_t>+qh=osz7zYts<`DhJZCOpiw}! zm%-DnkgS6Nl?midSz@eKD{ z7x1|5wfE1le{hZmb7eJF50+xHkTS;xf9Dn|smgi=VOJh9#-`^H9y3LmWt*g?+$Z$p G@bnKZx2o6x literal 0 HcmV?d00001 diff --git a/oops/RepairShop.java b/oops/RepairShop.java deleted file mode 100644 index f119ee3..0000000 --- a/oops/RepairShop.java +++ /dev/null @@ -1,20 +0,0 @@ -package oops; - -public class RepairShop { - - - public static void repair (Watches ws) { - System.out.println("watch is repaired"); - } - public static void repair(Sonata sn) { - System.out.println("watch is repaired"); - } - public static void main(String[] args) { - Mor Mo = new Mor(); - Sonata sn = new Sonata(); - - repair(Mo); - repair(sn); - } - -} diff --git a/oops/Sonata.class b/oops/Sonata.class new file mode 100644 index 0000000000000000000000000000000000000000..b85e4f94f30953a84a5215d80ecab8be2957987e GIT binary patch literal 580 zcmZvY%TB^T6o&ud)(b^$;{5`y(1l&Hz_`)4YK*Z4*8?;-rgTUn{=&OdT|_N%C^87+T)4ETnrEi%9t@4*0ZhVvC`k?$8!V zdz?aT>|oEpE<-b8%E3Mk=mj$k3L|27Q+TSaC_U-xm5cXs!9x?rwCq|V)=382m-BcO z+z7pSIW3=SHFQ9arjG_$f}lj!pvWc9$QRE(V7}5N2b-)e>((+^Cv6~Kp@?B)HQb|a o-Dka_+GxFFdkwIu1X3{RtRdD4a+nP{%7EBQL>8n?5;=5!0g5GR2LJ#7 literal 0 HcmV?d00001 diff --git a/oops/Sonata.java b/oops/Sonata.java deleted file mode 100644 index 7d8972d..0000000 --- a/oops/Sonata.java +++ /dev/null @@ -1,12 +0,0 @@ -package oops; - -public class Sonata extends Watches{ - - @Override - public void Digital() { - System.out.println("Sonata is digital"); - } - public void Royal() { - System.out.println("Sonata is royal"); - } -} diff --git a/oops/StaticKeyword.class b/oops/StaticKeyword.class new file mode 100644 index 0000000000000000000000000000000000000000..1267bdc46f1c7d61d51340b99352e3148dbe1a9a GIT binary patch literal 978 zcmZuv=}r?-6#gz0W;zT|yMVYL?kyF@eWADjY9uy7QqzR^>$bhtA+t2oDTb%;Su{$G zBtC!-W&CD_gw*!WJ@@S2Ip_QH_t$R#kMK&vm_XL|J6)?5%Fu4URfnJbprs)tklB|9 z(sHENwsso(su>DQuG^j+J`)%(mg)kjEx)ARoheVdTv7n?`6YLEME1S z(y7b9j`R~_D*R-31@hJ5&J|X5rR@pK6+cu@5!AxK_S%(FUBelHsW@?01zq1WkU?5U zo{1Z-^wL!4Ow8jf4W4vk3`2FIsB;nKk5wZm?xToadZg^_-b zODH6;Y~R`?rjW>#bSnm~;f99m0=c-`pxeYv6a}bTGKEOGM4_Ru659`n4i(@|ba zU}Y4#p?W8{IC=?dCMsAL&_h2t70+870YL}ZGxf%I{hI99$|DU@GH6reMw~lZd1GH- zI$=t3a8ksm`Msd2UfVIn2B^ClZI9<-Dme~}@keg*)u>sNf^uTH5B+QGHuy$vFky6|wzP$~r8W1P3lBv?suWSARF*29HqMf4<=B?v6!BRg zlprec0elo<){ZD4dD-#o?woV>%=p*uA3p&+!z&#H1}lo1&3Wn(Z-YZ=#kkF$2TGEan*I>oOGY`rW2Tj(IZ>42$*1=Yhu) zsq)dLmUd*1p;Z5u(h8cv`XbPY8O7P{A&OtJW0O{O44Ak?tCe4%c$qQ-CCt-~D(27#4%j+J`D93w`4yFOte)(A z!?o|YHN@6pZGi0o_6B%(0ba_Klu#s~O)O+2)f|X^p63Kur1^M(mqf$hQeMFR9}e-t AF8}}l literal 0 HcmV?d00001 diff --git a/oops/Vehicle.java b/oops/Vehicle.java deleted file mode 100644 index b6058cb..0000000 --- a/oops/Vehicle.java +++ /dev/null @@ -1,19 +0,0 @@ -package oops; - -class transport{ - int wheels; - transport(){ - wheels = 4; - } -} - -public class Vehicle { - - public static void main(String[] args) { - - transport car = new transport(); - System.out.println(car.wheels + " wheels"); - - } - -} diff --git a/oops/Watches.class b/oops/Watches.class new file mode 100644 index 0000000000000000000000000000000000000000..c151fa5ef94488bf9dfe4bd4a5f9f29ce9a3963a GIT binary patch literal 290 zcmYk1Jx;?w5QX13{sCj+kQ>ke1uj#7(tuJ~AOQ;X+N|ug9B*WAB5^D#B#In>Lq(Yp zDQMoevu|ei&F}ta2VjP21dotdyB@N4<;q$Q5q!d=QCpR@s;jc+qS2)zg!iU1ZcZ3o zT`vj#gZGacPRp|ar6|E*rb6cu*sd^*z@zQs-83^P2|DSh+=+RWh zsg@AD*iT{nYBznU7e?Mnj_GbCn12b5!3%(u2N1GGTxCpR1~=b0`Qn3zm{n|PJ!4J& T8kpyhO~>pCQz3g3Ru2~kzCAZK literal 0 HcmV?d00001 diff --git a/oops/Watches.java b/oops/Watches.java deleted file mode 100644 index 863a6d9..0000000 --- a/oops/Watches.java +++ /dev/null @@ -1,8 +0,0 @@ -package oops; - -public abstract class Watches { - - public abstract void Digital(); - public abstract void Royal(); - -} diff --git a/oops/transport.class b/oops/transport.class new file mode 100644 index 0000000000000000000000000000000000000000..c6e4891a5fa78cf839f1f2b1610a68b833b81f2b GIT binary patch literal 304 zcmY+9y-ve06ot=C(uM?+hMxyugbrk6pkhHnLW*DjWp{!_T$#9XTzD>qsuBYaz(XN! zLKg;G_ndo=@8|EI&o2O%IEfJuGHX|T;hpUIm32NwM97!&O%_IWFU3Q>RE;N0-&>_j zPoO&%3*BjdO$g7N!CUYj!N4|Q%R=> zy)z@OsI`<;vG<0c8F76X_O$Lb3)gXj4AXxMO~*YBVZy<#0hh%URUcKd z&@JkiYw@6{?Y4zIc;uyS!OP$2Yn8h?n1z&OGG)ITYuc!($1_d6rjh&ta~Lm@iT_gR z&#bQ|WKW~9Y`*7E0VVD@0$dGx9<89Q>>i@}wYWC9>TB@939i;Mfc7N48cw0k6aDxT z#Y(j957_SxIYHg6Mvhk3wsV~Oh6~*sS99E4?r!C{vr4ed6rf185H!(bst!{)6xT`H WOJUr@eR@^$Kfpt#6?jCyg#ABrV62+} literal 0 HcmV?d00001 diff --git a/oopsEncapsulation/EncapIntro.java b/oopsEncapsulation/EncapIntro.java deleted file mode 100644 index e069086..0000000 --- a/oopsEncapsulation/EncapIntro.java +++ /dev/null @@ -1,17 +0,0 @@ -package oopsEncapsulation; - -public class EncapIntro { - - public static void main(String[] args) { - - S obj = new S(); - - obj.setName("Milan"); - obj.setAge(16); - System.out.println(obj.getName()); - System.out.println(obj.getAge()); - - - } - -} diff --git a/oopsEncapsulation/S.class b/oopsEncapsulation/S.class new file mode 100644 index 0000000000000000000000000000000000000000..4f55d5f5d70d0f9a3f7f7115100b136c1c0ea9cc GIT binary patch literal 886 zcmZvZU279T7=_Oy+ud~Cq-j3Y_>oqvNvh4IV5K0UP>5An33%bfBwgax%}&^C1pklV zjTb6b!3%$YKT13^3D(#Un0;sRo@dT^=hyEaKLOmso`Z})S*gkNaXgfh=`50IsN$~g zz!E5)$hWc^$#~R#HaH1}sX$ha0s(O-V8wFGveY|k^3x=YNBaWygD?)$1Gcx?eYQSQ z$AOD1@*dXV3T*VkI5?V(2SM^e4kCk5LmBmD66*cp&`Mv2Q-Nx4g+YDGG)Nz6J67wk z-Csu)bqBR2+y1+08jL+$#3hg$6yGsjcmDuvWRNWY literal 0 HcmV?d00001 diff --git a/oopsEncapsulation/S.java b/oopsEncapsulation/S.java deleted file mode 100644 index f8de03c..0000000 --- a/oopsEncapsulation/S.java +++ /dev/null @@ -1,30 +0,0 @@ -package oopsEncapsulation; - -public class S { - - /*we have to put the variables private to achieve encapsulation*/ - private int age; - - private String name; - - //setter methods - public void setAge(int age) { - if(age>20) System.out.println(" You are to old:"); - else this.age = age; - } - - public void setName(String name) { - this.name = name; - } - - //getter methods - public int getAge() { - return age; - } - - public String getName() { - return name; - } - - -} diff --git a/oopsabstraction/Audi.class b/oopsabstraction/Audi.class new file mode 100644 index 0000000000000000000000000000000000000000..861fcd6be56277b70e3d21f1b2361ff8e98f6cd6 GIT binary patch literal 616 zcmZvZ%TB^T6o&tSLN9#WaUbfckgkcOQ{23dxpCqr>N9S=l&&j*2ED0`95gFcU?j{lN|dXx!6-CGyY z@*M_;`@RT7%$2ZFLfOPNL+OdXa5v!L$nDJ%CB}JFP^D3#sbZ*k^RkTGyI6**r((g! z9Se1Oq^34x(pXYuIC8LyeG_~1(hV2$IKUx;Ink^jBz$YZU&t#;k2-n-IX;;Lvxfnx zJzF@TDgVXhDQctF^rC6(iyNu;Ve9&ZmP8XYJpBxiWqN;PO^RIdjC|(&1J)}YQgF!X zGGHJ_Hos^fU!aI#Yk9d%-MY_yL$O?Y$Ic4iPzj`9(YJ!wOUTh?$nge9ju3^7kOoPl G(EJ6^ad^W3 literal 0 HcmV?d00001 diff --git a/oopsabstraction/Audi.java b/oopsabstraction/Audi.java deleted file mode 100644 index 26d5ed8..0000000 --- a/oopsabstraction/Audi.java +++ /dev/null @@ -1,14 +0,0 @@ -package oopsabstraction; - -public class Audi extends Car{ - - public void accelerate() { - System.out.println("Audi is accelerating"); - } - @Override - public void apply_break() { - System.out.println("Audi is breaking"); - - } - -} diff --git a/oopsabstraction/Car.class b/oopsabstraction/Car.class new file mode 100644 index 0000000000000000000000000000000000000000..fae234a772649c0cb0f44f01048e3eeb45f76a6e GIT binary patch literal 309 zcmZvXF-`+95JmrNHrZqoNC?US=zxMPQv}gOqFO-#N{hzE0td5Rc^xEziuLp+HWUZTW>O$IU}^t+qx-!rw5^71DCSL5!&U|Oi&&>Dh_m7_d_VL)llE8Wxj>fVxjIe>oX; zeEmjt2EIU{8FuBMEwwW1v(0pLq{adp&3`*+2-rIIb0D=q#ht@)zfo`7xP+pG!a2LG zPvgiRW>LZ#t%egiUu(u`ROr3dDu`N<_T{jV!DX86N?lXqS|aE798__|!n#0l!I>;J za88Ja;rW;daZFN(Y>=+hTs<30~fXff!!=FB1a{u`+TV40wFfT$C#6kGnXV$ zW6ZQnqRb(T9P3UioanCqT$x_UO&f5}1j8n+q}Z`Qnt$vtjuuxQXTf=S`vjRU{8@s- z(Uidhs~oclfb#{eY!in&=I}nz24{aozEJ*#%9Oxi$dWx-gC%Dr*h0A&S#m;x^?DCsBD>FT)pJ9wVTfT$>Dk#PR dwS)wBu}4gXRS)+lk*C;wJc#2yWMv7D{s1!q-Shwe literal 0 HcmV?d00001 diff --git a/oopsabstraction/RepairShop.java b/oopsabstraction/RepairShop.java deleted file mode 100644 index 6a09ac2..0000000 --- a/oopsabstraction/RepairShop.java +++ /dev/null @@ -1,21 +0,0 @@ -package oopsabstraction; - -public class RepairShop { - - public static void repairCar(Car car) { - System.out.println("car is repaired"); - } - - public static void repairCar(Car...Audi) { - System.out.println("car is repaired"); - } - - public static void main(String[] args) { - WagonR wagonR = new WagonR(); - Audi audi = new Audi(); - - repairCar(wagonR); - repairCar(audi); - } - -} diff --git a/oopsabstraction/WagonR.class b/oopsabstraction/WagonR.class new file mode 100644 index 0000000000000000000000000000000000000000..1936815a04344ba509ff3a7fed6fbb412ee55450 GIT binary patch literal 752 zcmZvZ%TC)s7=_P-fMX}+k`M}%f}sTkknoa4P&Y_jMO9TQSaeZM%qUFjcp`g(#ACq% zBo;gX4~00kxkg!dZvUL~oqv4)aC-+}A6pJe0t?0rQrS&yB15Z99Gu9WiGMjL3p7S+ zhcXeEI?%DU-vlOF+s6XsLvyM;Ou(&S5>o;*9UZG5!+uvKzhyU40`-mwWppePo$a3v z%l1sC0*jqdND-h-=f2c26Sn?z{>gJ0L^AFLM>f%Mubq=+(xXFTOj*E_VW=XNNUL1T zW5GdFVD^pAMQT;QhL2ceCuV2`ngvFi;3pZDBqjUp3YM9n2<7Y4fAM7u4=Y%8@R=cU z=l9YY*5C^`gUl^rC(YLQMyhf!h%Wwi$@^cy7lGw`nbTO&>eSbbuUK zwpyI-Wq7QEt?=IhWv=)$I6B+~oCW8}of}jxxhTQon3X|6m1C{A!1)7rE~YWVlT5tJ zFS{p3h0YrxpB8iZ#rg|%pO{SOUZGK6y2hth1CJ$8ULo(5?mp248+nfY&SYbZ$sA4U LV@dkyM zQSnGl0wqxEN4^ZkGS%1K zv-Xdg1;mImTk6?a&Fq+<=f)DhP(r#qjOMYgUTQO!%HLUUn6Lj|!)psX+3!U295w3NPvB`Cv z>((heGIs~v+Pxz@=pLiV)j3bphDm3k#IM5OHQIHiZ7`Wfq{(Dm&SZy-5#ufr5_?Fi Vgci258a&?H!ERRFBQiNW{sYp2pi2M% literal 0 HcmV?d00001 diff --git a/oopsinheritance/MainClass.java b/oopsinheritance/MainClass.java deleted file mode 100644 index c4c5dd6..0000000 --- a/oopsinheritance/MainClass.java +++ /dev/null @@ -1,20 +0,0 @@ -package oopsinheritance; - -public class MainClass { - - public static void main(String[] args) { - - Teacher T = new Teacher(); - T.name = "Mr Harry "; - T.eat(); - T.walk(); - T.teach(); - - Singer s = new Singer(); - s.name = "Justin B "; - s.sing(); - s.eat(); - - } - -} diff --git a/oopsinheritance/Person.class b/oopsinheritance/Person.class new file mode 100644 index 0000000000000000000000000000000000000000..ff00e65f74af1e5d69340452b29c4499607abdfe GIT binary patch literal 907 zcma))+ip@p6o&s{QwDaYR_TGNMO&*C&~|&S3C0Ueyph-@7?NHNFt$@Sv&lZx_*fc4 zjV3;T4`p1#CIu7|Z)VmU*1x{>&;0!L?FWE8JmttRtOh|p(&ku&I+muRyaN?Rf#Jw9 zTs)Dd((|P`^7h*&suMG0jqE9gVq<*Nj6-dX>I}JO+UWQ>gHx%t=<3U$t6Vsk7vRV< zEH<=JZ<1bHg>PlsAIbzB>9=I4?RvDCjgNK2u-2GOMuoB;r2oEvB9=LprZAfyqgeF> zR<1LBN{R>@wSV~wHoXA>_H?RQmJ0K*l5Ipkcd;~GbKy2!9$f$P{{ z;HT10)c!k$?aG8HsbBT##Ma0s7bV=Vj%*RzWXkBg+REb=gR7$r+a_6SGj0o1P$iFL zzpqS}VP{tAU)4qp)vd%GfxFmY$j3oiieb4j6VStbj(ZGCLw}~76L?_BdEc7p8**96 zIFH8+1tO-HfQh~tBwmT=TCBCY6Y&XZr0s7)?^#-;Bl9oD|!@>g6v!)Ed30NVr92G|{o ix+D%tUZ=`q;qtlg!~YR}^iN?y!V5EnpHSHh_I?9>*~5GQ literal 0 HcmV?d00001 diff --git a/oopsinheritance/Person.java b/oopsinheritance/Person.java deleted file mode 100644 index d4c4805..0000000 --- a/oopsinheritance/Person.java +++ /dev/null @@ -1,15 +0,0 @@ -package oopsinheritance; - -public class Person { - - protected String name; - - public void walk() { - System.out.println(name + "is walking"); - } - - public void eat() { - System.out.println(name + "is eating"); - } - -} diff --git a/oopsinheritance/Singer.class b/oopsinheritance/Singer.class new file mode 100644 index 0000000000000000000000000000000000000000..a5a11476e7028c9bb110b095d5159345735f54c6 GIT binary patch literal 795 zcmZuvT~8B16g{^sY`d(2g@Pzm5X80u>j%b%8Xq+A#Rf=fn)o_kR!s0s70lvd_7Az!O^2!*#{U%JSnBpv~k3H;RpHMX6#EP&|%M9q_se>nk<&3U+cxID3BirbJC&F!q zNz{|?l>ONYlNma&L~L=3^E_}sj^B7ZxH`P^c_m)w8kZGw00g{{Hjh7l2oIX(2~g4Z~rqf^!)uEdo!vCsKHvStt-z zrom$w#bH30d#wVc-w^WkMwd`{7xtx%JjxD=m?JE-RUkhmgPx2|M9-ImN;~v~-xZNE zd3IRP=PD+wwWoD56D>kf8$V?%qGI6=Vevv-3fC9GncMjsYdLVRgk?4oCYn%fr?3j$ z<46U%qa!H>Eek8$=mb$Sc=k3?eqTmq5bioy!#(aJ5QEg~^xc+?bv&?8``18P$H7Bv z5Ufk#C-UeMVXr=Rk(xZ}T}V&28WTtCisiXv6p?7V2+{e zJE)_e~)wxap literal 0 HcmV?d00001 diff --git a/oopsinheritance/Teacher.java b/oopsinheritance/Teacher.java deleted file mode 100644 index 71e38d8..0000000 --- a/oopsinheritance/Teacher.java +++ /dev/null @@ -1,9 +0,0 @@ -package oopsinheritance; - -public class Teacher extends Person { - - public void teach() { - System.out.println(name + "is teaching"); - } - -} diff --git a/oopspolymorphism/Animal.class b/oopspolymorphism/Animal.class new file mode 100644 index 0000000000000000000000000000000000000000..f700d0032199058b9f75009a61e93eb6f6292954 GIT binary patch literal 277 zcmZ`!yKcfj5S%qO2Ah{?5G7qgfy)#@ND)#hD=C8L&*qezb@o}tM9ODTAyMQ5_$b7l zla^*?XIHy3d%2!}0X$*k!y!zJDfgw(Ke?&OFSXC3mqO)2`)~=POni$-i{dkSPcoU- zg!WPus$LOV506`dyEZ!+poMM^9@>OqtP1&d$P-y@M4}~O9Gg_=t*DgM|4p}MFTymw zWB*JDKFpy?<*Tws!oO4t8wfM7J^uh^vbKyqtEka{H$S0s3jA!DzpJ?1_u J!hq4i@CLdvJ177E literal 0 HcmV?d00001 diff --git a/oopspolymorphism/Animal.java b/oopspolymorphism/Animal.java deleted file mode 100644 index d46eeb4..0000000 --- a/oopspolymorphism/Animal.java +++ /dev/null @@ -1,5 +0,0 @@ -package oopspolymorphism; - -public class Animal { - -} diff --git a/oopspolymorphism/Dog.class b/oopspolymorphism/Dog.class new file mode 100644 index 0000000000000000000000000000000000000000..4f02caabe90af51ac5492b8a6084287b184c95e8 GIT binary patch literal 499 zcmZvYxlY4C5QhKFfe#D`xws*8fdZE)f@nZg7K#*cg*;w33v!6{DyEHVMfhMBk z0tI@}ImlWR`Q#b-^2I0Yx4G<+H8QARldQM+Kz@rNntNH?ox=d<9hF-11G_7LOOnCZ P)MW*6mXKpo3pn`$TKi_T literal 0 HcmV?d00001 diff --git a/oopspolymorphism/Dog.java b/oopspolymorphism/Dog.java deleted file mode 100644 index 995b0d6..0000000 --- a/oopspolymorphism/Dog.java +++ /dev/null @@ -1,10 +0,0 @@ -package oopspolymorphism; - -public class Dog extends Pet { - - public void walk() { - System.out.println("dog is walking"); - } - - -} diff --git a/oopspolymorphism/MainClass.class b/oopspolymorphism/MainClass.class new file mode 100644 index 0000000000000000000000000000000000000000..5e443cbf683b717595dd2f3b4dc35834dba06d48 GIT binary patch literal 1148 zcmZ`&TW=CU6#fP%%Wk1m3cX^jcM7z4uZo(O8e(n-- z<*wVZ+trW|m^_d#WzCjuyY_VVz-$Eq$$OS-1rG$`rR5!g#Jaa<8i+$rV+=`wY{PQR zt)8=M`p@L9Z3^TXUQ60L(znz)+DrtL6DT(R@1QQAw|&zLEVtd&F^QapQ~!8s9(4oL zNn;9m`tf?SS7?NmEw8riTW-({d{a906s84IPpoRNZ~C-5i+K%m0#hTB(^x=JK3=BLEu;G1l^WE=`IJ{w;w_Gmx#rP1*U~6o=hc_!q;p z%R2@HE~hbpq=sdI{7~l}d2ItF=xV5@v7(M6@k-i<25P8kxH1Z~ZPHLe`fXM-HA0t8 z_h@POoT$bV5}lDjvZ|mIm>WhubS+2Pj2lg_=eNwqmbxYrf3DuDIu)E{xpCfA@LsWX zNOIJ;s_`woem9ARG9R*%tw)*KGkj)kPm^mRZ!jOg( zA4Q@P6|@*ZZ*fOSqzEmKKpGSn|4TlF(^!l+&O{tGIaE!B`2BatL_}|5qPXz(=Qm{~ z9@dgWg7XZEo(OBmBO4Mg4ZsmGX|NQwDTW-*aTddQ;`n8M$C%LR{sJyW%C8wzq_ZD! z=`%{tk5O(^HY;0|J}T8dR!{n{7&aDogb>+$M{_9p=Pv_ZLw}-v|Hz literal 0 HcmV?d00001 diff --git a/oopspolymorphism/MainClass.java b/oopspolymorphism/MainClass.java deleted file mode 100644 index 112fc11..0000000 --- a/oopspolymorphism/MainClass.java +++ /dev/null @@ -1,29 +0,0 @@ -package oopspolymorphism; - -public class MainClass { - - - public static void greetings() { - System.out.println("Hi,there"); - } - public static void greetings(String s) { - System.out.println(s); - } - public static void greetings(String s, int count) { - for(int i=0;idGaQ7fr2el1R)_LsuhY9l->zeFzl{ZyACLy1qDbHd;lMX z7$+zxLNnu;>p64n@1M^v09_ng$T8HFO0q9tZ6Mrzvw1_;^P$v^=su>!=T$al3r!v+9oeCcHY&03R z5~15NYa5)5CoXodXJMD2_RolieH<`YiJ^osfjbNGVzH+7q-S334%9RqiyLX)XOrV| zL&FKk5&bWaqZ54xMT;t*GNW8P`+)sAmtBfR1`TXb^cEK=Z&F3Rm&4sT3~=61t~TD$ VS^->=492D{D~Pj%9Fm&D(J$gjXdM6m literal 0 HcmV?d00001 diff --git a/oopspolymorphism/Pet.java b/oopspolymorphism/Pet.java deleted file mode 100644 index 2e46d5b..0000000 --- a/oopspolymorphism/Pet.java +++ /dev/null @@ -1,9 +0,0 @@ -package oopspolymorphism; - -public class Pet extends Animal{ - - public void walk() { - System.out.println("pet is walking"); - } - -} diff --git a/patternsByloops/Pattern1.class b/patternsByloops/Pattern1.class new file mode 100644 index 0000000000000000000000000000000000000000..5ef22c0c94887ecb097eda348c0e017b2b57cb67 GIT binary patch literal 709 zcmZ`%%Wl&^6g@X~V#hd5NJuGd0<;uJ0>Wa&BBcwEkdOjY3d)AnBv`@0u_MPp>b^hH z1?n0WMPk7R@D=<6I|P(7P7$h97IPmn=iYPf%zXX*`3ryt=vc@J)@CYA{Un+{+7IJ+ zHuv_H`F#tfpfXYKlozUK?7bLH{81_>>;zGe?h1@ndmu0$$FF?{28u57CQ0{w{k@RS*eQTd#WmboA3Ch{oOapooj8 zS*V^-+25b1{?x@K)TuCDP;h-&9K_xpD^u3{YTC7NSs)z;SFmAWT~Ny?&Z1m2&=lln zx{#e(=jqTbuDQ6bhqp3hNYSQB#+Il9B%; z(AQV``y%(WLTrMA@d1GxBVIYJ#mu7@`h4dT><`(oL#vMg6BlURC4j!ftcVqqxuc8U zvzbYMw^G1-ra25~jxE@ zDv_a1-z38gBJS{|G=FEw!4bBy+BQ$OsUVMAxXCC-Y>n|YJKZLt4D%Okk)QmE&JVT~ Jw78u^`wwiFj{*Py literal 0 HcmV?d00001 diff --git a/patternsByloops/Pattern1.java b/patternsByloops/Pattern1.java deleted file mode 100644 index 4546ec7..0000000 --- a/patternsByloops/Pattern1.java +++ /dev/null @@ -1,18 +0,0 @@ -package patternsByloops; - -public class Pattern1 { - - public static void main(String[] args) { - - int n = 6; - - for(int i= 0;iTNoXle3T-Kn7zs;UIHdFd5)x8?N zs8Y{xC=v%gfUn>mxFI0CO^Q&Za@d)j-I@2^%8KZ^FH|oI1eJEuS5a4`p^ncE&FpnJ5p1;o$KN9MNQJRrt?{z`Pe&(9!+6kYc8j=# zs)foqm7T*$7K~h6#wryiQwm;P6o-j_z{-sEff}`JToD-FmV>LPS=bO%=N#wLT-32C z$d7d;p&Azn(Gb^NZ0YW;d1ge_rb-8FuzG=ZfxP2-!WD821*J}=`fr}9@!52oPBKmV z!Q)WRuk`mx?rMeD20P;m0tR=SIjzOWrx*IX_X+lg`L#oTq<$jmAx0z9f`3siFPku$` K2f+l5Md2S2^N=6_ literal 0 HcmV?d00001 diff --git a/patternsByloops/Pattern2.java b/patternsByloops/Pattern2.java deleted file mode 100644 index 7a507b6..0000000 --- a/patternsByloops/Pattern2.java +++ /dev/null @@ -1,17 +0,0 @@ -package patternsByloops; -public class Pattern2 { - - public static void main(String[] args) { - - int w = 5; //size of the pattern - - for(int i=1;i<=w;i++){ //i for vertical Stars - - for(int j=w;j>=i;j--) //j for horizontal stars - System.out.print("* "); //printing the stars - - System.out.println(); - } - } - -} diff --git a/patternsByloops/Pattern3.class b/patternsByloops/Pattern3.class new file mode 100644 index 0000000000000000000000000000000000000000..3ee38b0906b0dbb8c7209b378610390f867604c3 GIT binary patch literal 712 zcmZ`%O>YuW6g`(27?=(P!G2h%t!-7nSQai^P`l8?#00eo4I5VvI>EtVh75yA_x&Zt zgtabe;=&)`kMK{pGb)}p)R-o9@$P;1y>sq8_rCY__vbGF9-?6(C0HM;ICi68^7zyb z!||kfw1^*AFa^b-daIhg3I@%Wy`kHW1(^dc@Zv*(QLA?a=9BQmwP7IVAdQTm(DnlN z#dOqjqhrMRzN<#9EY<|6#c4re#uwAEJK;3y zyH7nmzx>}P+1Cnj3+#+92&A~<%xNt~O?shEH$EZzA-T3`^)*OXqIDJk`aGi?mQmn| zCeN76q~9-Q4$Mb0>{iT^!x@%8qF7oz$NHHu->klye`kD-n`bGhR^HFQ=_&?vl^tYh zE&UI;TVh@ZYxG;JahqrNQA`vx7FF29PQty1UF=aq8a3kfsKP-Rcepcfmxuz)U&xC5 PVgH literal 0 HcmV?d00001 diff --git a/patternsByloops/Pattern3.java b/patternsByloops/Pattern3.java deleted file mode 100644 index d2a20ca..0000000 --- a/patternsByloops/Pattern3.java +++ /dev/null @@ -1,18 +0,0 @@ -package patternsByloops; - -public class Pattern3 { - - public static void main(String[] args) { - - int n = 6; //size of the pattern - - for(int i=1;i<=n;i++) { //i for horizontal stars operation - - for(int j=n-1;j>=i;j--) //j for vertical stars operation - System.out.print("* "); //printing the stars - - System.out.println(); // for new line - } - } - -} diff --git a/patternsByloops/Pattern4.class b/patternsByloops/Pattern4.class new file mode 100644 index 0000000000000000000000000000000000000000..316241f68ebff7b0fc705bad4167178a432b3b04 GIT binary patch literal 768 zcmZ`$O>YuW6g_tsm|+Sn1^ZzE+xiJu%Z5ZFZDZQR#00eohK;KSo#0TIA;VzOeSb+~ z(zPyX;=;YI{U_ZS70(Q9Op}_I_wM&S=ic}I&zG+N9^;V#O|U#vL16ptX!oe^dBah4 ze`?nZ=z>g7y;s$~a=X>n?VjBU1c@!jb%Gs1tW<6Z^gZvuwh%)yg*Xy|xrXD~uf~J6 z?Y~j&zAeZ$ypHO(l<$Q0g;NjSIU~VJ*ZDw^T-*< zUSZih8U^+sg&SBPLvKvN3)5o9tM0QhV7;vdbrVYhS+j5xc>^ngTm*47D}@4zg7`2j zWT(<~JWQ+#v`W-!J%!uh5{#&#Px89*yPPw3%?QM2g1q2$cze8uf^;)box_)Ec(Ev} z>5cu4{oDyxnZEp;&5$kD!6EsXfJTk$=WEcaQVM0f@)_pGC~WZ!!(hP--_$gLGEFOq zS>%ycId6SoknGXVMwg zj!?;bLWxx4O8S7|H4XIKiORHkO2)Fe*vbSny>%> literal 0 HcmV?d00001 diff --git a/patternsByloops/Pattern4.java b/patternsByloops/Pattern4.java deleted file mode 100644 index 3635f7e..0000000 --- a/patternsByloops/Pattern4.java +++ /dev/null @@ -1,20 +0,0 @@ -package patternsByloops; - -public class Pattern4 { - public static void main(String[] args) { - - int n=6; //size of the pattern - - for(int i=n;i>=1;i--){ //i for horizontal stars - - for(int j=n-1;j>=i;j--) //j for vertical and for print & handling the spaces - System.out.print(" "); - - for(int k=1;k<=i;k++) //k variable for print the values - System.out.print("* "); //printing the stars - - System.out.println(); - } - } - -} diff --git a/patternsByloops/Pattern5.class b/patternsByloops/Pattern5.class new file mode 100644 index 0000000000000000000000000000000000000000..01175383ffcf448950116749ef20cb73f1d81f9e GIT binary patch literal 855 zcmZ`%OHUJF6g{_{>9nOlZ5hA<3X0fPp>DuLu!)cONUD_7bmOA=S|;s4J2ROMChYkm zMibV$z{G_Mm;M`F8e=^(_y`F$neRTnd+s^kz5Vj@<0k;OamzqVFzcxxuzY8D|FG}6 z-mp?Xjn@rmg6y7pr7C^pbSvBKJ*yK45?i)o2US75SZWHi2kx$wMjWXObR-0mHQTYC z9}L=-|3bCO=;_TWYYG#Ed`|)3}H^0|h}oqBvWX!8{fO zx)%c3sd%1_BrXeL<*3zC23Nu%7!jgR@tX3xd}scgCkRpl+i490<+DPb3X)!{XW88z zxeTv0^i+rA6Pw>2zkR`YBT$|FXUdDFXkb~8Zny`2$9iOkqaOdWy|wT)SOSN@WdkvK zTn|r!QH54$_3{TK-$mDHp5ZkJ7~`2aEubA|l)?linITxl*et=^PJAnyxI3@yR<#Z7 z7}bRh{TLJPkjLd{Ok))@Sf{OWgZEItW7gDp8;XAty>bUvvCJrjZCt|& zE{D3a$O!_i;j--) - System.out.print(" "); - - for(int k=0;k<=min_stars;k++) - System.out.print("* "); - - min_stars+=2; - System.out.println(); - } - - }//end of main -}//end of class diff --git a/patternsByloops/Pattern5_2.class b/patternsByloops/Pattern5_2.class new file mode 100644 index 0000000000000000000000000000000000000000..50ad91c6b8bddbbc589bb0faa2eeda91cd4fbc39 GIT binary patch literal 825 zcmZ{iQE$>v6vzL!v=mr35C&6Vy6L8XZjC151BeMGMiVws3@<*If(F$O@!_JuWWO zkjJKgGV+xyRk#c!f*S%NsI;x&rhg4;AQ%u{HryUhn!4l&6mfxgL5|TU-%J@<{QCl{ zEzjtFI50-Rg{jyPh_#%F+clqA{;kH(Tea_VV;ej#dkaYP*b7>fk=px && j<=py) System.out.print("* "); //if condition is true then print the stars - else System.out.print(" "); //else print the spaces - - px--; //post decrementing the left print control - py++; //post incrementing the right print control - System.out.println(); - } - - } -} diff --git a/patternsByloops/Pattern6.class b/patternsByloops/Pattern6.class new file mode 100644 index 0000000000000000000000000000000000000000..904edc559e5842296326d67d4f96f86b1dbad516 GIT binary patch literal 766 zcmZ`%O>YuW6g_Vk7#M-JV6hgc)K5U|EHr+Ew$YlHn4mVnuyOUE6C66skYOxap7LK{*>;FI-WPQF-_{?z5DU*z31F}-}gUXz5;lNy9P9YrLhb{JMbo3d#>+~ zC)W1NeqcZsm>iIl)x+wtsI z(^1b3-pHP73l!RZU%FixILbb8>ft+QBCy>4AAXCqN7C^GO7*wxe>^&2;CO>pqnp73 ziUta2Sa$X%p*_mtA{NQepOWz6EZOm`ZDxkdx8@0vX zM=OIo=IBw$KUhqs+)A&PHxBWrtnX|dBL4~Vh0+n0_7hRHau6Nsr_PnwDXNtZ(J_OL zP}|p{ihdA%Q^*M@7F%PO0Gu tZr~<4>e#?7Y8s=8s8dUzMy(NRO~x)D^&5r|zqkrBWBz1|f)J|6oxhdxnt=cS literal 0 HcmV?d00001 diff --git a/patternsByloops/Pattern6.java b/patternsByloops/Pattern6.java deleted file mode 100644 index efb017c..0000000 --- a/patternsByloops/Pattern6.java +++ /dev/null @@ -1,21 +0,0 @@ -package patternsByloops; - -public class Pattern6 { - - public static void main(String[] args) - { - int n=5; - //size of pattern - for(int i= n;i>=1;i--) - { - for(int j=n-1;j>=i;j--) // loop for print the spaces - System.out.print(" "); //printing the spaces - - for(int k =1;k<=i;k++) // loop for print the stars - System.out.print("*"); //printing the stars - - System.out.println(); //for new line - }//end of loop - - }//end of main -}//end of class diff --git a/patternsByloops/Pattern7.class b/patternsByloops/Pattern7.class new file mode 100644 index 0000000000000000000000000000000000000000..1694ff48a9ccdad52c33c4fdb3d1b6549c475f4a GIT binary patch literal 759 zcmZ`%O>YuW6g_Vk7#IhN&|)pre%LCYGVZ#dcA<$03DqVvY+OBXLLb5m86GBe-Cxp8 z-Rhzm7ybZ$gFnKxQSl7aG)?N_-8=Wbd+s^!-ud?D%U1w9cx=HCSRP5Oz0e;&Jst$X zXzU)$;~fj8K(;U6N_Qarp8K-X_qtjjv8#Ng_XJ|)N?X8u7QFUs#E^0jM?zqsseJFn zWZ3b-L)jU40=Z_;m4mhnRTN(&O?{-s0xQk`@z>dVD3vczD8Fi6>S*au`Mr9jox)Az zE#$7KY#ooaH*~OwB`ORi6udMCtH3=VQWNjVVLgdk0!DS+#%&ZWtO(?199PR6l&~rg zA4N#EDqknW#u_#(tP5l=W$sIT-g6aAJN<8gwMYy$Kmpu0VDO6@qO};g z^nyNK{eKJ)!0*}2q<0g$#V2RjD(;;j^AXux;T+2+ zvFU2*Gwz&De=v29trKHfD(che_lPEjh-MQ>+9cc9Z0O7=7HQW=vCUkKyNx7N=QOyF pG9v?zP+^Wkp?$z(P*wpC`4!_Gh&F%265=-size;i--) //loop to print the stars - { - for( int j=size;j>=Math.abs(i);j--) //inner or nested loop for print the stars - System.out.print("* "); - - System.out.println(); //for new line - }//end of loop - }//end of main -}//end of class diff --git a/patternsByloops/Pattern8.class b/patternsByloops/Pattern8.class new file mode 100644 index 0000000000000000000000000000000000000000..a228241ded08ee647cf117d108c2b00249fe6ae2 GIT binary patch literal 817 zcmZ`%O>YuG7=8v87S@GQXt5S*i&h1!UB8l=KzpdM4GGmI7%rX$+|Z@4OP0l?p8HE0 zlb-cZjR#Mj{007uo{fsnE^V47HIte5`+c5yXMX(s`VGJuo~Q^3%nhXHnXWzDJm@*j zU})@4>}M(zfmBz%lSWV49phE2YqmXsXw|YUZ$ltlEHwp`=gwPGLl|)#5kv*1>XvQ3 z9Q9kK`&zbora-#xv}La;UCX!6oQk(+4F%@w|HH4acVAkzK(_d%e!-*Rxt86jl$vo& zBcmdHiDlzp=$U;TGngeqXGFrYlVZy;c3J7M-jw}H4A%w3l7<_|shAhY1Q3_AbmXxh z5E=M|>{PsphlWKIR4fT3FIetKZ%@Z9+$Iaz;zgBWtyGKQ4nfO4=sg`pe_U$NyT@xP z((N!YbH!yD99r)=N>SssxVzl@0*Qtv+xt6ma5hz~;f&n2xn=otPn1 z{Df3GdxE*cuvo}{!Oaij)7-g#Iq;7I|IzrAsVBI57#inu-qHBG4;$G< literal 0 HcmV?d00001 diff --git a/patternsByloops/Pattern8.java b/patternsByloops/Pattern8.java deleted file mode 100644 index 8ef97cb..0000000 --- a/patternsByloops/Pattern8.java +++ /dev/null @@ -1,21 +0,0 @@ -package patternsByloops; - -public class Pattern8 -{ - public static void main(String[] args) - { - int size = 3; //size of pattern - - for(int i=size;i>=-size;i--) { //loop for handling spaces & stars - - for(int j=1;j<=Math.abs(i);j++) //inner or nested loop to handle or print spaces - System.out.print(" "); //printing the spaces - - for(int k=size;k>=Math.abs(i);k--) //inner or nested loop to handle or print stars - System.out.print("*"); //printing the stars - - System.out.println(); //for new line - }//end of loop - - }//end of main -}//end of class diff --git a/patternsByloops/Pattern9.class b/patternsByloops/Pattern9.class new file mode 100644 index 0000000000000000000000000000000000000000..3f33e35e70c53a802d28b94981bfb87a8b606f14 GIT binary patch literal 818 zcmZ`%O>YuW6g_Vk7?=(%1&g&%Em{?@cKk{j1MQ;58WO5aFl<~sa6*T|3>gNKy6!J& zOuE)ZH7;Da@)!6sx;84F8QL^W>f*io@$S9n+kfwI&cuGIK@~`K7D$M!b_BE?cuKz-)EwRA*~Fc3vdV5V+6 z*2_`9WqGeuy{2n$oia`_!rWyY^6Eq5ePo3TyYJ?FeLxZ|dhf8op;col2>h zz$`Kv(id1Z_J_XJH*f`WWay4acy5wxyXFovedb%TUy0+YfLPLT4LJ=90+|rvVw8bA z76qb%Ad!`dm+{bX0|gCB0@LR#x23;p;3jU7g>11=wOA|F;S3R-oZ1NFvZ)L1W+bvB`}Q{dV=JiET&Svh*fjzN2sbB zN0|PER62W%`Gbg9%zwf4595>EnSVL-k3;|A_=KUyxO1S4^Ev-;{5^n=Ab?*Df%!)f zCy-9)DQ-0wb`r}ZutK?p6xR8^g>)GGgk6yeN+?q*c#eCF95gSXkg;Sme<^ih`zf literal 0 HcmV?d00001 diff --git a/patternsByloops/Pattern9.java b/patternsByloops/Pattern9.java deleted file mode 100644 index d9ea106..0000000 --- a/patternsByloops/Pattern9.java +++ /dev/null @@ -1,19 +0,0 @@ -package patternsByloops; - -public class Pattern9 { - - public static void main(String[] args) { - - int size = 3; //size of pattern - for(int i=size;i>=-size;i--) //loop for handle stars & spaces - { - for(int j=1;j<=Math.abs(i);j++) //inner or nested loop for spaces - System.out.print(" "); //printing the spaces - - for(int k=size;k>=Math.abs(i);k--) //inner or nested loop for stars - System.out.print("* "); //printing the stars - - System.out.println(); //new line - } - }//end of main -}//end of class diff --git a/practiceProblems/Cylinder.class b/practiceProblems/Cylinder.class new file mode 100644 index 0000000000000000000000000000000000000000..a5b1aae7f739ca3ddda239c6c4af6bc81f06586d GIT binary patch literal 1448 zcmaJ>=~B~B7(KTZnqrhv7B`eAExa!&$TPX^uSCE z9Reqt?8l|&Nw+$eudic{JJ%r9h6Lhj>eA7T9)WmOdK1zvE|OW)%nZ!54rvSzKc%%- z$3FCiS`VxRyGF!Ob5v=?4}8D>`+c9%GIShNTCMbzvt=CpI12)Y&N0pHQb2dxSBO;e0ffj1NI7iTyTVzFcZqgkBk!n#O z)!bhHYY(=ZAP6xk(3W>b^$FAob<2l7uaBVrh0_`g| z5q1#*F=()zdp%U(x`U@UcA`Br7E$U&dG}=%iP;tYGzJs>J~{`xu*=6DF8h7-eZ!$u zn6pVfaAMF$%Evh$mwcoff}v0_>|-pM@o{&fbTX9YXqL>cNtGjxoEl3@oQFRyWf~42 z(!^BykJj|pnH>-KY0$`RCpmSKRWFaK5^s3(0X_JP-2r?Q+{h6g`_SE3TR*cGBjnRE3f%fyAV3Xoug z0{mc@;T_-!aA%yEc7_Mwp%~7tB-_EEKcv0)?A^Qfo_p{9{m+ZP0Ng|+g#m%tdf=2p zw=A~<|F9}+jojul8I;|ITuos}VEl>m)X7yHuabLk_(YaNfq_O@AY0TM&CsppN@d6M zWRMp)*Jx^^{nh=N6a3f^5QQG}T7q`$uJ<7~`jE8*F*eFo*K@-U1P1NJU4fyy{*g>! zLSUjVno(pimBQqS6iPoeLRm9$9v7I0>j_LndANSA;MJR9DGa1j%cn7p856UZ6ByZu z@0_+zwO!mDg}_A-fXJNr3VGOpQY~C=Df}x~0O^im;RTJq*S~PJc zlHM|5!XR%&*OT{~wL=-~I4q7prs$WQ>aG*GO4nc-gUG2+$H+(c*d^!l#s4oVi!@Yo zROaXHhfzMdxJ=yjDtVPm7HcNn#Z3n8HyM7HqHWqF6s7QG@|eYS2-T}*tVm`l}Fsj8lVZ^?}+ zMCgZ3)$;rmR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@tF z-KG!He%{AC7Pu?oOWwN995y<57dM!-gf13oWr@AYyi08JRr=rOnSnLFoPo8>`!|q3 sU~1FAO#_YeKPH5MTLQ2O)&U=H=A;kwHU5FQ$R(Hin*s?k(rP#V1DUiPVE_OC literal 0 HcmV?d00001 diff --git a/practiceProblems/Getters_Setters_For_Cylinder.class b/practiceProblems/Getters_Setters_For_Cylinder.class new file mode 100644 index 0000000000000000000000000000000000000000..d0a3dfb7738a35683f0de16e4817369fc7d456df GIT binary patch literal 1182 zcmb7CT~E|N6g|@|ExVTG`%6RzP$-K~zY-HMJP1KaRwXXs&5)rCyMx_!({@StKPJAI z7!7FRgFnC@WxUg^pky^M+4Ro6JNMjk&YkZ+zJ3Gn5D#n^49l%p_^I;cb{y>ovYB{K zWtz%3*{kJoGm7`tPXZMl$k>L-FmNP}g%^mh?!DYUl77lyHKeLH=)krpiN%3xCzNb3 z6k1AB>9Gn`x<;wHxXWO!M+dTm0?H0bxWdq1RiS**Ztlx?M-UB$p=#udU{}OS=Xudg z8;Wqf>VJ`5Whf>xeU?)+-L1vlBE~RbWBd;_wUZ>3O$U>>N=&0R=^3qNVpZgA$0|%~ zX)Hx^wHMbIp75Q9zN)1#+;q?bi=nTU3jfV>(aH_ex?knn zFx`#Lyr{!MrF&%>SbW`j=J{8P9eE;Y|~ZNA&JdFgWV MLf7Vd*@*i;0V9dYvj6}9 literal 0 HcmV?d00001 diff --git a/queues/ArrayDequeDemo.class b/queues/ArrayDequeDemo.class new file mode 100644 index 0000000000000000000000000000000000000000..f5f303075d4376c163312da6b3cd896eecb6910f GIT binary patch literal 1272 zcmZuwZBr6a6n-wEyR2&x2$q$hm4PIrWtNyFqP^iuVKh!tGb`M571(vzb;e)R=lXz6 z&NO{%rvK3NN1E!~1q+a2=A3)ZJ@@SM9G>(2_vbGFW{{WQVF>Lz+~L*af@Nuk8BS4# zmkkMC2LG;hpe0LMWjndHwaW`OL(iOE(d~JLu4pXJ;9WF|TtOFnD!S3b(4W;SeAOv$ zace`{DshHD)+lJDyk_YlZX~_-j$UOL%y#^EiW-+Sy}}TVzRvy!k+UtmvYm<%@Usj9 z?uBFPr6%kO{P4*bU|qh>%K!f+$mnEdFs-a6G~Xo%*IM6Im59E zd|4Mu6Kvhag!r2=0)j@H3wY>6>qb_hC`q1??;byb{K36e$ck&gi(ay7y?}flMLwKC zKV`(@pH$%?|MnRE%_G{@cpz9qC>}WP+6%6|6&tr{h7@kuk*vSx?7j()|#s|+YOiJ(%Q(}V>9=!Yun_edl literal 0 HcmV?d00001 diff --git a/queues/ArrayDequeDemo.java b/queues/ArrayDequeDemo.java deleted file mode 100644 index 4443dd3..0000000 --- a/queues/ArrayDequeDemo.java +++ /dev/null @@ -1,24 +0,0 @@ -package queues; -import java.util.*; -public class ArrayDequeDemo { - - public static void main(String[] args) { - - ArrayDeque adq = new ArrayDeque(); - - adq.push("A"); - adq.push("B"); - adq.push("C"); - adq.push("D"); - adq.push("E"); - - System.out.print("Popping the stack:"); - - while(adq.peek()!=null) - System.out.print(adq.pop()+" "); - - System.out.println(); - - } - -} diff --git a/recursion/Factorial.class b/recursion/Factorial.class new file mode 100644 index 0000000000000000000000000000000000000000..8d80eddca161d8e6113f1f15f4307196e22d46b1 GIT binary patch literal 1198 zcmZ`&?NZY~6g}Gp(}qAl__S6nD%utyet@V2R8X`vpfhzk!}x1S0|wKilO~QlfIoc* zAAle7qc}3-1NcymchmBrl*!C)cK6(K?w))1_n)7?0L)`uMucI=GmXG&S+1k4a>I8$ zi`z0JhU5bVn)YsoiI7shT&O5uNU0b^g7lrB z!NAH4167|JAJ=&Eh`Yfphha4TUO&md>U);6T`JUMj1x(C5crm@RSoVqrWZ#BSs9o9 zxpZ~6<(mx^mvMz5B1lI%l$NWNoo3(@tH~QB1!Kqw111>8^F1MjngCr_aRZYKvSWVs z%MSTTHkO6#o zF?Q1mi+OB@K-^PtAG1_h-fWsqogqtBpK-3MQi|aLC7D|c$sdZ)M-0=w$j_w^q9qZz zAhasyYYE_ziYIu=5cAzm)(pe>vmsQ1WjvR$Lfsr1L=`$^or)L21i2~Pw5g5~_qM64 zhI+IJRk~%+Q78Y?JwlBc-#U6A)O!^MrRoNrVXj)D(+7{;pAk7=g4#7o?+i3D@jPgh zX{FK3XznW>AoiVpB2Z`)$AE->8r2Sf<^fv8Ma$EU2-XQ9aH)*+4Fj1k8L9pQNo!Bp zqs?eYG#IMNq!^8}k!wJZ@vLjb|s<7!64hq?)8JMFMHelB&2?kt9d}t9VIs bKdoP(O!7%ghM7eOokIn$L&tQ&M6mW3E4l=+ literal 0 HcmV?d00001 diff --git a/recursion/Factorial_using_Recursion.class b/recursion/Factorial_using_Recursion.class new file mode 100644 index 0000000000000000000000000000000000000000..3bb5894139cc5c6c753178d90ed3fa315038cac2 GIT binary patch literal 1246 zcma)5?M@Rx6g|@}Y`ZMIaBgKm|ox3mR*h5Py(iyWrw>x7qF*c>sU< z5Iz7upkxHIeYo6&Eb#u4HOp#K$ zkSQu)h^gp9gz~Yx8UrgZ^p;(&eO%@Bj#iBu7Q;~bed+iRh|m{8trxOz>+6^t?j1nFRl(y(&{tM0kPs`FZ2!7x(7kTHgl^tq5s zMS#XtT*m~1Z0Voff<^w4tp%ZdQ$-pXTH7A&9?QI;v^z2~CK-lL-)YG+%&P8$Fhy1z z)i-5tr4(e56KUNh#&%kMagWRph`TE8VTLNr>vi3#G9=0BGtRYD@*&)(BvT7M`2!L9 zkYVaP@(U@1XkJ9l3$5bCS^~JJ;xV2ugj~CoHN!yqYzUQL3D0CKGxYlgQH4%er{cLV zL9PooO{$~Boo(u>{&QM{D&5fNsFnZ89-+nzZ*?9J^6P^WE0mGk|eOSj~j=`uE%d3U^>~vo%n1Mb7M_BYGR>@r^nYA@<}438l^8r q0&&ccs<>8`BuD@&ctLXytzV)*@=;9qnFR=)LJ_Zg$4Z0=VD&FK(HOe` literal 0 HcmV?d00001 diff --git a/recursion/Factorial_using_Recursion.java b/recursion/Factorial_using_Recursion.java deleted file mode 100644 index f31d5d1..0000000 --- a/recursion/Factorial_using_Recursion.java +++ /dev/null @@ -1,21 +0,0 @@ -package recursion; -import java.util.Scanner; - -public class Factorial_using_Recursion { - public static long multiplyNumbers(int num) - { - if (num >= 1) - return num * multiplyNumbers(num - 1); - else - return 1; - } - public static void main(String[] args) { - - @SuppressWarnings("resource") - Scanner sc = new Scanner(System.in); - int num = sc.nextInt(); - long factorial = multiplyNumbers(num); - System.out.println("Factorial of " + num + " = " + factorial); - } - -} diff --git a/recursion/NRaiseP.class b/recursion/NRaiseP.class new file mode 100644 index 0000000000000000000000000000000000000000..3c4dc942975301505a427ab2ff3e0ca2549b4b7e GIT binary patch literal 668 zcmZuu%Wl&^6g`tTc4M42eGnkw(UwA;F7UDvL2QtaEQL}L$cEL#9i>weJ93;#{gr-0 zH?V-Ji+%tfg*Y<_Diti|&fLd2_uM-_e_dSz*hlE0B(R#RWR_2LmPQ93q@Jon4~{_n zM4rlMB-3H^esH3aLco2cQ(e3kD2MI7fb%9hQa;M42B^RlSn29i9n8i9m4B3jkrG(z zW{Dj2Wv-3C2s*{Fo(imY|7qM2@KUQ`B2WqAxE=eT!T`%y5fCX)%)@N0SIFecJ30A7 zI+mL0M)KV4AV$>Sgt1+Z%!g*o{|FNBd)X{c)LU(~6fE}s!mwkD6PNiv zpyd|e(t7kF-hy{!?+2E?@==0MYtp9l4s9?m;9a9vHCtoEfIq=uJy36*qvBjNn=R+) z67}N?#>$pw**0}q=aF;C@-^ldtYMvXL}P<5uF0Z=%N7mXTeNs-^-{z)+;=^af5+n+ YnZBh8NL%|$YJeR)BbmT++7fnu1K~q>#sB~S literal 0 HcmV?d00001 diff --git a/recursion/NaturalNoSum.class b/recursion/NaturalNoSum.class new file mode 100644 index 0000000000000000000000000000000000000000..573879742b1da7d2daf803c9b99b7d15d6119fed GIT binary patch literal 659 zcmZuu%Wl&^6g@X_>cnx|q@ksRSIaYDftLscu|Wbw3IWL|8#YYbQJCUK<=B<_H+(=h zumHq@58$H^XOc*1rONWXb7#&u_spHY|9<}g@C=V#R0Mmuj>>#)vNRa0qRdr1&cZTr z;RssC>Qn`>N@u~l>9LLq!Nv=dn&PFP+UrjQ&a3Q5d#Iw}qlOK^_Q<4qTqaYUe^Ap{ z3wB0Xq~eLnjjdOkPVw2y1^c6`yAP|F8~p3MuL z__&5$`pZh%-CdGR7Q833AYZFw;6ZTR$3AWlH!l-*>ka!u4>xh!#VtW+(eg6O#~s`i zxF=R9rZvm4BT)H_SLs~gQy^phL&0WPsOZaEb+Wp@7iMK1>DR_isC{wpPi<=)(qWaa z1V*uwWpr5u%)(rI@)PxMTvXsO+G87=jQ$e9yveG8Eo^hglAjZ8an0{&)qi2{2fAws zkB1iS@mtF@aX>FX-41Id^Jd`*Xmy>hs5$4|u5(1SPv^u{7j~9fTWs3Cpw+@X+$ZM2 N0w*rz9&%a1qyKSue5(Ke literal 0 HcmV?d00001 diff --git a/recursion/Problem_01.class b/recursion/Problem_01.class new file mode 100644 index 0000000000000000000000000000000000000000..ca50119836377feab9f5e08d2ddb6f97d4041ae2 GIT binary patch literal 653 zcmZuu!EVz)5Pg$4b>g^9nzRK1rO*~gI1o5hD2NLZC{k!E1?AEMY}{44CAK5SM&fVy zfL`DLhyx$ck3zgnBBhlo%QHJWZ{EC_z5Ms*FMtC)agh^jBs$2FsfnZZaS{*5I{f(j zg$qYeJy%~;d#s{S`)GKsgH*8c%0wo8Eyy=p1A+4Nkf z1n$HVjVaC6*afI$#6jve=oH8y|E^%QpQ_;Vdo@{1@Acy>3G`cI_fuIe{h4iyht!wn z`+!#LR%u;EZF-?EJpF~@cOG)^Xl>fsGOa%c(62HoVGR}D*y5K&TU_}Es>R>f`iaJp z!ei3HJ$_4?G9FM1P_(OB(7c;z0;&z?8w$=vqv4#A?b8Ku`I($K*BYCyU*W1^7kk9) O&v4?B?h%hUJpK=!{CNEU literal 0 HcmV?d00001 diff --git a/recursion/Subsequences.class b/recursion/Subsequences.class new file mode 100644 index 0000000000000000000000000000000000000000..23cbd05cafbe4dd461025ee7be2c4b1fa76e2705 GIT binary patch literal 1374 zcmZuw%Tg0T6g`~`P7((pfgmbDP?Wqdh!0c{1r$YtS`~{b%8ip`NCqd9IGI@L+P!;s zuH2%FKxxSb_znJqRj$#~6GR@VO6GRozK?TG-~O@vbql~G9;xsN^f^YM;ndBloyj%w zb>n5junR_Ag(A?sroYlNmTs3akMnCr!4)_%ZQ7l& zX)5vTurGu#dQ?RA5opD0=tYz)EW<9jWsk*T0LKL&lTK(jiBkf>I+gJ13q<3KiFPdn zVj7O2OT}q{;|FogHB75$II`%lhBG+Jo`tgR%u+&y73by2ISuDADxkj7t%mV!VnQI`R$Foj^v2r& zqHdH&UhP5Nyg0vZ^JaV6+zSiWE4pRP$^c>VzbMd|bM?ZDCB5cNhKj2csG^%TCo|rr zMq)XDTWs?B&D$VmF|T57|24m)?8?^#euaDy{Hok#XgOr) zNNynTnF}8W4&E`K;3(HxD}c6>yP%w{RG#a(4xEqoZdVQ594Ci9l$G7^c~&CFgs_OGSnv zGuaf`d#t;@;C5OPT9CxkB>qb(-Qsf6!<6JMMMh~d8ABiKX^eZAldXDqNPIFU=Aq}r dqJIZzh>ZUs1@nE|=u{Dw@QxBzmT5jL{RN)gBOd?& literal 0 HcmV?d00001 diff --git a/recursion/Tower_Of_Hanoi.class b/recursion/Tower_Of_Hanoi.class new file mode 100644 index 0000000000000000000000000000000000000000..84e5032be0eaf1a04486efbfb5ce1e51aaf3c2aa GIT binary patch literal 1180 zcmZ`&e^1j;6g_Vnw3`LS1_QRCML;_gCjLSlqEJPb3}-SjV*GkY97Pjs<4H(#t=4gRfdS^)U6o8h-w(XAj3#W*w(vF zbI)?O`Ch|fNR*r!Z&bM}bH0b?SNyDP&}iSwa{=YG0TjK_OR_i0c||Kqr-Wt7X}BhOA-c`oL$^ z3My_gsJiFuo>!QY@$(FemsPkjkF0!KgMl2S^PGSY!*fB8N(=dz?755opJ!NFchm!0g*<-Q4P_M@o3iNgKyHxQs=-F45f!XvH$t9JR z2s)Z1U?2)n;hismd#K{^+R+woosUqH3kpsdANz!%uR){9-2)o2`!%7YirpNIjFC{(<~CaG8MVE*>Nv z6VQ)%axsEZhkZI}q5>i_KqTgf#ysNmX-82-(x=0) m[Math.abs(m[i])] = -m[Math.abs(m[i])]; - else System.out.print(Math.abs(m[i]) + " "); - } - } - - //Driver Method - public static void main(String[] args) { - - FindDuplicate duplicate = new FindDuplicate(); // Making an object of FindDuplicate class - - int m[] = {1,2,3,1,3,6,6}; // Putting or declare values in or to array - int m_size = m.length; // variables which store size or length of array - - duplicate.printRepeating(m,m_size); // calling above function to pass value in it to print repeating elements - - } - - } diff --git a/sdeProblems/RotateArray.java b/sdeProblems/RotateArray.java deleted file mode 100644 index 69b6ef1..0000000 --- a/sdeProblems/RotateArray.java +++ /dev/null @@ -1,38 +0,0 @@ -package sdeProblems; - -public class RotateArray { - - //function to rotate the elements of an array - - void rotateL(int a[], int d, int n) { - for(int i= 0;i=0; i--) - { - /* Find the smallest element greater than ar2[i]. Move all elements one position ahead till the smallest greater - element is not found */ - int j, last = arr1[m-1]; - - for (j=m-2; j >= 0 && arr1[j] > arr2[i]; j--) - arr1[j+1] = arr1[j]; - - // If there was a greater element - if (j != m-2 || last > arr2[i]) { - arr1[j+1] = arr2[i]; - arr2[i] = last; } - } - } - - // Driver method to test the above function - public static void main1(String[] args) - { - merge(arr1.length,arr2.length); - System.out.print("After Merging nFirst Array: "); - System.out.println(Arrays.toString(arr1)); - System.out.print("Second Array: "); - System.out.println(Arrays.toString(arr2)); - } -} diff --git a/searchingAlgorithms/BinarySearch.class b/searchingAlgorithms/BinarySearch.class new file mode 100644 index 0000000000000000000000000000000000000000..004ec80fe9e18003b66e62d72748ecd7decb688f GIT binary patch literal 1302 zcmah|U2hvz5IuLj>$SITyH2_Z4K|qcYi*}-DPW*(ZJLToQC*DWD(W^;)wR7OTh_bQ zdX1Vl$}cGr5-)jyheV>NuSon3#E(D-IM;SdN-JT>cjn&loH=u5{OeyoJp=F|HgqTg zrLpJ6{aruYxgP99v7hV?$F&VVbmP75G@?TlFdw>KxwXIzcWRy9L$99*q_6s+pELzh zc6m!cy%7yO11V&4(2y25+4e*4v&pdM#dq9Z;0Y|WqrMw#xv?+r^G7w=^~VCM?f>J^ z5Xkk8@Dj+_+nfB9Hw_5nb2x#MWaGxMfU>|I6F%=sAI* z>xTkM_ICTa3Vb9e`E8K~lt99BhomveXz?{lo~Xyk>|sbFuGUnw}p zZODvzj!X0r$B;xbxdcwxucmNrsvGZc#*42}n4^k%91r_TQ3>Uf>x^>BJ%?s1qM$U22>p5nVbE9_Bd~li^CV0 z{L2&wXcY_JqERRo23qi-u2n5<-BO<*ZE5>6|2vqKYQfUffu$b6+^_IieNdcTlzl>_ zre#-=p>GiO*tE%8i{o6g)~c0{w8QzM^lH;(Gr5|utbzk Ih^gTEKcgZ3O8@`> literal 0 HcmV?d00001 diff --git a/searchingAlgorithms/BinarySearch.java b/searchingAlgorithms/BinarySearch.java deleted file mode 100644 index d331720..0000000 --- a/searchingAlgorithms/BinarySearch.java +++ /dev/null @@ -1,46 +0,0 @@ -package searchingAlgorithms; - -public class BinarySearch { - - // Returns index of x if it is present in arr[l.. - // r], else return -1 - int binarySearch(int arr[], int l, int r, int x) - { - if (r >= l) { - int mid = l + (r - l) / 2; - - // If the element is present at the - // middle itself - if (arr[mid] == x) - return mid; - - // If element is smaller than mid, then - // it can only be present in left subarray - if (arr[mid] > x) - return binarySearch(arr, l, mid - 1, x); - - // Else the element can only be present - // in right subarray - return binarySearch(arr, mid + 1, r, x); - } - - // We reach here when element is not present - // in array - return -1; - } - - // Driver method to test above - public static void main(String args[]) - { - BinarySearch ob = new BinarySearch(); - int arr[] = { 2, 3, 4, 10, 40, 50, 90, 130, 230, 740}; - int n = arr.length; - int x = 130; - int result = ob.binarySearch(arr, 0, n - 1, x); - if (result == -1) - System.out.println("Element not present"); - else - System.out.println("Element found at index " + result); - } -} - diff --git a/searchingAlgorithms/LinearSearch.class b/searchingAlgorithms/LinearSearch.class new file mode 100644 index 0000000000000000000000000000000000000000..81c8aaf7b9a6f592b76a382eacd41936a56bf29e GIT binary patch literal 1162 zcmah}+int36kTTqm|>uHN-x?{EcMob+T#62X}rWHjVLA<656LJOz2b?$S@fDZv2k= zmWtz>n}FeD|^rv|6=^klAOSv-e(mt$il*`TP4%0Is5-K@muI9ow&Mx?bZ} zv(fh5V6)ZD6~<$gp%NWk2(pV+yk?KN_xjV-4Z2t<}#&kdFZR4Y>v2;FJd9Rn(& zafA^O7?vOpdaVt|e`Ieo9f3r#U9+1N+jr%D?=Tc>x?O=2#sBfhv*jR%jOb-LmyAGvybT!Eo-VAmesw>$fdTDHs3gtcD$Ev6j!RG!aN3z8bOuNBrFNdrz_2qQVQ%-Bbxs)kC{P`FeLM@rR*R;p^IQL5^uRjQg1^8&4AF45}d z8g0~kNNboYrJ}i3n4f-!$>o%?gClQ{Ow8`$gTJ&{ zSL%Cz1P{DaLh3U-IEbQ3yz<6BD1QS1<;>V}R3+kJ=H9t;KhC*x=l6eqc?sYaY9{ascGwN$s(_X+ z>6)S*_R3$%*m@iVey3t$LE!R9Q)p)YHV0w56+|}P#gd7| zH&ZJQ2UoEyU_SQSgTVWS>GRu#Q3ci9QJ#v8E6B?}7Np1N`@*h;BAG5o$LkJCDDy%5 zen0581g@VIaVp6etg3ax!76SFSaENJK;UBjOk8WYWnx_*bw*bld?*1Ms>wFi@Uer6 z90gNZ+I%Cu8CPjL3(XDcpKA9 z>PH70q0|{UIUcc>-uvPi)p>YrGH)e0dw-OZg3x2 zJSEbG_f!{YJ(F$et!J>Y8w657?mQy9PchsGjN&FE{uO*3Gp`!v6T3W zxggs=ru#j;bXr!&baOx9ofo*$C}vAPBX^8zGb=;9H^loxe4rRTd;N+oLwt0?YF43~ zC5Ab&%3zVQ$iH|4^NPjFsKSKB>V!pk!eV*MLL#=1P>8ea#BJOeBmIt9a[j+1]) { - //swap a[j+1] and a[i] - int temp = a[j]; - a[j] = a[j+1]; - a[j+1] = temp; - } - } - } - } - - //function to print the array - void printArray(int a[]) { - - int n = a.length; - for(int i=0;iw$uE^StPufDZi%UpAvYJpY_szB#G=f0CEIpxhve*KS$( zO9JZE%7&{$L7RanVgeltUfI3b*j{)2JI;E^73f~56rIwN<9l-7GOG10uO^UK_)4ThCE1uA}cvA%KYT)F+$zlt_rjl>Q3>S zMW@Q&z>*Qb5odC-O-9M>@XjtqqdHAXaW0w*a!rNId1 zLZFgY$=s563w7Uhw#PM`66o90k7f!z)9^|guCHShwuaQZp#u*CA7G5M?mMN1o4?EO z$=qm|A*e$bXI#e!GE(x>(&PQ}(WN-flG&hiJa6CvvaFp`t-9q6fwBE=yceVeHpum% zfsb%WAYQM82n2eQ`{J6wl!i%xo_$m?a9IM51|sX2z_fuG*)>{VDY0ze48#ex)VQJ}vi0n7Hb zi)^!5Jp;cFdqxlcYYEq)to6 zFANNzgQVDP?Dn30I1zBI$fJ<$+oah4k;=M;RShN^vruXHMR(4VPpbX(D@{u&NS*-s ztU+p27cq_+cNxw?T2niS|H4HCI!Ad7s5rpU2pu@Lb0;J(j`H#!^oVkvvR_OlqNS-P zXiwP*tBKBs%C7ap?!O6jgGS3%(plA3Y%86&EmO^>Y)ff5{kZ#=%&G)g(?Py?u+zEj zqP3q{2bl8&v!>8Vz}?8wHi_QAdx}_zpoLDZdSMcuf^i%|ANgpE)6bQH1Z4kI`+L(X?%<>7SvQ z(X495LSyWWF-D_m{X_+73_aYSbWMsuW?5y<`RAQ;19_t}a*@#xXw5A^wer z$>$`daSC%tVv&D`0)GQ52sOJM;(VjRYD)!TZ>bOtoJyphA-RKe_n9Wn zHF2?t@rMzSIQnS!Pr5X5WsmQXpmOIJ=R9Lyz;VttYkP)lW#0{k83HDt>Ig|N_utN6Hu?{E6c&YXXa+2yC0-@%OqyNR2ViQn{_N>+V>gJY&DE%}G4 zFxAAP-G81#Ebrjv$1Db-UA)VJwiW3KP&8Jo&W#< literal 0 HcmV?d00001 diff --git a/sortingAlgorithms/HeapSort.java b/sortingAlgorithms/HeapSort.java deleted file mode 100644 index 62ba46d..0000000 --- a/sortingAlgorithms/HeapSort.java +++ /dev/null @@ -1,77 +0,0 @@ -package sortingAlgorithms; -//Java program for implementation of Heap Sort -public class HeapSort -{ - public void sort(int A[]) - { - int n = A.length; - - // Build heap (rearrange array) - for (int i = n / 2 - 1; i >= 0; i--) - heapify(A, n, i); - - // One by one extract an element from heap - for (int i=n-1; i>0; i--) - { - // Move current root to end - int temp = A[0]; - A[0] = A[i]; - A[i] = temp; - - // call max heapify on the reduced heap - heapify(A, i, 0); - } - } - - // To heapify a subtree rooted with node i which is - // an index in arr[]. n is size of heap - void heapify(int A[], int n, int i) - { - int largest = i; // Initialize largest as root - int l = 2*i + 1; // left = 2*i + 1 - int r = 2*i + 2; // right = 2*i + 2 - - // If left child is larger than root - if (l < n && A[l] > A[largest]) - largest = l; - - // If right child is larger than largest so far - if (r < n && A[r] > A[largest]) - largest = r; - - // If largest is not root - if (largest != i) - { - int swap = A[i]; - A[i] = A[largest]; - A[largest] = swap; - - // Recursively heapify the affected sub-tree - heapify(A, n, largest); - } - } - - /* A utility function to print array of size n */ - static void printArray(int A[]) - { - int n = A.length; - for (int i=0; iYxd6g|%~6;4u$u%zuw!ELQ9{9qi-FQcGM!4UB3apVk_=&jJrj+` zNRhhCFX*-_#3F0Da1fyUfc7tR(PjTa7c@O@Y&ArQR9SxazW46E=iKw|{Pxeg0|0mN zt&W7iWH$&S&)=-KH-pfNo_D&HWxwn4EbyDW(xD2Zx15(wrS15e6?<*VU5^Bki=OXA zH36kiToF(o1skpj1tS(TBn3trp6`Cw>#Vuq56)WK6&Py->rQ*c2|c+V9;(rEuPZR! z_#YZoLdXySt+2W*5fvv41rn>v0>bBCT93ys+#Pyb0;y)?tiO2bY!9K#?a=e1dKfx8 zBbY!=$E9PPHFvs^+p&J;ROKM(@kyIcq;?#SX1uU^f={)$VnSd`7Sk-JaO?q<9w(Hm&RvC8&}wu0Fy7Efz~m~g!Gtqhtw8{7 ziaSVhJdw$Nuvn6|UOHG(YkOEI<;x3dUfo#G_K+@RHT6d>WqVgU%xb^DlAEmh`tYy# zDy!PNipb|)9sVwXl^D1jLmKi!g29s%_hVeMgqU|jm`COy^kAxe6gDlxl6AO|71uX_l{bdh-qG6or|nJ zfh)8n7?Cw57F93?dkPWA77Q;qJH$=<3s_)&0&VWt0>|c=27^BR~e7+ Ym@zrB8pu0CjlQO!337PCn*_f37uSjg&Hw-a literal 0 HcmV?d00001 diff --git a/sortingAlgorithms/InsertionSort.java b/sortingAlgorithms/InsertionSort.java deleted file mode 100644 index 2efb58c..0000000 --- a/sortingAlgorithms/InsertionSort.java +++ /dev/null @@ -1,42 +0,0 @@ -package sortingAlgorithms; - -public class InsertionSort { - - /*Function to sort array using insertion sort*/ - void sort(int arr[]) - { - int n = arr.length; - for (int i = 1; i < n; ++i) { - int key = arr[i]; - int j = i - 1; - - while (j >= 0 && arr[j] > key) { - arr[j + 1] = arr[j]; - j = j - 1; - } - arr[j + 1] = key; - } - } - - /* A utility function to print array of size n*/ - static void printArray(int arr[]) - { - int n = arr.length; - for (int i = 0; i < n; ++i) - System.out.print(arr[i] + " "); - - System.out.println(); - } - - // Driver method - public static void main(String args[]) - { - int arr[] = { 12, 11, 13, 5, 6 }; - - InsertionSort ob = new InsertionSort(); - ob.sort(arr); - - printArray(arr); - } -} - diff --git a/sortingAlgorithms/MergeSort.class b/sortingAlgorithms/MergeSort.class new file mode 100644 index 0000000000000000000000000000000000000000..672ac311d90d3b59539ebcd51d58528c55d3d240 GIT binary patch literal 2009 zcmaJ>TTdHD6#m9ud+qfC24|B3b_(QX>|i&PIBm$K2`z-y#z~+g4!yA8Em`6VS`1QN zBP#W&4}EBrM^aVvt!*Bhs6BBY?MG&5(;IdkSa-#N3-|M_(b zz&XsQ@CbA-SDl(&S-4VKs5*A-Zh1MKvz!HMl4=!-KzPwyHPa=tvXIWtEn4$60sjTN zV%IJSc;o%k0?J6WXld{wsKW=pKwH+XSQ9JdIm?+c=Sr49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{Xtg6{)SoNyF z^mR9`fLw_6xaM^%U{N60bUF$I229;DLCLIJB)|;TE`RFPnzec zvHpUea$wq=hEiKsG|i{IDu#l1CZNmmTGa#_#XOd9YZC6REUuwr920~x-CcIzz%@v$ zytB>9mz|coW3AY-i+j5-BPZn(gH`5R0y9nBP&sN`zqFZ^HE2!Q~6eAmts)ls_LR`P6rQq@QP;@WXeTbkRpJ5O&+`t5GBE!`T z{r547C5&Me2^idw+P_Cg>g#IX;O$Sncs7VKz-Z;}AT2-f4Mb@vWLd=!tpJ&)$TGlu zOpyI1EsY!lo~4o(JnMgth!A2-V(}eza)Y0EJ3vn|7C%KIla0mOh!qqXQAMe?F`CKJ zcuDW5OnWEPA@9l*#~ISilI9+X=e$s6J8<1llHE{}-B6Mjq4aW2P^RKZ^g~RrPHdwK zZ9fxAHp89F`GSA(4aR>%@*UEZOf2^n*)!bkpKYVi##e1TIPr49|^bMX~=sV>p zh3Lx>^^b7H9|;>3C88OXKqP2X)JVvvXo^t@28~koeDNJb8zg}$aGR^|7shh z>|3l~cJ!#%?oXJ775*JQWnGI*?lY<`v7&39=1hkb&+&rn Array to be sorted, - low --> Starting index, - high --> Ending index */ - void sort(int arr[], int low, int high) - { - if (low < high) - { - /* pi is partitioning index, arr[pi] is - now at right place */ - int pi = partition(arr, low, high); - - // Recursively sort elements before - // partition and after partition - sort(arr, low, pi-1); - sort(arr, pi+1, high); - } - } - - /* A utility function to print array of size n */ - static void printArray(int arr[]) - { - int n = arr.length; - for (int i=0; iUvIPWumlFbscZDyq>vl6`hTFZfj5lj5X_#l_^=3m5jNxW-ogJ zEjOHs2%<&c^o&!n=j!Dp+x@^=D%k=ZGu36Qv|zc8TsJpW zZ`D~BNX+~Xg>gn(vAtPqgT~-uKA+4ptmV1_fkm34!jE&HOb6izoSOHn<&S2qS~Ey^ zxmvGyG8+L+0_2kmI(iY;5Zh0#?m4B*gzH+5*CR-vk10KLN~QgXOi{5nYFt+9Uad}` zpbx5{T_EgAwPXf51TI9-hSSoz7{M95MowkA*IcLKg)xL-4VU(#`jXB+Uia*B1ZiX# zh4=!|8DDXynz<*h&3mqGmB%$)7C3WQ3vRP&x9U!*XuCSz!W9i~{}BcdT zCRsn$tq3MDB@ptejZ6f(22bQQjk_A|2y~vHN(4zsSS?!)`=EPp@mS1pS#5!t2;M-S zwC3a;Sz*gvVe@sKa793$uh!jVd)kq`+jj6C(vkxDiK6fY0WJL4@LX%OGMt6nNj*pC zM;Za>9OW^fqLpK$;lTM6S0ULe+>w{Rq_@hsFQufjYHkbdsYE*dJv2_)O+_SP-|hVs z|A8KgkJ{@85A%+WFtH6{cF~R#Sw>1V(74~u6>-slPR3H%`dzdFyx)x|Erm0Pp}a&` z2t7brY}^JdVbV=z`82kx&l&ozem&R|RCds#TvfNw-4jej)pWdM=(PuF^+R)06;YK; z|5W91v?mx2E1?Ly~Df)lQ}ur4Zdry@z8j1~_LZz!kiXDb8~^hXtI+8ZO{t+MiOaFZec}aQ+6D zeED*XtPkXS+LVt<5Jk$T;%jz7J7ag^b6-eViYGYBy`V2?Cql2#t>K*D*U{SEHlXVi zmwni*`DeT=Yo18Oc5vRWdRr=%*ug-;&{uQuMCsYyk^H)e3tT3%QF0t(oKcqh+L3Z6 z4)`XTd|Oz{L7#7kWtYqwEL9A(Ke=uMwke*^G mx) - mx = arr[i]; - return mx; - } - - // A function to do counting sort of arr[] according to - // the digit represented by exp. - static void countSort(int arr[], int n, int exp) { - int output[] = new int[n]; // output array - int i; - int count[] = new int[10]; - Arrays.fill(count,0); - - // Store count of occurrences in count[] - for (i = 0; i < n; i++) - count[ (arr[i]/exp)%10 ]++; - - // Change count[i] so that count[i] now contains - // actual position of this digit in output[] - for (i = 1; i < 10; i++) - count[i] += count[i - 1]; - - // Build the output array - for (i = n - 1; i >= 0; i--) - { - output[count[ (arr[i]/exp)%10 ] - 1] = arr[i]; - count[ (arr[i]/exp)%10 ]--; - } - - // Copy the output array to arr[], so that arr[] now - // contains sorted numbers according to curent digit - for (i = 0; i < n; i++) - arr[i] = output[i]; - } - - // The main function to that sorts arr[] of size n using - // Radix Sort - static void radixsort(int arr[], int n) { - // Find the maximum number to know number of digits - int m = getMax(arr, n); - - // Do counting sort for every digit. Note that instead - // of passing digit number, exp is passed. exp is 10^i - // where i is current digit number - for (int exp = 1; m/exp > 0; exp *= 10) - countSort(arr, n, exp); - } - - // A utility function to print an array - static void print(int arr[], int n) { - for (int i=0; iY`k6g`ibVaDTeOiV~x2mFywFbUMOg|x&@?KBB)ai~OP33<_u&BPf87&IQD zdY^yLZ8z>F>vn;wrpl_T{)+Ci>N1POJ#Rp`mMv9?_ujql-h0lu@6KQEe}4_2gmoPe zf!RIJ58TeqN^8gS-Qa0^FJE_B&UWB>ojR{{r~ZzH^&D(As5A;Iz8}6ZOE}eztCRhp1-P zcRRs~@7w!hxQvvJXc2)AtM{QAR|uSXEqGn zqS84Tn6r?_M|>H(+jTlkf!k+goGLOT8)6kKe2h;7jKCW(5V(*&lUEUUbd&_*XLQBF zXOgfMHrYfGWea!ZOz5Gf#n)2Xw#)5edh-;Ya%RJXz?fWCES$rnf%^iM97d-($5*%a zWzh$+=z@%TWZ^?hvZ(FvaF*g{)a0OeTLNa?>-pQxLpPkq6LX%ELNL#A3cn6O<%xsL zRi~BbF1Tw8hcJHOAp(=Dyap4-xmtq&?h~{iiPIyK|6#Ex_e%EllCt~~6apu$K{ zekAC|P>`f-AQDnek>e7UhfIHD70I;p3Zij{d+Wv@WXnJ8ykc%y$iBT{0%EV~=2PR&4Ylxvf-_F8r>FUKd-=WWYeBSrn{`lbD zw*dCxV-*zwjh=6$F2x7z3)bxU(aibbjOX*HLJ_FBXk0PkX~Uk14^3P&Q@%i`&$2E5 zkU(WLHYT7XGLvQml?ZF7LP%hJ(z4By*_jE`9W^G>ra)aXlQPm{hHJ@t;ZgCYEl;31 zS>AdtH4nRHid!@h8xW{SO$&&Gz}gY%?x5im6s@zQ%c6=5mcuHgx6VX{)whI^P< zQ=$X0Lgtdy#JGYQlNsA6FfBrGoaFW6I!D?4(|dDxYO ztP}Iwae3#<1vCWAt1JBuHCtjP1b!tSxDelwsSZ8^$y)s-P<+lVxPi^UWCz zmyl+kOQm|C(#miuIa!}tO=E^En6PD2W@HtWg~Y}r=&}YkUzWBx>&tN@6Cakgvl_18 zbtW^DWx9%HhB+mQW(4Lm)T1GSH}STLw;uK@{V4%zct?&0)seDkTN-{>!+UZDR;AJz zkEAPxJH;VaUnWJ2)FTu1K^Q^8gB;1+I-J1*k&#T+O_|3mIYsry2lQ^4U5*(>!)XpE zJaGc^tMV4-F1S~9ETZ}w9x4#wSN>T-*YK+a0PbsftCn@i7b*NccZut3`HElQ09O@P z2UibQC)XaXU4=c)UB17{wNF{7S_myvEbv^Jx7nDNRng7cURv3YS{y_}i4T3K;TurL z6@t<&1ZRq5An-^0MNPCXB1_Q6>zWp^A-ROs@kMMJtUNT2dmU{#Y~HKr%3W-|iIyeA z#yjt#a}jY}$>GTyx|8#`p({1fTd3)hu>Cpoo}P!tx7aNV&tpT0P*)Dm=8%wLJRbWD zb=*#Thiy3wQpNIb5h zLN-6eZhT1=zvoc=iL$?v#ozgl!5`%4PY!E=9#Ks#vRb+W1~87ZyhT_Z=Xl~o!ryoq zudu!v@B=I0Jh|G0ukjigRbUV+>nuP`5G6U@jI|HYq(WEGD*oXQVtrWGRej@qX!jAR z)e%MtlL7g-MuiH6b}qpjzk{ho%p^N=a0ZtkSOVV3JMg>iVm602_n*G$;0V1> zu)dBlPsf>$0mgqKA5ll3meqcZxHXLbIzFJ$8s<<&SwV^Q_>kRE$=4giRN$k30qx5d A_y7O^ literal 0 HcmV?d00001 diff --git a/stack/MYStackByList.class b/stack/MYStackByList.class new file mode 100644 index 0000000000000000000000000000000000000000..2dc7c0fce7853aadc791117021185f025839d4c4 GIT binary patch literal 961 zcmZ`&ZEw<06n-wS6}sxWF;H6=?7*s z>UV#X@!Zm6kjxJ~=broWoaZ^`^v~b#zW_XhE+N5?4ML+c&|b9~!apC?%^;MJVo>|W zk)c_J)6;g_eclNf=C@7944*P2%atZWYRBzz8A)Um%we8kv2Hs2_0Vo}f6r)JoME}{ zb_}a&_@;>C%~W`31`N6SDXDdWwGGo@$d}*MPbf4(-*kFx3N8q;Qr8ST%NS*F5tk&a&M0n-f{@z^F5?QR zb%!KAH(_JC+8d%05+QEbdKx9Fp}gmMMQ(AMJ7Libifdh2q`IcyI@SaQ&IeJ|YBFx3 zBB9K%bRw?iguKUn1?#91u_MD8^4$Ybf?8#&2Jtmr#w}A4DgAxddMifZUiYAM!M3F|Gk)K;XM*2&1ERz+-zNnhIjIps# z>#g|v-<1", temp.data); - - // assign temp link to temp - temp = temp.link; - } - } - } -} -//main class -public class MYStackByList { - public static void main(String[] args) - { - // create Object of Implementing class - StackUsingLinkedlist obj = new StackUsingLinkedlist(); - // insert Stack value - obj.push(11); - obj.push(22); - obj.push(33); - obj.push(44); - - // print Stack elements - obj.display(); - - // print Top element of Stack - System.out.printf("\nTop element is %d\n", obj.peek()); - - // Delete top element of Stack - obj.pop(); - obj.pop(); - - // print Stack elements - obj.display(); - - // print Top element of Stack - System.out.printf("\nTop element is %d\n", obj.peek()); - } -} diff --git a/stack/Parenthesis_Checker_Problem.class b/stack/Parenthesis_Checker_Problem.class new file mode 100644 index 0000000000000000000000000000000000000000..5e2806c95e52cdc7494bf12071c8807ba52f18f9 GIT binary patch literal 1870 zcmah~T})eL7=FI~9oinCz`B7$2b66s462)SI(`(oAFJiZbt?i+Jd`tfpgnEc(?wiN zG+Ru(^LD!##zbObVz!H7w#0blg)uQP@m}MVi8m%*=%V8Dwfq#eXh_fZ_q@;h_k17U z{B!?H0H?96z$VaHw6xSpcuFhirj^!A8bVScKRTgd2H1r7n2kYO6uh=4s9N(wllxkcRrJKQRqa0xWV4O5>eWf%0qC5=P^&GB4H%Otge zA=g`*4l8XG1p@K^4P=l`vYKHE91PCIcLPdT1;bn#3?&sb2{cs>N|uocCsLYe>IFAi z;8$>9PZo*QqNQh59K<03nX68#4S#>Qt=z$MyGNUI1T7!>;gpv}}uHs2N zC7_u4TUN|ufmoNAJn2x;i7tUUc_ND;Rd3 z0H;(uivbenOU1Onv8@`^NMW$nxT=ndMQ`cAa zS7V2v4=<>A5u*ZbnO#zbTj5}S0Yp`tl^phbE-&kIUd07je^*8~m#nmGdQ8R3c!iK$ ziIv&y?-cd2-QPNl3wVs;n8u7!`l1JucvZpFcIhaG8n}v!NHC+kWXMR-)RtpMh;_Iu zpqe?WV_}PyxoU+a>b&JK%B28{DIQfNQ7c_aUNCeK|Im(FKg4-T(uH!vILTl)fn`gd4Ul}95;2Ko9 z9wWMnnj`9+eW>e?pazJ#vJXY~`?wl!x`f|FN9R7;j8|g04HskaJ8z-k9$spWmoc#p zubf`uwEd=S^Y*4!*3bc2!%q<6*TWim`6Q{l9Svw@?K;tfZmxRZ$4S117jTFgZ^dOC z#uc>VO}=U=bYPjtx6y@ndG&74;(Z*&2ju*amTTxG{|S7`XXi8Y<8v~VaSC7a<@go@ z_zn?#&;K|-(9cg8#xEGbuNcK|7{i~4;xC*P4yeM5Sf$4ot9?Wg(~Q|G1YW}oyX+%! z7IPF$EA3xre0E0lGv2^Fv+Tx?7-zgrJ_h%p5$9qYA7g>>D_A6x)J_$z6MvOE5%~T_ tivpk6WbTTBB{^4cTtR?t>91YX*B^26?;)JFhp6*3{y{c@G_7qg{sl**suchL literal 0 HcmV?d00001 diff --git a/stack/Postfix.class b/stack/Postfix.class new file mode 100644 index 0000000000000000000000000000000000000000..027ac23d9450cdf4050232038228bf2380fae87e GIT binary patch literal 2335 zcmaJ?+iw(Q6#sqgbf>!v(A&196sTOvZd+K8a&19i%cZ!zU~8e^ZMq%Wf$i)tGmEV^ zR8TZA@fn{m(e%NZAP-wY6Qe%rlZnyzADH;yt09K^`(_q)OREpxWxhR^-#Nc?&i?r5 z!M6bR<6{+N0;^q5PhUw4W?k=+IjuqwsJg6Q(-Rrpnn(7Mg-*uYp6g-U~S5@jQ-rznBffTV;MuBCY4R=nGxMF<#*vx@g_}IN-uHRMT3Km zk>(Lg#(M?I(vt!rNpM3FT%T?i^w*dcK@MjNXa!nhsUp}R&oQluuK4mN74=KP3M4Dh zNH;AJMA0PUST7J=$=-;H4Fv5w%6Voc;iHP68DXj0qTv~AW{%R6x^s-lQewUFWCUB$ zs$!c!Z4qIT5_;M*91YtMqfOII86Lj}oE~$+^mUW*3o6{c9<_znp)E;afjdQ`r0eH3q@-)bHjFDW)P4;E z7!(Lg_D3WgzA*V0ctOJ&td)cfYj_cCoKVKFCOk&VKI*N+dG<-KMH0>NmJ`#qW4NxF zwfL(s&A@7w@xe|BQ7D&TrBwJmBv2hl6$_I>!sH@;!JevL+K4mu<7O;mrKs3l;;%^6 z5!s$ox=C2|v5O@lLE5_FY!4P-bxC`qb;~lGFeY(X1)-D-l%W~dGp00LL56)UjYb2L zW;W4l**T9^4Sk9%7_ekhW@QzvC=wr$LRU37epy<^v?r&KeDpNr{aIcejhDJQ2^m~J~|MmbuDm-8A>c;m3;uJS9vQ}C>4 zn@8n0yp$orUH&ZhRot~efahv{RmxiAi&TD}rgkM!|0@^eW=0#X73Q{OE7fvwVLuZTp=i(LU4}A90z#B zU$jL3BC>$!XidXB)}3FK&Py%vp{N$Qj+6MSp5hMDxxZy#XtNLtPMw_YIOZWXb%yojv|aS#sl(kg9a5U zZC`*fdJhxxm`b(hVfS%!7a&*$*ZS|_^^W^^Gmp26wcf;90!|YBDc09%;yWWJH1m=2 nBWerGvf6J@ZWVvKi4W+siaC@~mhoj3K4f>4^Ys>G%J9*@)20kv literal 0 HcmV?d00001 diff --git a/stack/StackUsingLinkedlist$Node.class b/stack/StackUsingLinkedlist$Node.class new file mode 100644 index 0000000000000000000000000000000000000000..af980348fffaa7f54adfa17b51a6d2e062a8fbb0 GIT binary patch literal 520 zcmah`O-sW-5Pg%@rj60Y`q^4hp@&+*dJsG)9xRB3SP#{L$8EaQZDRu2RPbkc5W#~# zz#k>f2Cvq`zMVI`oqaR&_5JY);1oMHEW)l%MKEpm4c==NjeQkO-iw2>!x z6Y(tCp@_!q+u=k8DIq@+sUT37!;qg4_WgfKoe>J@qtcCILVb?d=+0H7(hIiNoF_aO z@b4XVSpuQ#q6Ei54l6DeQ6c1-Mo{LCWN-E~l*yeKhLTY6<3NN1ktoA|lX+u};Pm5J z638o+32z>-yed?&&6#?Zul@km9CjlB literal 0 HcmV?d00001 diff --git a/stack/StackUsingLinkedlist.class b/stack/StackUsingLinkedlist.class new file mode 100644 index 0000000000000000000000000000000000000000..94b06a75df7e593720c2f22c4fa4d201836eefcb GIT binary patch literal 1604 zcmah}VN(-V6g`h!SXfp-z#tMztXh*0O;QGzX}>ztztMlu>9jrX?N-AK+7H>hci(;IoO|xw{r&Hse*-Xs`xd$cPKA-X z@uXN&&y~;%Hp^b{MAm&Tj4YS}LtE}sx9GdUW^s9aOKwC0M$~8uoG!op=GkhaE@uUL z=Dfg*=6NNXTNN-D8Ma}d-+_hRJ_sCh(2X8}LDI@gPXKwvmHL>U$&H6wQxdU>VKr#7{!>is{oq2A^>m$!%I?dEu??X0)Sy_=ZJmw<~V*zp9#2@&-*R+4Lmq;C-Cw zLmmYS(}!A6+X)Hj-~ui(ztLtlPLy?ryhibE%L}4f)ROM@Y%e|(7|=W!FU(Lzv}5CA zT()pYVC0A^4nD!B)Y?=ien8-CjI4W4SkA_*>Y~wXG<)$Gb=figN>G=rM}FfwMKJ4N zPT_QG9OBizu<5&+{F;O7xWTc|XO9Htj-Yth!5UB8Z0^VsZ5p)b;3h_Bw0!18y;$Pv zT>ZkljW2M=LP_BGoAE6Lk=&Fm2VbI0T~A%VEte@G#WCsNOwu?;cCFEFZOA20k7H#` zSG%xN=Bsg0!3sE~Adsy^-wi{_u{71#3-niI7*(X20dCqMzmC= zFtLyELVgdpL)a;*0Vau?At2u@SKQp^cWc<1@A zs_R!ouh4Do8oS&Yx`ZBmROpc2pTM5gIYNB|&XGHI<3Zxac>VzAzmFmJFuwaEa>K;~ zeAM*@d6>2UmuTf>qR-HtD;+H3hgk-RKl9r2Zxfbutk_ZLR}OIXMP3E=Fqt?Nmk>L3 zokTZCut4A?I(55)EPa@4h-9C?Ci_7f2HcFv#x$AnD~tooe{H_R!gEZkqw;f1sk2)q z&(@4-mi-d9YbuND$@288fBsOT5sS*h=DJK#6@GfEIEiJ7y2nP{XJb}y6%TNY>qR`& xLQ^c68WN!y=BP#rs4g6XIq?@P3!@W%65b%Bn!qX{K^j2{~HMOqa>Q2`563oIr3WrbO~Wif-<3=U4yAI=J^t->y|ELPv9uV8;* zQ%xVB57l(ut`6fs!|>jH_nmw1x#!*e^Y_PZ04sQ{ARsW-a`ozQe#ib~ID6X%dvA2h zHWh>fqDT6Pp0DfHVSao6$f&vkS5{5Sbk_ue*<3{+q}eqif*=M}4B(2uNXfK}x9!Hh z;q2)9bweOlva5Q%qC2KMpF2bDN3$i6DD|sd5KvvoX8XY7BA{f8nx^F{gBV3zLF^K> z@|TutG*paXoV4sVS&o-H=BAy0=a`mTb{#`+6ckJdOmusq+q4ch+Gf3GIAKgNZp%I~ zGBvYxoLSBsICdlB*tJXq38Z9yX(Fh-)gYBSVGsX49~00_m)l>j9rv zD}-@FAe?dSy^9KSGJalQv0sJ%=8=_esmLP7bgu0);+tlBOBW)zjYS1_1mb<^;aY1YCujYpx1UdG3Pyz`_~Ar!)eHaFy3`y~FMvtUjUa0Om=WT_J}|) z;_>AOrVe^^lB5EX86b%{(wIk-PdkbV;vU5Xp9Y?yKpY8S70*1{yI7+Y@O;l{1@VG5 zHJHaB*0FKkNs$R8Xh>O2Mc1QRbb~y*att#9m?UJ13{qargdYG6FL@WBPga*|zVgnS F{{S;*`XT@T literal 0 HcmV?d00001 diff --git a/string/.cph/.Append.java_c181a202ca338689c15dd0c5b3b84d60.prob b/string/.cph/.Append.java_c181a202ca338689c15dd0c5b3b84d60.prob new file mode 100644 index 0000000..7592ea9 --- /dev/null +++ b/string/.cph/.Append.java_c181a202ca338689c15dd0c5b3b84d60.prob @@ -0,0 +1 @@ +{"name":"Local: Append","url":"c:\\Users\\AmanSoni\\Desktop\\Java Program's\\Java-Eclipse\\Placement Prepration\\string\\string\\Append.java","tests":[{"id":1608220330360,"input":"","output":""}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"c:\\Users\\AmanSoni\\Desktop\\Java Program's\\Java-Eclipse\\Placement Prepration\\string\\string\\Append.java","group":"local","local":true} \ No newline at end of file diff --git a/string/Append.class b/string/Append.class new file mode 100644 index 0000000000000000000000000000000000000000..c0bcb24e9df1a980bc85972fdf13a8088ecead52 GIT binary patch literal 879 zcmZuw+fEZv6kVq+o#`+L_J)Wec)_+%Dk$D+OvJ>e3MQB)#;4QvfJ0_F&2)yOpQR7Q zXyOO>QO0#TjkMTIa&CL=wf1d(|M~F?z%#rwkPukthk?^Qt-a~>RJUUwC9rfR&t=V( zd_8KNsdgxke&uwX@U=j)RBj5S-ufM7A&HEQIiv*^8%|dpMqWz=A7#r`0@;S&mTpr9 zj=ql{Q{fkqrllbFoLO{@wS=hBVT(TTujX+kj0wqBli8pmKEkJ~!eHG#sU%fA>kV%^3D z?y_2PR7`>DEa-pi?#;{ZM%}wy@1I`4Jme zh}9gw_JM5<$*H7Ar5!vnP!q_FYB+7Sv8(emdfLNfTT(JOW!rKynnPnh40d(DuXaPX zm9{Q2ahDE+;=K&EZ?i<;qMmGEYC-R@RzN2`7TiZk28RFjIH$1EkQN1KC yQk!aYO!G6bLc(=eBcV!6hCMtcCW$pX!9JzZSjAJG5=5K)vG!>bcuq_LFa84X0K*~x literal 0 HcmV?d00001 diff --git a/trees/.cph/.BinaryTree_Traversal.java_99fbe9a6d479d3fea744cafd49bd01c0.prob b/trees/.cph/.BinaryTree_Traversal.java_99fbe9a6d479d3fea744cafd49bd01c0.prob new file mode 100644 index 0000000..46d1433 --- /dev/null +++ b/trees/.cph/.BinaryTree_Traversal.java_99fbe9a6d479d3fea744cafd49bd01c0.prob @@ -0,0 +1 @@ +{"name":"Local: BinaryTree_Traversal","url":"c:\\Users\\AmanSoni\\Desktop\\Java Program's\\Java-Eclipse\\Placement Prepration\\src\\trees\\BinaryTree_Traversal.java","tests":[{"id":1608219457557,"input":"","output":""}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"c:\\Users\\AmanSoni\\Desktop\\Java Program's\\Java-Eclipse\\Placement Prepration\\src\\trees\\BinaryTree_Traversal.java","group":"local","local":true} \ No newline at end of file diff --git a/trees/BST_Deletion$Node.class b/trees/BST_Deletion$Node.class new file mode 100644 index 0000000000000000000000000000000000000000..94cb5a54ccfbbacbc951227023a50c8d41b47da5 GIT binary patch literal 569 zcmZ`$$w~u36s*p^jAl`@Xk4NZbOhtggW|!67zpuT2h8JHObKg+`)c<=-K zD6u-^AQ%t*`mObtJJBf%uIq;)y#EVgmU`>&0r? zmNRNz4j$z&5Qsj>R{_x$h}rU5tr$!I#NdyndZyX3L&S+*|;#fHSfuA>~;eI5^_ z*Ruw;6exDwp=I|iPw9A?jA^D^rUE$@$XvP4-cX(^-Cy{v(Y{tjz-T*;^jfy%`_fNh zlc;~yAe>fIAk~$AaN+s^Hpnc>Ux@LLGA%UC$xY%wKCd6im|F9ZbF}k}t~sISs^(sZ zocWG|Sqrgfn&KuzDMaOs#R!&ZixcoHbuc(OhYIZq^Ci{^fZB9j6{{o=A?(^@cAezF O<$7@)Tl5=~eEkQuC~YPH literal 0 HcmV?d00001 diff --git a/trees/BST_Deletion.class b/trees/BST_Deletion.class new file mode 100644 index 0000000000000000000000000000000000000000..33e8c8ada2c76508c5360a5618d213ba57d44578 GIT binary patch literal 2628 zcmah~TW=dh6#h1G;!C!vn`@gGo!BL}J+31r6ZGZ9ydw>}b?lLb2HRX%bYz74bnM3y z8Uh8=${P6`Q*5uEbl6NneA@-?Aj z66dI^Q*;l^vmbsp1xOlfGX!HSL-Wxx%~k|@?u!7wci9q~(>d=I$=-z25Gs3U>a z04{6TlXex2IkvGX?2?g>73X8lqKGY+tHPpL@KT<~RUOx)C%^KPw@TPlKMeEMbr4jZ#Sv%qLrshNcNoa>j-1FC|_`)*+jo#)sX9 zV~`I!5-oBzj5@UzN~|N4(C$P3fz~=Sb8J>8+u>tZ38E9*Y17@^2xAAoAc^si#<;JJ zmgYnvaSwWT8EqTTLTa@e+YnJm9q#T5QnPF$3Y|U7!~C6?GWvY-AsUivk>oveeTUX$ zf|F=Od5GS{q_W@f>^-i%=Pr)QT@Ml9t7lCP?mW7t&i9nD_ddGZIaj+BTu*Y1{_0i! z1I!laA!~d2y$@0LE_N>*!66(+iZ`(jX%@`{25}L`u!JF%SOl389cFBQnE9P1G0 zJb=c=&d#Q$Zq6mDtH-N+%Z#HkqT_cF<~u5<@|}^x!@vKCe9s+jj9p68lk{+kh@j0uaXzaW(PjzgIm($W{D-RVgic4eZpv{!4in^^;(@&8 z-Hra_uSlulCD4yJ@&Lm#Qs|#>VjX8%o-HF?#&{Vo$UQ7j<;)ejg8>5t0u@=7%S`Yl z6D(CR-(PXu?vBFT=V6}6$*=jUl|{8e#7!$pYK0y*tUMz1Dr*IJnWVl!LEl6h z-a;4NW+Qut*W_IszQ+Z@By0D!y*>Iu__FKxB*UOkTVqzw5~EO}=I8@8)B3UgG1E-~RxJ;{a9w literal 0 HcmV?d00001 diff --git a/trees/BT_Traversal$Node.class b/trees/BT_Traversal$Node.class new file mode 100644 index 0000000000000000000000000000000000000000..8ee6fa80c5b8af8a6c433c03cc99a1179bd0a6a5 GIT binary patch literal 494 zcmZ`#Jx>Bb5Pb^=2YAY-AR>y11zaJeg~mb>BMHI63x$nYaD~O=F4;Xu{8<*n#KIro zk221l6eh-EXJ%jK&3iMSU+*6P&Twoa!BC5o5W0KiJ$Q<*gwotU8HSI-hQ&~r^A+#< zJeYQG$8#}>7?RK8g@N@MEMGhkP#^p=;hZ6*V=Dz{0XeKpD z$Ve<0a(CfUO~kb{{l(u~o|@eloPH1p)$_U5Lfbf`sekvOapoornW50pO{gQZ$XSx^ zXdYRn2xBwOWSlZxiI&@<=+MuDg#_h_`-W||u|~ml+5H-&H7c)!Cs3tWqAn2IqUE#1 kE)%~-NcD${y^TTzb<#8r_G4}X2b6QMW)nx$)r#@vHx0*H-~a#s literal 0 HcmV?d00001 diff --git a/trees/BT_Traversal.class b/trees/BT_Traversal.class new file mode 100644 index 0000000000000000000000000000000000000000..b20935e91dd75b58361e6514fe88a2703eb166ab GIT binary patch literal 2089 zcmah}ZBrXn6n<_AY!X)91BJdA3T>0nHq=(BO9R_&K-YyWXbs1kT3V7}mkX3n4@>W?)oc?0+gSaav&ul;xHmCfErRLl_R> zEY2G^_gYi(&nv#%G4VE{tk$ivF_Db!ne8TX3Ra#;teupB3rzT`n^fCQX`yPDiC96J zHgOS`8049JE+Eoj#E>u$e?6V{GBJZI0>++IuFBOdri`WI^{jeQ_1LK}CUH%5JgF>N z@8g9at}|6s8Qw5)6Yp|#*6yx!HU+M>^JoduC_v|$GjR*=3j}?)j(`J;wZ)afT?2On zhTC+?#61PLThCNA=DvvsY8>63UD{UsbI2w#DDPXvXDiljgCeGONIRMWYHCX+KEN;y z>+JC4@lD#qhw3J_j zd(xpw%BWqr9YzXy6Kkp%LqjM#Dr7;y3aZ=B)on0{F9a?glecq7fiD#o>GZY0bgog; zNj~4GdV?&$@=DyI;Wp*+QUMnT=iRDTluNeS#lhz9!8J830W?16GgZYBODfIEbPdoM_fB~8h zqMtgmZcNP}rJ&lyMxbwLrvl9;{zl+M;&+T3VEiS{9Aa{v($oPi@8jywYz^Y%GagyO=x%{j1wW$G3GkWy&Fdo6HU2iv7qf1wV&uF2vVy9h=(VGc=#rWa|Cgo zAff~@Ne~wZVyZI;vbY0?<&!}yzX{?JL0l$?I6))`Vum2DbOu2>HbBhiVQ|tfVK%y4 zpK6%X1taxfR>xA3YGHdv-I->`8+5$conNHT^A`;E~svpw|XRP8E9cW!nKAHZwUD4iKcF8K zohPlLTFjmMdG5LAeSE&X131Ng0uh1D&{ry`UusYK(_1BdXV77$)*e5o1Y!cYp?sEg zS9<;WO>d~2P$2rGrUIfV5OdWd6P4CKC}#o-zU~j$7Y_$IsGSHD{}^Cz{9JoFybvfK z{MFPv>~eL33{xOM3u$E1h$3&n!V38v9Cl4*&B6lW##^_LLeh983kf6zvMueY_GHvk zen<9PC6I589qD$ZuTA`&j2XsUrb9InNZ*bpzN40kS)*|AYdz-oG)@*A!U0u>~% zD^U1d9l{!w1(IzQgxBLB#10uo`8qLvq)rP%cmC%AKrUyFWla5f>>}+FqdQKRxsrV} zL)L!9vR$5G)wad`422nrFDyo|L7Sh0r>RGVqZWz;*<`-JIss7rUROee1R{jpn$K>N Q9Jt&pu40dVZJw`w0Y`m!6aWAK literal 0 HcmV?d00001 diff --git a/trees/BinarySearchTree.class b/trees/BinarySearchTree.class new file mode 100644 index 0000000000000000000000000000000000000000..d23e2ae3ec154150feb21ea7d24b9cecfac45aed GIT binary patch literal 1542 zcmaJ>U2hXt5Ixs6INod$gB_D5&L?THcMGPW5Q-B51Olc`3K&H~ecG7YWWiaZ^#&=w zg8zV!`bsP6NJZ*nEA>ZJJ#%*zK9nG9XYZYR=ggd$={rMpWB5u|b2iROTQVK}OC*l3ZG0n+6QRGoLv};0$ZJ1e z_g*B8$@)Pze5yks?AUPet%8;K4C9&OlE;jtfD5>oMeUP$xAuFH-nH=^7D&3g$IPQm zBL}}*dl33T)FOFrw{GEkT*>0HLg9#Gn>s5fWM4=`Cm^p~&*!UD`8h^2;v$qEY}ezd z4GNPb8>dl_)pZ*c3^33Ow<&bS4zH5Ti|?VH9N=2h%`fy(ck@%m z7LBbKyJqZ?u@A)dvHXFo1B>`KNcJ8Z-9Qod`33lqdTjC|uuiHQSinPE!K06=Tx5H1 gFm3=f+@!)pySKPcVHLOemVePWpF3Qy@yW>kf0ol4aR2}S literal 0 HcmV?d00001 diff --git a/trees/BinaryTreeNode.class b/trees/BinaryTreeNode.class new file mode 100644 index 0000000000000000000000000000000000000000..ace45e803d0eb2d26aad134cfd3458cb25629888 GIT binary patch literal 596 zcmZuuO;5r=6r62~*n)t7_<9g^z#nCt z0+R5thut@C-n=)v`}6zt4d4bBNf-jfC{$`vyVrpXXCC9$xUZ711ac$!CTqS72DPW| zNcAECt1lxdkZ*2McLH`>4+0rYLnUB(9y6A&o+&Cdca0!l-bvJ{ZIDfbdN8DXudV|f zH3W{_?Xi^(3tTGVzMjMzYVIr;n#HRX80 literal 0 HcmV?d00001 diff --git a/trees/BinaryTreeUse.class b/trees/BinaryTreeUse.class new file mode 100644 index 0000000000000000000000000000000000000000..e3af7525f6a0db48bb164c3502707854f7296c8e GIT binary patch literal 2177 zcma)7TUQ%Z7~Ll%&4t0X;a=Jjdch=IQd%wAAR-ks8lW~bO6zS1Ll_8?IGJGcrvJnz zpW7}4maOGtUCX~@m&^Ulgpxp9t1mfo&e`YN-?zU@{{HumKLJdm9)wS!+p!I!nwmE) z-L9|l`%%>h!mn^)Ti?@DCEY5fR@S$Tf}?P5#YrE@)y{fO5425X6T+mB--8N<4IP^PPW>uj#+lD%=5O(w(BV$!+WE_iUT{miu zSxV&!x@8%5I&tRVG98hZIkRZ#PR%Cs+?&6g@i^R2GnQi%$uXM_qZ_?J^t33Et5+Rk zS3@8AsX|#??Dbxo<SrRtQ$aP|2e0Mi8!Rv}{_%bRr+Y2(AZljRa@J(QpGdX~Hs|I*i3lRVIkH6?#sq zEuuw`z*rE;V^hr8C}6(-x?wWmqsgIHAPKj}Iz-}5!Iv|-p0 zEFdhJWHfw+&l#c@ZL}#N4ZQ`rq+uB=>{z{0F{}-RiRMZ=PE6C=7BW`v7Zj4!x`3Qm zT0LdpxD@}_fV|9W_!3_+H%{5Zvj*eM1=O$-!DD74y}kMKPU_|oM)>yL%cSwYH(z71`4Hel`i^qyC_B8hFl?%E7$CT zv1q!JwPj*YN+cv@keuy+pI;ow{0(xK;;Og?k_QMq=Z6mw{>rsLJNc`50Ipr!g{4=C zy1;KAF1kj3rD-vK`vs!Wfqh&`?jtrcKA7FB6Jb8$z-*Kn0PLDt1 zE5FNl)wL8thzwoi?IBN$OmQ;ZB9C|y^H^{XY3{mk6E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#gvb8_9;R4D literal 0 HcmV?d00001 diff --git a/trees/BinaryTree_Traversal$Node.class b/trees/BinaryTree_Traversal$Node.class new file mode 100644 index 0000000000000000000000000000000000000000..724af57114788265b35a52b121d44b3af4fd1773 GIT binary patch literal 617 zcmah`O-lk%6g|)HY*Mo?HOnl6njqV?C|VRmg4iMvY7ij#eu`^;3~H0*T(tk4=Oly-zlvH5nRE5f%pL$3%iv-Zd&*n-;ft?n^eYfnq|jJ=N0e*!`qt~149D6 zpZMpo2ZHd%|R zYg_Z3F)@gnsy3raPu6<3O57Q5&Ui)?RgNq0rydMk?~PU;EhSa&UCFfI@d zycz<53yGGvCUD=tj{?yaOj&rK0C(uBvn(#VjGa{o?B$Iad#m0$mcGuqx+PTA9$NSb zQ4HqM6?zhjM>5MKi^}gA)!|Pq{DJ~AE6HH0 zY**N{(F2+3Ly{1~GetP3BYskoX0nR=7Xm{cLB)fQgBtf%<4bygc_wAtsjxl*zbeGx zFkT8=HRJWf4_n!;zk9&ywPJ-GFcw>f6wOdj%5GFsiUsB1opofV*Xr#VQDqjevaTzAO_ik6ka|`~@T{x^Gg7@36$~)bc0Oo=A72vw!~FQV@Fc?B zINJ1`nc9Py5`V&a%hNV=@!zE_dlBM1N6?3JJhN)rIFBzVK@E1@)9=)4Dq_2i*sl>@qNmG58^>8b12Hvp z7}C*uY7rXIM=?nYfhp}lbZ}wMo&;$61R#&f#?4M1Q#ISdNdz;PtvmUjU8FkD-G^A%!(473 zvEhX(^3Owim~RLj%|d6hU^EM13anB0^C}(i?#hLwSQCF+n+caV|##j!kA;% z=GnVXk>)!$jsmeiqg3So1zuqRHWuOFB{uQ8sctTou|gkVtU_|a)aI%TG>o#~&`ciVpVZXz-;JG*<&x#ynqo$r44{{8PCe*&1pnvQ_L zpyygvGrMTlP51fQ3XQc(mvv|Yr=OX7X4Wz5o7rOZnYHc-Xl|pypHc7^EjMabPM~Mr zuG`*qfnYLKX3#CVqX?qcfR1nk0;ddw&?68l*mY}pce`r2D`wTP1o{h&b<-)Et}X43 zQ}ed$rod3A%u#GC7~65}x>vCFET`z!EH}y$g9grEh+wuXdvl8*W6AeXrt&gq#K2jc z>n6Bs?^$(~h0Pv`&dWZ;7T-Kyn+=pabNz=0=8i%bK>`yxE(k;qi7;?cwx~JQh9?82 z3`|Q$$o28)P8XT(`lATa_((_Q2-T(MP0!jkFoRhV+Sp|$X9{X3>_+yX?7PI8=5|iU zC4u3?J)+yLZ!YfI4jGXEt{C_jaU!ajo*BibnA36fXf3tGz-PE7pzoQ^u2tM%y<|S+ zmsFeYC(cEYMNaPMyo@+LpDKqz4TyvcylLPIEOIx@ogJ%Q6PP(^#jzwE^s3fv153Cg z5cV2A0`770L|pf9Uq@bG-~^fsd?^8klw$aIq-e;=wrSU?u;l7747pTUN~JeS3LnXS zzhXEUVS6hANu`%WL&`4Ux#phbHccnd*ho~>38K%k5_Xd;+(X&GV_98S)t$P`TQSg& zFjJcDCN(~A0sv0REL2yivFol|cWil5296$sS=lThQY1Xhf-g^)`m!Fv^h9XQBcSG@ z={BNi@f(a+^ajw!Z=YH@2@O+>okom4!;i*kd_W5lYA4f=jFy!W>GT^IEeyN%*-sbt0TQk2ov!@(_=56u=mx z!U()YpAfwq^Kf^N{LER6o~g`V2nAoJGjA|XJPUF#$-(vb=sxtg_WjFIz6|u?jFA@L zDwocYs2pL;V+1!??j|l!trAw+PyDX^DMc#p3l{%S!5YCSBsmIp0rtG*g(B(a#nJ)z zE3-(dmIzRL71w^j#A~DukgX8m<=^p18=vHtfuA3#*vC>AmYNK~{o9#S`iZb&nv%<-<-qs&QZavNlTei+d4g#8$D&|hld>r4wz z4plgcRyhJOwf^XQ(D$4i{Px(}_raBw);c<4AFvI+QOP%u0VVqR;)Bgb# C)L69u literal 0 HcmV?d00001 diff --git a/trees/Construct_Tree_from_Preorder_and_Inorder.class b/trees/Construct_Tree_from_Preorder_and_Inorder.class new file mode 100644 index 0000000000000000000000000000000000000000..c1bba4f8c538955fcdfd2bb46d78df2eae7029eb GIT binary patch literal 1436 zcmb7E+fEZv6kVsC>6BU&FD>?hc(;IUK?N^GLvM`|^rcUn@WGWZko+SGHWcY`TGMKojVBYCX4#HOs9Q?=L@<6<;7S?zoOWArQ_D zEC^`Rbz8;|Mpqm%JV)(2PR(C+ngYYK|EH=X z&{vhdl75HEcZA<|?T&1LY;Mt9GzU7wQ;utSFBSeCg)+Qr&Z)YV-}0zzWFP4G?C#x7 z*Oyi4l_p9t2po;$7!s_+s;o7nC(xfWO{Ux@X}F=%g%(XNjw^6w|A@VF8^{P8YuD?~ zYsJuqegh{24*w-Oj*~bgU_7^KEqQ-MAem!v{(|vlX`E3#JS&jM{RU_^zBI7VMa20y zE+EIY+m>&s*6tE@a7xQy97DJ$5OrLCLFEmm#Z&}^IEol1K~1i3nv#3BNg*%AaakdC z&#A5w8f6XVe9NOLSVzNgJ3HNRXI#4t2u3$J>{yytuQP&Z)3xOb#yTqN9~1equ``uJ zd&=3n9Rl4HPKHhS16<>60H595b>Scm5!FLGgu?;JBnd+b84eF^Y4+gICmh)b&Ud*k z1YF5B4oUR#TyY<#C76>V|BE%HSj7lcM2Tsp^ILBa&1Bc1i;XWxKgp*HpOD?e=^J`@ zERq>B-l8w1C5%E!e~)ut(f1JpuVEyNvB)b!B#i9(kMAixtu18|5zWr0H0t|+JY9*% zQpVPn=w8b1_(xK@60Ze?C~JMQ|Etm|>LVxXEbMh&F11 Zs9W?LgnmG5qt`%Mh-8T8lk|pg`zPDvM3Ddh literal 0 HcmV?d00001 diff --git a/trees/Count_leaf_nodes$BinaryTreeNode.class b/trees/Count_leaf_nodes$BinaryTreeNode.class new file mode 100644 index 0000000000000000000000000000000000000000..14510dc638d04dac456cb6da0bc551b1e913def1 GIT binary patch literal 1617 zcma)6+fEZv6kVsC(o%+t2ndLZg3t?4yelnKs3J{jeV`%H7d(_B4A!ZcnHup^`~hEl zF%gZL7~f3%5a0X*qpmY8$TcC;nVz%vK5O<~d+qu0=kr$pH;@k_AaK!hlyXzKYR&eR zD@s0DwyUek9iFpn>1>whEOH-)A<(fQU&vHN+H0u?D;uip2^g!=lLDQE{jRh?^P;t8 zORwfAfncdbOQgJRRaPBk3v|~{)I6(_nspqxS+HD>A-TisnZmJ>%jm0w&l$TjK_`&I#^YFi3ekRk6su#GSdu!lO{~GMiE4}i8l1G-dKD|dwNZT z&=f{LgM5ni792$%x^>(c6U~SUv==N}6>HB{lv9!`6*AXZsFr1ANjjF^H;jg^Phj+j z#P>Ci#rEt)*?hi@G6hD5Ij4L4DSF>L@+~J&@XJzr%lJ#3)Asg#@C~= w^xh_FKaAgqh?c)-K`0EtpYGIToy=KA1TfcVNDg^Z)<= literal 0 HcmV?d00001 diff --git a/trees/Count_leaf_nodes.class b/trees/Count_leaf_nodes.class new file mode 100644 index 0000000000000000000000000000000000000000..d710deb3830ac3df0f6040238dac0e2bf718de4c GIT binary patch literal 400 zcmZutO-sW-5Pg#-ji#|*TJb63q zZ1Gfjm^bs@46|?c=lAOyzy&5DJi@+hq%=udx7yAtDW2!Lev&4HPZ%!5QY4koFUdo( zkfkMbuas8yn$S5poe}($ha+^b9V0-OFvygadHYt#W-5wG62@6wifSer<@mqo+gD`> z2ifM=FA33O-8QAXRc^;*-QKx#Mu_jUmQ7j-W1QtN;dt}HqZ_3~^FHNUb9PMVuM53g z8hbCDaf3tff&59}OztqokXf?gKydbntq&GFM2xNtjL>6@S9QR7hgk=GMh^oFIY-1r)_pFexD+KA3?HWpJ31>6C;I;2-=4 zpEL?Y5*~T*%|GzL2mJ}-Ix}s7P~*d#bN1eA@4e1Cd%peodJ13)FBSL%dK_EV3&{n; z$}SX5b19$I3yaq5oMCD9{t9CX`~s0}ZBI*@nw3i~uW#!cjzD1AungysKus*ZD&U`I zW*9XHsi;LjpfPP&`ciRcUAI@XbyF8;PUkl?b5*kqX_uUSXUixE^ripDBPF12USP=% zu~L#GorrSsnDnb?MH}gv`X))M7c;^T=upvsMw!{EqDvxcZ6mkkgm4`< z72LRV^~`?3(RWmIqleed7g?|^?J8sBldo;Vax!eJ?W7d+vGloSbQ@M~u4tH9-ImSz zRSaN|w6dC`35dloVn`^6U+(9osTjtHfU>8VMSXdbJ!6Y;udVwaUhz~Iy%>|)Cne%) zJiZ#lZMN!>zzG$1G08{Nc6W6vD==Cu<4Tdz4cuN+D(>TfK+ws138qiwuuH7LtkENr58!uWGl?^#5}y${M!Ve3Fvu->hVD#Jxj2ln^G!rZsNUF17_n-H$dl?m#D^nB+iDbB@o6%-}KOz!QFc_$C9SG>bWp zl30^IMt+~5Y0ZCx`Sh?n)$;TO5%(N$&(UELl_8}RDw)AbG%BMJ4;>-evpu+*UCM}f zDK4b!3Y`}%yTX;ik#eoN3MyJgsaH|;6&Fz+iH4G^B%k+Yb9^tLk8<==paDMlAjUC7 zxnfvG9B+|;&HwNKBY2Nde83n^IRM{@`iTkrqS#XAc27Vo;5n@jez=0mF?m7ThsD30 C1Ua4n literal 0 HcmV?d00001 diff --git a/trees/FindFullNodesInABinaryTree.java b/trees/FindFullNodesInABinaryTree.java deleted file mode 100644 index 9ef37e1..0000000 --- a/trees/FindFullNodesInABinaryTree.java +++ /dev/null @@ -1,47 +0,0 @@ -package trees; - -//A Binary Tree Node -class Node{ - int data; - Node left , right; - Node(int data) { - this.data = data; - left = right = null ; - - } -} - -public class FindFullNodesInABinaryTree { - - //Traverse given tree in In-order fashion & prints all nodes that have both children as non-empty - public static void findFullNode(Node root) { - if (root!=null) { - findFullNode(root.left); - if(root.left != null && root.right != null) - System.out.println(root.data +" "); - findFullNode(root.right); - } - } - - //Driver method - public static void main(String[] args) { - Node root = new Node(1); - root.left = new Node(2); - root.right = new Node(3); - root.left.left = new Node(4); - root.left.right = new Node(5); - root.right.left = new Node(6); - root.right.right = new Node(7); - root.right.right.right = new Node(8); - root.right.left.right = new Node(9); - root.right.left.left = new Node(10); - root.left.left.left= new Node(11); - root.left.left.right = new Node(12); - root.left.right.left = new Node(13); - root.left.right.right = new Node(14); - - findFullNode(root); - - } - -} diff --git a/trees/Insertion_In_BinaryTree$Node.class b/trees/Insertion_In_BinaryTree$Node.class new file mode 100644 index 0000000000000000000000000000000000000000..c3494029508f7421a5a7fb37aa540aef4fdf6b0b GIT binary patch literal 531 zcmah_Jx>Bb5Pb`W2j|JR_yH&}6hI-Rg~mb><0S+O355+=aD~NlFWEax_*oXj#KIro zk221lv}&>QX5Y^2n>U|d?;ilp(6EtUIEl0nVb@ck(2)$(*i+*xskmMZ>7h9Y9)t~x zA-~`+yz6r{>)uWlVj3|dpTvrRc?^~>9*Jo7|NrcqA*JPPPUTw{QpxC&+FM?GM9?EK z2T5dIILMJet3Aqqq2MBgEt8d8WRN!5t_vG!hFo7NF<3rNgdXyVFBppbV9Naw*V5cK zq!rC&$l%-sOFb3W(iGNyF@0*RGPs^nLicwat1P5{NA*zH9X_0pvQPpwG*S-O1ylX-L literal 0 HcmV?d00001 diff --git a/trees/Insertion_In_BinaryTree.class b/trees/Insertion_In_BinaryTree.class new file mode 100644 index 0000000000000000000000000000000000000000..6d80297f4da874b5d4475da6a76f585c816f482d GIT binary patch literal 2214 zcma)7T~`xV6x|mB6T(oCAjp?QK};eVY88}Fszhz00kqIipsfz%1_qLuFqzQu)~EJ2 z^cV1~wt{u7uD-ce|4RQtSKEDOg33p!JTUj;oO{mR=bW8C{{Hnh0HY{ts1fLO9VyF+ zv{jalYueW1wDow>vF zQOFvOsrJ>w`f=~U5NZ+DaS9D8*qT`u=sP(zW~G^y?c}5*a4~wav5zB`Z9pfwHFOD_ z|9{*%dK8dALFU~Mk)74ij*bRIa9+c?1FX(&m&uThehiQryFzA9XFSqPJMqvlEq9jj zjABy5pg_mla`4!+RwpZFfjCrlQ5`YF`N)Rc77*zWhHyp0<%8ioFC7UClZ7p#P?0lv zhK#0TepIj2{@ckAF5s%7_9JC+^gfmi;yOb`l;Nn38@MS@ZX$_ZRP&f~}gcX%w}X^e9Y@m{q8;41#S}MDF9bYQDdPf%REg2%%MOCjQy0W5K zW%IR;Z}3>PeEDv%;*=?@+CG4if- z-f>}U!&#*ygpUa=5Sq0s&WgNeDv{~=4;{RsYDk?*Tb6WE1*2S+d@!K&O`vgFmfb0- zw5p7AOt6;vT7#g{G_Hb5(fF<7DhMTVA?_~ntNyfSXnc;Qr(D*cng8p(i#D`)C*Y2< zR&`47tK911yJ$V^Qs=qoz5&{BnubB8IaTLx5%BJYdOX#Ic4&Vw`3H~q+ zV+>a*7uS%%bq?1EmT(h!+S*8ZKqEeeDo~DZljb8Q z!F{j3);x<#Z`QU&ALpWb4{L0M*7Y~%Z+mM5O-$<+Q@@RFs%ji53iKUJlb|Oo>>5jJ z;XXF;0N+t+zUR#knDJ<8_aUKxBH!3#FZwjq(nGboP2#|55Y#Ne`yd?dRhM@D3qOnW A@&Et; literal 0 HcmV?d00001 diff --git a/trees/Insertion_In_BinaryTree.java b/trees/Insertion_In_BinaryTree.java deleted file mode 100644 index 98e45ad..0000000 --- a/trees/Insertion_In_BinaryTree.java +++ /dev/null @@ -1,78 +0,0 @@ -package trees; - - // Java program to insert element in binary tree -import java.util.LinkedList; -import java.util.Queue; -public class Insertion_In_BinaryTree { - /* A binary tree node has key, pointer to - left child and a pointer to right child */ - static class Node { - int key; - Node left, right; - - // constructor - Node(int key){ - this.key = key; - left = right = null; - } - } - static Node root; - static Node temp = root; - - //Inorder traversal of a binary tree - static void inorder(Node temp) - { - if (temp == null) - return; - - inorder(temp.left); - System.out.print(temp.key+" "); - inorder(temp.right); - } - - //function to insert element in binary tree - static void insert(Node temp, int key) - { - Queue q = new LinkedList(); - q.add(temp); - - // Do level order traversal until we find - // an empty place. - while (!q.isEmpty()) { - temp = q.peek(); - q.remove(); - - if (temp.left == null) { - temp.left = new Node(key); - break; - } else - q.add(temp.left); - - if (temp.right == null) { - temp.right = new Node(key); - break; - } else - q.add(temp.right); - } - } - - // Driver code - public static void main(String args[]) - { - root = new Node(10); - root.left = new Node(11); - root.left.left = new Node(7); - root.right = new Node(9); - root.right.left = new Node(15); - root.right.right = new Node(8); - - System.out.print( "Inorder traversal before insertion:"); - inorder(root); - - int key = 12; - insert(root, key); - - System.out.print("\nInorder traversal after insertion:"); - inorder(root); - } -} diff --git a/trees/Node.class b/trees/Node.class new file mode 100644 index 0000000000000000000000000000000000000000..e882920baff1cfe8813314b682f14ffb1d88ba51 GIT binary patch literal 390 zcmYLEO;5r=6r63#N3jYP#1A}pgdXJRLE}La6OslFHXOW|Ev&Glv`Hx@{wxo~#DhP; zA7z|H5)b?4y~&%MH{U;>UjVLfUV$Z0D{`e){b4p$6*vNog?yF$M5eR;C|;;ZA>d49 zAqB*MZK7Vtc;Ub5TA-Bc*_?FwMyI;Cp8x!vNYYjFIJk(GZu)Dpn3xPuqC6rCq z^x&dux+4!2R0ZmxPStR|j8z`VI8g$Am`!9dmbo_bj&zE-UeQ7qYRMFj**c%72W|G7 zcRH2%Tf|_`;V8N^iEu#+o4L)SH!FOk-mStw|z31LL=boA0e}4P|u!pvdoIoShN+q4oIv$1UM1rq942 zo+ulZK;>AT%1$Vw!_KGCu^OiW)_H@zRyTud=!Kets;Ti zykeRLVdtIJ@~j^uDO2|T7w`6OB-Ul)9zTJV^e9N0yN1kiwn4i=6r??YZ8r;N*|&x) zaoO7#);<*|Lg1bQ2X{)yqvl{0bhw9HHb>lw<6i{WVX>y>BUE~__gE}P3HP&$aGdaT|D zhC=!3;$N8|1l+FwCM!-a8xn9nMv>C{p-d8$*l6*&EMEg3z~y_QIZ#RZAx=_kP?tPk zp;;7>o=q!<0(XkF@NZWtMt(*G*DA`)nP*mTmyuI;Fg@11of)d$IqrMy86J2)(fD$X z^%)+0Cz{6-?p0XaJ@(&Wr#7$WC7v=;XHRw@r%nEiWfBv%uT z?U|Ncx-Kv<^qk`HC3?I->#<~HSs<9Qa<=J}U0NJ}iT2c7Bc`P7$((d!aRs5{fIv@G zSoW-ZlyPjx?3`8dLg+@Y1HE`v$3aHe(795UWoe)fhscMS%?gBv_Tbkzi$#{z<--PE z!x0kb%7Sy7UiJ({p4ZheDA3nR%ClG%&@ltAA;l2PLQKaQfrAZuJhtrI`LdPIN;ibl2&&;d1CwCl17@)(ZL)ac zMJ(=#rU@q2jz)bonKmDBaMk5YRZo#OEP>wU2fta|ee`4hZScj z?#EH*F3MSO_7C4j`_ENzh@%n%$I-#js3~yX$6XMwppzh7T(@Dr0ulEJ9pHXv_%Zyx z?T6^TaUVVNBf}36Zo{<^QJa17Eqpcd0Q~}wFfgh0X^(M;`=bKiA+QB!S8)qB`?O#2 z#v?>3c)R}|{Mz;}h(5$=;!adW6};O$RYAOh=?X6T&iJr=JoCfkoxy76c8IaUUF~LuH*5MU)X(y~AHl%iIIN>rJVC#Xfl${I e9232N!DuIdq)HoBk>ebq0|WflxVHFdYX2`xn8}s^ literal 0 HcmV?d00001 From 3969bc2b2c7b77d16a1a448660f6a048def90b6f Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Fri, 16 Apr 2021 14:55:19 +0530 Subject: [PATCH 30/56] #Modification 26 --- .vs/ProjectSettings.json | 3 + .vs/VSWorkspaceState.json | 8 +++ .vs/slnx.sqlite | Bin 0 -> 196608 bytes .vs/src/v16/.suo | Bin 0 -> 15360 bytes arrays/Array_Problem_1.java | 41 ++++++----- arrays/Array_Problem_19.java | 28 +++++--- arrays/Array_Problem_20.java | 31 ++++---- binary_search_tree/Find_a_value_in_bst.java | 66 +++++++++++++++++ graphs/Graph.java | 31 ++++---- ...java_5317e4db975f6452a2d44820a699b094.prob | 1 + linkedList/Reverse_a_LL.java | 57 +++++++++++++++ .../linkedList/Multiply_2_no_rep_by_ll.java | 67 ++++++++++++++++++ linkedList/linkedList/Reverse_a_LL$Node.class | Bin 0 -> 416 bytes linkedList/linkedList/Reverse_a_LL.class | Bin 0 -> 1630 bytes 14 files changed, 272 insertions(+), 61 deletions(-) create mode 100644 .vs/ProjectSettings.json create mode 100644 .vs/VSWorkspaceState.json create mode 100644 .vs/slnx.sqlite create mode 100644 .vs/src/v16/.suo create mode 100644 binary_search_tree/Find_a_value_in_bst.java create mode 100644 linkedList/.cph/.Reverse_a_LL.java_5317e4db975f6452a2d44820a699b094.prob create mode 100644 linkedList/Reverse_a_LL.java create mode 100644 linkedList/linkedList/Multiply_2_no_rep_by_ll.java create mode 100644 linkedList/linkedList/Reverse_a_LL$Node.class create mode 100644 linkedList/linkedList/Reverse_a_LL.class diff --git a/.vs/ProjectSettings.json b/.vs/ProjectSettings.json new file mode 100644 index 0000000..f8b4888 --- /dev/null +++ b/.vs/ProjectSettings.json @@ -0,0 +1,3 @@ +{ + "CurrentProjectSetting": null +} \ No newline at end of file diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json new file mode 100644 index 0000000..e91e68d --- /dev/null +++ b/.vs/VSWorkspaceState.json @@ -0,0 +1,8 @@ +{ + "ExpandedNodes": [ + "", + "\\arrays" + ], + "SelectedNode": "\\arrays\\Array_of_objects.java", + "PreviewInSolutionExplorer": false +} \ No newline at end of file diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..eccf197ce05c6df753e79ace0958420acc55b3c3 GIT binary patch literal 196608 zcmeFa2YeGp+CM(4l~!75iv$?cjBPN*7=h((N{Dd*gE3&67BE7V)>vT6Mv?(15F$uO z2&DIfTzZFu^xpeja_OD)#eJs1i`gWVx7{TW(Y7wlB(1KxTgA-TG#wyLEzr@pbKc6rXq-xNoy zXwQMag^j85tvM4{CMVmPAIlJ}nbnZZImX#+^mQr5nUfBaxkSjrWC;tl=2S0iXuxG{ zTv%PzT$_KwOu?Gzb~7itqrSFIMPGFNwWwyMrD}FVtwG5}`$Vdj6eZRNT0y@pwR38l zauzk!FQ{r-ku$$`MNZX{mWB0=5bc86#umsG{9n@0FjDpk5T%ySR6^J`Zb6+H?bj4Mur?4t>5~2SUT{d+4eYk%%b#EHD z0Gd#BcV}-`C{<3h=f|cxteIZuS6H#O_Dm+1wCRhTdOjCL-sE6g_Tg$i-&E!pUtrT^ius} z=vS3`F+5=~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nf;!qxc6w@C|vLVC;t<9x%f_bvbPH2>M>U$c2r zEY4qTbe{15u&Do=_8C6_h^G0|{{ZBfBMbWAQ}cZF zD4`Z5>;UH1ht6Nfey9FiwEeVVEdJB8f3%ah@qf=K!laY`KTiJtu;%`v^Y2#p|Koe( z`TKtV|6|_yW8TyPZHD{_q>D)&O_SpY@}G1jo%<2Z<1fIALg&F6&Pmo_JJ25~9sGSc zc@BFX{OSKv`rmZX`A2>w(g8$^^3Rx7!pO@*=QtM8|6jzH{%>8BKjpRfALjon4J|Lh z)}Vf%vvDG7Kk>E5jJ(0EfbW+4pVmJo|Np$d{{NY0g^xV2H<(Q0&o6%Eoj=|CuW!;a zI25&Hqg&R?zdUMwlH())v5ol#!cUMR5)Q`-4jrF(58aTLtb?to^Dgt%`gVEWb(Zt) zOLEgV=r6k8+HTJs-1kqv_Vb^ find common elements in 3 sorted arrays */ public class Array_Problem_19 { // This function prints common elements in a1 - void findCommon(int[] a1, int[] a2, int[] a3){ + void findCommon(int[] a1, int[] a2, int[] a3) { // Initialize starting indexes for a1[], a2[] and a3[] int i = 0, j = 0, k = 0; // Iterate through three arrays while all arrays have elements - while(i < a1.length && j < a2.length && k < a3.length){ + while (i < a1.length && j < a2.length && k < a3.length) { // if x = y and y = z, print any of them and move ahead in all arrays - if(a1[i] >= a2[j] && a2[j] == a3[k]){ + if (a1[i] >= a2[j] && a2[j] == a3[k]) { System.out.print(a1[i] + " "); i++; k++; } - //x < y - else if(a1[j] < a2[j]) i++; + // x < y + else if (a1[j] < a2[j]) + i++; // y < z - else if(a2[j] y and z < y, i.e., z is smallest - else k++; + else + k++; } } + /* Driver Code */ - public static void main(String[] args){ + public static void main(String[] args) { - int a1[] = {1,5,10,20,40,80}; - int a2[] = {6,7,20,80,100}; - int a3[] = {3,4,15,20,30,70,80,120}; + int a1[] = { 1, 5, 10, 20, 40, 80 }; + int a2[] = { 6, 7, 20, 80, 100 }; + int a3[] = { 3, 4, 15, 20, 30, 70, 80, 120 }; + Array_Problem_19 ob = new Array_Problem_19(); System.out.print("Common elements are "); ob.findCommon(a1, a2, a3); } diff --git a/arrays/Array_Problem_20.java b/arrays/Array_Problem_20.java index db564b2..f327fea 100644 --- a/arrays/Array_Problem_20.java +++ b/arrays/Array_Problem_20.java @@ -1,44 +1,47 @@ package arrays; + /* Problem Title :-> Rearrange the array in alternating positive and negative items with O(1) extra space */ public class Array_Problem_20 { - void rightrotate(int[] a, int n, int outofplace, int cur){ + void rightrotate(int[] a, int n, int outofplace, int cur) { int temp = a[cur]; - for(int i = cur; i > outofplace; i--){ + for (int i = cur; i > outofplace; i--) { a[i] = a[i - 1]; } a[outofplace] = temp; } - void rearrange(int[] a, int n){ + void rearrange(int[] a, int n) { int outofplace = -1; - for(int index = 0; index < n; index++){ - if(outofplace <= 0){ - if(((a[index] > = 0) && (a[outofplace] < 0) || (a[index] < 0) && (a[outofplace] >= 0))){ - if(index-outofplace >= 2) outofplace = outofplace + 2; - else outofplace = -1; + for (int index = 0; index < n; index++) { + if (outofplace <= 0) { + if (((a[index] >= 0) && (a[outofplace] < 0) || (a[index] < 0) && (a[outofplace] >= 0))) { + if (index - outofplace >= 2) + outofplace = outofplace + 2; + else + outofplace = -1; } } - if(outofplace == -1){ - if(((a[index] >= 0) && ((index * 0x01) == 0)) || ((a[index] < 0) && (index & 0x01) == 1)) + if (outofplace == -1) { + if (((a[index] >= 0) && ((index * 0x01) == 0)) || ((a[index] < 0) && (index & 0x01) == 1)) outofplace = index; } } } - void printArray(int[] a, int n){ - for(int i = 0; i < n; i++) + void printArray(int[] a, int n) { + for (int i = 0; i < n; i++) System.out.print(a[i] + " "); System.out.println(" "); } - public static void main(String[] args){ + public static void main(String[] args) { Array_Problem_20 rearrange = new Array_Problem_20(); - int[] a = {-5, -2, 5, 2, 4, 7, 1, 8, 0, -8}; + int[] a = { -5, -2, 5, 2, 4, 7, 1, 8, 0, -8 }; int n = a.length; System.out.println("Given array is "); diff --git a/binary_search_tree/Find_a_value_in_bst.java b/binary_search_tree/Find_a_value_in_bst.java new file mode 100644 index 0000000..e2beb8d --- /dev/null +++ b/binary_search_tree/Find_a_value_in_bst.java @@ -0,0 +1,66 @@ +package binary_search_tree; + +public class Find_a_value_in_bst { + + class Node { + int key; + Node left, right; + + public Node(int item) { + key = item; + left = right = null; + } + } + + Node root; + + // ! Constructor + Find_a_value_in_bst() { + root = null; + } + + // This method mainly calls insertRec() + void insert(int key) { + root = insertRec(root, key); + } + + // * A recursive function to insert a new key in BST + Node insertRec(Node root, int key) { + if (root == null) { + root = new Node(key); + return root; + } + if (key < root.key) + root.left = insertRec(root.left, key); + else if (key > root.key) + root.right = insertRec(root.right, key); + return root; + } + + // The method mainly calls InorderRec() + void inorder() { + inorderRec(root); + } + + // ? A utility function to do inorder traversal of BST + void inorderRec(Node root) { + if (root != null) { + inorderRec(root.left); + System.out.println(root.key); + inorderRec(root.right); + } + } + + public static void main(String[] args) { + Find_a_value_in_bst tree = new Find_a_value_in_bst(); + tree.insert(50); + tree.insert(30); + tree.insert(20); + tree.insert(40); + tree.insert(70); + tree.insert(60); + tree.insert(80); + // ? print inorder traversal of BST + tree.inorder(); + } +} diff --git a/graphs/Graph.java b/graphs/Graph.java index 2ff08b8..11b1c23 100644 --- a/graphs/Graph.java +++ b/graphs/Graph.java @@ -1,41 +1,42 @@ -package dataStructures.graphs; +package graphs; + import java.util.*; public class Graph { - + private LinkedList adj[]; - + @SuppressWarnings("unchecked") public Graph(int v) { - //array of Linked List - adj = new LinkedList[v]; - - for(int i=0;i(); } } - + public void addEdge(int source, int destination) { adj[source].add(destination); - adj[destination].add(source); + adj[destination].add(source); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); - + System.out.println("Enter number of vertices and edges"); int v = sc.nextInt(); int e = sc.nextInt(); - + Graph graph = new Graph(v); System.out.println("Enter " + e + " edges"); - - for(int i=0;i"); + node = node.next; + } + System.out.printf("\n"); + } + + public static void main(String[] args) { + Node first = null; + Node second = null; + first = push(first, 6); + first = push(first, 4); + first = push(first, 9); + System.out.printf("First list is: "); + printList(first); + + second = push(second, 4); + second = push(second, 8); + System.out.printf("Second list is: "); + printList(second); + + System.out.printf("Result is: "); + System.out.println(mul2Lists(first, second)); + } +} diff --git a/linkedList/linkedList/Reverse_a_LL$Node.class b/linkedList/linkedList/Reverse_a_LL$Node.class new file mode 100644 index 0000000000000000000000000000000000000000..7832cfa63ff8e6075a6446024b3b3f100d3ac8c4 GIT binary patch literal 416 zcmaJ-Jx>Bb6r6>FgY)FWFI0@NumB1vEG#rOBu0`8CTeKO0x#z9T$0;^__r*GiG@GF zA7z}Sve9hbo430&^WN^)_s1uI3p4{1uv3PIU6=NJG<@tUcvGEe1=VM1z zWi08V9w#&o9_EX5A~&(y)PGx@&GeG9lm=q6+qunr9E1pQ7@`P2L%^=WAvTE>R_A0mPPOw6)oHGf>!=m- kZ);+ed5cD%(4(kKS%oW)8qad5^VZ=u0%AZ*k98TPAET2|qW}N^ literal 0 HcmV?d00001 diff --git a/linkedList/linkedList/Reverse_a_LL.class b/linkedList/linkedList/Reverse_a_LL.class new file mode 100644 index 0000000000000000000000000000000000000000..ac38191b26f372a92082c54e8f7d6775fe593ff3 GIT binary patch literal 1630 zcmah~QF9Yj6#i}!x=Fg2Hf>U28ssGr5QP&;$l6C54H1xzI>F#$4Oi?@QFa8<#m;S*>GJo ztUJ>8l~3=Ml3jsC%dy>_>RPrRRKHcbYUr!`^1fvi^{$%0#AVyHgDV2@Qu!{o)kCn1 zWxJ}i)8ACXJ95(@yfKV63tTB3jafcAEO5LX$WE^*2P5dzU}(F6W+-s_|G+iJzO-F| zeCbDPTkguLBi#qpc0iB^HQhtH?d=RZYQxsNr^lOK)A<6EE#(JIrMvS@ zGEu{26Q6;4OkMN5zz>FU&{V;e*Yz_KxSGW0CceNm19cN$;wyo~9D_tx22@5g(zuQr0x?1SxxVbFy61Le@Vy;u(eeZ7 z2Ar;3sZl;GzQ9b#=yi0?PI$l$&n#Cuyek|#;@vgS(BfJG#e>Fdch~Ew(eXxHHe@I8 zhIFQ{{9=?@J4|5A^V-Hcdjs``^zo^SWUq~DF@mT| z$7$Pvsu{Q?aOO}$Z{o(s_2@hl`0P*fH6f7HvqLMvA19ce6SPk8&XK{f<$Z|XXb7C- zbs}`eX>p`z>r@{x9OHdSG%GD}DY5zj`PIjW(OUTfvDN0uMC;+JzgMivugr>tILk=W z&T=)w!m}ik!z9a3lR%!RCz!R!3I#0i17r|;3By1t`sV54V2=pgButE+g~|)eKSI3n z7>TEv(i2S3j#&?1{iR!oN@v4P3%s6Y@g){1h9we=&+{Gm9*aheJ!g)_{rMS;d;3UQ z&ycz|_1!+wzhm+dCc|ZhOLoa6D`}50?il%|X8(1@v!-Un^d~qT-QEe&;@J!XWS^Zn zNH`FF9VVHaS8|N{^I`$aV9qO)^n61xOu)7&r ZT6X Date: Fri, 16 Apr 2021 15:03:39 +0530 Subject: [PATCH 31/56] readme updated --- README.md | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/README.md b/README.md index dc17978..c6a646b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -<<<<<<< HEAD # Java-Programs This is a repository where, I will upload and keep up to date my Java, DataStructure and algorithms code and question regarding to them,which i practiced on eclipse & IntelliJ with help of Books and programming websites. The books I prefer and use for learning java and algorithms are: @@ -6,11 +5,4 @@ This is a repository where, I will upload and keep up to date my Java, DataStruc 2. Java The Complete Reference by Herberth Schildt. 3. Algorithms by Sedwig. 4. Algorithms by Cormen. -======= -# Java-Programs java -This is a repository where, I will upload and keep up to date my Java, DataStructure and algorithms code and question regarding to them,which i practiced on eclipse & IntelliJ with help of Books and programming websites. The books I prefer and use for learning java and algorithms are: - -1. Java for Dummies. -2. Algorithms by Sedwig. -3. Algorithms by Cormen. ->>>>>>> fc390b5cc5867b507eabc367ba4f0b0ac46bf243 + java From 74fbcac5e7e743b08b72f8847ac69e35a46e8c81 Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Mon, 19 Apr 2021 22:03:08 +0530 Subject: [PATCH 32/56] #Modification 29 --- .../Deletion_of_a_node_in_bst.java | 115 ++++++++++++++++++ binary_search_tree/Find_a_value_in_bst.java | 2 - .../Count_set_bit_in_integer.class | Bin 0 -> 581 bytes .../Count_set_bit_in_integer.java | 22 ++++ 4 files changed, 137 insertions(+), 2 deletions(-) create mode 100644 binary_search_tree/Deletion_of_a_node_in_bst.java create mode 100644 bit_manupulation/Count_set_bit_in_integer.class create mode 100644 bit_manupulation/Count_set_bit_in_integer.java diff --git a/binary_search_tree/Deletion_of_a_node_in_bst.java b/binary_search_tree/Deletion_of_a_node_in_bst.java new file mode 100644 index 0000000..b601f0c --- /dev/null +++ b/binary_search_tree/Deletion_of_a_node_in_bst.java @@ -0,0 +1,115 @@ +/** + * Deletion_of_a_node_in_bst + */ +public class Deletion_of_a_node_in_bst { + class Node { + int key; + Node left, right; + + Node(int item) { + key = item; + left = right = null; + } + } + + Node root; + + Deletion_of_a_node_in_bst() { + root = null; + } + + void deleteKey(int key) { + root = deleteRec(root, key); + } + + Node deleteRec(Node root, int key) { + if (root == null) + return root; + if (key < root.key) + root.left = deleteRec(root.left, key); + else if (key > root.key) + root.right = deleteRec(root.right, key); + else { + if (root.left == null) + return root.right; + else if (root.right == null) + return root.left; + + root.key = minValue(root.right); + root.right = deleteRec(root.right, root.key); + } + return root; + } + + int minValue(Node root) { + int minv = root.key; + while (root.left != null) { + minv = root.left.key; + root = root.left; + } + return minv; + } + + void insert(int key) { + root = insertRec(root, key); + } + + Node insertRec(Node root, int key) { + if (root == null) { + root = new Node(key); + return root; + } + if (key < root.key) + root.left = insertRec(root.left, key); + else if (key > root.key) + root.right = insertRec(root.right, key); + return root; + } + + void inorder() { + inorderRec(root); + } + + void inorderRec(Node root) { + if (root != null) + inorderRec(root.left); + System.out.print(root.key + " "); + inorderRec(root.right); + + } + + public static void main(String[] args) { + Deletion_of_a_node_in_bst tree = new Deletion_of_a_node_in_bst(); + // * Let us create following BST + // ? 50 + // ? / \ + // ? 30 70 + // ? / \ / \ + // ?20 40 60 80 */ + tree.insert(50); + tree.insert(30); + tree.insert(20); + tree.insert(40); + tree.insert(70); + tree.insert(60); + tree.insert(80); + + System.out.println("Inorder traversal of the given tree"); + tree.inorder(); + + System.out.println("\nDelete 20"); + tree.deleteKey(20); + System.out.println("Inorder traversal of the modified tree"); + tree.inorder(); + + System.out.println("\nDelete 30"); + tree.deleteKey(30); + System.out.println("Inorder traversal of the modified tree"); + tree.inorder(); + + System.out.println("\nDelete 50"); + tree.deleteKey(50); + System.out.println("Inorder traversal of the modified tree"); + tree.inorder(); + } +} \ No newline at end of file diff --git a/binary_search_tree/Find_a_value_in_bst.java b/binary_search_tree/Find_a_value_in_bst.java index e2beb8d..b6dc3b9 100644 --- a/binary_search_tree/Find_a_value_in_bst.java +++ b/binary_search_tree/Find_a_value_in_bst.java @@ -1,5 +1,3 @@ -package binary_search_tree; - public class Find_a_value_in_bst { class Node { diff --git a/bit_manupulation/Count_set_bit_in_integer.class b/bit_manupulation/Count_set_bit_in_integer.class new file mode 100644 index 0000000000000000000000000000000000000000..a953708ae28e48c13fdcbdfd92b9c2dcb771dd79 GIT binary patch literal 581 zcmZuuO-~b16g_Wdn4xtjgU~8172LHf=+Z?S7m|=bP)WwHaZz8(OY^YvrfJ`h;KHBc z){PrkpmE_3@aMQD%6Y8`Au*ZUd*8k1ocl4q{`~j};2Czx2=TClb!?QeglZWzJc{r* z!lppj(?;9p0)DG~DiG}FXG&o8SR3`K$OdZqMh?cz#KXKWHdXe8wlm^dhwVdwmDI}N z`9 zrhASXBf@fodW;6PVmv?`p&8=|wguV_pGl)9#aLRMo6f$Q?mtoj$=x8Y2j^;N@1@eq znN=CL&kGi+i>Yie=goUrl;J zzqI=e;wuB*fi_$u3FB^z9rTD)kG|^n>YtD_>cPi%y?XGW`}yzh#upa6Ikm=4VC0b+ zk{n}&e|MD@?CagY6AASyOf7Wx2z9!Zq}02D*Z2;+RhqYTt C5On+i literal 0 HcmV?d00001 diff --git a/bit_manupulation/Count_set_bit_in_integer.java b/bit_manupulation/Count_set_bit_in_integer.java new file mode 100644 index 0000000..5a949be --- /dev/null +++ b/bit_manupulation/Count_set_bit_in_integer.java @@ -0,0 +1,22 @@ +package bit_manipulation; + +import java.io.*; + +public class Count_set_bit_in_integer { + /* + * Function to get no of set bits in binary representation of positive integer n + */ + static int countSetBits(int n) { + int count = 0; + while (n > 0) { + count += n & 1; + n >>= 1; + } + return count; + } + + public static void main(String[] args) { + int i = 9; + System.out.println(countSetBits(i)); + } +} From aaef137579a57143c61330a2f33644a6193afdd0 Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Fri, 30 Apr 2021 22:04:49 +0530 Subject: [PATCH 33/56] #Modification 27 --- arrays/Array_Problem_21.java | 45 +++++++++++++++++- arrays/Array_Problem_22.java | 47 ++++++++++++++++++- arrays/Array_Problem_24.java | 38 ++++++++++++++- arrays/Array_Problem_25.java | 3 +- arrays/Array_Problem_26.java | 3 +- arrays/Array_Problem_27.java | 3 +- arrays/Array_Problem_28.java | 3 +- arrays/Array_Problem_29.java | 3 +- arrays/Array_Problem_4_Approach1.java | 1 + .../Deletion_of_a_node_in_bst.java | 2 + binary_search_tree/Find_a_value_in_bst.java | 2 + .../Count_set_bit_in_integer.java | 4 +- oops/Mor.java | 2 +- 13 files changed, 144 insertions(+), 12 deletions(-) diff --git a/arrays/Array_Problem_21.java b/arrays/Array_Problem_21.java index edd0ff8..1d752e9 100644 --- a/arrays/Array_Problem_21.java +++ b/arrays/Array_Problem_21.java @@ -1,4 +1,47 @@ package arrays; -/* Problem Title :-> */ +/* + * Problem Title :-> + * Find if there is any sub array with sum equal to 0 + */ + +import java.util.*; + +/* + * Generalisation + * a[2, 3, -1, -2, 4, 5]; -> The array + * here their are n^2 + 1 sub arrays, in an array of any size n. + * now the sub array of have a sum equal to zero is from index a[1] to index a[3] in this case. + */ + public class Array_Problem_21 { + static Boolean subArrayExists(int[] a) { + // Creates an empty hash set h_s + Set hs = new HashSet<>(); + // Initialise sum of elements + int sum = 0; + // Traverse through the given array + for(int i = 0; i < a.length; i++) { + // Add current element to sum + sum += a[i]; + /* + * Return true in following cases + * a). Current element is 0 + * b). sum of elements from 0 to i is 0 + * c). sum is already present in hash map + */ + if(a[i] == 0 || sum == 0 || hs.contains(sum)) return true; + // Add sum to hash set + hs.add(sum); + } + // We reach here only when there is no sub_array with 0 sum + return false; + } + // Driver Code + public static void main(String[] args) { + int[] a = {2, 3, -1, -2, 4, 5}; + if(subArrayExists(a)) + System.out.println("Found a subarray with 0 sum"); + else + System.out.println("No Such Sub Array Exists!"); + } } diff --git a/arrays/Array_Problem_22.java b/arrays/Array_Problem_22.java index 9279cf2..00979e1 100644 --- a/arrays/Array_Problem_22.java +++ b/arrays/Array_Problem_22.java @@ -1,4 +1,49 @@ package arrays; -/* Problem Title :-> */ +/* Problem Title :-> Find factorial of a large number + */ public class Array_Problem_22 { + + // This function finds factorial of large numbers and prints them + static void factorial(int n) { + + int[] res = new int[500]; + + res[0] = 1; + + int res_size = 1; + + for(int x = 2; x <= n; x++) + res_size = multiply(x, res, res_size); + + System.out.println("Factorial of given number is "); + + for(int i = res_size - 1; i >= 0; i--) + System.out.print(res[i]); + } + + // This function multiplies x with the number represented by res[]. + static int multiply(int x, int[] res, int res_size) { + + int carry = 0; + + // one by one multiply n with individual digits of res[]. + for(int i = 0; i < res_size; i++) { + int prod = res[i] * x + carry; + res[i] = prod % 10; + carry = prod/10; + } + + // put carry in res and increase result size + while(carry != 0) { + res[res_size] = carry % 10; + carry = carry/10; + res_size++; + } + return res_size; + } + + // Driver program + public static void main(String[] args) { + factorial(100); + } } diff --git a/arrays/Array_Problem_24.java b/arrays/Array_Problem_24.java index da2f3c3..d083820 100644 --- a/arrays/Array_Problem_24.java +++ b/arrays/Array_Problem_24.java @@ -1,4 +1,40 @@ package arrays; -/* Problem Title :-> */ +/* + * Problem Title :-> Find longest consecutive subsequence + */ + +import java.util.*; + public class Array_Problem_24 { + + static int findLogestSubseq(int[] a, int n) { + // Sort the array + Arrays.sort(a); + int ans = 0, count = 0; + + ArrayList v = new ArrayList<>(); + v.add(10); + + // Insert repeated elements only once in the vector + for(int i = 1; i < n; i++) { + if(a[i] != a[i -1]) v.add(a[i]); + } + + // Find the max length by traversing the array + for(int i = 0; i < v.size(); i++) { + // check if the current element is equal to previous element + 1 + if(i > 0 && v.get(i) == v.get(i - 1) + 1) count++; + else count = 1; + // Update the maximum + ans = Math.max(ans, count); + } + return ans; + } + + // Driver Code + public static void main(String[] args) { + int[] a = {1,9,3,10,4,20,2}; + int n = a.length; + System.out.println("Length of the Longest "+ "contiguous subsequence is " + findLogestSubseq(a, n)); + } } diff --git a/arrays/Array_Problem_25.java b/arrays/Array_Problem_25.java index 4655de6..fa7b610 100644 --- a/arrays/Array_Problem_25.java +++ b/arrays/Array_Problem_25.java @@ -1,4 +1,5 @@ package arrays; -/* Problem Title :-> */ +/* Problem Title :-> Given an array of size n and a number k, fin all elements that appear more than " n/k " times. + */ public class Array_Problem_25 { } diff --git a/arrays/Array_Problem_26.java b/arrays/Array_Problem_26.java index da75c41..53508f4 100644 --- a/arrays/Array_Problem_26.java +++ b/arrays/Array_Problem_26.java @@ -1,4 +1,5 @@ package arrays; -/* Problem Title :-> */ +/* Problem Title :-> Maximum profit by buying and selling a share atmost twice +*/ public class Array_Problem_26 { } diff --git a/arrays/Array_Problem_27.java b/arrays/Array_Problem_27.java index 4a5df23..c85cb6a 100644 --- a/arrays/Array_Problem_27.java +++ b/arrays/Array_Problem_27.java @@ -1,6 +1,7 @@ package arrays; -/* Problem Title :-> */ +/* Problem Title :-> Find whether an array is a subset of another array + */ public class Array_Problem_27 { diff --git a/arrays/Array_Problem_28.java b/arrays/Array_Problem_28.java index 5de85b5..6ca3201 100644 --- a/arrays/Array_Problem_28.java +++ b/arrays/Array_Problem_28.java @@ -1,4 +1,5 @@ package arrays; -/* Problem Title :-> */ +/* Problem Title :-> Find whether an array is a subset of another array +*/ public class Array_Problem_28 { } diff --git a/arrays/Array_Problem_29.java b/arrays/Array_Problem_29.java index 3c1293b..670e166 100644 --- a/arrays/Array_Problem_29.java +++ b/arrays/Array_Problem_29.java @@ -1,4 +1,5 @@ package arrays; -/* Problem Title :-> */ +/* Problem Title :-> Find the triplet that sum to a given value + */ public class Array_Problem_29 { } diff --git a/arrays/Array_Problem_4_Approach1.java b/arrays/Array_Problem_4_Approach1.java index b1e4e48..b3c5c4d 100644 --- a/arrays/Array_Problem_4_Approach1.java +++ b/arrays/Array_Problem_4_Approach1.java @@ -1,3 +1,4 @@ + package arrays; import java.io.*; diff --git a/binary_search_tree/Deletion_of_a_node_in_bst.java b/binary_search_tree/Deletion_of_a_node_in_bst.java index b601f0c..2ca3747 100644 --- a/binary_search_tree/Deletion_of_a_node_in_bst.java +++ b/binary_search_tree/Deletion_of_a_node_in_bst.java @@ -1,3 +1,5 @@ +package binary_search_tree; + /** * Deletion_of_a_node_in_bst */ diff --git a/binary_search_tree/Find_a_value_in_bst.java b/binary_search_tree/Find_a_value_in_bst.java index b6dc3b9..e2beb8d 100644 --- a/binary_search_tree/Find_a_value_in_bst.java +++ b/binary_search_tree/Find_a_value_in_bst.java @@ -1,3 +1,5 @@ +package binary_search_tree; + public class Find_a_value_in_bst { class Node { diff --git a/bit_manupulation/Count_set_bit_in_integer.java b/bit_manupulation/Count_set_bit_in_integer.java index 5a949be..838ed63 100644 --- a/bit_manupulation/Count_set_bit_in_integer.java +++ b/bit_manupulation/Count_set_bit_in_integer.java @@ -1,6 +1,4 @@ -package bit_manipulation; - -import java.io.*; +package bit_manupulation; public class Count_set_bit_in_integer { /* diff --git a/oops/Mor.java b/oops/Mor.java index 31ccaa6..d5c5cfd 100644 --- a/oops/Mor.java +++ b/oops/Mor.java @@ -1,5 +1,5 @@ package oops; - +import public class Mor extends Watches { //overrided function From 48361e264d75ca7b090cbf70f1a432e6b60414a0 Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Fri, 30 Apr 2021 22:07:03 +0530 Subject: [PATCH 34/56] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c6a646b..e557f61 100644 --- a/README.md +++ b/README.md @@ -5,4 +5,4 @@ This is a repository where, I will upload and keep up to date my Java, DataStruc 2. Java The Complete Reference by Herberth Schildt. 3. Algorithms by Sedwig. 4. Algorithms by Cormen. - java + java From e9a5b8d994a5543072de388ce9470f142b5b4871 Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Sat, 1 May 2021 12:11:37 +0530 Subject: [PATCH 35/56] #Modification 28 Array Completed --- arrays/Array_Problem_25.java | 90 +++++++++++++++++++++++++++++++++++- arrays/Array_Problem_26.java | 37 +++++++++++++++ arrays/Array_Problem_27.java | 23 ++++++++- arrays/Array_Problem_29.java | 21 +++++++++ 4 files changed, 169 insertions(+), 2 deletions(-) diff --git a/arrays/Array_Problem_25.java b/arrays/Array_Problem_25.java index fa7b610..cc0c8dc 100644 --- a/arrays/Array_Problem_25.java +++ b/arrays/Array_Problem_25.java @@ -1,5 +1,93 @@ package arrays; /* Problem Title :-> Given an array of size n and a number k, fin all elements that appear more than " n/k " times. */ -public class Array_Problem_25 { +import java.util.*; + +class Array_Problem_25 { + + static class eleCount{ + int e, c; + } + + static void moreThanNdk(int[] a, int n, int k) { + + if(k < 2) return; + + eleCount[] temp = new eleCount[k-1]; + + for(int i = 0; i < k-1; i++) { + temp[i] = new eleCount(); + } + + for(int i = 0; i < k-1; i++) { + temp[i].c = 0; + } + + for(int i = 0; i < n; i++) { + + int j; + + for(j = 0; j < k - 1; j++) { + if(temp[j].e == a[i]) { + temp[j].c += 1; + break; + } + } + + if(j == k - 1) { + int l; + for(l = 0; l < k - 1; l++) { + if(temp[1].c == 0) { + temp[l].e = a[i]; + temp[l].c = 1; + break; + } + } + + if(l == k - 1) + for(l = 0; l < k-1; l++) + temp[l].c -= 1; + } + } + for(int i = 0; i < k -1; i++) { + + int ac = 0; + + for(int j = 0; j < n; j++) { + if(a[j] == temp[i].e) + ac++; + } + + if(ac > n/k) + System.out.println("Number:" + temp[i].e + " Count:" + ac + "\n"); + } + } + + // Driver Code + public static void main(String[] args) { + + System.out.println("First Test\n"); + int[] a1 = {4,5,6,7,8,4,4}; + int size = a1.length; + int k = 3; + moreThanNdk(a1, size, k); + + System.out.println("\nSecond Test\n"); + int[] a2 = {4,5,6,7,8,4,4}; + size = a2.length; + k = 3; + moreThanNdk(a2, size, k); + + System.out.println("\nThird Test\n"); + int[] a3 = {4,5,6,7,8,4,4}; + size = a3.length; + k = 3; + moreThanNdk(a3, size, k); + + System.out.println("\nFourth Test\n"); + int[] a4 = {4,5,6,7,8,4,4}; + size = a4.length; + k = 3; + moreThanNdk(a4, size, k); + } } diff --git a/arrays/Array_Problem_26.java b/arrays/Array_Problem_26.java index 53508f4..dce5691 100644 --- a/arrays/Array_Problem_26.java +++ b/arrays/Array_Problem_26.java @@ -2,4 +2,41 @@ /* Problem Title :-> Maximum profit by buying and selling a share atmost twice */ public class Array_Problem_26 { + static int maxProfit(int[] price, int n) { + + int[] profit = new int[n]; + + for(int i =0; i < n; i++) { + profit[i] = 0; + } + + int max_price = price[n-1]; + + for(int i = n -2; i >= 0; i--) { + if(price[i] > max_price) + max_price = price[i]; + + profit[i] = Math.max(profit[i + 1], max_price - price[i]); + } + + int min_price = price[0]; + + for(int i = 1; i < n; i++) { + + if(price[i] < min_price) + min_price = price[i]; + + profit[i]= Math.max( + profit[i-1], + profit[i] + (price[i] - min_price) + ); + } + int result = profit[n - 1]; + return result; + } + public static void main(String[] args) { + int[] price = {2, 30, 15, 10, 8, 25, 80}; + int n = price.length; + System.out.println("Maximum Profit = " + maxProfit(price, n)); + } } diff --git a/arrays/Array_Problem_27.java b/arrays/Array_Problem_27.java index c85cb6a..09d417d 100644 --- a/arrays/Array_Problem_27.java +++ b/arrays/Array_Problem_27.java @@ -4,5 +4,26 @@ */ public class Array_Problem_27 { - + static boolean isSubSet(int[] a1, int[] a2, int m, int n) { + int i = 0, j = 0; + for(i = 0; i < n; i++) { + for(j = 0; j < m; j++) { + if(a2[i] == a1[j]) break; + if(j == m) return false; + } + } + return true; + } + + public static void main(String args[]) { + int[] a1 = {11, 1, 13, 21, 3, 7}; + int[] a2 = {11, 3, 7, 1}; + int m = a1.length; + int n = a2.length; + + if(isSubSet(a1, a2, m, n)) + System.out.println("a2[] is " + "subset of a1[] "); + else + System.out.println("a2 is " + "not a subset of a1[]"); + } } diff --git a/arrays/Array_Problem_29.java b/arrays/Array_Problem_29.java index 670e166..fd510ae 100644 --- a/arrays/Array_Problem_29.java +++ b/arrays/Array_Problem_29.java @@ -2,4 +2,25 @@ /* Problem Title :-> Find the triplet that sum to a given value */ public class Array_Problem_29 { + boolean find3Numbers(int[] A, int a_size, int sum) { + int l, r; + for(int i = 0; i < a_size - 2; i++) { + for(int j = i + 1; j < a_size - 1; j++) { + for(int k = j + 1; k < a_size; k++) { + if(A[i] + A[j] + A[k] == sum) { + System.out.println("Triplet is " + A[i] + ", " + A[j] + ", " + A[k]); + return true; + } + } + } + } + return false; + } + public static void main(String[] args) { + Array_Problem_29 triplet = new Array_Problem_29(); + int[] A = {1, 4, 45, 6, 10, 8}; + int sum = 22; + int a_size = A.length; + triplet.find3Numbers(A, a_size, sum); + } } From 5ec507a32d00400aa98d1d47588f260bada6e905 Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Tue, 4 May 2021 16:38:59 +0530 Subject: [PATCH 36/56] #Modification 29 --- backtracking/Word_Break_PUB.java | 41 +++++ binaryTree/BT_Problem_06_a.java | 2 +- binaryTree/BT_Problem_06_b.java | 110 ++++-------- binaryTree/BT_Problem_07.java | 15 -- binaryTree/BT_Problem_07_a.java | 55 ++++++ binaryTree/BT_Problem_07_b.java | 52 ++++++ binaryTree/BT_Problem_08.java | 10 -- binaryTree/BT_Problem_08_a.java | 90 ++++++++++ binaryTree/BT_Problem_08_b.java | 47 ++++++ dataStructures/graphs/Graph.class | Bin 1785 -> 0 bytes dataStructures/graphs/Graph.java | 41 ----- queues/ArrayDequeDemo.class | Bin 1272 -> 0 bytes stack/stack/Postfix.class | Bin 2162 -> 0 bytes .../Stack_Queue_Problem_03.class | Bin 1840 -> 0 bytes ...java_c181a202ca338689c15dd0c5b3b84d60.prob | 1 - string/Append.class | Bin 879 -> 0 bytes ...java_99fbe9a6d479d3fea744cafd49bd01c0.prob | 1 - ...java_63c5e7cc4610c2b023e3b74d2ff6f26b.prob | 1 - trees/BST_Deletion$Node.class | Bin 569 -> 0 bytes trees/BST_Deletion.class | Bin 2628 -> 0 bytes trees/BST_Deletion.java | 158 ------------------ trees/BT_Traversal$Node.class | Bin 494 -> 0 bytes trees/BT_Traversal.class | Bin 2089 -> 0 bytes trees/BT_Traversal.java | 82 --------- trees/BinarySearchTree$Node.class | Bin 593 -> 0 bytes trees/BinarySearchTree.class | Bin 1542 -> 0 bytes trees/BinarySearchTree.java | 83 --------- trees/BinaryTreeNode.class | Bin 596 -> 0 bytes trees/BinaryTreeNode.java | 13 -- trees/BinaryTreeUse.class | Bin 2177 -> 0 bytes trees/BinaryTreeUse.java | 51 ------ trees/BinaryTree_LOT.class | Bin 1756 -> 0 bytes trees/BinaryTree_LOT.java | 99 ----------- trees/BinaryTree_Traversal$Node.class | Bin 617 -> 0 bytes trees/BinaryTree_Traversal.class | Bin 2227 -> 0 bytes trees/BinaryTree_Traversal.java | 96 ----------- trees/Binary_Tree_01.class | Bin 1756 -> 0 bytes trees/Binary_Tree_01.java | 89 ---------- ...truct_Tree_from_Preorder_and_Inorder.class | Bin 1436 -> 0 bytes ...struct_Tree_from_Preorder_and_Inorder.java | 69 -------- trees/Count_leaf_nodes$BinaryTreeNode.class | Bin 1617 -> 0 bytes trees/Count_leaf_nodes.class | Bin 400 -> 0 bytes trees/Count_leaf_nodes.java | 29 ---- trees/FindFullNodesInABinaryTree.class | Bin 1406 -> 0 bytes trees/FindFullNodesInABinaryTree.java | 55 ------ trees/Insertion_In_BinaryTree$Node.class | Bin 531 -> 0 bytes trees/Insertion_In_BinaryTree.class | Bin 2214 -> 0 bytes trees/Insertion_In_BinaryTree.java | 80 --------- trees/Node.class | Bin 390 -> 0 bytes trees/Problem_01$TreeNode.class | Bin 878 -> 0 bytes trees/Problem_01.class | Bin 1893 -> 0 bytes trees/Problem_01.java | 85 ---------- trees/trees/BinaryTree_Traversal$Node.class | Bin 554 -> 0 bytes trees/trees/BinaryTree_Traversal.class | Bin 2145 -> 0 bytes trees/trees/FindFullNodesInABinaryTree.class | Bin 1159 -> 0 bytes trees/trees/Node.class | Bin 339 -> 0 bytes 56 files changed, 316 insertions(+), 1139 deletions(-) create mode 100644 backtracking/Word_Break_PUB.java delete mode 100644 binaryTree/BT_Problem_07.java create mode 100644 binaryTree/BT_Problem_07_a.java create mode 100644 binaryTree/BT_Problem_07_b.java delete mode 100644 binaryTree/BT_Problem_08.java create mode 100644 binaryTree/BT_Problem_08_a.java create mode 100644 binaryTree/BT_Problem_08_b.java delete mode 100644 dataStructures/graphs/Graph.class delete mode 100644 dataStructures/graphs/Graph.java delete mode 100644 queues/ArrayDequeDemo.class delete mode 100644 stack/stack/Postfix.class delete mode 100644 stack_and_queue/stack_and_queue/Stack_Queue_Problem_03.class delete mode 100644 string/.cph/.Append.java_c181a202ca338689c15dd0c5b3b84d60.prob delete mode 100644 string/Append.class delete mode 100644 trees/.cph/.BinaryTree_Traversal.java_99fbe9a6d479d3fea744cafd49bd01c0.prob delete mode 100644 trees/.cph/.FindFullNodesInABinaryTree.java_63c5e7cc4610c2b023e3b74d2ff6f26b.prob delete mode 100644 trees/BST_Deletion$Node.class delete mode 100644 trees/BST_Deletion.class delete mode 100644 trees/BST_Deletion.java delete mode 100644 trees/BT_Traversal$Node.class delete mode 100644 trees/BT_Traversal.class delete mode 100644 trees/BT_Traversal.java delete mode 100644 trees/BinarySearchTree$Node.class delete mode 100644 trees/BinarySearchTree.class delete mode 100644 trees/BinarySearchTree.java delete mode 100644 trees/BinaryTreeNode.class delete mode 100644 trees/BinaryTreeNode.java delete mode 100644 trees/BinaryTreeUse.class delete mode 100644 trees/BinaryTreeUse.java delete mode 100644 trees/BinaryTree_LOT.class delete mode 100644 trees/BinaryTree_LOT.java delete mode 100644 trees/BinaryTree_Traversal$Node.class delete mode 100644 trees/BinaryTree_Traversal.class delete mode 100644 trees/BinaryTree_Traversal.java delete mode 100644 trees/Binary_Tree_01.class delete mode 100644 trees/Binary_Tree_01.java delete mode 100644 trees/Construct_Tree_from_Preorder_and_Inorder.class delete mode 100644 trees/Construct_Tree_from_Preorder_and_Inorder.java delete mode 100644 trees/Count_leaf_nodes$BinaryTreeNode.class delete mode 100644 trees/Count_leaf_nodes.class delete mode 100644 trees/Count_leaf_nodes.java delete mode 100644 trees/FindFullNodesInABinaryTree.class delete mode 100644 trees/FindFullNodesInABinaryTree.java delete mode 100644 trees/Insertion_In_BinaryTree$Node.class delete mode 100644 trees/Insertion_In_BinaryTree.class delete mode 100644 trees/Insertion_In_BinaryTree.java delete mode 100644 trees/Node.class delete mode 100644 trees/Problem_01$TreeNode.class delete mode 100644 trees/Problem_01.class delete mode 100644 trees/Problem_01.java delete mode 100644 trees/trees/BinaryTree_Traversal$Node.class delete mode 100644 trees/trees/BinaryTree_Traversal.class delete mode 100644 trees/trees/FindFullNodesInABinaryTree.class delete mode 100644 trees/trees/Node.class diff --git a/backtracking/Word_Break_PUB.java b/backtracking/Word_Break_PUB.java new file mode 100644 index 0000000..5b48b5e --- /dev/null +++ b/backtracking/Word_Break_PUB.java @@ -0,0 +1,41 @@ +package backtracking; +import java.util.*; + +public class Word_Break_PUB { + + private static void backtrack(String sentence, String A, String sentence2, ArrayList result) { + + if(A.length() == 0) { + result.add(sentence); + return; + } + + for(int i = 0; i < A.length(); i++) { + + String substring = A.substring(0, i + 1); + + if(sentence2.contains(substring)) { + String newSentence = sentence + " " + substring; + backtrack(newSentence.trim(), A.substring( i + 1, A.length() ), sentence2, result); + } + } + } + + public static ArrayList wordBreak(String A, String sentence) { + ArrayList result = new ArrayList<>(); + backtrack("", A, sentence, result); + return result; + } + + public static void main(String[] args) { + + String sentence = "I Like mango icecream and SamSung Mobile"; + String A = null; + String[] result; + String[] dictionary = {"mobile", "samsung", "sam", "sung", "man", "mango", "icecream", "and", "go", "i", "like", + "icecream"}; + + System.out.println(wordBreak(A,sentence)); + } + +} diff --git a/binaryTree/BT_Problem_06_a.java b/binaryTree/BT_Problem_06_a.java index 9886cdd..6d7c25c 100644 --- a/binaryTree/BT_Problem_06_a.java +++ b/binaryTree/BT_Problem_06_a.java @@ -1,7 +1,7 @@ package binaryTree; import java.util.*; /* - * Problem Title :- In-order Traversal of a tree both using Recursion + * Problem Title :- In-order Traversal of a tree without using Recursion */ // Class to print the in-order traversal public class BT_Problem_06_a { diff --git a/binaryTree/BT_Problem_06_b.java b/binaryTree/BT_Problem_06_b.java index 1bb728f..cdace6c 100644 --- a/binaryTree/BT_Problem_06_b.java +++ b/binaryTree/BT_Problem_06_b.java @@ -1,98 +1,48 @@ package binaryTree; /* - * Problem Title :- In-order Traversal of a tree both using Recursion + * Problem Title :- In-order Traversal of a tree using Recursion */ public class BT_Problem_06_b { - // Root of Binary Tree - Node root; + Node root; + + // Constructor + BT_Problem_06_b(){ + root = null; + } - // Constructor - BT_Problem_06_b(){ - root = null; - } - - /* - * Given a binary tree, - * print its nodes according to the - * "bottom-up" post-order traversal. - */ - void printPostorder(Node node) { - if(node == null) - return; - // first recur on left subtree - printPostorder(node.left); - - // then recur on right subtree - printPostorder(node.right); - - // now deal with the node - System.out.print(node.data + " "); - } - - /* - * Given a binary tree, - * print its nodes in in-order - */ - void printInorder(Node node) { + //Given a binary tree, print its nodes in in-order + void printInorder(Node node) { - if(node == null) return; + if(node == null) return; - /* first recur on left child */ - printPreorder(node.left); + /* first recur on left child */ + printInorder(node.left); - /* then print data of node */ - System.out.print(node.data + " "); + /* then print data of node */ + System.out.print(node.data + " "); - /* now recur on right child */ - printPreorder(node.right); - } + /* now recur on right child */ + printInorder(node.right); + } - /* - * Given a binary tree, - * print its nodes in preorder - */ - void printPreorder(Node node) { - - if(node == null) return; - - /* first print data of node */ - System.out.print(node.data + " "); - - /* then recur on left subtree */ - printPreorder(node.left); - - /* now recur on right subtree */ - printPreorder(node.right); - } + // Wrappers over above recursive function + void printInorder() { printInorder(root); } - // Wrappers over above recursive functions - void printPostorder() { printPostorder(root);} - void printInorder() { printInorder(root); } - void printPreorder() { printPreorder(root); } - // Driver method - public static void main(String[] args) { + // Driver method + public static void main(String[] args) { - BT_Problem_06_b tree = new BT_Problem_06_b(); - - tree.root = new Node(1); - tree.root.left = new Node(2); - tree.root.right = new Node(3); - tree.root.left.left = new Node(4); - tree.root.left.right = new Node(5); - - System.out.println("Preorder traversal of binary tree is "); - tree.printPreorder(); + BT_Problem_06_b tree = new BT_Problem_06_b(); - System.out.println("\nInorder traversal of binary tree is "); - tree.printInorder(); + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); - System.out.println("\nPostorder traversal of binary tree is "); - tree.printPostorder(); - - } - - + System.out.println("\nInorder traversal of binary tree is "); + tree.printInorder(); + } } diff --git a/binaryTree/BT_Problem_07.java b/binaryTree/BT_Problem_07.java deleted file mode 100644 index 6d2485b..0000000 --- a/binaryTree/BT_Problem_07.java +++ /dev/null @@ -1,15 +0,0 @@ -package binaryTree; -/* Problem Title :- Write a Java program to find Left View of a tree - * - * Left View of a tree :- - * The left view of a binary tree, is set of nodes visible when tree is visited from left side - * between two end nodes. - */ - -public class BT_Problem_07 { - - public static void main(String[] args) { - - } - -} diff --git a/binaryTree/BT_Problem_07_a.java b/binaryTree/BT_Problem_07_a.java new file mode 100644 index 0000000..0c42b27 --- /dev/null +++ b/binaryTree/BT_Problem_07_a.java @@ -0,0 +1,55 @@ +package binaryTree; +import java.util.*; + +/* + * Problem Title :- Preorder Traversal of a tree without using Recursion or Iteratively + */ +public class BT_Problem_07_a { + + // Root of Binary Tree + Node root; + + // Given a binary tree, print its nodes in pre-order + void preorder() { + + if(root == null) return; + + Stack s = new Stack<>(); + s.push(root); + + // traverse the tree + while(s.empty() == false) { + + Node mynode = s.peek(); + System.out.print(mynode.data + " "); + + s.pop(); + + //Push right child of popped node to stack + if(mynode.right != null) + s.push(mynode.right); + + //Push left child of popped node to stack + if(mynode.left != null) + s.push(mynode.left); + + } + } + + // Driver method + public static void main(String[] args) { + + // creating a binary tree and entering the nodes + BT_Problem_07_a tree = new BT_Problem_07_a(); + + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + + tree.preorder(); + + } + +} diff --git a/binaryTree/BT_Problem_07_b.java b/binaryTree/BT_Problem_07_b.java new file mode 100644 index 0000000..bb10987 --- /dev/null +++ b/binaryTree/BT_Problem_07_b.java @@ -0,0 +1,52 @@ +package binaryTree; + +/* + * Problem Title :- Pre-order Traversal of a tree using Recursion + */ +public class BT_Problem_07_b { + // Root of Binary Tree + Node root; + + // Constructor + BT_Problem_07_b(){ + root = null; + } + + /* + * Given a binary tree, + * print its nodes in preorder + */ + void printPreorder(Node node) { + + if(node == null) return; + + /* first print data of node */ + System.out.print(node.data + " "); + + /* then recur on left subtree */ + printPreorder(node.left); + + /* now recur on right subtree */ + printPreorder(node.right); + } + + // Wrappers over above recursive function + void printPreorder() { + printPreorder(root); + } + + //Driver Code + public static void main(String[] args) { + BT_Problem_07_b tree = new BT_Problem_07_b(); + + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + + System.out.println("Preorder traversal of binary tree is "); + tree.printPreorder(); + } + +} diff --git a/binaryTree/BT_Problem_08.java b/binaryTree/BT_Problem_08.java deleted file mode 100644 index c894fb8..0000000 --- a/binaryTree/BT_Problem_08.java +++ /dev/null @@ -1,10 +0,0 @@ -package binaryTree; -// Post-order Traversal of a tree both using recursion and Iteration -public class BT_Problem_08 { - - public static void main(String[] args) { - // TODO Auto-generated method stub - - } - -} diff --git a/binaryTree/BT_Problem_08_a.java b/binaryTree/BT_Problem_08_a.java new file mode 100644 index 0000000..3c20961 --- /dev/null +++ b/binaryTree/BT_Problem_08_a.java @@ -0,0 +1,90 @@ +package binaryTree; +import java.util.*; +/* + * Post-order Traversal of a tree both using recursion and Iteration + */ +public class BT_Problem_08_a { + + Node root; + ArrayList list = new ArrayList(); + + // An iterative function to do postorder traversal + // of a given binary tree + ArrayList postOrderIterative(Node node) + { + Stack S = new Stack(); + + // Check for empty tree + if (node == null) + return list; + S.push(node); + Node prev = null; + while (!S.isEmpty()) + { + Node current = S.peek(); + + /* go down the tree in search of a leaf an if so process it + and pop stack otherwise move down */ + if (prev == null || prev.left == current || + prev.right == current) + { + if (current.left != null) + S.push(current.left); + else if (current.right != null) + S.push(current.right); + else + { + S.pop(); + list.add(current.data); + } + + /* go up the tree from left node, if the child is right + push it onto stack otherwise process parent and pop + stack */ + } + else if (current.left == prev) + { + if (current.right != null) + S.push(current.right); + else + { + S.pop(); + list.add(current.data); + } + + /* go up the tree from right node and after coming back + from right node process parent and pop stack */ + } + else if (current.right == prev) + { + S.pop(); + list.add(current.data); + } + + prev = current; + } + + return list; + } + + // Driver program to test above functions + public static void main(String args[]) + { + BT_Problem_08_a tree = new BT_Problem_08_a(); + + // Let us create trees shown in above diagram + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + tree.root.right.left = new Node(6); + tree.root.right.right = new Node(7); + + ArrayList mylist = tree.postOrderIterative(tree.root); + + System.out.println("Post order traversal of binary tree is :"); + System.out.println(mylist); + } + +} diff --git a/binaryTree/BT_Problem_08_b.java b/binaryTree/BT_Problem_08_b.java new file mode 100644 index 0000000..7929743 --- /dev/null +++ b/binaryTree/BT_Problem_08_b.java @@ -0,0 +1,47 @@ +package binaryTree; + +public class BT_Problem_08_b { + + // Root of Binary Tree + Node root; + + // Constructor + BT_Problem_08_b(){ + root = null; + } + + // Given a binary tree, print its nodes according to the "bottom-up" post-order traversal. + void printPostorder(Node node) { + //base case + if(node == null) + return; + // first recur on left subtree + printPostorder(node.left); + + // then recur on right subtree + printPostorder(node.right); + + // now deal with the node + System.out.print(node.data + " "); + } + + // Wrapper over above recursive function + void printPostorder() { + printPostorder(root); + } + + //Driver Code + public static void main(String[] args) { + BT_Problem_08_b tree = new BT_Problem_08_b(); + + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + + System.out.println("\nPostorder traversal of binary tree is "); + tree.printPostorder(); + } + +} diff --git a/dataStructures/graphs/Graph.class b/dataStructures/graphs/Graph.class deleted file mode 100644 index 936e873e25aac7bbab364bcb9451ab9495058568..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1785 zcmaJ>-Bue_7~Lm-lZ1f)AwZjirazWIX``rA8;VLxOEiVrAeGjtLuLpAVUjg7Vd;IZ zeTQE4+AbShvg`x&J-qc1#C=Xe2`-iwGiT1vx4-@E{hfLH&mV69+{BKCfI!+be52yK zt*YO0Ew4~>jpnvjxGx6{A%VdiW8Wy$4X0LE-Q2ONzCh40cLc_smep3vx9f$n?d)1+ z+4lURK&)cd97Ey>%$$8{z7wlpOO9{VEVsD8(8#>)*#3e*C|{ad=WwTCT5$x?uOo&5 z=FU&8YZw$5IV*V#0>e7Oh{TaVzd(Y-td-W@rsb{~n{^TzE;p)1ecf;{4YCvad`f(5f&PkbRCga3%`SvynC6mMV}@|PMDB51z(ox?fuR!xyQS*5gv$cj zzEN*kt6Ku2to95=WD)P_xQa<7x+###_Z;i^QJi{0-MmK2tulF^X?ea)_3eg3`SuK( z!)U(ig3_CA+fJ=0b-aGePMKJ#8jfSRF%o znk}EGma$iiV+J2fujT~CyJY`!WNKYz_(aF2xW&2}EwbFvyU9~K0ifj0ijep{2CwQ@C*G{EIPr($USmV*-%1T(5(T@eLpGCW;9ZsXjyc;^6;Hf~=Z*(?!ZSuX1)>)-# z0?%}0kd-3*pyNk*)xy{ME>_PsL2qteXM~$-pqFm+A1d?4JSAIcAotvCKfIgl66N%Rt3f_K+ zir8$rJClq8 ziqU{NoMeU(f~0y_WZ$vKBCl8w6jO>t4AZ#QNhl^+O_X@MhnU%Tg&PO>sQd~yhl_38 zzShPa^;$TD*vK5<{;d%A4pG_|{^|e^vTdvmSK9cdjc<88I2V42v<#YysJC`5l!~OZ zHokiv7O8Od#nE3}|NcbKIf@60(?@xd6lYv1F+t%jV3B?<^Z&Mj%UHt|JmY+eJ3A~# ziv6fV8wNHx>tm}`VX~-kRQO1-vy8R)6=c+1#*VSnC89_x!rV(JVIoA2DPc5aI# V84(RN4KqSWo4{CsZRQEU{uf*Pfdl{m diff --git a/dataStructures/graphs/Graph.java b/dataStructures/graphs/Graph.java deleted file mode 100644 index 2ff08b8..0000000 --- a/dataStructures/graphs/Graph.java +++ /dev/null @@ -1,41 +0,0 @@ -package dataStructures.graphs; -import java.util.*; - -public class Graph { - - private LinkedList adj[]; - - @SuppressWarnings("unchecked") - public Graph(int v) { - //array of Linked List - adj = new LinkedList[v]; - - for(int i=0;i(); - } - } - - public void addEdge(int source, int destination) { - adj[source].add(destination); - adj[destination].add(source); - } - - public static void main(String[] args) { - Scanner sc = new Scanner(System.in); - - System.out.println("Enter number of vertices and edges"); - int v = sc.nextInt(); - int e = sc.nextInt(); - - Graph graph = new Graph(v); - System.out.println("Enter " + e + " edges"); - - for(int i=0;i(2_vbGFW{{WQVF>Lz+~L*af@Nuk8BS4# zmkkMC2LG;hpe0LMWjndHwaW`OL(iOE(d~JLu4pXJ;9WF|TtOFnD!S3b(4W;SeAOv$ zace`{DshHD)+lJDyk_YlZX~_-j$UOL%y#^EiW-+Sy}}TVzRvy!k+UtmvYm<%@Usj9 z?uBFPr6%kO{P4*bU|qh>%K!f+$mnEdFs-a6G~Xo%*IM6Im59E zd|4Mu6Kvhag!r2=0)j@H3wY>6>qb_hC`q1??;byb{K36e$ck&gi(ay7y?}flMLwKC zKV`(@pH$%?|MnRE%_G{@cpz9qC>}WP+6%6|6&tr{h7@kuk*vSx?7j()|#s|+YOiJ(%Q(}V>9=!Yun_edl diff --git a/stack/stack/Postfix.class b/stack/stack/Postfix.class deleted file mode 100644 index 9b2d1c0b7e9f6d54e1885e7829b17130e328d262..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2162 zcmaJ?TTdHD6#mAyHO>;7iwPkiAzW=PanevAF`-Eu2oC1bm_i_JlEn;oVZG~m*A!Z* zPyG>1UJ|trR4NZC4+eqM_PGz0`dFz_)SpqQN_xh&umP(Nb7tnuIdi`AowKvQy*v0B zz#zWz;4=CoTy-PlfeqIrT=&35EX1&c+d@4eHXjMA zJ03LQt{e9xM5=HfqaOG%Cd30F#wA3BMV~l(C{`05#4ssgiorFk>Z&!uU=IZ67#tB} znKO7}s?MjfsU@D7RhBf;IA$_DK~o?Sj51WmEhVu&sicdiXH|Vg-JCUM4AY_oLuVki zrfeu7P0?3FaVw+htKr~j6KlrtF1L(srZe0$ zRf7_(DT9R_&IRPVYPr2LEMw(%$LK0;FD*!0A^|3O< zw@izth%wRB{(`@1gra&nYmq%yQj}n0G1Q3z(e7@YZ(8ExJBj}&m@}anroe7wMY)ec z%+NPh3Q_1%3Q(pdrqaSl(e{qjT&V@a=Cha55-8o3# z;Z=8Y4(hcECNzFu*5CI@+b8_!7>e2q|V4%IKwLetq_ z;myJ43%o*25AACXK>w%M_WQSDLoR&<+fH#yUCDtq-=FaKvlQtYJKKK$tl-&JauRr4 zwe@d~1^TP!%@IX&^zQ>MPzDzX#wC(1L|rQp-A2FR4vY|46GYG>1d*gNY@iok;~HM# zI({JPcgbg;i2a3#{T*Taf!lbCJ9&zm;CY972{s8%_AgplovTd>{sV7gHLB>o?qbp7 zM7x7fbRELKu#1L0oQw73&^Srr{2`jC02iiqaj|zF#QmjG2Q^U@fiaxH1FG&g>hX{g gn4sV>x>EFtjo@z3?4eK=Hj%~oe80G9KR{#fKe%iG6aWAK diff --git a/stack_and_queue/stack_and_queue/Stack_Queue_Problem_03.class b/stack_and_queue/stack_and_queue/Stack_Queue_Problem_03.class deleted file mode 100644 index c55e8e086c1a5f8f86e12a3b1ce7adc6137eb0bb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1840 zcmai#ZC4XV6vzLQY)D9!B!Xx)N`nIC!SblZ8tMbFNE8GctjFUEx{wi8lHF}~LrcFv zze3OHJKyw;Z`vd1p*{To{ZKvq&t`>CsGgj?GjnI={^oz@?&j}*_WuGfji+(+A=ixr z^2!vHDJpZd8=qk`hOs!tF%jorGKQ%ruEjZdU7637nO5dTFJsN9-j}@)n2F-HfaaP% zN&!(}*R!38b~8zjArN{_ch`(*ncgi<h||h+|%(D=5*XghI-nwPpn#dT42OgI#vy&x7n5gc!o@{W! zZgIN5ohZ{DTV|F#=1Llkl0csy>8M*E>ZnC^rnoDIoNX9evTR%HhWFI;HreC6<+%z_$sb32FzBQoG>Rpam8!td zVKz)_+ul+sSEbPA%^B;S-Q0=d35#;Uwzpc2fL^gI*(}!$*OffP&z&lR80`y~=RMY? zJJjA-I)2g)&ykHQJB~bId1t}4uddW7KL}Aa>h-GW$x;-&)Zt_LPCA>wz=zkd!V>%* z02&__J1tbb`z=e}Z}}#$?c&4o2;jMh~MWIhRsV4&rVg?8lv81dUHbtG&Yc!ZVJvZ&lLri;zZiNbUpn3`D<6CZI;l&ds^h7xS~h6Q5&A4)uB1klJw zp%)0fNYntKSwaU1y?g}9H#&gU0;NSI=NFuNuWWRtt(IUd^IA!a2NJ`t4>S%S%KixL z6`VqjO7a93F-&M4qdqbWp)$|!LqOaNh+~S#C;aMw8fjA_D#wwJP$zkTQ@p%uq+F-O zX%cVn@8afr>L9wQe>kB26i^@jfyA@eTj&eL*dBU{Y063#(<$F3d=Kw3Nx{WEr1n`M zpzdNici=p=5B~4ad018jmK1QCz&k9ayS(jL7HOHuzsKy%@qG7D!aU2h!efm1`MZLz Z*~WRiWvt*atKtieldPVb^p$*j>tB2Ld6xhH diff --git a/string/.cph/.Append.java_c181a202ca338689c15dd0c5b3b84d60.prob b/string/.cph/.Append.java_c181a202ca338689c15dd0c5b3b84d60.prob deleted file mode 100644 index 7592ea9..0000000 --- a/string/.cph/.Append.java_c181a202ca338689c15dd0c5b3b84d60.prob +++ /dev/null @@ -1 +0,0 @@ -{"name":"Local: Append","url":"c:\\Users\\AmanSoni\\Desktop\\Java Program's\\Java-Eclipse\\Placement Prepration\\string\\string\\Append.java","tests":[{"id":1608220330360,"input":"","output":""}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"c:\\Users\\AmanSoni\\Desktop\\Java Program's\\Java-Eclipse\\Placement Prepration\\string\\string\\Append.java","group":"local","local":true} \ No newline at end of file diff --git a/string/Append.class b/string/Append.class deleted file mode 100644 index c0bcb24e9df1a980bc85972fdf13a8088ecead52..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 879 zcmZuw+fEZv6kVq+o#`+L_J)Wec)_+%Dk$D+OvJ>e3MQB)#;4QvfJ0_F&2)yOpQR7Q zXyOO>QO0#TjkMTIa&CL=wf1d(|M~F?z%#rwkPukthk?^Qt-a~>RJUUwC9rfR&t=V( zd_8KNsdgxke&uwX@U=j)RBj5S-ufM7A&HEQIiv*^8%|dpMqWz=A7#r`0@;S&mTpr9 zj=ql{Q{fkqrllbFoLO{@wS=hBVT(TTujX+kj0wqBli8pmKEkJ~!eHG#sU%fA>kV%^3D z?y_2PR7`>DEa-pi?#;{ZM%}wy@1I`4Jme zh}9gw_JM5<$*H7Ar5!vnP!q_FYB+7Sv8(emdfLNfTT(JOW!rKynnPnh40d(DuXaPX zm9{Q2ahDE+;=K&EZ?i<;qMmGEYC-R@RzN2`7TiZk28RFjIH$1EkQN1KC yQk!aYO!G6bLc(=eBcV!6hCMtcCW$pX!9JzZSjAJG5=5K)vG!>bcuq_LFa84X0K*~x diff --git a/trees/.cph/.BinaryTree_Traversal.java_99fbe9a6d479d3fea744cafd49bd01c0.prob b/trees/.cph/.BinaryTree_Traversal.java_99fbe9a6d479d3fea744cafd49bd01c0.prob deleted file mode 100644 index 46d1433..0000000 --- a/trees/.cph/.BinaryTree_Traversal.java_99fbe9a6d479d3fea744cafd49bd01c0.prob +++ /dev/null @@ -1 +0,0 @@ -{"name":"Local: BinaryTree_Traversal","url":"c:\\Users\\AmanSoni\\Desktop\\Java Program's\\Java-Eclipse\\Placement Prepration\\src\\trees\\BinaryTree_Traversal.java","tests":[{"id":1608219457557,"input":"","output":""}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"c:\\Users\\AmanSoni\\Desktop\\Java Program's\\Java-Eclipse\\Placement Prepration\\src\\trees\\BinaryTree_Traversal.java","group":"local","local":true} \ No newline at end of file diff --git a/trees/.cph/.FindFullNodesInABinaryTree.java_63c5e7cc4610c2b023e3b74d2ff6f26b.prob b/trees/.cph/.FindFullNodesInABinaryTree.java_63c5e7cc4610c2b023e3b74d2ff6f26b.prob deleted file mode 100644 index 0a98957..0000000 --- a/trees/.cph/.FindFullNodesInABinaryTree.java_63c5e7cc4610c2b023e3b74d2ff6f26b.prob +++ /dev/null @@ -1 +0,0 @@ -{"name":"Local: FindFullNodesInABinaryTree","url":"c:\\Users\\AmanSoni\\Desktop\\Java Program's\\Java-Eclipse\\Placement Prepration\\src\\trees\\FindFullNodesInABinaryTree.java","tests":[{"id":1608875314842,"input":"","output":""}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"c:\\Users\\AmanSoni\\Desktop\\Java Program's\\Java-Eclipse\\Placement Prepration\\src\\trees\\FindFullNodesInABinaryTree.java","group":"local","local":true} \ No newline at end of file diff --git a/trees/BST_Deletion$Node.class b/trees/BST_Deletion$Node.class deleted file mode 100644 index 94cb5a54ccfbbacbc951227023a50c8d41b47da5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 569 zcmZ`$$w~u36s*p^jAl`@Xk4NZbOhtggW|!67zpuT2h8JHObKg+`)c<=-K zD6u-^AQ%t*`mObtJJBf%uIq;)y#EVgmU`>&0r? zmNRNz4j$z&5Qsj>R{_x$h}rU5tr$!I#NdyndZyX3L&S+*|;#fHSfuA>~;eI5^_ z*Ruw;6exDwp=I|iPw9A?jA^D^rUE$@$XvP4-cX(^-Cy{v(Y{tjz-T*;^jfy%`_fNh zlc;~yAe>fIAk~$AaN+s^Hpnc>Ux@LLGA%UC$xY%wKCd6im|F9ZbF}k}t~sISs^(sZ zocWG|Sqrgfn&KuzDMaOs#R!&ZixcoHbuc(OhYIZq^Ci{^fZB9j6{{o=A?(^@cAezF O<$7@)Tl5=~eEkQuC~YPH diff --git a/trees/BST_Deletion.class b/trees/BST_Deletion.class deleted file mode 100644 index 33e8c8ada2c76508c5360a5618d213ba57d44578..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2628 zcmah~TW=dh6#h1G;!C!vn`@gGo!BL}J+31r6ZGZ9ydw>}b?lLb2HRX%bYz74bnM3y z8Uh8=${P6`Q*5uEbl6NneA@-?Aj z66dI^Q*;l^vmbsp1xOlfGX!HSL-Wxx%~k|@?u!7wci9q~(>d=I$=-z25Gs3U>a z04{6TlXex2IkvGX?2?g>73X8lqKGY+tHPpL@KT<~RUOx)C%^KPw@TPlKMeEMbr4jZ#Sv%qLrshNcNoa>j-1FC|_`)*+jo#)sX9 zV~`I!5-oBzj5@UzN~|N4(C$P3fz~=Sb8J>8+u>tZ38E9*Y17@^2xAAoAc^si#<;JJ zmgYnvaSwWT8EqTTLTa@e+YnJm9q#T5QnPF$3Y|U7!~C6?GWvY-AsUivk>oveeTUX$ zf|F=Od5GS{q_W@f>^-i%=Pr)QT@Ml9t7lCP?mW7t&i9nD_ddGZIaj+BTu*Y1{_0i! z1I!laA!~d2y$@0LE_N>*!66(+iZ`(jX%@`{25}L`u!JF%SOl389cFBQnE9P1G0 zJb=c=&d#Q$Zq6mDtH-N+%Z#HkqT_cF<~u5<@|}^x!@vKCe9s+jj9p68lk{+kh@j0uaXzaW(PjzgIm($W{D-RVgic4eZpv{!4in^^;(@&8 z-Hra_uSlulCD4yJ@&Lm#Qs|#>VjX8%o-HF?#&{Vo$UQ7j<;)ejg8>5t0u@=7%S`Yl z6D(CR-(PXu?vBFT=V6}6$*=jUl|{8e#7!$pYK0y*tUMz1Dr*IJnWVl!LEl6h z-a;4NW+Qut*W_IszQ+Z@By0D!y*>Iu__FKxB*UOkTVqzw5~EO}=I8@8)B3UgG1E-~RxJ;{a9w diff --git a/trees/BST_Deletion.java b/trees/BST_Deletion.java deleted file mode 100644 index 240dd72..0000000 --- a/trees/BST_Deletion.java +++ /dev/null @@ -1,158 +0,0 @@ -package trees; - -//Java program to demonstrate delete operation in binary search tree -class BST_Deletion{ - - // Class to make a Node - static class Node { - int key; - Node left, right; - - public Node(int item) { - key = item; - left = right = null; - } - } - - // Root of BST - Node root; - - // Constructor - BST_Deletion() { - root = null; - } - - // This method mainly calls deleteRec() - void deleteKey(int key) { - root = deleteRec(root, key); - } - - /* A recursive function to insert a new key in BST */ - Node deleteRec(Node root, int key) { - /* Base Case: If the tree is empty */ - if (root == null) return root; - - /* Otherwise, recur down the tree */ - if (key < root.key) - root.left = deleteRec(root.left, key); - else if (key > root.key) - root.right = deleteRec(root.right, key); - - // if key is same as root's key, then This is the node - // to be deleted - else - { - // node with only one child or no child - if (root.left == null) - return root.right; - else if (root.right == null) - return root.left; - - // node with two children: Get the inorder successor (smallest - // in the right subtree) - root.key = minValue(root.right); - - // Delete the inorder successor - root.right = deleteRec(root.right, root.key); - } - - return root; - } - - int minValue(Node root) - { - int minv = root.key; - while (root.left != null) - { - minv = root.left.key; - root = root.left; - } - return minv; - } - - // This method mainly calls insertRec() - void insert(int key) - { - root = insertRec(root, key); - } - - /* A recursive function to insert a new key in BST */ - Node insertRec(Node root, int key) - { - - /* If the tree is empty, return a new node */ - if (root == null) - { - root = new Node(key); - return root; - } - - /* Otherwise, recur down the tree */ - if (key < root.key) - root.left = insertRec(root.left, key); - else if (key > root.key) - root.right = insertRec(root.right, key); - - /* return the (unchanged) node pointer */ - return root; - } - - // This method mainly calls InorderRec() - void inorder() - { - inorderRec(root); - } - - // A utility function to do inorder traversal of BST - void inorderRec(Node root) - { - if (root != null) - { - inorderRec(root.left); - System.out.print(root.key + " "); - inorderRec(root.right); - } - } - - // Driver Program to test above functions - public static void main(String[] args) - { - BST_Deletion tree = new BST_Deletion(); - - /* Let us create following BST - 50 - / \ - 30 70 - / \ / \ - 20 40 60 80 */ - - tree.insert(50); - tree.insert(30); - tree.insert(20); - tree.insert(40); - tree.insert(70); - tree.insert(60); - tree.insert(80); - - System.out.println("Inorder traversal of the given tree"); - tree.inorder(); - - System.out.println("\nDelete 20"); - tree.deleteKey(20); - - System.out.println("Inorder traversal of the modified tree"); - tree.inorder(); - - System.out.println("\nDelete 30"); - tree.deleteKey(30); - - System.out.println("Inorder traversal of the modified tree"); - tree.inorder(); - - System.out.println("\nDelete 50"); - tree.deleteKey(50); - - System.out.println("Inorder traversal of the modified tree"); - tree.inorder(); - } -} \ No newline at end of file diff --git a/trees/BT_Traversal$Node.class b/trees/BT_Traversal$Node.class deleted file mode 100644 index 8ee6fa80c5b8af8a6c433c03cc99a1179bd0a6a5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 494 zcmZ`#Jx>Bb5Pb^=2YAY-AR>y11zaJeg~mb>BMHI63x$nYaD~O=F4;Xu{8<*n#KIro zk221l6eh-EXJ%jK&3iMSU+*6P&Twoa!BC5o5W0KiJ$Q<*gwotU8HSI-hQ&~r^A+#< zJeYQG$8#}>7?RK8g@N@MEMGhkP#^p=;hZ6*V=Dz{0XeKpD z$Ve<0a(CfUO~kb{{l(u~o|@eloPH1p)$_U5Lfbf`sekvOapoornW50pO{gQZ$XSx^ zXdYRn2xBwOWSlZxiI&@<=+MuDg#_h_`-W||u|~ml+5H-&H7c)!Cs3tWqAn2IqUE#1 kE)%~-NcD${y^TTzb<#8r_G4}X2b6QMW)nx$)r#@vHx0*H-~a#s diff --git a/trees/BT_Traversal.class b/trees/BT_Traversal.class deleted file mode 100644 index b20935e91dd75b58361e6514fe88a2703eb166ab..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2089 zcmah}ZBrXn6n<_AY!X)91BJdA3T>0nHq=(BO9R_&K-YyWXbs1kT3V7}mkX3n4@>W?)oc?0+gSaav&ul;xHmCfErRLl_R> zEY2G^_gYi(&nv#%G4VE{tk$ivF_Db!ne8TX3Ra#;teupB3rzT`n^fCQX`yPDiC96J zHgOS`8049JE+Eoj#E>u$e?6V{GBJZI0>++IuFBOdri`WI^{jeQ_1LK}CUH%5JgF>N z@8g9at}|6s8Qw5)6Yp|#*6yx!HU+M>^JoduC_v|$GjR*=3j}?)j(`J;wZ)afT?2On zhTC+?#61PLThCNA=DvvsY8>63UD{UsbI2w#DDPXvXDiljgCeGONIRMWYHCX+KEN;y z>+JC4@lD#qhw3J_j zd(xpw%BWqr9YzXy6Kkp%LqjM#Dr7;y3aZ=B)on0{F9a?glecq7fiD#o>GZY0bgog; zNj~4GdV?&$@=DyI;Wp*+QUMnT=iRDTluNeS#lhz9!8J830W?16GgZYBODfIEbPdoM_fB~8h zqMtgmZcNP}rJ&lyMxbwLrvl9;{zl+M;&+T3VEiS{9Aa{v($oPi@8jywYz^Y%GagyO=x%{j1wW$G3GkWy&Fdo6HU2iv7qf1wV&uF2vVy9h=(VGc=#rWa|Cgo zAff~@Ne~wZVyZI;vbY0?<&!}yzX{?JL0l$?I6))`Vum2DbOu2>HbBhiVQ|tfVK%y4 zpK6%X1taxfR>xA3YGHdv-I->`8+5$conNHT^A`;E~svpw|XRP8E9cW!nKAHZwUD4iKcF8K zohPlLTFjmMdG5LAeSE&X131Ng0uh1D&{ry`UusYK(_1BdXV77$)*e5o1Y!cYp?sEg zS9<;WO>d~2P$2rGrUIfV5OdWd6P4CKC}#o-zU~j$7Y_$IsGSHD{}^Cz{9JoFybvfK z{MFPv>~eL33{xOM3u$E1h$3&n!V38v9Cl4*&B6lW##^_LLeh983kf6zvMueY_GHvk zen<9PC6I589qD$ZuTA`&j2XsUrb9InNZ*bpzN40kS)*|AYdz-oG)@*A!U0u>~% zD^U1d9l{!w1(IzQgxBLB#10uo`8qLvq)rP%cmC%AKrUyFWla5f>>}+FqdQKRxsrV} zL)L!9vR$5G)wad`422nrFDyo|L7Sh0r>RGVqZWz;*<`-JIss7rUROee1R{jpn$K>N Q9Jt&pu40dVZJw`w0Y`m!6aWAK diff --git a/trees/BinarySearchTree.class b/trees/BinarySearchTree.class deleted file mode 100644 index d23e2ae3ec154150feb21ea7d24b9cecfac45aed..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1542 zcmaJ>U2hXt5Ixs6INod$gB_D5&L?THcMGPW5Q-B51Olc`3K&H~ecG7YWWiaZ^#&=w zg8zV!`bsP6NJZ*nEA>ZJJ#%*zK9nG9XYZYR=ggd$={rMpWB5u|b2iROTQVK}OC*l3ZG0n+6QRGoLv};0$ZJ1e z_g*B8$@)Pze5yks?AUPet%8;K4C9&OlE;jtfD5>oMeUP$xAuFH-nH=^7D&3g$IPQm zBL}}*dl33T)FOFrw{GEkT*>0HLg9#Gn>s5fWM4=`Cm^p~&*!UD`8h^2;v$qEY}ezd z4GNPb8>dl_)pZ*c3^33Ow<&bS4zH5Ti|?VH9N=2h%`fy(ck@%m z7LBbKyJqZ?u@A)dvHXFo1B>`KNcJ8Z-9Qod`33lqdTjC|uuiHQSinPE!K06=Tx5H1 gFm3=f+@!)pySKPcVHLOemVePWpF3Qy@yW>kf0ol4aR2}S diff --git a/trees/BinarySearchTree.java b/trees/BinarySearchTree.java deleted file mode 100644 index d6a2105..0000000 --- a/trees/BinarySearchTree.java +++ /dev/null @@ -1,83 +0,0 @@ -package trees; - -class BinarySearchTree { - - /* Class containing left and right child of current node and key value*/ - static class Node { - int key; - Node left, right; - - public Node(int item) { - key = item; - left = right = null; - } - } - - // Root of BST - Node root; - - // Constructor - BinarySearchTree() { - root = null; - } - - // This method mainly calls insertRec() - void insert(int key) { - root = insertRec(root, key); - } - - /* A recursive function to insert a new key in BST */ - Node insertRec(Node root, int key) { - - /* If the tree is empty, return a new node */ - if (root == null) { - root = new Node(key); - return root; - } - - /* Otherwise, recur down the tree */ - if (key < root.key) - root.left = insertRec(root.left, key); - else if (key > root.key) - root.right = insertRec(root.right, key); - - /* return the (unchanged) node pointer */ - return root; - } - - // This method mainly calls InorderRec() - void inorder() { - inorderRec(root); - } - - // A utility function to do inorder traversal of BST - void inorderRec(Node root) { - if (root != null) { - inorderRec(root.left); - System.out.println(root.key); - inorderRec(root.right); - } - } - - // Driver Program to test above functions - public static void main(String[] args) { - BinarySearchTree tree = new BinarySearchTree(); - - /* Let us create following BST - 50 - / \ - 30 70 - / \ / \ - 20 40 60 80 */ - tree.insert(50); - tree.insert(30); - tree.insert(20); - tree.insert(40); - tree.insert(70); - tree.insert(60); - tree.insert(80); - - // print inorder traversal of the BST - tree.inorder(); - } -} diff --git a/trees/BinaryTreeNode.class b/trees/BinaryTreeNode.class deleted file mode 100644 index ace45e803d0eb2d26aad134cfd3458cb25629888..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 596 zcmZuuO;5r=6r62~*n)t7_<9g^z#nCt z0+R5thut@C-n=)v`}6zt4d4bBNf-jfC{$`vyVrpXXCC9$xUZ711ac$!CTqS72DPW| zNcAECt1lxdkZ*2McLH`>4+0rYLnUB(9y6A&o+&Cdca0!l-bvJ{ZIDfbdN8DXudV|f zH3W{_?Xi^(3tTGVzMjMzYVIr;n#HRX80 diff --git a/trees/BinaryTreeNode.java b/trees/BinaryTreeNode.java deleted file mode 100644 index fe8e3f1..0000000 --- a/trees/BinaryTreeNode.java +++ /dev/null @@ -1,13 +0,0 @@ -package trees; - -public class BinaryTreeNode { - - public T data; - public BinaryTreeNode left; - public BinaryTreeNode right; - - BinaryTreeNode(T data){ - this.data = data; - } - -} diff --git a/trees/BinaryTreeUse.class b/trees/BinaryTreeUse.class deleted file mode 100644 index e3af7525f6a0db48bb164c3502707854f7296c8e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2177 zcma)7TUQ%Z7~Ll%&4t0X;a=Jjdch=IQd%wAAR-ks8lW~bO6zS1Ll_8?IGJGcrvJnz zpW7}4maOGtUCX~@m&^Ulgpxp9t1mfo&e`YN-?zU@{{HumKLJdm9)wS!+p!I!nwmE) z-L9|l`%%>h!mn^)Ti?@DCEY5fR@S$Tf}?P5#YrE@)y{fO5425X6T+mB--8N<4IP^PPW>uj#+lD%=5O(w(BV$!+WE_iUT{miu zSxV&!x@8%5I&tRVG98hZIkRZ#PR%Cs+?&6g@i^R2GnQi%$uXM_qZ_?J^t33Et5+Rk zS3@8AsX|#??Dbxo<SrRtQ$aP|2e0Mi8!Rv}{_%bRr+Y2(AZljRa@J(QpGdX~Hs|I*i3lRVIkH6?#sq zEuuw`z*rE;V^hr8C}6(-x?wWmqsgIHAPKj}Iz-}5!Iv|-p0 zEFdhJWHfw+&l#c@ZL}#N4ZQ`rq+uB=>{z{0F{}-RiRMZ=PE6C=7BW`v7Zj4!x`3Qm zT0LdpxD@}_fV|9W_!3_+H%{5Zvj*eM1=O$-!DD74y}kMKPU_|oM)>yL%cSwYH(z71`4Hel`i^qyC_B8hFl?%E7$CT zv1q!JwPj*YN+cv@keuy+pI;ow{0(xK;;Og?k_QMq=Z6mw{>rsLJNc`50Ipr!g{4=C zy1;KAF1kj3rD-vK`vs!Wfqh&`?jtrcKA7FB6Jb8$z-*Kn0PLDt1 zE5FNl)wL8thzwoi?IBN$OmQ;ZB9C|y^H^{XY3{mk6EpaL-o+5bEbh{u4|y*BdM9%{ z`G_Zs=9NtAuq5}j?;pF2|Int7n4gn>!T5XY-A6Y1U>^_n@hHpvotGGu z+p$9s@on^bUdeF-xqgD2eucF4J5@d{2s`D@Y%+)Q`&; z#C2T4BEOb!1v?mq&G72X=uf!j%F^cr;7S1E3<|VG5st-RaJ-wNeG!BI%7Isy3*zw& z3SwfLNU4N+BZ-4Y7+HIPodcA!40dX1oX*i*TO90o?HbsBotR*DCYh@g1~Ao>qe0ZL aM|>x takeInput(Scanner s){ - int rootdata; - System.out.println("Enter root data: "); - rootdata = s.nextInt(); - - if(rootdata == -1) return null; - - - BinaryTreeNode root = new BinaryTreeNode<>(rootdata); - root.left = takeInput(s); - root.right = takeInput(s); - return root; - - } - - public static void printTree(BinaryTreeNode root) { - if(root == null) return; - String s = root.data+" "; - - if(root.left!=null) - s+="L. "+root.left.data+" ,"; - - if(root.right!=null) - s+="R. "+root.right.data; - - System.out.println(s); - printTree(root.left); - printTree(root.right); - } - - public static void main(String[] args) { - -// BinaryTreeNode root= new BinaryTreeNode(1); -// BinaryTreeNode node1=new BinaryTreeNode(2); -// root.left=node1; -// BinaryTreeNode node2=new BinaryTreeNode(3); -// root.left=node2; - - Scanner s = new Scanner(System.in); - BinaryTreeNode root = takeInput(s); - printTree(root); - s.close(); - - } - -} diff --git a/trees/BinaryTree_LOT.class b/trees/BinaryTree_LOT.class deleted file mode 100644 index 5e39d518a12bb0709539a37fd3a49f23cab50687..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1756 zcmZux-%}e^6#j0qVUw_h3KVD?AV8`4VTrcdS_4#}P|!fC!B}i9E@XkN%ZAx3ndyv= z{s;a8J}}c6r!Vc)#3?gxJT~4o%?v6SHpS9Mj#-6*rz(o4$bNRjd3Mh2YRiwPNK3I;L#b z_GbjbsdSk^b9BcMMyCNC(HI2I8Hk`mpu1qZ*2@0whUKlA8;&K=Q>bp5PTBNqX}6r3 zzhl<~`dcvV+z8mc=h?1buc zaL=w=uFAq<+oG3b9b$*i5+9odlzemZr)6_bF^nOJF&(1<@e?5ojLQ-=$J+8`z=VOT z(h>0jKDu+nO!tCS3>kc&Bikl*>1oZkb`4y^Bn7SRvyux1brW_qcVE_BBBr^U*YTmi zz{wraZM)mE`?fSq) zevmjHM-F*;qf;{C^nSV=1$#gwW#H!qzQ8PR!`$1m+={@pvre2!(qgZ$?i!fKfdh$-g^cCZptj|u2Oa1+q4#JIVrvEV=yU;#V9j|In9C(CrrJGhbTQUT2lzAy?CaH zct-pI;|0ATbn)G#PWD5?0AmNyO`j1&<2>G@1xdA)>1Reuq+}-Z3PuCHQ`+=1bSo>- zz`!pdk+^*D-#;>cSmp00BVd@hM`@1{WfUVE5{Z)xa?P8N$gPp#M}OkuCO+$#Zs1M>a}C^khT(*EfQzb-gjS)Ls+3@PqURX( z0A`r{4r$FIjyaaIz)}`*n{9p<%kOAAe_X_Ts|XT8;aJ-U!jbVyyqsmMw0Jj}Iz))g zLx{B|iiPYUl51KM_t`h3Zb&nt%#kCrLz!2k$!m}S`bj{`6AfahK~JfHZ?g?NIO)Qx zs!vO-t&Bd7%QznJQr1|__w+o%W2|EXrmCzzpvRquq#5P=5&M+?9Q;5#gvb8_9;R4D diff --git a/trees/BinaryTree_LOT.java b/trees/BinaryTree_LOT.java deleted file mode 100644 index 43777cd..0000000 --- a/trees/BinaryTree_LOT.java +++ /dev/null @@ -1,99 +0,0 @@ -package trees; - -//Node of tree -class Node{ - int data; - Node left,right; - - //making public constructor of Node class - public Node(int item) { - data = item; - left = right = null; - } -} - -//main class to find linear order traversal -public class BinaryTree_LOT { - - //root node - Node root; - - //making an constructor - public BinaryTree_LOT() { - root = null; - } - - //function to print level order - void printLevelOrder() { - - //variable to store height which will be received from height function - int h = height(root), i; - - //loop for calculating given level - for(i = 1 ; i<= h ; i++) - printGivenLevel(root, i); - } - - //function to find the height of tree - int height(Node root) { - - //if their is no value at root node or node is empty then simply return 0; - if(root == null) - return 0; - - else { - //declare l-height for height of left & r-height variables for height of right, by using recursive call - int lheight = height(root.left); - int rheight = height(root.right); - - //if(l-height is greater then r-height then return(l-height + 1); - if(lheight > rheight) - return(lheight + 1); - - //else return r-height + 1; - else return(rheight + 1); - } - } - - //function to print the given level of tree - void printGivenLevel(Node root, int level) { - - //if their is no value at root node or node is empty then simply return; - if(root == null) - return; - - //if level is equal to 1 then print the data of root node - if(level == 1) - System.out.print(root.data + " "); - - //else if level is greater then 1, then call the function "RECUSIVELY" for left node & -1th level - else if(level > 1) { - //recursive call for left node at level-1 level - printGivenLevel(root.left, level-1); - - //recursive call for right node at level-1 level - printGivenLevel(root.right, level-1); - } - } - - //main or driver method - public static void main(String[] args) { - - //Making an object of BinaryTree_LOT class - BinaryTree_LOT tree = new BinaryTree_LOT(); - - //setting values of the different nodes of tree with use of tree object of tree classs - tree.root = new Node(1); - tree.root.left = new Node(2); - tree.root.right = new Node(3); - tree.root.left.left = new Node(4); - tree.root.left.right = new Node(5); - - System.out.println("Level order traversal of binary tree is "); - - //calling printLevelOrder() function - tree.printLevelOrder(); - - } - -} diff --git a/trees/BinaryTree_Traversal$Node.class b/trees/BinaryTree_Traversal$Node.class deleted file mode 100644 index 724af57114788265b35a52b121d44b3af4fd1773..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 617 zcmah`O-lk%6g|)HY*Mo?HOnl6njqV?C|VRmg4iMvY7ij#eu`^;3~H0*T(tk4=Oly-zlvH5nRE5f%pL$3%iv-Zd&*n-;ft?n^eYfnq|jJ=N0e*!`qt~149D6 zpZMpo2ZHd%|R zYg_Z3F)@gnsy3raPu6<3O57Q5&Ui)?RgNq0rydMk?~PU;EhSa&UCFfI@d zycz<53yGGvCUD=tj{?yaOj&rK0C(uBvn(#VjGa{o?B$Iad#m0$mcGuqx+PTA9$NSb zQ4HqM6?zhjM>5MKi^}gA)!|Pq{DJ~AE6HH0 zY**N{(F2+3Ly{1~GetP3BYskoX0nR=7Xm{cLB)fQgBtf%<4bygc_wAtsjxl*zbeGx zFkT8=HRJWf4_n!;zk9&ywPJ-GFcw>f6w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h9XQBcSG@ z={BNi@f(a+^ajw!Z=YH@2@O+>okom4!;i*kd_W5lYA4f=jFy!W>GT^IEeyN%*-sbt0TQk2ov!@(_=56u=mx z!U()YpAfwq^Kf^N{LER6o~g`V2nAoJGjA|XJPUF#$-(vb=sxtg_WjFIz6|u?jFA@L zDwocYs2pL;V+1!??j|l!trAw+PyDX^DMc#p3l{%S!5YCSBsmIp0rtG*g(B(a#nJ)z zE3-(dmIzRL71w^j#A~DukgX8m<=^p18=vHtfuA3#*vC>AmYNK~{o9#S`iZb&nv%<-<-qs&QZavNlTei+d4g#8$D&|hld>r4wz z4plgcRyhJOwf^XQ(D$4i{Px(}_raBw);c<4AFvI+QOP%u0VVqR;)Bgb# C)L69u diff --git a/trees/Binary_Tree_01.java b/trees/Binary_Tree_01.java deleted file mode 100644 index 75fd229..0000000 --- a/trees/Binary_Tree_01.java +++ /dev/null @@ -1,89 +0,0 @@ -package trees; - -/* - * Level Order Traversal - */ - -/* - * Algorithm: - * There are basically two functions in this method. - * One is to print all node at a given level(printGIvenLevel), - * and other is to print level order traversal of the tree(printLevelorder). - * printLevelorder makes use of printGivenLevel to print nodes at all levels one by one starting from root. - */ - -//Recursive Java program for level order traversal of Binary Tree - -class Binary_Tree_01 { - - /* Class containing left and right child of current node and key value */ - class Node { - int data; - Node left, right; - - public Node(int item) { - data = item; - left = right = null; - } - } - - // Root of the Binary Tree - Node root; - - public Binary_Tree_01() { - root = null; - } - - /* function to print level order traversal of tree */ - void printLevelOrder() { - int h = height(root); - int i; - for (i = 1; i <= h; i++) - printGivenLevel(root, i); - } - - /* - * Compute the "height" of a tree -- the number of nodes along the longest path - * from the root node down to the farthest leaf node. - */ - int height(Node root) { - if (root == null) - return 0; - else { - /* compute height of each subtree */ - int lheight = height(root.left); - int rheight = height(root.right); - - /* use the larger one */ - if (lheight > rheight) - return (lheight + 1); - else - return (rheight + 1); - } - } - - /* Print nodes at the given level */ - void printGivenLevel(Node root, int level) { - if (root == null) - return; - if (level == 1) - System.out.print(root.data + " "); - else if (level > 1) { - printGivenLevel(root.left, level - 1); - printGivenLevel(root.right, level - 1); - } - } - - /* Driver program to test above functions */ - public static void main(String args[]) { - Binary_Tree_01 tree = new Binary_Tree_01(); - tree.new Node(1); - tree.new Node(2); - tree.new Node(3); - tree.new Node(4); - tree.new Node(5); - - System.out.println("Level order traversal of binary tree is "); - tree.printLevelOrder(); - } -} diff --git a/trees/Construct_Tree_from_Preorder_and_Inorder.class b/trees/Construct_Tree_from_Preorder_and_Inorder.class deleted file mode 100644 index c1bba4f8c538955fcdfd2bb46d78df2eae7029eb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1436 zcmb7E+fEZv6kVsC>6BU&FD>?hc(;IUK?N^GLvM`|^rcUn@WGWZko+SGHWcY`TGMKojVBYCX4#HOs9Q?=L@<6<;7S?zoOWArQ_D zEC^`Rbz8;|Mpqm%JV)(2PR(C+ngYYK|EH=X z&{vhdl75HEcZA<|?T&1LY;Mt9GzU7wQ;utSFBSeCg)+Qr&Z)YV-}0zzWFP4G?C#x7 z*Oyi4l_p9t2po;$7!s_+s;o7nC(xfWO{Ux@X}F=%g%(XNjw^6w|A@VF8^{P8YuD?~ zYsJuqegh{24*w-Oj*~bgU_7^KEqQ-MAem!v{(|vlX`E3#JS&jM{RU_^zBI7VMa20y zE+EIY+m>&s*6tE@a7xQy97DJ$5OrLCLFEmm#Z&}^IEol1K~1i3nv#3BNg*%AaakdC z&#A5w8f6XVe9NOLSVzNgJ3HNRXI#4t2u3$J>{yytuQP&Z)3xOb#yTqN9~1equ``uJ zd&=3n9Rl4HPKHhS16<>60H595b>Scm5!FLGgu?;JBnd+b84eF^Y4+gICmh)b&Ud*k z1YF5B4oUR#TyY<#C76>V|BE%HSj7lcM2Tsp^ILBa&1Bc1i;XWxKgp*HpOD?e=^J`@ zERq>B-l8w1C5%E!e~)ut(f1JpuVEyNvB)b!B#i9(kMAixtu18|5zWr0H0t|+JY9*% zQpVPn=w8b1_(xK@60Ze?C~JMQ|Etm|>LVxXEbMh&F11 Zs9W?LgnmG5qt`%Mh-8T8lk|pg`zPDvM3Ddh diff --git a/trees/Construct_Tree_from_Preorder_and_Inorder.java b/trees/Construct_Tree_from_Preorder_and_Inorder.java deleted file mode 100644 index 0531425..0000000 --- a/trees/Construct_Tree_from_Preorder_and_Inorder.java +++ /dev/null @@ -1,69 +0,0 @@ -package trees; - - -/* - * Code: Construct Tree from Preorder and Inorder - * - * - *Given Pre-order and In-order traversal of a binary tree, - *create the binary tree associated with the traversals. - *You just need to construct the tree and return the root. - * - *Note: Assume binary tree contains only unique elements. - * - * Input format : - * - * Line 1 : n (Total number of nodes in binary tree) - * Line 2 : Pre order traversal - * Line 3 : Inorder Traversal - * - * Output Format : - * - * Elements are printed level wise, each level in new line (separated by space). - * - * Sample Input : - * 12 - * 1 2 3 4 15 5 6 7 8 10 9 12 - * 4 15 3 2 5 1 6 10 8 7 9 12 - * - * Sample Output : - * 1 - * 2 6 - * 3 5 7 - * 4 8 9 - * 15 10 12 - */ -public class Construct_Tree_from_Preorder_and_Inorder { - - public static BinaryTreeNode getTreeFromPreorderAndInorder(int[] pre , int[] in){ - return helper (0, 0, in.length - 1, pre, in); - } - - private static BinaryTreeNode helper(int preStart , int inStart , int inEnd , int[] preorder , int[] inorder){ - - //Base Case - if(preStart > preorder.length || inStart > inEnd) - return null; - - - //get the root node with current pre-order element - BinaryTreeNode root = new BinaryTreeNode(preorder[preStart]); - - //get inIndex; finding preorder's element's index in in-order - int inIndex = 0; - - for(int i = inStart ; i<= inEnd ; i++) { - if(inorder[i] == root.data) - inIndex = i; - } - - //(next, left of inIndex is the end for left subtree) - root.left = helper(preStart + 1, inStart, inIndex - 1, preorder, inorder); - - //(prestart + length of left subtree + 1) - root.right = helper(preStart + inIndex - inStart + 1, inIndex + 1, inEnd, preorder, inorder); - - return root; - } - -} diff --git a/trees/Count_leaf_nodes$BinaryTreeNode.class b/trees/Count_leaf_nodes$BinaryTreeNode.class deleted file mode 100644 index 14510dc638d04dac456cb6da0bc551b1e913def1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1617 zcma)6+fEZv6kVsC(o%+t2ndLZg3t?4yelnKs3J{jeV`%H7d(_B4A!ZcnHup^`~hEl zF%gZL7~f3%5a0X*qpmY8$TcC;nVz%vK5O<~d+qu0=kr$pH;@k_AaK!hlyXzKYR&eR zD@s0DwyUek9iFpn>1>whEOH-)A<(fQU&vHN+H0u?D;uip2^g!=lLDQE{jRh?^P;t8 zORwfAfncdbOQgJRRaPBk3v|~{)I6(_nspqxS+HD>A-TisnZmJ>%jm0w&l$TjK_`&I#^YFi3ekRk6su#GSdu!lO{~GMiE4}i8l1G-dKD|dwNZT z&=f{LgM5ni792$%x^>(c6U~SUv==N}6>HB{lv9!`6*AXZsFr1ANjjF^H;jg^Phj+j z#P>Ci#rEt)*?hi@G6hD5Ij4L4DSF>L@+~J&@XJzr%lJ#3)Asg#@C~= w^xh_FKaAgqh?c)-K`0EtpYGIToy=KA1TfcVNDg^Z)<= diff --git a/trees/Count_leaf_nodes.class b/trees/Count_leaf_nodes.class deleted file mode 100644 index d710deb3830ac3df0f6040238dac0e2bf718de4c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 400 zcmZutO-sW-5Pg#-ji#|*TJb63q zZ1Gfjm^bs@46|?c=lAOyzy&5DJi@+hq%=udx7yAtDW2!Lev&4HPZ%!5QY4koFUdo( zkfkMbuas8yn$S5poe}($ha+^b9V0-OFvygadHYt#W-5wG62@6wifSer<@mqo+gD`> z2ifM=FA33O-8QAXRc^;*-QKx#Mu_jUmQ7j-W1QtN;dt}HqZ_3~^FHNUb9PMVuM53g z8hbCDaf3tff&59}OztqokXf?gKydbntq&GFM2xNtjL>6@S9QR7hgk=GMh^oFIY-Bb5Pb`W2j|JR_yH&}6hI-Rg~mb><0S+O355+=aD~NlFWEax_*oXj#KIro zk221lv}&>QX5Y^2n>U|d?;ilp(6EtUIEl0nVb@ck(2)$(*i+*xskmMZ>7h9Y9)t~x zA-~`+yz6r{>)uWlVj3|dpTvrRc?^~>9*Jo7|NrcqA*JPPPUTw{QpxC&+FM?GM9?EK z2T5dIILMJet3Aqqq2MBgEt8d8WRN!5t_vG!hFo7NF<3rNgdXyVFBppbV9Naw*V5cK zq!rC&$l%-sOFb3W(iGNyF@0*RGPs^nLicwat1P5{NA*zH9X_0pvQPpwG*S-O1ylX-L diff --git a/trees/Insertion_In_BinaryTree.class b/trees/Insertion_In_BinaryTree.class deleted file mode 100644 index 6d80297f4da874b5d4475da6a76f585c816f482d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2214 zcma)7T~`xV6x|mB6T(oCAjp?QK};eVY88}Fszhz00kqIipsfz%1_qLuFqzQu)~EJ2 z^cV1~wt{u7uD-ce|4RQtSKEDOg33p!JTUj;oO{mR=bW8C{{Hnh0HY{ts1fLO9VyF+ zv{jalYueW1wDow>vF zQOFvOsrJ>w`f=~U5NZ+DaS9D8*qT`u=sP(zW~G^y?c}5*a4~wav5zB`Z9pfwHFOD_ z|9{*%dK8dALFU~Mk)74ij*bRIa9+c?1FX(&m&uThehiQryFzA9XFSqPJMqvlEq9jj zjABy5pg_mla`4!+RwpZFfjCrlQ5`YF`N)Rc77*zWhHyp0<%8ioFC7UClZ7p#P?0lv zhK#0TepIj2{@ckAF5s%7_9JC+^gfmi;yOb`l;Nn38@MS@ZX$_ZRP&f~}gcX%w}X^e9Y@m{q8;41#S}MDF9bYQDdPf%REg2%%MOCjQy0W5K zW%IR;Z}3>PeEDv%;*=?@+CG4if- z-f>}U!&#*ygpUa=5Sq0s&WgNeDv{~=4;{RsYDk?*Tb6WE1*2S+d@!K&O`vgFmfb0- zw5p7AOt6;vT7#g{G_Hb5(fF<7DhMTVA?_~ntNyfSXnc;Qr(D*cng8p(i#D`)C*Y2< zR&`47tK911yJ$V^Qs=qoz5&{BnubB8IaTLx5%BJYdOX#Ic4&Vw`3H~q+ zV+>a*7uS%%bq?1EmT(h!+S*8ZKqEeeDo~DZljb8Q z!F{j3);x<#Z`QU&ALpWb4{L0M*7Y~%Z+mM5O-$<+Q@@RFs%ji53iKUJlb|Oo>>5jJ z;XXF;0N+t+zUR#knDJ<8_aUKxBH!3#FZwjq(nGboP2#|55Y#Ne`yd?dRhM@D3qOnW A@&Et; diff --git a/trees/Insertion_In_BinaryTree.java b/trees/Insertion_In_BinaryTree.java deleted file mode 100644 index efdb19a..0000000 --- a/trees/Insertion_In_BinaryTree.java +++ /dev/null @@ -1,80 +0,0 @@ -package trees; -import java.util.*; - -//Java program to insert element in binary tree -public class Insertion_In_BinaryTree { - - /* A binary tree node has key, pointer to - left child and a pointer to right child */ - static class Node { - int key; - Node left, right; - - // constructor - Node(int key){ - this.key = key; - left = right = null; - } - } - static Node root; - static Node temp = root; - - //In-order traversal of a binary tree - static void inorder(Node temp) - { - if (temp == null) - return; - - inorder(temp.left); - - System.out.print(temp.key+" "); - inorder(temp.right); - } - - //function to insert element in binary tree - static void insert(Node temp, int key) - { - Queue q = new LinkedList(); - q.add(temp); - - // Do level order traversal until we find - // an empty place. - while (!q.isEmpty()) { - temp = q.peek(); - q.remove(); - - if (temp.left == null) { - temp.left = new Node(key); - break; - } else - q.add(temp.left); - - if (temp.right == null) { - temp.right = new Node(key); - break; - } - else - q.add(temp.right); - } - } - - // Driver code - public static void main(String args[]) - { - root = new Node(10); - root.left = new Node(11); - root.right = new Node(9); - root.left.left = new Node(7); - root.right.left = new Node(15); - root.right.right = new Node(8); - - System.out.print( "Inorder traversal before insertion:"); - inorder(root); - - int key = 12; - insert(root, key); - - System.out.print("\nInorder traversal after insertion:"); - inorder(root); - } -} diff --git a/trees/Node.class b/trees/Node.class deleted file mode 100644 index e882920baff1cfe8813314b682f14ffb1d88ba51..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 390 zcmYLEO;5r=6r63#N3jYP#1A}pgdXJRLE}La6OslFHXOW|Ev&Glv`Hx@{wxo~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=bKiA+QB!S8)qB`?O#2 z#v?>3c)R}|{Mz;}h(5$=;!adW6};O$RYAOh=?X6T&iJr=JoCfkoxy76c8IaUUF~LuH*5MU)X(y~AHl%iIIN>rJVC#Xfl${I e9232N!DuIdq)HoBk>ebq0|WflxVHFdYX2`xn8}s^ diff --git a/trees/Problem_01.java b/trees/Problem_01.java deleted file mode 100644 index c7bf03c..0000000 --- a/trees/Problem_01.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Check if generic tree contain element x - * - * Send Feedback - * Given a generic tree and an integer x, check if x is present in the given tree or not. - * Return : true :- if x is present, - * Return : false :- otherwise. - * - * Input format : - * Line 1 : Integer x - * Line 2 : Elements in level order form separated by space (as per done in class). - * - * Order is - - * Root_data , n (No_Of_Child_Of_Root) , n children , and so on for every element. - * - * Output format : true or false - * Sample Input 1 : - * 40 - * 10 3 20 30 40 2 40 50 0 0 0 0 - * - * Sample Output 1 : - * true - * - * Sample Input 2 : - * 4 - * 10 3 20 30 40 2 40 50 0 0 0 0 - * - * Sample Output 2: - * false - */ - -package trees; -import java.util.*; - -public class Problem_01 { - // TreeNode class - class TreeNode { - T data; - ArrayList> children; - - TreeNode(T data){ - this.data = data; - children = new ArrayList>(); - } - } - - public static boolean checkIfContainsX(TreeNode root, int x){ - - // Write your code here - if(root==null) - return false; - - // Write your code here - Queue> queue = new LinkedList<>(); - - //added 1st level here - queue.add(root); - queue.add(null); - @SuppressWarnings("unused") - int ans=0; - - // if(x frontNode = queue.remove(); - if(frontNode == null) - { - if(queue.isEmpty()) - break; - - queue.add(null); - } - else{ - if(frontNode.data==x) - return true; - System.out.print(frontNode.data+" "); - - for(int i=0;i473lIei2dIg7^Weup5+e!0gM@<@v)~HFT9VyD!q4*1n0W99 z_@j)kJu4n|W?yz^-n`wf?~hLaXE@40N6CbNafkOjT2JJ51on zs6T%a3|80oh3t4-DWMqZy+8_~+SjhnZ>oCEdxC9Q0u7s>Ufp zWsQjL>ld!?23HKV=DLgB){s(l;#B#b>x=&4btL3~k37n0-p?0uEN9`$xSgxOK+QrPwuMd9Eu@jLkVDpji7Z3)pE()q$gk~jf6~4i&BT}{F8?i}7jCwO zsL`7n^d(7J)R7QTznG~xVB1k9s_8Q*Sb=bhs!LL6#3koA1asbza4I1*$6*g4k|9!W lv1FUD5S!=7JWuo3D3Xna9Xd&17ke=mVG)~TuG9Gj@B=h%cZvW2 diff --git a/trees/trees/BinaryTree_Traversal.class b/trees/trees/BinaryTree_Traversal.class deleted file mode 100644 index 440edb1d157fc0231cea1eac491988f5cc955c97..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2145 zcmah~ZBr9h6n<_9Bw03qC{n0mu)&7J5^W2$f^UG7v>~8DC~CD!xWbxcm+o$8^H2IW z>{#gNOsC&E(;wC8b2mFBfq;|Qd(S=hob#O5n}7a&_a}g_u%+Q65=O?jxR7;^j#^v{H$pkZhe*X%T?Fdm#$}6X{9(V&^2S) zrhiwUBQw56&AGr{Z_%`6skXZ*-Bn}LB0|reYuf&b8}PaTy~zKE@>-i)tCgRUHLfis4%w-=U~u2_=EPS*FeNU1M)a`a8~+ z*V~2VI97B#!s8gqI#%&SM_OsGDQXN?1%^*gvcQ$oFM|riu&(2KY$z9>3XH9UnMl!# zMxj#9tJG#tK=PzanO;f(j|g1TQehsCOB=RZZ<05P{8zj_~#A64>wNBLjgd@U>N zr>G@gaqD!=?H%q-66Lz*%Uw2+Q{%-zqjsi~Ur|lN@=0Ttz1C5cbpcV(@C?rdA|fR) zxNB79oMTrEf8F$VNO`_t`)uNYOkw*7gK`ZFVD6YV_u!VQ*Q|OE)B^PX^t@X;ECQ@5wge&GXhK z-q6IHVOeFDfJ@cjOG4D^i4MR799tOs=br@Z|EWwd#At-kWeNg zfyrTXk-kimBj_Y2NrMBN`ZUMx6W(+{baLY}a2Af%YQH;#)sEwg6DLcY>%^I0@Hc4q zW-|^SnYK7>>@z$)#L&=;4WEW8e=!DC&|lsoxp9b|;(PRN z4^ylb_^%Pi zGMjIOK0d-E9%CM5{+{rGTf<8}?AzEtl_w9+@iSh~{|xma7-!AFli)x6FsXj>dTCQN S@Cz8!9l{r+S=$W6Ja5J*TWY9JcqX`n+Lm`<^sn()p~=&L5a z@S;HwNsLdJ_yK-_UtzqhGsP5QeCR%Vud~kHd+jr)Uw(b~2w)tyHAK-KMg=-lbZYRS zy#meXlBQdlt15cJ2%%S+n2NYYZo9^yFN_5GWjLT=5J?r+1pN72&K1y8Zr(Ht$)#M{ zoD>L7S&rq-2>4?0ha}Ar7N|~Hj=5CKuABK4W8EgAXH0jYXxnqSqQfj?FA7vHyT-=$ zU1P^1sTg8{tYJ9<4Y9Sju9e39o9Ap1Z&bFy37XO#eUEADbkwD(cJmKn(Ey~HAYh!u0;F?(` z%N4m_U&>+SlJ_}gm%}!VEU&iKYw{w@R(2%GcF@7kBg!vL@W%<$`sj1uv<-}|aFu(3 zz9Wb?bObKZ20gHb9*0CRYI<%bEQ2G(Mrhc-|t)YSx)g9nn5-FMyO~)7%kM) zO4~-;fnIcC2wl9#Zp@+wi$qos#~S*uiGEmo9Zfu4k6`#G>Qpp~ALvpMihf5_@zTjL zNR8j9P~rOO1QnE~rxGU!tp<)z`3_2gDrFc^y*T_g4tb#_L+bGu!3z*|OVnRJM&211 zsW?ydc#-f0=!|$)^ew6qhp0Y8q5XB5e=uu&AW!)|_Ar6x P{O(_3np#`QSJ3tch#2l{ diff --git a/trees/trees/Node.class b/trees/trees/Node.class deleted file mode 100644 index 306771cee78f9af2cb76992fbfd929b6870d5b3d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 339 zcmYLEO-sW-6r63+#>UmuwtnG3k8KX-sGtZc6au9lEIoMJG;7@wQ%DoRpXDJ49{d6R zC~>wI4{zq}+nM+A^ZWG;-~z`!TIjaXM9)Is!oG(C4~GJ7s!AmwVy2mXE(PScEVN!n zlU1s(1e%3eys+H5Hn}NpC>zAX8R?$?0>RkidQ!b6x|pgYW5s`5RmEJ7jD4JrOrDOa zEVJF#aejMea#g%fIpKV%-jsyIk%WgWiEa22ZTM{Qzkxu<>Y_~Li|8R)>N$6D2E!T7 zct(o{It==WucJFP7U{CqYj8&s;tYUuT5VM L0sS4;8rb^-@TxjV From 9ab4dc3a83cbea6c1e9b5546d3486c17c2205935 Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Fri, 7 May 2021 12:10:05 +0530 Subject: [PATCH 37/56] #Modification 30 --- {oopsabstraction => abstraction}/Audi.class | Bin {oopsabstraction => abstraction}/Audi.java | 2 +- {oopsabstraction => abstraction}/Car.class | Bin {oopsabstraction => abstraction}/Car.java | 2 +- .../RepairShop.class | Bin abstraction/RepairShop.java | 20 +++++ {oopsabstraction => abstraction}/WagonR.class | Bin abstraction/WagonR.java | 14 +++ binaryTree/BT_Problem_10.java | 35 ++++++-- binaryTree/BT_Problem_15.java | 2 +- binaryTree/BT_Problem_17.java | 84 +++++++++++++++++- binaryTree/BT_Problem_18.java | 5 +- binaryTree/BT_Problem_19.java | 4 +- binaryTree/BT_Problem_20.java | 5 ++ binaryTree/BT_Problem_21.java | 5 ++ binaryTree/BT_Problem_22.java | 5 ++ binaryTree/BT_Problem_23.java | 5 ++ binaryTree/BT_Problem_24.java | 5 ++ binaryTree/BT_Problem_25.java | 5 ++ binaryTree/BT_Problem_26.java | 5 ++ binaryTree/BT_Problem_27.java | 5 ++ binaryTree/BT_Problem_28.java | 5 ++ binaryTree/BT_Problem_29.java | 5 ++ binaryTree/BT_Problem_30.java | 5 ++ binaryTree/BT_Problem_32.java | 5 ++ binaryTree/BT_Problem_33.java | 5 ++ binaryTree/BT_Problem_34.java | 5 ++ bitManipulation/BM_02.java | 7 +- bitManipulation/BM_03.java | 4 +- bitManipulation/BM_04.java | 4 +- bitManipulation/BM_05.java | 4 +- bitManipulation/BM_06.java | 4 +- bitManipulation/BM_07.java | 4 +- bitManipulation/BM_08.java | 4 +- bitManipulation/BM_09.java | 4 +- bitManipulation/BM_10.java | 21 ++++- bit_manupulation/Bitmain.class | Bin 672 -> 0 bytes bit_manupulation/Bitmain.java | 13 --- .../Count_set_bit_in_integer.class | Bin 581 -> 0 bytes .../Count_set_bit_in_integer.java | 20 ----- dataStructures/Info.class | Bin 385 -> 0 bytes dataStructures/Info.java | 10 --- .../EncapIntro.class | Bin .../EncapIntro.java | 2 +- {oopsEncapsulation => encapsulation}/S.class | Bin {oopsEncapsulation => encapsulation}/S.java | 2 +- .../MainClass.class | Bin .../MainClass.java | 2 +- {oopsinheritance => inheritance}/Person.class | Bin inheritance/Person.java | 12 +++ {oopsinheritance => inheritance}/Singer.class | Bin inheritance/Singer.java | 8 ++ .../Teacher.class | Bin inheritance/Teacher.java | 7 ++ linkedList/linkedList/Reverse_a_LL$Node.class | Bin 416 -> 0 bytes linkedList/linkedList/Reverse_a_LL.class | Bin 1630 -> 0 bytes .../Multiply_2_no_rep_by_ll.java | 2 +- oops/A$B.class | Bin 383 -> 0 bytes oops/A$C.class | Bin 344 -> 0 bytes oops/A.class | Bin 339 -> 0 bytes oops/MYStaticKeyword.class | Bin 966 -> 0 bytes oops/Mor.class | Bin 593 -> 0 bytes oops/Mor.java | 15 ---- oops/MyConstructor.class | Bin 596 -> 0 bytes oops/Person.class | Bin 364 -> 0 bytes oops/RepairShop.class | Bin 905 -> 0 bytes oops/Sonata.class | Bin 580 -> 0 bytes oops/StaticKeyword.class | Bin 978 -> 0 bytes oops/Vehicle.class | Bin 861 -> 0 bytes oops/Watches.class | Bin 290 -> 0 bytes oops/transport.class | Bin 304 -> 0 bytes patternsByloops/Pattern1.class | Bin 709 -> 0 bytes patternsByloops/Pattern2.class | Bin 709 -> 0 bytes patternsByloops/Pattern3.class | Bin 712 -> 0 bytes patternsByloops/Pattern4.class | Bin 768 -> 0 bytes patternsByloops/Pattern5.class | Bin 855 -> 0 bytes patternsByloops/Pattern5_2.class | Bin 825 -> 0 bytes patternsByloops/Pattern6.class | Bin 766 -> 0 bytes patternsByloops/Pattern7.class | Bin 759 -> 0 bytes patternsByloops/Pattern8.class | Bin 817 -> 0 bytes patternsByloops/Pattern9.class | Bin 818 -> 0 bytes .../Animal.class | Bin polymorphism/Animal.java | 7 ++ {oopspolymorphism => polymorphism}/Dog.class | Bin polymorphism/Dog.java | 7 ++ polymorphism/Main.java | 25 ++++++ .../MainClass.class | Bin {oopspolymorphism => polymorphism}/Pet.class | Bin polymorphism/Pet.java | 7 ++ searchingAlgorithms/BinarySearch.java | 4 +- searchingAlgorithms/LinearSearch.java | 23 +++++ 91 files changed, 367 insertions(+), 93 deletions(-) rename {oopsabstraction => abstraction}/Audi.class (100%) rename {oopsabstraction => abstraction}/Audi.java (89%) rename {oopsabstraction => abstraction}/Car.class (100%) rename {oopsabstraction => abstraction}/Car.java (80%) rename {oopsabstraction => abstraction}/RepairShop.class (100%) create mode 100644 abstraction/RepairShop.java rename {oopsabstraction => abstraction}/WagonR.class (100%) create mode 100644 abstraction/WagonR.java create mode 100644 binaryTree/BT_Problem_20.java create mode 100644 binaryTree/BT_Problem_21.java create mode 100644 binaryTree/BT_Problem_22.java create mode 100644 binaryTree/BT_Problem_23.java create mode 100644 binaryTree/BT_Problem_24.java create mode 100644 binaryTree/BT_Problem_25.java create mode 100644 binaryTree/BT_Problem_26.java create mode 100644 binaryTree/BT_Problem_27.java create mode 100644 binaryTree/BT_Problem_28.java create mode 100644 binaryTree/BT_Problem_29.java create mode 100644 binaryTree/BT_Problem_30.java create mode 100644 binaryTree/BT_Problem_32.java create mode 100644 binaryTree/BT_Problem_33.java create mode 100644 binaryTree/BT_Problem_34.java delete mode 100644 bit_manupulation/Bitmain.class delete mode 100644 bit_manupulation/Bitmain.java delete mode 100644 bit_manupulation/Count_set_bit_in_integer.class delete mode 100644 bit_manupulation/Count_set_bit_in_integer.java delete mode 100644 dataStructures/Info.class delete mode 100644 dataStructures/Info.java rename {oopsEncapsulation => encapsulation}/EncapIntro.class (100%) rename {oopsEncapsulation => encapsulation}/EncapIntro.java (88%) rename {oopsEncapsulation => encapsulation}/S.class (100%) rename {oopsEncapsulation => encapsulation}/S.java (94%) rename {oopsinheritance => inheritance}/MainClass.class (100%) rename {oopsinheritance => inheritance}/MainClass.java (92%) rename {oopsinheritance => inheritance}/Person.class (100%) create mode 100644 inheritance/Person.java rename {oopsinheritance => inheritance}/Singer.class (100%) create mode 100644 inheritance/Singer.java rename {oopsinheritance => inheritance}/Teacher.class (100%) create mode 100644 inheritance/Teacher.java delete mode 100644 linkedList/linkedList/Reverse_a_LL$Node.class delete mode 100644 linkedList/linkedList/Reverse_a_LL.class rename {linkedList/linkedList => list}/Multiply_2_no_rep_by_ll.java (98%) delete mode 100644 oops/A$B.class delete mode 100644 oops/A$C.class delete mode 100644 oops/A.class delete mode 100644 oops/MYStaticKeyword.class delete mode 100644 oops/Mor.class delete mode 100644 oops/Mor.java delete mode 100644 oops/MyConstructor.class delete mode 100644 oops/Person.class delete mode 100644 oops/RepairShop.class delete mode 100644 oops/Sonata.class delete mode 100644 oops/StaticKeyword.class delete mode 100644 oops/Vehicle.class delete mode 100644 oops/Watches.class delete mode 100644 oops/transport.class delete mode 100644 patternsByloops/Pattern1.class delete mode 100644 patternsByloops/Pattern2.class delete mode 100644 patternsByloops/Pattern3.class delete mode 100644 patternsByloops/Pattern4.class delete mode 100644 patternsByloops/Pattern5.class delete mode 100644 patternsByloops/Pattern5_2.class delete mode 100644 patternsByloops/Pattern6.class delete mode 100644 patternsByloops/Pattern7.class delete mode 100644 patternsByloops/Pattern8.class delete mode 100644 patternsByloops/Pattern9.class rename {oopspolymorphism => polymorphism}/Animal.class (100%) create mode 100644 polymorphism/Animal.java rename {oopspolymorphism => polymorphism}/Dog.class (100%) create mode 100644 polymorphism/Dog.java create mode 100644 polymorphism/Main.java rename {oopspolymorphism => polymorphism}/MainClass.class (100%) rename {oopspolymorphism => polymorphism}/Pet.class (100%) create mode 100644 polymorphism/Pet.java create mode 100644 searchingAlgorithms/LinearSearch.java diff --git a/oopsabstraction/Audi.class b/abstraction/Audi.class similarity index 100% rename from oopsabstraction/Audi.class rename to abstraction/Audi.class diff --git a/oopsabstraction/Audi.java b/abstraction/Audi.java similarity index 89% rename from oopsabstraction/Audi.java rename to abstraction/Audi.java index fd35932..646fd21 100644 --- a/oopsabstraction/Audi.java +++ b/abstraction/Audi.java @@ -1,4 +1,4 @@ -package oopsabstraction; +package abstraction; //Audi Class public class Audi extends Car{ diff --git a/oopsabstraction/Car.class b/abstraction/Car.class similarity index 100% rename from oopsabstraction/Car.class rename to abstraction/Car.class diff --git a/oopsabstraction/Car.java b/abstraction/Car.java similarity index 80% rename from oopsabstraction/Car.java rename to abstraction/Car.java index 9a5d83e..2182427 100644 --- a/oopsabstraction/Car.java +++ b/abstraction/Car.java @@ -1,4 +1,4 @@ -package oopsabstraction; +package abstraction; public abstract class Car { public abstract void accelerate(); diff --git a/oopsabstraction/RepairShop.class b/abstraction/RepairShop.class similarity index 100% rename from oopsabstraction/RepairShop.class rename to abstraction/RepairShop.class diff --git a/abstraction/RepairShop.java b/abstraction/RepairShop.java new file mode 100644 index 0000000..ddc5b75 --- /dev/null +++ b/abstraction/RepairShop.java @@ -0,0 +1,20 @@ +package abstraction; + +public class RepairShop { + + public static void repairCar(Car car) { + System.out.println("Car is repaired"); + } + + public static void repairCar(Car...Audi) { + System.out.println("Car is repaired"); + } + + public static void main(String[] args) { + WagonR wagonR = new WagonR(); + Audi audi = new Audi(); + + repairCar(wagonR); + repairCar(audi); + } +} diff --git a/oopsabstraction/WagonR.class b/abstraction/WagonR.class similarity index 100% rename from oopsabstraction/WagonR.class rename to abstraction/WagonR.class diff --git a/abstraction/WagonR.java b/abstraction/WagonR.java new file mode 100644 index 0000000..6d0f44c --- /dev/null +++ b/abstraction/WagonR.java @@ -0,0 +1,14 @@ +package abstraction; + +public class WagonR extends Car{ + + @Override + public void accelerate() { + System.out.println("WagonR is accelerating"); + } + + @Override + public void apply_break() { + System.out.println("break is applied in WagonR"); + } +} diff --git a/binaryTree/BT_Problem_10.java b/binaryTree/BT_Problem_10.java index 5b9101a..01cea10 100644 --- a/binaryTree/BT_Problem_10.java +++ b/binaryTree/BT_Problem_10.java @@ -5,26 +5,47 @@ * The right view of a binary tree, is set of nodes visible when tree is visited from rights side * between two end nodes. */ +class Max_level{ + int max_level; +} public class BT_Problem_10 { Node root; - static int max_level = 0; - void leftViewUtil(Node node, int level) { + Max_level max_level = new Max_level(); + + void rightViewUtil(Node node, int level, Max_level max_level) { if(node == null) return; - if(max_level < level) { - System.out.print(" " + node.data); - max_level = level; + if(max_level.max_level < level) { + System.out.print(node.data + " " ); + max_level.max_level = level; } - + rightViewUtil(node.right, level+1,max_level); + rightViewUtil(node.left, level+1,max_level); + } + + void rightView() { + rightView(root); } + + void rightView(Node node) { + rightViewUtil(node, 1, max_level); + } + public static void main(String[] args) { + BT_Problem_10 tree = new BT_Problem_10(); + tree.root = new Node(12); + tree.root.left = new Node(10); + tree.root.right = new Node(30); + tree.root.right.left = new Node(25); + tree.root.right.right = new Node(40); + + tree.rightView(); - } } diff --git a/binaryTree/BT_Problem_15.java b/binaryTree/BT_Problem_15.java index 1b70b05..f0ad436 100644 --- a/binaryTree/BT_Problem_15.java +++ b/binaryTree/BT_Problem_15.java @@ -2,7 +2,7 @@ import java.util.*; import java.util.Map.Entry; /* - * Problem Title :- Diagnol Traversal of a Binary tree + * Problem Title :- Daignol Traversal of a Binary tree */ public class BT_Problem_15 { diff --git a/binaryTree/BT_Problem_17.java b/binaryTree/BT_Problem_17.java index d5a38e4..a1ff4a8 100644 --- a/binaryTree/BT_Problem_17.java +++ b/binaryTree/BT_Problem_17.java @@ -1,10 +1,86 @@ package binaryTree; - +import java.util.*; +/* + * Problem Title :- Construct Binary Tree from String with Bracket Representation. + */ public class BT_Problem_17 { - + // Binary Tree node + static class Node{ + int data; + Node left, right; + }; + + // Helper function that allocates a new node + static Node newNode(int data) { + Node node = new Node(); + node.data = data; + node.left = node.right = null; + return(node); + } + + // function just for testing + static void preOrder(Node node) { + if(node == null) + return; + System.out.printf("%d ", node.data); + preOrder(node.left); + preOrder(node.right); + } + + // function to return the index of close parenthesis + static int findIndex(String str, int si, int ei) { + // base case + if(si > ei) + return -1; + //Inbuilt Stack + Stack s = new Stack<>(); + // loop for iterations of the index + for(int i = si; i <= ei; i++) { + // if open parenthesis, push it to the stack + if(str.charAt(i) == '(') + s.add(str.charAt(i)); + // if close parenthesis, pop it and else stack is empty that will be the required index + else if(str.charAt(i) == ')') { + if(s.peek() == '(') { + // pop from stack + s.pop(); + //if stack is empty, this is the required index + if(s.isEmpty()) return i; + } + } + } + return -1; + } + + // function to construct tree from string + static Node treeFromString(String str, int si, int ei) { + + // Base Case + if(si > ei) return null; + + // new root + Node root = newNode(str.charAt(si) - '0'); + int index = -1; + + // if next char is '(' find the index of its complement + if(si + 1 <= ei && str.charAt(si+1) == '(') + index = findIndex(str, si + 1, ei); + + // if index found + if(index != -1) { + // call for left subtree + root.left = treeFromString(str, si+2, index - 1); + // call for left subtree + root.right = treeFromString(str, index + 2, ei - 1); + } + return root; + } + + //Driver Code public static void main(String[] args) { - // TODO Auto-generated method stub - + String str = "4(2(3)(1))(6(5))"; + Node root = treeFromString(str, 0, str.length() - 1); + preOrder(root); } } diff --git a/binaryTree/BT_Problem_18.java b/binaryTree/BT_Problem_18.java index 6f39679..9731805 100644 --- a/binaryTree/BT_Problem_18.java +++ b/binaryTree/BT_Problem_18.java @@ -1,9 +1,10 @@ package binaryTree; - +/* + * Problem Title :- Convert Binary tree into Doubly Linked List + */ public class BT_Problem_18 { public static void main(String[] args) { - // TODO Auto-generated method stub } diff --git a/binaryTree/BT_Problem_19.java b/binaryTree/BT_Problem_19.java index 777ba6f..1aee9bb 100644 --- a/binaryTree/BT_Problem_19.java +++ b/binaryTree/BT_Problem_19.java @@ -1,5 +1,7 @@ package binaryTree; - +/* + * Problem Title :- Construct Binary Tree from String with Bracket Representation. + */ public class BT_Problem_19 { public static void main(String[] args) { diff --git a/binaryTree/BT_Problem_20.java b/binaryTree/BT_Problem_20.java new file mode 100644 index 0000000..11f5cfb --- /dev/null +++ b/binaryTree/BT_Problem_20.java @@ -0,0 +1,5 @@ +package binaryTree; + +public class BT_Problem_20 { + +} diff --git a/binaryTree/BT_Problem_21.java b/binaryTree/BT_Problem_21.java new file mode 100644 index 0000000..d928a7b --- /dev/null +++ b/binaryTree/BT_Problem_21.java @@ -0,0 +1,5 @@ +package binaryTree; + +public class BT_Problem_21 { + +} diff --git a/binaryTree/BT_Problem_22.java b/binaryTree/BT_Problem_22.java new file mode 100644 index 0000000..4d87770 --- /dev/null +++ b/binaryTree/BT_Problem_22.java @@ -0,0 +1,5 @@ +package binaryTree; + +public class BT_Problem_22 { + +} diff --git a/binaryTree/BT_Problem_23.java b/binaryTree/BT_Problem_23.java new file mode 100644 index 0000000..bf554c3 --- /dev/null +++ b/binaryTree/BT_Problem_23.java @@ -0,0 +1,5 @@ +package binaryTree; + +public class BT_Problem_23 { + +} diff --git a/binaryTree/BT_Problem_24.java b/binaryTree/BT_Problem_24.java new file mode 100644 index 0000000..07b9d8e --- /dev/null +++ b/binaryTree/BT_Problem_24.java @@ -0,0 +1,5 @@ +package binaryTree; + +public class BT_Problem_24 { + +} diff --git a/binaryTree/BT_Problem_25.java b/binaryTree/BT_Problem_25.java new file mode 100644 index 0000000..38bf165 --- /dev/null +++ b/binaryTree/BT_Problem_25.java @@ -0,0 +1,5 @@ +package binaryTree; + +public class BT_Problem_25 { + +} diff --git a/binaryTree/BT_Problem_26.java b/binaryTree/BT_Problem_26.java new file mode 100644 index 0000000..df387b4 --- /dev/null +++ b/binaryTree/BT_Problem_26.java @@ -0,0 +1,5 @@ +package binaryTree; + +public class BT_Problem_26 { + +} diff --git a/binaryTree/BT_Problem_27.java b/binaryTree/BT_Problem_27.java new file mode 100644 index 0000000..331c4a1 --- /dev/null +++ b/binaryTree/BT_Problem_27.java @@ -0,0 +1,5 @@ +package binaryTree; + +public class BT_Problem_27 { + +} diff --git a/binaryTree/BT_Problem_28.java b/binaryTree/BT_Problem_28.java new file mode 100644 index 0000000..ce61fed --- /dev/null +++ b/binaryTree/BT_Problem_28.java @@ -0,0 +1,5 @@ +package binaryTree; + +public class BT_Problem_28 { + +} diff --git a/binaryTree/BT_Problem_29.java b/binaryTree/BT_Problem_29.java new file mode 100644 index 0000000..54d7095 --- /dev/null +++ b/binaryTree/BT_Problem_29.java @@ -0,0 +1,5 @@ +package binaryTree; + +public class BT_Problem_29 { + +} diff --git a/binaryTree/BT_Problem_30.java b/binaryTree/BT_Problem_30.java new file mode 100644 index 0000000..ba65099 --- /dev/null +++ b/binaryTree/BT_Problem_30.java @@ -0,0 +1,5 @@ +package binaryTree; + +public class BT_Problem_30 { + +} diff --git a/binaryTree/BT_Problem_32.java b/binaryTree/BT_Problem_32.java new file mode 100644 index 0000000..233a48d --- /dev/null +++ b/binaryTree/BT_Problem_32.java @@ -0,0 +1,5 @@ +package binaryTree; + +public class BT_Problem_32 { + +} diff --git a/binaryTree/BT_Problem_33.java b/binaryTree/BT_Problem_33.java new file mode 100644 index 0000000..cbd980a --- /dev/null +++ b/binaryTree/BT_Problem_33.java @@ -0,0 +1,5 @@ +package binaryTree; + +public class BT_Problem_33 { + +} diff --git a/binaryTree/BT_Problem_34.java b/binaryTree/BT_Problem_34.java new file mode 100644 index 0000000..39333f5 --- /dev/null +++ b/binaryTree/BT_Problem_34.java @@ -0,0 +1,5 @@ +package binaryTree; + +public class BT_Problem_34 { + +} diff --git a/bitManipulation/BM_02.java b/bitManipulation/BM_02.java index 2caa1c6..61cfa26 100644 --- a/bitManipulation/BM_02.java +++ b/bitManipulation/BM_02.java @@ -1,10 +1,11 @@ package bitManipulation; - +/* + * Problem Title :- Find the two non-repeating elements in an array of repeating elements + */ public class BM_02 { public static void main(String[] args) { - // TODO Auto-generated method stub - + } } diff --git a/bitManipulation/BM_03.java b/bitManipulation/BM_03.java index 6a15b06..e4fa0bf 100644 --- a/bitManipulation/BM_03.java +++ b/bitManipulation/BM_03.java @@ -1,5 +1,7 @@ package bitManipulation; - +/* + * Problem Title :- Count number of bits to be flipped to convert A to B + */ public class BM_03 { public static void main(String[] args) { diff --git a/bitManipulation/BM_04.java b/bitManipulation/BM_04.java index e61a030..fa80059 100644 --- a/bitManipulation/BM_04.java +++ b/bitManipulation/BM_04.java @@ -1,5 +1,7 @@ package bitManipulation; - +/* + * Problem Title :- Count total set bits in all numbers from 1 to n + */ public class BM_04 { public static void main(String[] args) { diff --git a/bitManipulation/BM_05.java b/bitManipulation/BM_05.java index 8dd10a5..1934915 100644 --- a/bitManipulation/BM_05.java +++ b/bitManipulation/BM_05.java @@ -1,5 +1,7 @@ package bitManipulation; - +/* + * Problem Title :- Program to find whether a no is power of two + */ public class BM_05 { public static void main(String[] args) { diff --git a/bitManipulation/BM_06.java b/bitManipulation/BM_06.java index 9f93c54..40093b3 100644 --- a/bitManipulation/BM_06.java +++ b/bitManipulation/BM_06.java @@ -1,5 +1,7 @@ package bitManipulation; - +/* + * Problem Title :- Find position of the only set bit + */ public class BM_06 { public static void main(String[] args) { diff --git a/bitManipulation/BM_07.java b/bitManipulation/BM_07.java index d4fedae..1c58cb8 100644 --- a/bitManipulation/BM_07.java +++ b/bitManipulation/BM_07.java @@ -1,5 +1,7 @@ package bitManipulation; - +/* + * Problem Title :- Copy set bits in a range + */ public class BM_07 { public static void main(String[] args) { diff --git a/bitManipulation/BM_08.java b/bitManipulation/BM_08.java index 196de0e..f0b2763 100644 --- a/bitManipulation/BM_08.java +++ b/bitManipulation/BM_08.java @@ -1,5 +1,7 @@ package bitManipulation; - +/* + * Problem Title :- Divide two integers without using multiplication, division and mod operator + */ public class BM_08 { public static void main(String[] args) { diff --git a/bitManipulation/BM_09.java b/bitManipulation/BM_09.java index 705e43d..2266941 100644 --- a/bitManipulation/BM_09.java +++ b/bitManipulation/BM_09.java @@ -1,5 +1,7 @@ package bitManipulation; - +/* + * Problem Title :- Calculate square of a number without using *, / and pow() + */ public class BM_09 { public static void main(String[] args) { diff --git a/bitManipulation/BM_10.java b/bitManipulation/BM_10.java index 7701b37..6dbde29 100644 --- a/bitManipulation/BM_10.java +++ b/bitManipulation/BM_10.java @@ -1,10 +1,27 @@ package bitManipulation; +/* + * Problem Title :- Divide two integers without using multiplication, division and mod operator + */ + public class BM_10 { + static void printPowerSet(char[] set, int set_size) { + long pow_set_size = (long)Math.pow(2, set_size); + int counter , j; + + for(counter = 0; counter < pow_set_size; counter++) { + for(j = 0; j < set_size; j++) { + if((counter & (1 << j)) > 0) System.out.print(set[j]); + } + System.out.println(); + } + } + + //Driver Program public static void main(String[] args) { - // TODO Auto-generated method stub - + char[] set = {'a','b','c'}; + printPowerSet(set, 3); } } diff --git a/bit_manupulation/Bitmain.class b/bit_manupulation/Bitmain.class deleted file mode 100644 index 113b5a78909e8080342fb6704d06b5bb6b68910b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 672 zcmZ`$O;6iE5PcKdabg_8M+p#G3N39N4)u{k5C@PdSxRZ8R2=A`+JsfQ)E|*qSM7!W z(f`1uJ(Q}4{($}{#H>zMaA*>9P{*Z{Y7#Fe7DoewC zr4yl27dBz;RD2d;EYeZUN?!ma*z$<<6!0U(d8me6+E~s#(FkmL_DCg>RXunJ-1s z^+0&!V-`&hkFn`ugRoe3xeN611WyU>*l=TZV+Y6Om_$Be%Zv9|BY6F+$cOTkGSl*> z^M7g7vB`ZcelBq2IiSkX9 zrhASXBf@fodW;6PVmv?`p&8=|wguV_pGl)9#aLRMo6f$Q?mtoj$=x8Y2j^;N@1@eq znN=CL&kGi+i>Yie=goUrl;J zzqI=e;wuB*fi_$u3FB^z9rTD)kG|^n>YtD_>cPi%y?XGW`}yzh#upa6Ikm=4VC0b+ zk{n}&e|MD@?CagY6AASyOf7Wx2z9!Zq}02D*Z2;+RhqYTt C5On+i diff --git a/bit_manupulation/Count_set_bit_in_integer.java b/bit_manupulation/Count_set_bit_in_integer.java deleted file mode 100644 index 838ed63..0000000 --- a/bit_manupulation/Count_set_bit_in_integer.java +++ /dev/null @@ -1,20 +0,0 @@ -package bit_manupulation; - -public class Count_set_bit_in_integer { - /* - * Function to get no of set bits in binary representation of positive integer n - */ - static int countSetBits(int n) { - int count = 0; - while (n > 0) { - count += n & 1; - n >>= 1; - } - return count; - } - - public static void main(String[] args) { - int i = 9; - System.out.println(countSetBits(i)); - } -} diff --git a/dataStructures/Info.class b/dataStructures/Info.class deleted file mode 100644 index b14e8240eff4fe42874bdcfda5156886c1ce7259..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 385 zcmZutO-sW-5Pj38O%totM!kEh3g+mc;zbaIpodB?o+jxUx1<}`Zv0=K1P}fIf0Q^I z1x0$;H=l3j&3=5oy#qMMeuxesS+L`ovrXX|tJdj_d8|VOgxw`Sb6T+})4P1B3P>4t4zdla zr!scM+7J#W581B-QK(HhZP&6bg`R9E6XIFj*g{=vzdiEDocSR*f~c0WfsS~hRxp$( z6-#1!C$AX1wB=aPmm!2L!Qpp<*lmd->|i7rPd=6B`{+M$@P{ZriM_UQEZ9Nv1zFZg AG5`Po diff --git a/dataStructures/Info.java b/dataStructures/Info.java deleted file mode 100644 index 6f332ad..0000000 --- a/dataStructures/Info.java +++ /dev/null @@ -1,10 +0,0 @@ -package dataStructures; - -public class Info { - - public static void main(String[] args) { - // TODO Auto-generated method stub - - } - -} diff --git a/oopsEncapsulation/EncapIntro.class b/encapsulation/EncapIntro.class similarity index 100% rename from oopsEncapsulation/EncapIntro.class rename to encapsulation/EncapIntro.class diff --git a/oopsEncapsulation/EncapIntro.java b/encapsulation/EncapIntro.java similarity index 88% rename from oopsEncapsulation/EncapIntro.java rename to encapsulation/EncapIntro.java index c243ead..dda3649 100644 --- a/oopsEncapsulation/EncapIntro.java +++ b/encapsulation/EncapIntro.java @@ -1,4 +1,4 @@ -package oopsEncapsulation; +package encapsulation; public class EncapIntro { diff --git a/oopsEncapsulation/S.class b/encapsulation/S.class similarity index 100% rename from oopsEncapsulation/S.class rename to encapsulation/S.class diff --git a/oopsEncapsulation/S.java b/encapsulation/S.java similarity index 94% rename from oopsEncapsulation/S.java rename to encapsulation/S.java index ad56e91..0fc2320 100644 --- a/oopsEncapsulation/S.java +++ b/encapsulation/S.java @@ -1,4 +1,4 @@ -package oopsEncapsulation; +package encapsulation; //Student class short name as S public class S { diff --git a/oopsinheritance/MainClass.class b/inheritance/MainClass.class similarity index 100% rename from oopsinheritance/MainClass.class rename to inheritance/MainClass.class diff --git a/oopsinheritance/MainClass.java b/inheritance/MainClass.java similarity index 92% rename from oopsinheritance/MainClass.java rename to inheritance/MainClass.java index 8332e70..b13c4cf 100644 --- a/oopsinheritance/MainClass.java +++ b/inheritance/MainClass.java @@ -1,4 +1,4 @@ -package oopsinheritance; +package inheritance; public class MainClass { diff --git a/oopsinheritance/Person.class b/inheritance/Person.class similarity index 100% rename from oopsinheritance/Person.class rename to inheritance/Person.class diff --git a/inheritance/Person.java b/inheritance/Person.java new file mode 100644 index 0000000..10654d0 --- /dev/null +++ b/inheritance/Person.java @@ -0,0 +1,12 @@ +package inheritance; + +public class Person { + protected String name; + public void walk() { + System.out.println(name + "is walking"); + } + public void eat() { + System.out.println(name + "is eating"); + } + +} diff --git a/oopsinheritance/Singer.class b/inheritance/Singer.class similarity index 100% rename from oopsinheritance/Singer.class rename to inheritance/Singer.class diff --git a/inheritance/Singer.java b/inheritance/Singer.java new file mode 100644 index 0000000..d243608 --- /dev/null +++ b/inheritance/Singer.java @@ -0,0 +1,8 @@ +package inheritance; + +public class Singer extends Person{ + + public void sing() { + System.out.println(name + "is singing"); + } +} diff --git a/oopsinheritance/Teacher.class b/inheritance/Teacher.class similarity index 100% rename from oopsinheritance/Teacher.class rename to inheritance/Teacher.class diff --git a/inheritance/Teacher.java b/inheritance/Teacher.java new file mode 100644 index 0000000..3e9f746 --- /dev/null +++ b/inheritance/Teacher.java @@ -0,0 +1,7 @@ +package inheritance; + +public class Teacher extends Person { + public void teach() { + System.out.println(name + "is teaching"); + } +} diff --git a/linkedList/linkedList/Reverse_a_LL$Node.class b/linkedList/linkedList/Reverse_a_LL$Node.class deleted file mode 100644 index 7832cfa63ff8e6075a6446024b3b3f100d3ac8c4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 416 zcmaJ-Jx>Bb6r6>FgY)FWFI0@NumB1vEG#rOBu0`8CTeKO0x#z9T$0;^__r*GiG@GF zA7z}Sve9hbo430&^WN^)_s1uI3p4{1uv3PIU6=NJG<@tUcvGEe1=VM1z zWi08V9w#&o9_EX5A~&(y)PGx@&GeG9lm=q6+qunr9E1pQ7@`P2L%^=WAvTE>R_A0mPPOw6)oHGf>!=m- kZ);+ed5cD%(4(kKS%oW)8qad5^VZ=u0%AZ*k98TPAET2|qW}N^ diff --git a/linkedList/linkedList/Reverse_a_LL.class b/linkedList/linkedList/Reverse_a_LL.class deleted file mode 100644 index ac38191b26f372a92082c54e8f7d6775fe593ff3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1630 zcmah~QF9Yj6#i}!x=Fg2Hf>U28ssGr5QP&;$l6C54H1xzI>F#$4Oi?@QFa8<#m;S*>GJo ztUJ>8l~3=Ml3jsC%dy>_>RPrRRKHcbYUr!`^1fvi^{$%0#AVyHgDV2@Qu!{o)kCn1 zWxJ}i)8ACXJ95(@yfKV63tTB3jafcAEO5LX$WE^*2P5dzU}(F6W+-s_|G+iJzO-F| zeCbDPTkguLBi#qpc0iB^HQhtH?d=RZYQxsNr^lOK)A<6EE#(JIrMvS@ zGEu{26Q6;4OkMN5zz>FU&{V;e*Yz_KxSGW0CceNm19cN$;wyo~9D_tx22@5g(zuQr0x?1SxxVbFy61Le@Vy;u(eeZ7 z2Ar;3sZl;GzQ9b#=yi0?PI$l$&n#Cuyek|#;@vgS(BfJG#e>Fdch~Ew(eXxHHe@I8 zhIFQ{{9=?@J4|5A^V-Hcdjs``^zo^SWUq~DF@mT| z$7$Pvsu{Q?aOO}$Z{o(s_2@hl`0P*fH6f7HvqLMvA19ce6SPk8&XK{f<$Z|XXb7C- zbs}`eX>p`z>r@{x9OHdSG%GD}DY5zj`PIjW(OUTfvDN0uMC;+JzgMivugr>tILk=W z&T=)w!m}ik!z9a3lR%!RCz!R!3I#0i17r|;3By1t`sV54V2=pgButE+g~|)eKSI3n z7>TEv(i2S3j#&?1{iR!oN@v4P3%s6Y@g){1h9we=&+{Gm9*aheJ!g)_{rMS;d;3UQ z&ycz|_1!+wzhm+dCc|ZhOLoa6D`}50?il%|X8(1@v!-Un^d~qT-QEe&;@J!XWS^Zn zNH`FF9VVHaS8|N{^I`$aV9qO)^n61xOu)7&r ZT6XsS3ac*vnvupR^tiqICsLZ}C&_f1`DN=zi1`oBDg;K3i@ zj}qUe_3(CQX6L;(?9cDlH-JkVd9VnzJb%@_emL;p5Q4dUlf6`Cv)+9?SJRSU%b6n3 zh~Spbi4M=XCt5aLv38wgNqIwPbpFMY3BeiWPpS^Wx(^RE0UJ#pbp$-GV+_qG$<%o9 z6071-#wl-TMfp^w6ImpNuSCbJB#71QaKJ0YL%t}c>NYW5ZvV_gCitT)Q^hcqS}W~g zpP!Z?Is1SkkCiU(a$Vw>Q`!6h7S|eFAP7uEX2ey8;Jd--f*r;qx~CuTyPw#2XJ%oO iPq*?qXfgIHEU<-bW;S*z*Dm(>HnRwA956nt^!6XK%t9jo diff --git a/oops/A$C.class b/oops/A$C.class deleted file mode 100644 index 781219e991ff43803cf67531ab275a4abead0d75..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 344 zcmYLEJx{|h5PjE#q=Z0A%g4&V01RYg09C3YA&{an6m@rkRa~Vuie3H}6A}YIfFFf= zaf=x2yZ7$h-MgRPuWtZ1IE~REbd7nl+4ww<5fb_f@h-Aj=y~>3E@b5hp%zO?7!?1d zscV#;-x8ubrIi~If{V);OLOxg69m{x5u;1!6-vv=YFWzWS(LROV=7V4M59`~B}4bB zEFmfWyzuB`YF14p?^W9sjj!A7g!EBs+2pmbR@xXxT-x*yDCc7)(z*v@9nQd}_)Oxr zgJ_$vDQ0#VWgLC&>J!Na6CI@dN1lwa&w08L-~c^F0s3BbhylmMw-0g515Z3ZTmwLZ BKJ5Si diff --git a/oops/A.class b/oops/A.class deleted file mode 100644 index 9c7b12c55b2b8439303cbb7a4cd57ee351820ef4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 339 zcmYLE%SyvQ6g@XhGBJ&|#`@R_F4Totx=@5RAPBK8lQx*YDE@1M^v0OvRm@CaekyxMFk;1kA6`6jbkny2ipT&k+$@ufDpyCMvZPZk6} zZyr^Q0X7l@2nnM?8#Q0Ol&XD@WvvKl(NwZt$W}Z57y8|^wuGoyZ@VDG_sy!U)U|e< zaC+ue6OtQaRGZh*T4e=NuB;nJGXl*7cK?%{6MnwtN)&$bvnj4)n+a diff --git a/oops/MYStaticKeyword.class b/oops/MYStaticKeyword.class deleted file mode 100644 index 6522dab41eb710290f7cce490456309c9a1d8479..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 966 zcmZuwT~8BH5Iwh)?si$Bv{1iLi&kjCQo(PFn6`N;M(`nEfey->j1?77NQ;g-Nesk|$YZ2EgLjWnhVSQk>-hoevqZP>WP zVE=&G^R0+c`PFxU^1^l)NM~3xF(Y6puh4b<-si%)g<0ebWCe0#!fni9UclJb46aAg zQp_6ZB&G8Dweqfs%jZcq1ZG;wlRF2)t_1p{|E$QUR#bfIM%C6o#FW!Q9` z5sT$Y<#S{aShG;Xs@8N*V5$_Wsk2uDYiEQ_3l%JwSZ9p#MruzMVtGj?=xgFJBH4o9 z9n?wkk2FRa9N{TaZ0JTA)jWqaiCJy`An3_gN>6m|zcpIZA5g%4?RheYnvj$r$Say0 z1^0rB2)<2BB1PYz_Y8>$o&5nbJAH(Vwt3p`gcG>J_jHt)Vp=E88ci z5UuWLW%n;A%d-)!&!nzAvLw!7i7Ttit;Cerzyo?F%RR&+7R+qTQL6uc8kBH diff --git a/oops/Mor.class b/oops/Mor.class deleted file mode 100644 index e96459c2722535b0ee41d95986d822a037412f4a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 593 zcmZvY%T7Wu5QhJ9I~Nav;1zG+3SD@XEHG{~uFx1UxHJVCs5zXHQb>3#U1;LM2k@bc zQ}MPqX)@F4Ouv6--alU705ovmAjRM+HJ*f*N;}9f1Ygk|H@%^lFyu~TEX^rHx_;PU z$egLZ@R5cWAd4JBp(SH+H63+@zUAFWFqB%V$D9BReUU6C@A;< zK9qQp3L=&;$^0kh|IV2+pI>hu01mNhBE?WvY8*ArA6qJjbU5*~3QZUcr2)U^jUf;E zjmz#p_?jVmBm=3B8PfH=4ujEBJz*ma%RvTN3vdRi=K@N7ELTLRA$&5RI$Whj$_g=Ab5RBPx>ab z4EoKu*PwU#TJ^STpbL^R}9H#*~6DOAhgUr8nHHRYb1=9Ib8 zYcatHyAfhc8D^zo_e>tEBg&yv#O^xp-v#w637DaDQK8^fQ& z&ii$73>rzN_s@e*2m}}tF0n&D^%8dw5~Ey931{RagQlLdH_Ts$k_Dkpb|1D!7!BOR NJ`PAR91=P>`UdU|N1p%y diff --git a/oops/RepairShop.class b/oops/RepairShop.class deleted file mode 100644 index 2f6df4fecb7df7bf17ceda72fd0704ea69a29e25..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 905 zcma))U2hUW6o%gc+Wjak6k2Tkq-u3(YuC^80^^N|SD;1=#&|W*2}}dKWOuRgXX%A) zY~l~_M;YJQCBYgl%p~)1&Y9=D=gj>2{o^NqBRsQ^6DWn@B=+B_iPTYN7)~q{1j;A! zv-C$Y82E2`C#s(aEI-$QPF@J)y+&7{@G?ABF7j}SSi&+nEgh)W({WEl?`3bK1S+kt zFGpP&X>*<#3&~K&0_&}R(l(hPN=4A=W!?`m=?_)hY;+y0qiUgYNm=JhoTzaT8`z|( za7vMztyH)U{kM@0l1>sSId0mxLg=ZX)pcCY(x_t>+qh=osz7zYts<`DhJZCOpiw}! zm%-DnkgS6Nl?midSz@eKD{ z7x1|5wfE1le{hZmb7eJF50+xHkTS;xf9Dn|smgi=VOJh9#-`^H9y3LmWt*g?+$Z$p G@bnKZx2o6x diff --git a/oops/Sonata.class b/oops/Sonata.class deleted file mode 100644 index b85e4f94f30953a84a5215d80ecab8be2957987e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 580 zcmZvY%TB^T6o&ud)(b^$;{5`y(1l&Hz_`)4YK*Z4*8?;-rgTUn{=&OdT|_N%C^87+T)4ETnrEi%9t@4*0ZhVvC`k?$8!V zdz?aT>|oEpE<-b8%E3Mk=mj$k3L|27Q+TSaC_U-xm5cXs!9x?rwCq|V)=382m-BcO z+z7pSIW3=SHFQ9arjG_$f}lj!pvWc9$QRE(V7}5N2b-)e>((+^Cv6~Kp@?B)HQb|a o-Dka_+GxFFdkwIu1X3{RtRdD4a+nP{%7EBQL>8n?5;=5!0g5GR2LJ#7 diff --git a/oops/StaticKeyword.class b/oops/StaticKeyword.class deleted file mode 100644 index 1267bdc46f1c7d61d51340b99352e3148dbe1a9a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 978 zcmZuv=}r?-6#gz0W;zT|yMVYL?kyF@eWADjY9uy7QqzR^>$bhtA+t2oDTb%;Su{$G zBtC!-W&CD_gw*!WJ@@S2Ip_QH_t$R#kMK&vm_XL|J6)?5%Fu4URfnJbprs)tklB|9 z(sHENwsso(su>DQuG^j+J`)%(mg)kjEx)ARoheVdTv7n?`6YLEME1S z(y7b9j`R~_D*R-31@hJ5&J|X5rR@pK6+cu@5!AxK_S%(FUBelHsW@?01zq1WkU?5U zo{1Z-^wL!4Ow8jf4W4vk3`2FIsB;nKk5wZm?xToadZg^_-b zODH6;Y~R`?rjW>#bSnm~;f99m0=c-`pxeYv6a}bTGKEOGM4_Ru659`n4i(@|ba zU}Y4#p?W8{IC=?dCMsAL&_h2t70+870YL}ZGxf%I{hI99$|DU@GH6reMw~lZd1GH- zI$=t3a8ksm`Msd2UfVIn2B^ClZI9<-Dme~}@keg*)u>sNf^uTH5B+QGHuy$vFky6|wzP$~r8W1P3lBv?suWSARF*29HqMf4<=B?v6!BRg zlprec0elo<){ZD4dD-#o?woV>%=p*uA3p&+!z&#H1}lo1&3Wn(Z-YZ=#kkF$2TGEan*I>oOGY`rW2Tj(IZ>42$*1=Yhu) zsq)dLmUd*1p;Z5u(h8cv`XbPY8O7P{A&OtJW0O{O44Ak?tCe4%c$qQ-CCt-~D(27#4%j+J`D93w`4yFOte)(A z!?o|YHN@6pZGi0o_6B%(0ba_Klu#s~O)O+2)f|X^p63Kur1^M(mqf$hQeMFR9}e-t AF8}}l diff --git a/oops/Watches.class b/oops/Watches.class deleted file mode 100644 index c151fa5ef94488bf9dfe4bd4a5f9f29ce9a3963a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 290 zcmYk1Jx;?w5QX13{sCj+kQ>ke1uj#7(tuJ~AOQ;X+N|ug9B*WAB5^D#B#In>Lq(Yp zDQMoevu|ei&F}ta2VjP21dotdyB@N4<;q$Q5q!d=QCpR@s;jc+qS2)zg!iU1ZcZ3o zT`vj#gZGacPRp|ar6|E*rb6cu*sd^*z@zQs-83^P2|DSh+=+RWh zsg@AD*iT{nYBznU7e?Mnj_GbCn12b5!3%(u2N1GGTxCpR1~=b0`Qn3zm{n|PJ!4J& T8kpyhO~>pCQz3g3Ru2~kzCAZK diff --git a/oops/transport.class b/oops/transport.class deleted file mode 100644 index c6e4891a5fa78cf839f1f2b1610a68b833b81f2b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 304 zcmY+9y-ve06ot=C(uM?+hMxyugbrk6pkhHnLW*DjWp{!_T$#9XTzD>qsuBYaz(XN! zLKg;G_ndo=@8|EI&o2O%IEfJuGHX|T;hpUIm32NwM97!&O%_IWFU3Q>RE;N0-&>_j zPoO&%3*BjdO$g7N!CUYj!N4|Q%R=> zy)z@Wa&BBcwEkdOjY3d)AnBv`@0u_MPp>b^hH z1?n0WMPk7R@D=<6I|P(7P7$h97IPmn=iYPf%zXX*`3ryt=vc@J)@CYA{Un+{+7IJ+ zHuv_H`F#tfpfXYKlozUK?7bLH{81_>>;zGe?h1@ndmu0$$FF?{28u57CQ0{w{k@RS*eQTd#WmboA3Ch{oOapooj8 zS*V^-+25b1{?x@K)TuCDP;h-&9K_xpD^u3{YTC7NSs)z;SFmAWT~Ny?&Z1m2&=lln zx{#e(=jqTbuDQ6bhqp3hNYSQB#+Il9B%; z(AQV``y%(WLTrMA@d1GxBVIYJ#mu7@`h4dT><`(oL#vMg6BlURC4j!ftcVqqxuc8U zvzbYMw^G1-ra25~jxE@ zDv_a1-z38gBJS{|G=FEw!4bBy+BQ$OsUVMAxXCC-Y>n|YJKZLt4D%Okk)QmE&JVT~ Jw78u^`wwiFj{*Py diff --git a/patternsByloops/Pattern2.class b/patternsByloops/Pattern2.class deleted file mode 100644 index 06183700724e8f64113cb2aa101e658c0f1d9256..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 709 zcmZ`%!EVz)5Pjn~vEw>TNoXle3T-Kn7zs;UIHdFd5)x8?N zs8Y{xC=v%gfUn>mxFI0CO^Q&Za@d)j-I@2^%8KZ^FH|oI1eJEuS5a4`p^ncE&FpnJ5p1;o$KN9MNQJRrt?{z`Pe&(9!+6kYc8j=# zs)foqm7T*$7K~h6#wryiQwm;P6o-j_z{-sEff}`JToD-FmV>LPS=bO%=N#wLT-32C z$d7d;p&Azn(Gb^NZ0YW;d1ge_rb-8FuzG=ZfxP2-!WD821*J}=`fr}9@!52oPBKmV z!Q)WRuk`mx?rMeD20P;m0tR=SIjzOWrx*IX_X+lg`L#oTq<$jmAx0z9f`3siFPku$` K2f+l5Md2S2^N=6_ diff --git a/patternsByloops/Pattern3.class b/patternsByloops/Pattern3.class deleted file mode 100644 index 3ee38b0906b0dbb8c7209b378610390f867604c3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 712 zcmZ`%O>YuW6g`(27?=(P!G2h%t!-7nSQai^P`l8?#00eo4I5VvI>EtVh75yA_x&Zt zgtabe;=&)`kMK{pGb)}p)R-o9@$P;1y>sq8_rCY__vbGF9-?6(C0HM;ICi68^7zyb z!||kfw1^*AFa^b-daIhg3I@%Wy`kHW1(^dc@Zv*(QLA?a=9BQmwP7IVAdQTm(DnlN z#dOqjqhrMRzN<#9EY<|6#c4re#uwAEJK;3y zyH7nmzx>}P+1Cnj3+#+92&A~<%xNt~O?shEH$EZzA-T3`^)*OXqIDJk`aGi?mQmn| zCeN76q~9-Q4$Mb0>{iT^!x@%8qF7oz$NHHu->klye`kD-n`bGhR^HFQ=_&?vl^tYh zE&UI;TVh@ZYxG;JahqrNQA`vx7FF29PQty1UF=aq8a3kfsKP-Rcepcfmxuz)U&xC5 PVgH diff --git a/patternsByloops/Pattern4.class b/patternsByloops/Pattern4.class deleted file mode 100644 index 316241f68ebff7b0fc705bad4167178a432b3b04..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 768 zcmZ`$O>YuW6g_tsm|+Sn1^ZzE+xiJu%Z5ZFZDZQR#00eohK;KSo#0TIA;VzOeSb+~ z(zPyX;=;YI{U_ZS70(Q9Op}_I_wM&S=ic}I&zG+N9^;V#O|U#vL16ptX!oe^dBah4 ze`?nZ=z>g7y;s$~a=X>n?VjBU1c@!jb%Gs1tW<6Z^gZvuwh%)yg*Xy|xrXD~uf~J6 z?Y~j&zAeZ$ypHO(l<$Q0g;NjSIU~VJ*ZDw^T-*< zUSZih8U^+sg&SBPLvKvN3)5o9tM0QhV7;vdbrVYhS+j5xc>^ngTm*47D}@4zg7`2j zWT(<~JWQ+#v`W-!J%!uh5{#&#Px89*yPPw3%?QM2g1q2$cze8uf^;)box_)Ec(Ev} z>5cu4{oDyxnZEp;&5$kD!6EsXfJTk$=WEcaQVM0f@)_pGC~WZ!!(hP--_$gLGEFOq zS>%ycId6SoknGXVMwg zj!?;bLWxx4O8S7|H4XIKiORHkO2)Fe*vbSny>%> diff --git a/patternsByloops/Pattern5.class b/patternsByloops/Pattern5.class deleted file mode 100644 index 01175383ffcf448950116749ef20cb73f1d81f9e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 855 zcmZ`%OHUJF6g{_{>9nOlZ5hA<3X0fPp>DuLu!)cONUD_7bmOA=S|;s4J2ROMChYkm zMibV$z{G_Mm;M`F8e=^(_y`F$neRTnd+s^kz5Vj@<0k;OamzqVFzcxxuzY8D|FG}6 z-mp?Xjn@rmg6y7pr7C^pbSvBKJ*yK45?i)o2US75SZWHi2kx$wMjWXObR-0mHQTYC z9}L=-|3bCO=;_TWYYG#Ed`|)3}H^0|h}oqBvWX!8{fO zx)%c3sd%1_BrXeL<*3zC23Nu%7!jgR@tX3xd}scgCkRpl+i490<+DPb3X)!{XW88z zxeTv0^i+rA6Pw>2zkR`YBT$|FXUdDFXkb~8Zny`2$9iOkqaOdWy|wT)SOSN@WdkvK zTn|r!QH54$_3{TK-$mDHp5ZkJ7~`2aEubA|l)?linITxl*et=^PJAnyxI3@yR<#Z7 z7}bRh{TLJPkjLd{Ok))@Sf{OWgZEItW7gDp8;XAty>bUvvCJrjZCt|& zE{D3a$O!_v6vzL!v=mr35C&6Vy6L8XZjC151BeMGMiVws3@<*If(F$O@!_JuWWO zkjJKgGV+xyRk#c!f*S%NsI;x&rhg4;AQ%u{HryUhn!4l&6mfxgL5|TU-%J@<{QCl{ zEzjtFI50-Rg{jyPh_#%F+clqA{;kH(Tea_VV;ej#dkaYP*b7>fkYuW6g_Vk7#M-JV6hgc)K5U|EHr+Ew$YlHn4mVnuyOUE6C66skYOxap7LK{*>;FI-WPQF-_{?z5DU*z31F}-}gUXz5;lNy9P9YrLhb{JMbo3d#>+~ zC)W1NeqcZsm>iIl)x+wtsI z(^1b3-pHP73l!RZU%FixILbb8>ft+QBCy>4AAXCqN7C^GO7*wxe>^&2;CO>pqnp73 ziUta2Sa$X%p*_mtA{NQepOWz6EZOm`ZDxkdx8@0vX zM=OIo=IBw$KUhqs+)A&PHxBWrtnX|dBL4~Vh0+n0_7hRHau6Nsr_PnwDXNtZ(J_OL zP}|p{ihdA%Q^*M@7F%PO0Gu tZr~<4>e#?7Y8s=8s8dUzMy(NRO~x)D^&5r|zqkrBWBz1|f)J|6oxhdxnt=cS diff --git a/patternsByloops/Pattern7.class b/patternsByloops/Pattern7.class deleted file mode 100644 index 1694ff48a9ccdad52c33c4fdb3d1b6549c475f4a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 759 zcmZ`%O>YuW6g_Vk7#IhN&|)pre%LCYGVZ#dcA<$03DqVvY+OBXLLb5m86GBe-Cxp8 z-Rhzm7ybZ$gFnKxQSl7aG)?N_-8=Wbd+s^!-ud?D%U1w9cx=HCSRP5Oz0e;&Jst$X zXzU)$;~fj8K(;U6N_Qarp8K-X_qtjjv8#Ng_XJ|)N?X8u7QFUs#E^0jM?zqsseJFn zWZ3b-L)jU40=Z_;m4mhnRTN(&O?{-s0xQk`@z>dVD3vczD8Fi6>S*au`Mr9jox)Az zE#$7KY#ooaH*~OwB`ORi6udMCtH3=VQWNjVVLgdk0!DS+#%&ZWtO(?199PR6l&~rg zA4N#EDqknW#u_#(tP5l=W$sIT-g6aAJN<8gwMYy$Kmpu0VDO6@qO};g z^nyNK{eKJ)!0*}2q<0g$#V2RjD(;;j^AXux;T+2+ zvFU2*Gwz&De=v29trKHfD(che_lPEjh-MQ>+9cc9Z0O7=7HQW=vCUkKyNx7N=QOyF pG9v?zP+^Wkp?$z(P*wpC`4!_Gh&F%265YuG7=8v87S@GQXt5S*i&h1!UB8l=KzpdM4GGmI7%rX$+|Z@4OP0l?p8HE0 zlb-cZjR#Mj{007uo{fsnE^V47HIte5`+c5yXMX(s`VGJuo~Q^3%nhXHnXWzDJm@*j zU})@4>}M(zfmBz%lSWV49phE2YqmXsXw|YUZ$ltlEHwp`=gwPGLl|)#5kv*1>XvQ3 z9Q9kK`&zbora-#xv}La;UCX!6oQk(+4F%@w|HH4acVAkzK(_d%e!-*Rxt86jl$vo& zBcmdHiDlzp=$U;TGngeqXGFrYlVZy;c3J7M-jw}H4A%w3l7<_|shAhY1Q3_AbmXxh z5E=M|>{PsphlWKIR4fT3FIetKZ%@Z9+$Iaz;zgBWtyGKQ4nfO4=sg`pe_U$NyT@xP z((N!YbH!yD99r)=N>SssxVzl@0*Qtv+xt6ma5hz~;f&n2xn=otPn1 z{Df3GdxE*cuvo}{!Oaij)7-g#Iq;7I|IzrAsVBI57#inu-qHBG4;$G< diff --git a/patternsByloops/Pattern9.class b/patternsByloops/Pattern9.class deleted file mode 100644 index 3f33e35e70c53a802d28b94981bfb87a8b606f14..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 818 zcmZ`%O>YuW6g_Vk7?=(%1&g&%Em{?@cKk{j1MQ;58WO5aFl<~sa6*T|3>gNKy6!J& zOuE)ZH7;Da@)!6sx;84F8QL^W>f*io@$S9n+kfwI&cuGIK@~`K7D$M!b_BE?cuKz-)EwRA*~Fc3vdV5V+6 z*2_`9WqGeuy{2n$oia`_!rWyY^6Eq5ePo3TyYJ?FeLxZ|dhf8op;col2>h zz$`Kv(id1Z_J_XJH*f`WWay4acy5wxyXFovedb%TUy0+YfLPLT4LJ=90+|rvVw8bA z76qb%Ad!`dm+{bX0|gCB0@LR#x23;p;3jU7g>11=wOA|F;S3R-oZ1NFvZ)L1W+bvB`}Q{dV=JiET&Svh*fjzN2sbB zN0|PER62W%`Gbg9%zwf4595>EnSVL-k3;|A_=KUyxO1S4^Ev-;{5^n=Ab?*Df%!)f zCy-9)DQ-0wb`r}ZutK?p6xR8^g>)GGgk6yeN+?q*c#eCF95gSXkg;Sme<^ih`zf diff --git a/oopspolymorphism/Animal.class b/polymorphism/Animal.class similarity index 100% rename from oopspolymorphism/Animal.class rename to polymorphism/Animal.class diff --git a/polymorphism/Animal.java b/polymorphism/Animal.java new file mode 100644 index 0000000..faa7eb0 --- /dev/null +++ b/polymorphism/Animal.java @@ -0,0 +1,7 @@ +package polymorphism; + +public class Animal { + public void walk() { + System.out.println("Animal is walking"); + } +} diff --git a/oopspolymorphism/Dog.class b/polymorphism/Dog.class similarity index 100% rename from oopspolymorphism/Dog.class rename to polymorphism/Dog.class diff --git a/polymorphism/Dog.java b/polymorphism/Dog.java new file mode 100644 index 0000000..0037a45 --- /dev/null +++ b/polymorphism/Dog.java @@ -0,0 +1,7 @@ +package polymorphism; + +public class Dog extends Pet{ + public void walk() { + System.out.println("dog is walking"); + } +} diff --git a/polymorphism/Main.java b/polymorphism/Main.java new file mode 100644 index 0000000..dcd322d --- /dev/null +++ b/polymorphism/Main.java @@ -0,0 +1,25 @@ +package polymorphism; + +public class Main { + + public static void greetings() { + System.out.println("Hi, there"); + } + public static void greetings(String s) { + System.out.println(s); + } + public static void greetings(String s, int count) { + for(int i = 0; i < count; i++) + System.out.println(s); + } + public static void main(String[] args) { + greetings("Good Mornig"); + Dog d = new Dog(); + Pet p = d; + @SuppressWarnings("unused") + Animal a = d; + d.walk(); + p.walk(); + } + +} diff --git a/oopspolymorphism/MainClass.class b/polymorphism/MainClass.class similarity index 100% rename from oopspolymorphism/MainClass.class rename to polymorphism/MainClass.class diff --git a/oopspolymorphism/Pet.class b/polymorphism/Pet.class similarity index 100% rename from oopspolymorphism/Pet.class rename to polymorphism/Pet.class diff --git a/polymorphism/Pet.java b/polymorphism/Pet.java new file mode 100644 index 0000000..7e00f0a --- /dev/null +++ b/polymorphism/Pet.java @@ -0,0 +1,7 @@ +package polymorphism; + +public class Pet extends Animal { + public void walk() { + System.out.println("pet is walking"); + } +} diff --git a/searchingAlgorithms/BinarySearch.java b/searchingAlgorithms/BinarySearch.java index 3eda77a..9b5be7a 100644 --- a/searchingAlgorithms/BinarySearch.java +++ b/searchingAlgorithms/BinarySearch.java @@ -3,7 +3,7 @@ //Binary Search Algorithm public class BinarySearch { - // Returns index of x if it is present in arr[l.. + // Returns index of x if it is present in a[l.. // r], else return -1 int binarySearch(int arr[], int l, int r, int x) { @@ -16,7 +16,7 @@ int binarySearch(int arr[], int l, int r, int x) return mid; // If element is smaller than mid, then - // it can only be present in left subarray + // it can only be present in left sub array if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x); diff --git a/searchingAlgorithms/LinearSearch.java b/searchingAlgorithms/LinearSearch.java new file mode 100644 index 0000000..cc3d60a --- /dev/null +++ b/searchingAlgorithms/LinearSearch.java @@ -0,0 +1,23 @@ +package searchingAlgorithms; + +public class LinearSearch { + + public static int search(int[] a, int x) { + int n = a.length; + for(int i = 0; i < n; i++) { + if(a[i] == x) return i; + } + return -1; + } + public static void main(String[] args) { + int arr[] = { 2, 3, 4, 10, 40, 50, 90, 130, 230, 740}; + int x = 10; + int result = search(arr, x); + if (result == -1) + System.out.println("Element not present"); + else + System.out.println("Element found at index " + result); + + } + +} From b612e9652f7fe25355fb3f7de928a07bad7ea38a Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Sun, 16 May 2021 16:01:52 +0530 Subject: [PATCH 38/56] #Modification 33 --- .vs/ProjectSettings.json | 3 + .vs/VSWorkspaceState.json | 8 + .vs/slnx.sqlite | Bin 0 -> 196608 bytes .vs/src/v16/.suo | Bin 0 -> 15360 bytes .vscode/settings.json | 5 + README.md | 8 + abstraction/Audi.class | Bin 0 -> 616 bytes abstraction/Audi.java | 14 ++ abstraction/Car.class | Bin 0 -> 309 bytes abstraction/Car.java | 6 + abstraction/RepairShop.class | Bin 0 -> 1026 bytes abstraction/RepairShop.java | 20 +++ abstraction/WagonR.class | Bin 0 -> 752 bytes abstraction/WagonR.java | 14 ++ arrays/ArrayLevel1.class | Bin 0 -> 922 bytes arrays/ArrayLevel2.class | Bin 0 -> 1545 bytes arrays/Array_Problem_1.class | Bin 0 -> 1320 bytes arrays/Array_Problem_1.java | 53 +++--- arrays/Array_Problem_10.class | Bin 0 -> 1182 bytes arrays/Array_Problem_11.class | Bin 0 -> 1239 bytes arrays/Array_Problem_12.class | Bin 0 -> 1229 bytes arrays/Array_Problem_16.java | 4 + arrays/Array_Problem_17.java | 35 +--- arrays/Array_Problem_18.class | Bin 0 -> 1249 bytes arrays/Array_Problem_19.java | 40 ++++- arrays/Array_Problem_2$Pair.class | Bin 0 -> 411 bytes arrays/Array_Problem_2.class | Bin 0 -> 1418 bytes arrays/Array_Problem_2.java | 4 +- arrays/Array_Problem_20.java | 54 +++++- arrays/Array_Problem_21.java | 45 ++++- arrays/Array_Problem_22.java | 47 +++++- arrays/Array_Problem_23.class | Bin 0 -> 1311 bytes arrays/Array_Problem_24.java | 38 ++++- arrays/Array_Problem_25.java | 93 ++++++++++- arrays/Array_Problem_26.java | 40 ++++- arrays/Array_Problem_27.java | 26 ++- arrays/Array_Problem_28.java | 3 +- arrays/Array_Problem_29.java | 24 ++- arrays/Array_Problem_3.class | Bin 0 -> 2027 bytes arrays/Array_Problem_32.class | Bin 0 -> 1141 bytes arrays/Array_Problem_4_Approach1.class | Bin 0 -> 1530 bytes arrays/Array_Problem_4_Approach1.java | 1 + arrays/Array_Problem_4_Approach2.class | Bin 0 -> 1276 bytes arrays/Array_Problem_5.class | Bin 0 -> 1314 bytes arrays/Array_Problem_6.class | Bin 0 -> 2149 bytes arrays/Array_Problem_7.class | Bin 0 -> 1478 bytes arrays/Array_Problem_8.class | Bin 0 -> 1100 bytes arrays/Array_Problem_9.class | Bin 0 -> 1416 bytes arrays/Array_of_objects.class | Bin 0 -> 1546 bytes arrays/Candy_Distribution_Problem.class | Bin 0 -> 1001 bytes arrays/Cricketer.class | Bin 0 -> 427 bytes arrays/KadanesAlgorithm.class | Bin 0 -> 1042 bytes arrays/MultiDArray.class | Bin 0 -> 1018 bytes backtracking/N_Queen.class | Bin 0 -> 1900 bytes backtracking/N_Queen.java | 86 ++++++++++ backtracking/Rat_In_A_Maze.class | Bin 0 -> 1911 bytes backtracking/Sudoku_Solver.class | Bin 0 -> 2183 bytes backtracking/Sudoku_Solver.java | 72 ++++++++ backtracking/Word_Break_PUB.java | 41 +++++ basicProblems/Armstrong_Number.class | Bin 0 -> 1055 bytes basicProblems/Factorial.class | Bin 1124 -> 1096 bytes basicProblems/Fibonacci_Series.class | Bin 0 -> 1344 bytes .../Multiplicative_Table_till_20.class | Bin 0 -> 1264 bytes basicProblems/Palindrome_Number.class | Bin 0 -> 422 bytes basicProblems/Prime_Number_Or_Not.class | Bin 0 -> 1090 bytes ...ve_decimal_number_from_right_to_left.class | Bin 0 -> 965 bytes basicProblems/Reverse_Given_number.class | Bin 0 -> 888 bytes basicProblems/Series_Sum_1.class | Bin 0 -> 862 bytes basicProblems/Series_Sum_2.class | Bin 0 -> 895 bytes basicProblems/Swap_two_numbers.class | Bin 0 -> 1142 bytes basicProblems/Swapping_2.class | Bin 0 -> 979 bytes basicProblems/X_raisedTo_power_Y.class | Bin 0 -> 896 bytes basic_idea_of_DS/ArrayDequeDemo.class | Bin 0 -> 1292 bytes basic_idea_of_DS/ArrayListDemo.class | Bin 0 -> 1352 bytes basic_idea_of_DS/Graph.class | Bin 0 -> 1775 bytes basic_idea_of_DS/HashMapIntro.class | Bin 0 -> 1521 bytes basic_idea_of_DS/LinkedListDemo.class | Bin 0 -> 1826 bytes basic_idea_of_DS/List.class | Bin 0 -> 841 bytes basic_idea_of_DS/MYStackByList.class | Bin 0 -> 1005 bytes basic_idea_of_DS/MyArrayList.class | Bin 0 -> 1346 bytes basic_idea_of_DS/MyHashMap.class | Bin 0 -> 1512 bytes basic_idea_of_DS/MyHashSet.class | Bin 0 -> 859 bytes basic_idea_of_DS/MyLinkedList.class | Bin 0 -> 1820 bytes basic_idea_of_DS/MyQueue.class | Bin 0 -> 1167 bytes basic_idea_of_DS/Node.class | Bin 0 -> 401 bytes basic_idea_of_DS/Queue.class | Bin 0 -> 1662 bytes basic_idea_of_DS/SetExample.class | Bin 0 -> 1553 bytes basic_idea_of_DS/Stack$MyStack.class | Bin 0 -> 1110 bytes basic_idea_of_DS/Stack.class | Bin 0 -> 1456 bytes .../StackUsingLinkedlist$Node.class | Bin 0 -> 575 bytes basic_idea_of_DS/StackUsingLinkedlist.class | Bin 0 -> 1659 bytes basic_idea_of_DS/Tree.class | Bin 0 -> 808 bytes basics/ControlStatements.class | Bin 0 -> 773 bytes basics/DoWhileLoop.class | Bin 0 -> 764 bytes basics/Fast_Inputs_Main$InputReader.class | Bin 0 -> 1366 bytes basics/Fast_Inputs_Main.class | Bin 0 -> 1066 bytes basics/Operators.class | Bin 0 -> 1078 bytes basics/VariablesandDataTypes.class | Bin 0 -> 1034 bytes basics/WhileLoop.class | Bin 0 -> 761 bytes binaryTree/BT_Problem_06_a.java | 2 +- binaryTree/BT_Problem_06_b.java | 110 ++++-------- binaryTree/BT_Problem_07_a.java | 55 ++++++ binaryTree/BT_Problem_07_b.java | 52 ++++++ binaryTree/BT_Problem_08_a.java | 90 ++++++++++ binaryTree/BT_Problem_08_b.java | 47 ++++++ binaryTree/BT_Problem_10.java | 35 +++- binaryTree/BT_Problem_15.java | 2 +- binaryTree/BT_Problem_17.java | 91 ++++++---- binaryTree/BT_Problem_18.java | 5 +- binaryTree/BT_Problem_19.java | 4 +- binaryTree/BT_Problem_20.java | 5 + binaryTree/BT_Problem_21.java | 5 + binaryTree/BT_Problem_22.java | 5 + binaryTree/BT_Problem_23.java | 5 + binaryTree/BT_Problem_24.java | 5 + binaryTree/BT_Problem_25.java | 5 + binaryTree/BT_Problem_26.java | 5 + binaryTree/BT_Problem_27.java | 5 + binaryTree/BT_Problem_28.java | 5 + binaryTree/BT_Problem_29.java | 5 + binaryTree/BT_Problem_30.java | 5 + binaryTree/BT_Problem_32.java | 5 + binaryTree/BT_Problem_33.java | 5 + binaryTree/BT_Problem_34.java | 5 + .../Deletion_of_a_node_in_bst.java | 117 +++++++++++++ binary_search_tree/Find_a_value_in_bst.java | 66 ++++++++ bitManipulation/BM_02.java | 48 ++---- bitManipulation/BM_03.java | 12 +- bitManipulation/BM_04.java | 28 +++- bitManipulation/BM_05.java | 20 ++- bitManipulation/BM_06.java | 6 +- bitManipulation/BM_07.java | 4 +- bitManipulation/BM_08.java | 4 +- bitManipulation/BM_09.java | 4 +- bitManipulation/BM_10.java | 21 ++- dp/Coin_change_problem.java | 19 +++ dp/DP_Problem_01.java | 46 +++++ dp/DP_Problem_02.java | 33 ++++ dp/DP_Problem_03.java | 24 +++ dp/DP_Problem_04.java | 9 + dp/definition.txt | 5 + encapsulation/EncapIntro.class | Bin 0 -> 805 bytes encapsulation/EncapIntro.java | 14 ++ encapsulation/S.class | Bin 0 -> 886 bytes encapsulation/S.java | 29 ++++ exercise_and_practice_Problems/Cylinder.class | Bin 0 -> 1504 bytes .../Exercise1.class | Bin 0 -> 1747 bytes .../Exercise2.class | Bin 0 -> 1355 bytes .../Getters_Setters_For_Cylinder.class | Bin 0 -> 1210 bytes graphs/Graph.class | Bin 0 -> 1755 bytes graphs/Graph.java | 42 +++++ graphs/Graph_Traversal_DFS.class | Bin 0 -> 2133 bytes graphs/Graph_Traversal_DFS.java | 57 +++++++ inheritance/MainClass.class | Bin 0 -> 782 bytes inheritance/MainClass.java | 20 +++ inheritance/Person.class | Bin 0 -> 907 bytes inheritance/Person.java | 12 ++ inheritance/Singer.class | Bin 0 -> 795 bytes inheritance/Singer.java | 8 + inheritance/Teacher.class | Bin 0 -> 800 bytes inheritance/Teacher.java | 7 + ...java_5317e4db975f6452a2d44820a699b094.prob | 1 + linkedList/Problem_1_1.java | 1 + linkedList/Reverse_a_LL.java | 57 +++++++ list/Insertion_in_Linked_List$Node.class | Bin 0 -> 603 bytes list/Insertion_in_Linked_List.class | Bin 0 -> 2038 bytes list/LinkedList$Node.class | Bin 0 -> 536 bytes list/LinkedList.class | Bin 0 -> 1834 bytes list/MainList.class | Bin 0 -> 534 bytes list/Multiply_2_no_rep_by_ll.java | 67 ++++++++ list/MyLL$Node.class | Bin 0 -> 422 bytes list/MyLL.class | Bin 0 -> 1471 bytes list/Node.class | Bin 0 -> 530 bytes list/Problem_1_1$Node.class | Bin 0 -> 454 bytes list/Problem_1_1.class | Bin 0 -> 1658 bytes list/Problem_1_1.java | 63 +++++++ list/Problem_1_2$Node.class | Bin 0 -> 454 bytes list/Problem_1_2.class | Bin 0 -> 1603 bytes list/Problem_1_2.java | 68 ++++++++ list/Queue.class | Bin 0 -> 1649 bytes list/Queue.java | 157 ++++++++++++++++++ list/QueueEmptyException.class | Bin 0 -> 1489 bytes matrix/Matrix_Problem_01.class | Bin 0 -> 1520 bytes matrix/Matrix_Problem_02.class | Bin 0 -> 2144 bytes polymorphism/Animal.class | Bin 0 -> 277 bytes polymorphism/Animal.java | 7 + polymorphism/Dog.class | Bin 0 -> 499 bytes polymorphism/Dog.java | 7 + polymorphism/Main.java | 25 +++ polymorphism/MainClass.class | Bin 0 -> 1148 bytes polymorphism/Pet.class | Bin 0 -> 502 bytes polymorphism/Pet.java | 7 + practiceProblems/Cylinder.class | Bin 0 -> 1448 bytes practiceProblems/Exercise1.class | Bin 0 -> 1719 bytes practiceProblems/Exercise2.class | Bin 0 -> 1327 bytes .../Getters_Setters_For_Cylinder.class | Bin 0 -> 1182 bytes recursion/Factorial.class | Bin 0 -> 1198 bytes recursion/Factorial_using_Recursion.class | Bin 0 -> 1246 bytes recursion/NRaiseP.class | Bin 0 -> 668 bytes recursion/NaturalNoSum.class | Bin 0 -> 659 bytes recursion/Problem_01.class | Bin 0 -> 653 bytes recursion/Subsequences.class | Bin 0 -> 1374 bytes recursion/Tower_Of_Hanoi.class | Bin 0 -> 1180 bytes searchingAlgorithms/BinarySearch.class | Bin 0 -> 1302 bytes searchingAlgorithms/BinarySearch.java | 4 +- searchingAlgorithms/LinearSearch.class | Bin 0 -> 1162 bytes searchingAlgorithms/LinearSearch.java | 37 ++--- searchingAlgorithms/package-info.class | Bin 0 -> 125 bytes sortingAlgorithms/BubbleSort.class | Bin 0 -> 1439 bytes sortingAlgorithms/HeapSort.class | Bin 0 -> 1974 bytes sortingAlgorithms/InsertionSort.class | Bin 0 -> 1372 bytes sortingAlgorithms/MergeSort.class | Bin 0 -> 2009 bytes sortingAlgorithms/QuickSort.class | Bin 0 -> 1701 bytes sortingAlgorithms/RadixSort.class | Bin 0 -> 1856 bytes sortingAlgorithms/RadixSort.java | 1 - sortingAlgorithms/SelectionSort.class | Bin 0 -> 1465 bytes ...java_cfba17b398252ca38e082cac809277ad.prob | 1 + stack/Infix_To_Postfix.class | Bin 0 -> 2365 bytes stack/Infix_To_Postfix.java | 76 +++++++++ stack/MYStackByList.class | Bin 0 -> 961 bytes stack/Parenthesis_Checker_Problem.class | Bin 0 -> 1870 bytes stack/Postfix.class | Bin 0 -> 2335 bytes stack/Postfix.java | 77 +++++++++ stack/StackUsingLinkedlist$Node.class | Bin 0 -> 520 bytes stack/StackUsingLinkedlist.class | Bin 0 -> 1604 bytes stack/Tower_Of_Hanoi.class | Bin 0 -> 1172 bytes ...java_4cd5b7badd85dac4f4b1d9cce25274ef.prob | 1 + stack_and_queue/Stack_Queue_Problem_03.class | Bin 0 -> 1836 bytes trie/Trie_Problem_01.java | 35 ++++ 229 files changed, 2420 insertions(+), 274 deletions(-) create mode 100644 .vs/ProjectSettings.json create mode 100644 .vs/VSWorkspaceState.json create mode 100644 .vs/slnx.sqlite create mode 100644 .vs/src/v16/.suo create mode 100644 .vscode/settings.json create mode 100644 README.md create mode 100644 abstraction/Audi.class create mode 100644 abstraction/Audi.java create mode 100644 abstraction/Car.class create mode 100644 abstraction/Car.java create mode 100644 abstraction/RepairShop.class create mode 100644 abstraction/RepairShop.java create mode 100644 abstraction/WagonR.class create mode 100644 abstraction/WagonR.java create mode 100644 arrays/ArrayLevel1.class create mode 100644 arrays/ArrayLevel2.class create mode 100644 arrays/Array_Problem_1.class create mode 100644 arrays/Array_Problem_10.class create mode 100644 arrays/Array_Problem_11.class create mode 100644 arrays/Array_Problem_12.class create mode 100644 arrays/Array_Problem_16.java create mode 100644 arrays/Array_Problem_18.class create mode 100644 arrays/Array_Problem_2$Pair.class create mode 100644 arrays/Array_Problem_2.class create mode 100644 arrays/Array_Problem_23.class create mode 100644 arrays/Array_Problem_3.class create mode 100644 arrays/Array_Problem_32.class create mode 100644 arrays/Array_Problem_4_Approach1.class create mode 100644 arrays/Array_Problem_4_Approach2.class create mode 100644 arrays/Array_Problem_5.class create mode 100644 arrays/Array_Problem_6.class create mode 100644 arrays/Array_Problem_7.class create mode 100644 arrays/Array_Problem_8.class create mode 100644 arrays/Array_Problem_9.class create mode 100644 arrays/Array_of_objects.class create mode 100644 arrays/Candy_Distribution_Problem.class create mode 100644 arrays/Cricketer.class create mode 100644 arrays/KadanesAlgorithm.class create mode 100644 arrays/MultiDArray.class create mode 100644 backtracking/N_Queen.class create mode 100644 backtracking/N_Queen.java create mode 100644 backtracking/Rat_In_A_Maze.class create mode 100644 backtracking/Sudoku_Solver.class create mode 100644 backtracking/Sudoku_Solver.java create mode 100644 backtracking/Word_Break_PUB.java create mode 100644 basicProblems/Armstrong_Number.class create mode 100644 basicProblems/Fibonacci_Series.class create mode 100644 basicProblems/Multiplicative_Table_till_20.class create mode 100644 basicProblems/Palindrome_Number.class create mode 100644 basicProblems/Prime_Number_Or_Not.class create mode 100644 basicProblems/Print_all_digits_of_positive_decimal_number_from_right_to_left.class create mode 100644 basicProblems/Reverse_Given_number.class create mode 100644 basicProblems/Series_Sum_1.class create mode 100644 basicProblems/Series_Sum_2.class create mode 100644 basicProblems/Swap_two_numbers.class create mode 100644 basicProblems/Swapping_2.class create mode 100644 basicProblems/X_raisedTo_power_Y.class create mode 100644 basic_idea_of_DS/ArrayDequeDemo.class create mode 100644 basic_idea_of_DS/ArrayListDemo.class create mode 100644 basic_idea_of_DS/Graph.class create mode 100644 basic_idea_of_DS/HashMapIntro.class create mode 100644 basic_idea_of_DS/LinkedListDemo.class create mode 100644 basic_idea_of_DS/List.class create mode 100644 basic_idea_of_DS/MYStackByList.class create mode 100644 basic_idea_of_DS/MyArrayList.class create mode 100644 basic_idea_of_DS/MyHashMap.class create mode 100644 basic_idea_of_DS/MyHashSet.class create mode 100644 basic_idea_of_DS/MyLinkedList.class create mode 100644 basic_idea_of_DS/MyQueue.class create mode 100644 basic_idea_of_DS/Node.class create mode 100644 basic_idea_of_DS/Queue.class create mode 100644 basic_idea_of_DS/SetExample.class create mode 100644 basic_idea_of_DS/Stack$MyStack.class create mode 100644 basic_idea_of_DS/Stack.class create mode 100644 basic_idea_of_DS/StackUsingLinkedlist$Node.class create mode 100644 basic_idea_of_DS/StackUsingLinkedlist.class create mode 100644 basic_idea_of_DS/Tree.class create mode 100644 basics/ControlStatements.class create mode 100644 basics/DoWhileLoop.class create mode 100644 basics/Fast_Inputs_Main$InputReader.class create mode 100644 basics/Fast_Inputs_Main.class create mode 100644 basics/Operators.class create mode 100644 basics/VariablesandDataTypes.class create mode 100644 basics/WhileLoop.class create mode 100644 binaryTree/BT_Problem_07_a.java create mode 100644 binaryTree/BT_Problem_07_b.java create mode 100644 binaryTree/BT_Problem_08_a.java create mode 100644 binaryTree/BT_Problem_08_b.java create mode 100644 binaryTree/BT_Problem_20.java create mode 100644 binaryTree/BT_Problem_21.java create mode 100644 binaryTree/BT_Problem_22.java create mode 100644 binaryTree/BT_Problem_23.java create mode 100644 binaryTree/BT_Problem_24.java create mode 100644 binaryTree/BT_Problem_25.java create mode 100644 binaryTree/BT_Problem_26.java create mode 100644 binaryTree/BT_Problem_27.java create mode 100644 binaryTree/BT_Problem_28.java create mode 100644 binaryTree/BT_Problem_29.java create mode 100644 binaryTree/BT_Problem_30.java create mode 100644 binaryTree/BT_Problem_32.java create mode 100644 binaryTree/BT_Problem_33.java create mode 100644 binaryTree/BT_Problem_34.java create mode 100644 binary_search_tree/Deletion_of_a_node_in_bst.java create mode 100644 binary_search_tree/Find_a_value_in_bst.java create mode 100644 dp/Coin_change_problem.java create mode 100644 dp/DP_Problem_01.java create mode 100644 dp/DP_Problem_02.java create mode 100644 dp/DP_Problem_03.java create mode 100644 dp/DP_Problem_04.java create mode 100644 dp/definition.txt create mode 100644 encapsulation/EncapIntro.class create mode 100644 encapsulation/EncapIntro.java create mode 100644 encapsulation/S.class create mode 100644 encapsulation/S.java create mode 100644 exercise_and_practice_Problems/Cylinder.class create mode 100644 exercise_and_practice_Problems/Exercise1.class create mode 100644 exercise_and_practice_Problems/Exercise2.class create mode 100644 exercise_and_practice_Problems/Getters_Setters_For_Cylinder.class create mode 100644 graphs/Graph.class create mode 100644 graphs/Graph.java create mode 100644 graphs/Graph_Traversal_DFS.class create mode 100644 graphs/Graph_Traversal_DFS.java create mode 100644 inheritance/MainClass.class create mode 100644 inheritance/MainClass.java create mode 100644 inheritance/Person.class create mode 100644 inheritance/Person.java create mode 100644 inheritance/Singer.class create mode 100644 inheritance/Singer.java create mode 100644 inheritance/Teacher.class create mode 100644 inheritance/Teacher.java create mode 100644 linkedList/.cph/.Reverse_a_LL.java_5317e4db975f6452a2d44820a699b094.prob create mode 100644 linkedList/Reverse_a_LL.java create mode 100644 list/Insertion_in_Linked_List$Node.class create mode 100644 list/Insertion_in_Linked_List.class create mode 100644 list/LinkedList$Node.class create mode 100644 list/LinkedList.class create mode 100644 list/MainList.class create mode 100644 list/Multiply_2_no_rep_by_ll.java create mode 100644 list/MyLL$Node.class create mode 100644 list/MyLL.class create mode 100644 list/Node.class create mode 100644 list/Problem_1_1$Node.class create mode 100644 list/Problem_1_1.class create mode 100644 list/Problem_1_1.java create mode 100644 list/Problem_1_2$Node.class create mode 100644 list/Problem_1_2.class create mode 100644 list/Problem_1_2.java create mode 100644 list/Queue.class create mode 100644 list/Queue.java create mode 100644 list/QueueEmptyException.class create mode 100644 matrix/Matrix_Problem_01.class create mode 100644 matrix/Matrix_Problem_02.class create mode 100644 polymorphism/Animal.class create mode 100644 polymorphism/Animal.java create mode 100644 polymorphism/Dog.class create mode 100644 polymorphism/Dog.java create mode 100644 polymorphism/Main.java create mode 100644 polymorphism/MainClass.class create mode 100644 polymorphism/Pet.class create mode 100644 polymorphism/Pet.java create mode 100644 practiceProblems/Cylinder.class create mode 100644 practiceProblems/Exercise1.class create mode 100644 practiceProblems/Exercise2.class create mode 100644 practiceProblems/Getters_Setters_For_Cylinder.class create mode 100644 recursion/Factorial.class create mode 100644 recursion/Factorial_using_Recursion.class create mode 100644 recursion/NRaiseP.class create mode 100644 recursion/NaturalNoSum.class create mode 100644 recursion/Problem_01.class create mode 100644 recursion/Subsequences.class create mode 100644 recursion/Tower_Of_Hanoi.class create mode 100644 searchingAlgorithms/BinarySearch.class create mode 100644 searchingAlgorithms/LinearSearch.class create mode 100644 searchingAlgorithms/package-info.class create mode 100644 sortingAlgorithms/BubbleSort.class create mode 100644 sortingAlgorithms/HeapSort.class create mode 100644 sortingAlgorithms/InsertionSort.class create mode 100644 sortingAlgorithms/MergeSort.class create mode 100644 sortingAlgorithms/QuickSort.class create mode 100644 sortingAlgorithms/RadixSort.class create mode 100644 sortingAlgorithms/SelectionSort.class create mode 100644 stack/.cph/.Postfix.java_cfba17b398252ca38e082cac809277ad.prob create mode 100644 stack/Infix_To_Postfix.class create mode 100644 stack/Infix_To_Postfix.java create mode 100644 stack/MYStackByList.class create mode 100644 stack/Parenthesis_Checker_Problem.class create mode 100644 stack/Postfix.class create mode 100644 stack/Postfix.java create mode 100644 stack/StackUsingLinkedlist$Node.class create mode 100644 stack/StackUsingLinkedlist.class create mode 100644 stack/Tower_Of_Hanoi.class create mode 100644 stack_and_queue/.cph/.Stack_Queue_Problem_03.java_4cd5b7badd85dac4f4b1d9cce25274ef.prob create mode 100644 stack_and_queue/Stack_Queue_Problem_03.class create mode 100644 trie/Trie_Problem_01.java diff --git a/.vs/ProjectSettings.json b/.vs/ProjectSettings.json new file mode 100644 index 0000000..f8b4888 --- /dev/null +++ b/.vs/ProjectSettings.json @@ -0,0 +1,3 @@ +{ + "CurrentProjectSetting": null +} \ No newline at end of file diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json new file mode 100644 index 0000000..e91e68d --- /dev/null +++ b/.vs/VSWorkspaceState.json @@ -0,0 +1,8 @@ +{ + "ExpandedNodes": [ + "", + "\\arrays" + ], + "SelectedNode": "\\arrays\\Array_of_objects.java", + "PreviewInSolutionExplorer": false +} \ No newline at end of file diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite new file mode 100644 index 0000000000000000000000000000000000000000..eccf197ce05c6df753e79ace0958420acc55b3c3 GIT binary patch literal 196608 zcmeFa2YeGp+CM(4l~!75iv$?cjBPN*7=h((N{Dd*gE3&67BE7V)>vT6Mv?(15F$uO z2&DIfTzZFu^xpeja_OD)#eJs1i`gWVx7{TW(Y7wlB(1KxTgA-TG#wyLEzr@pbKc6rXq-xNoy zXwQMag^j85tvM4{CMVmPAIlJ}nbnZZImX#+^mQr5nUfBaxkSjrWC;tl=2S0iXuxG{ zTv%PzT$_KwOu?Gzb~7itqrSFIMPGFNwWwyMrD}FVtwG5}`$Vdj6eZRNT0y@pwR38l zauzk!FQ{r-ku$$`MNZX{mWB0=5bc86#umsG{9n@0FjDpk5T%ySR6^J`Zb6+H?bj4Mur?4t>5~2SUT{d+4eYk%%b#EHD z0Gd#BcV}-`C{<3h=f|cxteIZuS6H#O_Dm+1wCRhTdOjCL-sE6g_Tg$i-&E!pUtrT^ius} z=vS3`F+5=~x;syX+ZoA%J^*gZvDut8b3KfFeTk8;UoTXXP7T>_{Oc!fRm-DJf%L%+ z6Wd|R_A7_Fd0sSJWS?{6raCiu9*(f)rmp6pSJY*v?O;By?4JZ zqWAjOx(dy6qLu%KnaF^3kQnR8IELp_`0rns68z^z`1%OeO>55V`qXJ)gD(TUWKDp(V%P8zwzAstwc7$-7x=re`D*%O>5VS&2r2p|zw>tMhHj zn3LO6svK!XWV%lS4Ag1!7n!)sf&yj*X*rP%Fh^6o5oJTK5`tM<@+F(pZgid#L(upq zL&*Ht9LAbCawM}|A#tjCQ^AxJ$4Zs$*W^^@-`3KW`Z{}|9(ApA2|TO0>>{|FZ~)1l z$`8udh^xivaFPB?Yap$GvHbwMsOy1RjXhhr7sprEg{H@pWbkntqZG zKQ7lNHoBVWf_S7*{c~f~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7##0$bFb-!N#yFI52;*Rh z`Nkl|Qy2#_p3Ha>}ULm@khpe5*^|{jC&;-;s?e(jNdcvX8exvTgGn~cQJm= zxKpAKUon2k_yyzV5;d`daXaH@gxV3Yjqy{)Pb3}|A2WW$_#xv55`Pu%Gj3(v!nj%D zFXBDMO^oj{Ze-lRxL)GV;vL3yjB6R!FupDEka&ynO~%!Xs~A^GJSbK$E@xcE_=dy- z;&sNQjIS{+VO%V6zj&4L6~>ntUy}Hvc#-knj4w#sC!S|~j`3NEd&M)1Pctr(_=9+g z@kz!fB<>N9Gd{-nsKoEZBa90f|0Qv^c$o2@jQ^1Mop^}x?~D&h{8l``ct7LcBz`0A zW4u@5E^!az-HdlJE?~Tq@eannO8i>f&Ul-|o#Ix;TO@uZZf5)o`TrY%KWTwa1B(I8 z|26kOa}PB4Kywc?_ds(GH1|Mr4>b2ca}PB4Kywc?_ds(G{GaWC?vbmZr01vv$lW=0 z=BVi~`)xov*7_+;>!x1PJ-2P-D(u1LnPdb*mOW9#7M&e!B3H^Sq`^V7C5n1U2lxL1 D6Jc7? literal 0 HcmV?d00001 diff --git a/.vs/src/v16/.suo b/.vs/src/v16/.suo new file mode 100644 index 0000000000000000000000000000000000000000..7fb62a3b06972f8307f131e695f90c97503ee628 GIT binary patch literal 15360 zcmeHNTa4pY8FsdmQfQ%fN?Bki+Y8KQ#?C$4c3H=cCzDL>x5;$M)^Tpm%^5qF$?WVK zuOL;RN<1K1Bq}KIfP{DfAzqP+iiE`N1(4_q;t9bMYM1YK;@vcx$!2EgvTWzKKKuCi zob#XS|NrMd{`H&p|M}G)J@yx7iq124Fz;NsoB7~Gylo=P+{Z9?;+^8&xpL(SeWEae zC-i^R11Uzs)n%5LAk)TEXNEMC3)3T*1y*xuKFp(Ey#D;d+S%XPK0=8;F-n;LM~$g7 z>)>8ND9G&2E8@Cuk1(gM@~3)SmtaPOf;dcHlPvzkx5G411Dz=YY4n8*l*j1~dYoZS z*{t?2%Kr-}tTiq$&h)^g$*5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EgV=r6k8+HTJs-1kqv_Vb^ java diff --git a/abstraction/Audi.class b/abstraction/Audi.class new file mode 100644 index 0000000000000000000000000000000000000000..861fcd6be56277b70e3d21f1b2361ff8e98f6cd6 GIT binary patch literal 616 zcmZvZ%TB^T6o&tSLN9#WaUbfckgkcOQ{23dxpCqr>N9S=l&&j*2ED0`95gFcU?j{lN|dXx!6-CGyY z@*M_;`@RT7%$2ZFLfOPNL+OdXa5v!L$nDJ%CB}JFP^D3#sbZ*k^RkTGyI6**r((g! z9Se1Oq^34x(pXYuIC8LyeG_~1(hV2$IKUx;Ink^jBz$YZU&t#;k2-n-IX;;Lvxfnx zJzF@TDgVXhDQctF^rC6(iyNu;Ve9&ZmP8XYJpBxiWqN;PO^RIdjC|(&1J)}YQgF!X zGGHJ_Hos^fU!aI#Yk9d%-MY_yL$O?Y$Ic4iPzj`9(YJ!wOUTh?$nge9ju3^7kOoPl G(EJ6^ad^W3 literal 0 HcmV?d00001 diff --git a/abstraction/Audi.java b/abstraction/Audi.java new file mode 100644 index 0000000..646fd21 --- /dev/null +++ b/abstraction/Audi.java @@ -0,0 +1,14 @@ +package abstraction; + +//Audi Class +public class Audi extends Car{ + + public void accelerate() { + System.out.println("Audi is accelerating"); + } + + @Override + public void apply_break() { + System.out.println("Audi is breaking"); + } +} diff --git a/abstraction/Car.class b/abstraction/Car.class new file mode 100644 index 0000000000000000000000000000000000000000..fae234a772649c0cb0f44f01048e3eeb45f76a6e GIT binary patch literal 309 zcmZvXF-`+95JmrNHrZqoNC?US=zxMPQv}gOqFO-#N{hzE0td5Rc^xEziuLp+HWUZTW>O$IU}^t+qx-!rw5^71DCSL5!&U|Oi&&>Dh_m7_d_VL)llE8Wxj>fVxjIe>oX; zeEmjt2EIU{8FuBMEwwW1v(0pLq{adp&3`*+2-rIIb0D=q#ht@)zfo`7xP+pG!a2LG zPvgiRW>LZ#t%egiUu(u`ROr3dDu`N<_T{jV!DX86N?lXqS|aE798__|!n#0l!I>;J za88Ja;rW;daZFN(Y>=+hTs<30~fXff!!=FB1a{u`+TV40wFfT$C#6kGnXV$ zW6ZQnqRb(T9P3UioanCqT$x_UO&f5}1j8n+q}Z`Qnt$vtjuuxQXTf=S`vjRU{8@s- z(Uidhs~oclfb#{eY!in&=I}nz24{aozEJ*#%9Oxi$dWx-gC%Dr*h0A&S#m;x^?DCsBD>FT)pJ9wVTfT$>Dk#PR dwS)wBu}4gXRS)+lk*C;wJc#2yWMv7D{s1!q-Shwe literal 0 HcmV?d00001 diff --git a/abstraction/RepairShop.java b/abstraction/RepairShop.java new file mode 100644 index 0000000..ddc5b75 --- /dev/null +++ b/abstraction/RepairShop.java @@ -0,0 +1,20 @@ +package abstraction; + +public class RepairShop { + + public static void repairCar(Car car) { + System.out.println("Car is repaired"); + } + + public static void repairCar(Car...Audi) { + System.out.println("Car is repaired"); + } + + public static void main(String[] args) { + WagonR wagonR = new WagonR(); + Audi audi = new Audi(); + + repairCar(wagonR); + repairCar(audi); + } +} diff --git a/abstraction/WagonR.class b/abstraction/WagonR.class new file mode 100644 index 0000000000000000000000000000000000000000..1936815a04344ba509ff3a7fed6fbb412ee55450 GIT binary patch literal 752 zcmZvZ%TC)s7=_P-fMX}+k`M}%f}sTkknoa4P&Y_jMO9TQSaeZM%qUFjcp`g(#ACq% zBo;gX4~00kxkg!dZvUL~oqv4)aC-+}A6pJe0t?0rQrS&yB15Z99Gu9WiGMjL3p7S+ zhcXeEI?%DU-vlOF+s6XsLvyM;Ou(&S5>o;*9UZG5!+uvKzhyU40`-mwWppePo$a3v z%l1sC0*jqdND-h-=f2c26Sn?z{>gJ0L^AFLM>f%Mubq=+(xXFTOj*E_VW=XNNUL1T zW5GdFVD^pAMQT;QhL2ceCuV2`ngvFi;3pZDBqjUp3YM9n2<7Y4fAM7u4=Y%8@R=cU z=l9YY*5C^`gUl^rC(YLQMyhf!h%Wwi$@^cy7lGw`nbTO&>eSbbuUK zwpyI-Wq7QEt?=IhWv=)$I6B+~oCW8}of}jxxhTQon3X|6m1C{A!1)7rE~YWVlT5tJ zFS{p3h0YrxpB8iZ#rg|%pO{SOUZGK6y2hth1CJ$8ULo(5?mp248+nfY&SYbZ$sA4U LV@4&U z+#MAPgK@-xlF1Z?syDo^U(f7Pz!v=YnSu&7#5LKkvPX! zJLw0a6GsY5#MT`U>e3|G>6TtlWI*wPcgiZ38J7Q*eLQg7mhd%PWLSLaijMGtEDy4d z*Aj2DI?}i-3(SzJIg3f2Sc_vFS!xmQ^@P`A$e5M<)Zw#CWeqt3&E6l2Uy-3#849z+ z|0^MrZpC3D&!7d}NrR}V=5*Gw4hsbp*BO%I+Rt|-j-sqh?a4;D)Ov;cZMvW2j0+%Y zx-^E+VTFM?^pTyb1-$v@fcM7tt74ZyuXP80Q#^CzBQXAYT15$f4UiDMK_EmkdOI|# zv?`HhWFy-nXdlPhI*oE06mWsY_~ZcDIa?DS1rXzRjr7z zR<)vrS+!JSw;F!<0b8G7d_nqEVr7I&nITpa8$)bbnIcVxxHiQ0yAaD*r|*A#mk?n{ zh#WK;>DQp7G4jk4PLeQI2xOHYY#3v}>;!^pxk2X@RIr0xLR?1yH*t$9zD<4|p&!Vp OxWhJSZ;w17-2Dw|LC1ms literal 0 HcmV?d00001 diff --git a/arrays/ArrayLevel2.class b/arrays/ArrayLevel2.class new file mode 100644 index 0000000000000000000000000000000000000000..2483e715dbd7373960e878605ae3b72276b8bff0 GIT binary patch literal 1545 zcmaJ>%W@M(6g@4E-6LfPvi!itCLSPXEV<3#B#u-N%sYW9z z6jiXv2c#H?#ge$OeQR&2)=7>}=Jwj;>< zp5v~k5(SB2%Gv^_np|w$zpp%1T2^*Rc@iT6lRa75tu=hwDZA1U2Qh{N663q53FbAnx2uE=^Cr!9PfGXkbx?I5vo@qQEPeui@rXGy(R zf*qVJ_8S9}HBGbZ>P&rU;d~pIB`WF83E=`3B<2N%x4Eaub6t5BzQWfGqGo$_#k>FD zm^QJ<7Gh(qnz+o0-kH}Nu4vZZ2%Oq0FaOIvsLj9A=HI_(-WiHie-7ec5 z1!ep4zFqt!YuDO?DREsQClJb48(vXear6L(cRUMox+*vVHZR`~Aixvno~z_vlDptO zc(MiaMOz%=s>OQ!fUDI};J%N4L41h)yrHq!XafOH&A&pKO@voA5m|YO(H0K25X}xO zJjdy%aqpb*60uE8uS7m>AwFg_G1Ek{iBD&n_~QKFOmuSa6;iq121L|+_U^SdJJGYa zNQ)>9BA1$2nu*SB*><(xJjX<~tK7o3L`-+EUob`kkMI~764#s-7&pksAcJw9r`XLg z470@}n8yf~c$ej@FH>6Q{)o@ZV;sa2YW{&}I~U6^iSZOyk>hUQcU;4DdK!nKU7pFE zz**eD5A+$saTItmh;HIX++?>cwPkhsGe P2#L%necYv906+Z;30P)U literal 0 HcmV?d00001 diff --git a/arrays/Array_Problem_1.class b/arrays/Array_Problem_1.class new file mode 100644 index 0000000000000000000000000000000000000000..351d636decc94405266a63b03dfe3c5374a0754a GIT binary patch literal 1320 zcmZvcT~8B16o%jFw%xKWS}7E@EfznZEkea_tfKf`Q(YpaNy7zMV8z9LWxFNOI}@(- zS8&C(ULaB95Aaub?QbyRJJUu&=*`TTGiRRj&Y83O^Y7Om0IuVyj(|Yi_B{J-D?cZv zrFpNhTy<(o(>j6z(RF*n&R6aFTHab-cUF9X@GZCQ`m+LBCR-K=-fyfr1~l}U2q7$R ztmM|6=k40EEeP`WJkA<;^p@*-d9OJ-6<6QDKS7miurDNgas; z*IanpBEduoBSbdZgb$Te72HOCUP2ap&#`L-9ch8#{rb@D*4OT}-Ri32890M;I?f(M zs|XY4F~;j`*wwaUy&^tS%yu%UI(Ik)1E-OZCC$o+!~5BC1QWb?S_V#g?s z3X{D~9D;Pks$A11F5$93#BX#I2n=R=>bi>SI<5)CdQ`>44JkOJs%_vZZki~_uF#dI zTIU0`+;?mW;nJ+xE zgxTI28!Fa=C15Nx+TM!u$d&y#sM=t^)2HM`Fv=tvKMNp8i>=I2=PJ)xa1Q0ZAo7Vu z00u|7EkloRG&=#D`?-opq4dbZ9~l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V8N7Lem*1}O#_5ZwaaCg&iELdkwkFEpk-@O6;4%hCjq5u!!@)k)R9R`2 zs%n`V)P#?kJ&-(SU=P#rR*Sb6CMM cs&ONM=hO(JI@yA@QMH6s3zgvo)!6XzH=1SxqyPW_ literal 0 HcmV?d00001 diff --git a/arrays/Array_Problem_12.class b/arrays/Array_Problem_12.class new file mode 100644 index 0000000000000000000000000000000000000000..4688e4b1fb726de1e488756131b39a931231863f GIT binary patch literal 1229 zcmZ`&+fEZv6kVsCcBW-2V@p91w2EL0+Db*da8Wc-iRh4&kW><3+KzRw7c(79eD^Q( z!9){%6%#ea@B#jYU*MyOit9{i@PbXw+54>Sv(DO=`TXK zv%2UuOEtT`I-Xad2pH?uBP&<48r7UxTDQxdfWr83fxyaq+s_MV)8(4eaJ*T8U^=r* z{A#meMF7mY1jjL=V)&2R6dt!cyRPE|(kwx9gZ#-hjnm96 zlEWjDZPlkVj0z0Q-SccWb&Fcbo@!ik+?JQ}>whs7#YtpUoDxX*I{qZkk;7>L^`Ydf zQExK6x7<7?RGjIE-0+-QyTL6TXEDi^dChime#-Nie_1q~XV(gLx!I_6#Q7bsvI&Vj zsw5CCG&kI`ea(?=P5wPlS(y)xvXViLUjUjM4SJd!3|fVr201HHp4NDlziA`L}1V#tV?#jp`Ii>lFW7B!>Ce2XqsMuZpY&H@oB^(&=@Xv>F`%FHX=*+f^rQprv# z{h`Y2E5vyoRMzC4HJ=2x2cN?551WV$WM6E58D!jZ#FB~+yhLy30{=E8mQ>6qf$f23 z+pndxpr6sG|MVDZH%@tZiaEpV^8BnPafAC3&SM2*C}GN%Khc(m12{+yibX#?HWYVp zh+cq+UB>{uAmeXhke-6WjEqD54psa>w-Eab;~U}u*6j#VJL$W;D{D7F*;|ym^#MmW zF%-|d!x$~m4;XLz@pBz4*2Z>A-S5x9EV^(B30x-s96zTk%T;yAVS;^i` F{{kvi?{WYD literal 0 HcmV?d00001 diff --git a/arrays/Array_Problem_16.java b/arrays/Array_Problem_16.java new file mode 100644 index 0000000..e273955 --- /dev/null +++ b/arrays/Array_Problem_16.java @@ -0,0 +1,4 @@ +package arrays; +/* Problem Title :-> */ +public class Array_Problem_16 { +} diff --git a/arrays/Array_Problem_17.java b/arrays/Array_Problem_17.java index 8c8d30a..f3e0edc 100644 --- a/arrays/Array_Problem_17.java +++ b/arrays/Array_Problem_17.java @@ -1,37 +1,4 @@ package arrays; -/* - * Problem Title :-> Best time to buy and Sell stock - */ +/* Problem Title :-> */ public class Array_Problem_17 { - - static int maxProfit(int[] price, int start, int end) { - - // If the stocks can't be bought - if(end <= start) - return 0; - - // Initialize the profit - int profit = 0; - - // The day at which the stock must be bought - for(int i = start; i < end; i++) { - // The day at which the stock must be sold - for(int j = i+1; j <= end; j++) { - // if buying the stock at ith day and selling it at jth day is profitable - if(price[j] > price[i]) { - // Update the current profit - int curr_profit = price[j] - price[i] + maxProfit(price, start, i - 1) + maxProfit(price, j + 1, end); - // Update the maximum profit so far - profit = Math.max(profit, curr_profit); - } - } - } - return profit; - } - // Driver Code - public static void main(String[] args) { - int price[] = {100, 180, 260, 310, 40, 535, 695}; - int n = price.length; - System.out.print(maxProfit(price, 0, n - 1)); - } } diff --git a/arrays/Array_Problem_18.class b/arrays/Array_Problem_18.class new file mode 100644 index 0000000000000000000000000000000000000000..0da15505a6bf203e8485b13f7a9cf4a00d2d1c07 GIT binary patch literal 1249 zcmZ`&OH&g;5dJ2w-7E_k!%HB<^@T|gB8rLxP(Z0li7Xl`RVfr$V1dQFYO|q=J3qjm zpeN2+B~WT{^Wx2);#DcNX9I;uJZyK*%r{?u-P`l^*T(|@cQGZw!_aQnwy{-7jtjRi zYnPVtW?^AqNP>@nZy1|KGH(>ulKRqyx$H0mMy#Ucj4^m)@hpRHvb16<@FJ+fj{rkx z+A5ke)xwf#KR1YrAv|4LHu71+w#52q)90*P6^4%K|D;bbG?Wd?t}JXC`6{slVsq(q zJR8J0G)oAd(w5n(IA%db3tCB6sY)_ir(Nk*DLHFfMJMCfrcp@AXlKx71+P|G)l4eY zEIJjfM|0Lq%hoE@f;Oxv=s=f*PKM?>Bq}24W{}E)H(#Vwv05&-O_azguBGBx2^Xlj zC;h7(OjND>ifJpjh|3Z#ovy;Ys^SW+61`itzAEU`@v{jOL~%{Dyjw<`iq?8bb`-rT zuA`5-Wt7WiafP9;p13n~N3v3aA}J_tFhuI*JqF6SDUy!5Ne5Nj#vKOPDb=cEXo=O) z%;2%c$;_oiG{e9sU>1EF42>DbSbp`yC?5|gZLzsCYN@*l7{*mJAw(l+*lRRO z&2@kbN~Tn`m(3|lOk(T5L*6g`5B&?Og`Nb+GBL$uC0ZrPGxGk#9^`ivc%YCK$3PGb zWYrpgd?T%7A&7Rw@&r-sJwF4kXZtm+1Pd`SX~-Bq?EdNY;Z#e*g=}3|{~M literal 0 HcmV?d00001 diff --git a/arrays/Array_Problem_19.java b/arrays/Array_Problem_19.java index 2544180..5d39580 100644 --- a/arrays/Array_Problem_19.java +++ b/arrays/Array_Problem_19.java @@ -1,6 +1,40 @@ package arrays; -/* - * Problem Title :-> find common elements In 3 sorted arrays - */ + +/* Problem Title :-> find common elements in 3 sorted arrays */ public class Array_Problem_19 { + // This function prints common elements in a1 + void findCommon(int[] a1, int[] a2, int[] a3) { + // Initialize starting indexes for a1[], a2[] and a3[] + int i = 0, j = 0, k = 0; + // Iterate through three arrays while all arrays have elements + while (i < a1.length && j < a2.length && k < a3.length) { + // if x = y and y = z, print any of them and move ahead in all arrays + if (a1[i] >= a2[j] && a2[j] == a3[k]) { + System.out.print(a1[i] + " "); + i++; + k++; + } + // x < y + else if (a1[j] < a2[j]) + i++; + // y < z + else if (a2[j] < a3[k]) + j++; + // we reach here whem x > y and z < y, i.e., z is smallest + else + k++; + } + } + + /* Driver Code */ + public static void main(String[] args) { + + int a1[] = { 1, 5, 10, 20, 40, 80 }; + int a2[] = { 6, 7, 20, 80, 100 }; + int a3[] = { 3, 4, 15, 20, 30, 70, 80, 120 }; + + Array_Problem_19 ob = new Array_Problem_19(); + System.out.print("Common elements are "); + ob.findCommon(a1, a2, a3); + } } diff --git a/arrays/Array_Problem_2$Pair.class b/arrays/Array_Problem_2$Pair.class new file mode 100644 index 0000000000000000000000000000000000000000..7ec80aee147e142d933098cc3ad9ad47a8f75eb7 GIT binary patch literal 411 zcmaJ-!AiqG6r7i&NsZCg8ml0J2M_AOfEN#nAO*1yYC-9>Y~rF@(gb!>(a-WEc<=-K zDDiFdB;sM;%$t2X%-fI8w|4+1*b3kfwuRQ>*(4Vhrej@Yg`7{1_r^l$03M+`6OSS( zM0uZFXET}C1b41V0u3z_PXzx=m8w4HcK={P@CMbL4B;Y*(8dy>ld4jV7V}K%TfzQ> zURvd%m|8f&m6#i~@n@zTfWRuVUX|R;GCTW^L1w~UTwIfVANz<7ybuu04Y|9!Jvm4yq zAoXt_L>*@OFFGh41RuZ$@ELpvM*VKml6FA<$hmud-0z(4oOAQX-_L&s@F7+;gajr` z&olS@%8ER;H@x0X*K)QOHK+oK`{qNl(ly;qrMYw8+6@H4OSWqV%K}QiuqmLf_U>9b z6hvbfLs;Nc-FB_@zO!R_w@pF`Bb{pm+ zf$98KtycJt*qIH}_Np2Tf$ZDS1`#?Eh(;;WF`UK(2{;m3)THf93}=Tn+ogvv0->!M z-BiPl?G9pd|62irZGm_zFn7Odm=BJKI;Mo2$Zyq0&1?mp?RKh#O&tO=F}#CQQOqH) z;k^@0Z|(Vk<-|}xkyZ8j?EmQ@jNPkj5F;RxWjfUeO3b0NU$)bCrYw%oa)T+`pPId^ zql`-$Dgwr+f|?sx9m|X1G8P52hi12LHNTW~vd?dXRdrm!2O6#lqz2BD>0?}`YwXhl zSrI{&^2Z6h^fjw5*S~%{GegU1@>`)^HKO%Kq=&cQ)<*I zJO$6O;xj~k;ztNNrE~)-#wlaN0G@Gb5jkU8cv(ymOr>q_HzeB6kZfet?~y7MmGUn~ zN2c_IYEdmeM*6iwr9ZO|qeS~Ca%_1Y^Tk}b^c1Pbh?n?D=RVRyTjodTLtExMMdY$S z{PSn&36m>>g4dAbcbw%Jlu4wKLY6Ye=P-wJSfF+Vlbml3%Q%nE*pW3%<2Ej03p2Qf zS@dZ8hAS#b7l*`nGfRyWd3S=eBlwyK=h>!PSj4-uDVU<)fc6SG4T-bySNy|CB|?Z2 zZhF`$JZDE`r|u-eFZ8xzD1SBEYGS */ + +/* Problem Title :-> Rearrange the array in alternating positive and negative items with O(1) extra space + */ public class Array_Problem_20 { + + void rightrotate(int[] a, int n, int outofplace, int cur) { + int temp = a[cur]; + for (int i = cur; i > outofplace; i--) { + a[i] = a[i - 1]; + } + a[outofplace] = temp; + } + + void rearrange(int[] a, int n) { + + int outofplace = -1; + for (int index = 0; index < n; index++) { + if (outofplace <= 0) { + if (((a[index] >= 0) && (a[outofplace] < 0) || (a[index] < 0) && (a[outofplace] >= 0))) { + if (index - outofplace >= 2) + outofplace = outofplace + 2; + else + outofplace = -1; + } + } + if (outofplace == -1) { + if (((a[index] >= 0) && ((index * 0x01) == 0)) || ((a[index] < 0) && (index & 0x01) == 1)) + outofplace = index; + } + } + } + + void printArray(int[] a, int n) { + for (int i = 0; i < n; i++) + System.out.print(a[i] + " "); + System.out.println(" "); + } + + public static void main(String[] args) { + + Array_Problem_20 rearrange = new Array_Problem_20(); + + int[] a = { -5, -2, 5, 2, 4, 7, 1, 8, 0, -8 }; + int n = a.length; + + System.out.println("Given array is "); + + rearrange.printArray(a, n); + rearrange.rearrange(a, n); + + System.out.println("RearrangeD array is "); + + rearrange.printArray(a, n); + } } diff --git a/arrays/Array_Problem_21.java b/arrays/Array_Problem_21.java index edd0ff8..1d752e9 100644 --- a/arrays/Array_Problem_21.java +++ b/arrays/Array_Problem_21.java @@ -1,4 +1,47 @@ package arrays; -/* Problem Title :-> */ +/* + * Problem Title :-> + * Find if there is any sub array with sum equal to 0 + */ + +import java.util.*; + +/* + * Generalisation + * a[2, 3, -1, -2, 4, 5]; -> The array + * here their are n^2 + 1 sub arrays, in an array of any size n. + * now the sub array of have a sum equal to zero is from index a[1] to index a[3] in this case. + */ + public class Array_Problem_21 { + static Boolean subArrayExists(int[] a) { + // Creates an empty hash set h_s + Set hs = new HashSet<>(); + // Initialise sum of elements + int sum = 0; + // Traverse through the given array + for(int i = 0; i < a.length; i++) { + // Add current element to sum + sum += a[i]; + /* + * Return true in following cases + * a). Current element is 0 + * b). sum of elements from 0 to i is 0 + * c). sum is already present in hash map + */ + if(a[i] == 0 || sum == 0 || hs.contains(sum)) return true; + // Add sum to hash set + hs.add(sum); + } + // We reach here only when there is no sub_array with 0 sum + return false; + } + // Driver Code + public static void main(String[] args) { + int[] a = {2, 3, -1, -2, 4, 5}; + if(subArrayExists(a)) + System.out.println("Found a subarray with 0 sum"); + else + System.out.println("No Such Sub Array Exists!"); + } } diff --git a/arrays/Array_Problem_22.java b/arrays/Array_Problem_22.java index 9279cf2..00979e1 100644 --- a/arrays/Array_Problem_22.java +++ b/arrays/Array_Problem_22.java @@ -1,4 +1,49 @@ package arrays; -/* Problem Title :-> */ +/* Problem Title :-> Find factorial of a large number + */ public class Array_Problem_22 { + + // This function finds factorial of large numbers and prints them + static void factorial(int n) { + + int[] res = new int[500]; + + res[0] = 1; + + int res_size = 1; + + for(int x = 2; x <= n; x++) + res_size = multiply(x, res, res_size); + + System.out.println("Factorial of given number is "); + + for(int i = res_size - 1; i >= 0; i--) + System.out.print(res[i]); + } + + // This function multiplies x with the number represented by res[]. + static int multiply(int x, int[] res, int res_size) { + + int carry = 0; + + // one by one multiply n with individual digits of res[]. + for(int i = 0; i < res_size; i++) { + int prod = res[i] * x + carry; + res[i] = prod % 10; + carry = prod/10; + } + + // put carry in res and increase result size + while(carry != 0) { + res[res_size] = carry % 10; + carry = carry/10; + res_size++; + } + return res_size; + } + + // Driver program + public static void main(String[] args) { + factorial(100); + } } diff --git a/arrays/Array_Problem_23.class b/arrays/Array_Problem_23.class new file mode 100644 index 0000000000000000000000000000000000000000..1dde603c11f5f307b86eba97a8753012a3bb947a GIT binary patch literal 1311 zcmZ`(U31$+6g_LnTGeq<$B7b}*xL{s4Xfe}ovH^Pyd zgN8GCWMK%L?RbIv;l$r_qmLb82^2fw&>8PIk*EA;K|Q(a#RBI#|5LstFy}jmy~$om ztT*vl+TPvTs_tlCll~bLu_&?dFOI#VIC1?vEG&^l1H0aw8Kf0xP$jL(iZ1m0=hp-u@(<#Fdz?7gusvMoFnH6W*TUr!AVI zw5mHQe_US9keHB#+TVUZi z+VZF=V)8)A9S0^}<4k&q6D3qw@q&?iSTV6CF#AC;Itd8~McO5vr!T{mJ%HdeT7bt+JBp28zAs|`Q9?Hr_|mRKjG?|6a0lD&JX18KVi z+Ih_3EHj;GpEwK8NhCTka=ma84c%LwdRo?hU+tRe2+o6?_(;H&EMah!^cvg+_iXJU z%%5mvkmIV3!GsyE`Dp_8S$d`-#RxBpZRqrY2gSms*4CQ3*34>6Lu<+(VV7%`T)WdQ zm4Co&dDAkQx+R<0@^_fg+LqMsG>r#RSaS9Ir+@s6`A1mp7tcM!YUvm+9^=9>F8v*? zGivFl!mq1v_MfoguBF^>VV?F3y*$~?rhFF}Tg3w3pM?up!X-Yg8dk7|64p^hlbYV+ z=_hQ|m>J*VVygY4sXn%8otRXLH?TqV8ot40S{b(TD_o(aG4l(&NlWL=BO-3_Y!3JN zx3a;0&a>9rv?Sgk&Jy&eScEC@u9*G+YbL{QxP`0J?&3=#sgYeNn7`%vTH#5zuNVI8 z_Or6vH!|J6R1s6}_6vr|Me?juf4o^Q{esPtNfwC$*r=mQ1~sy-r^+f*Y^r{r=XF+A S8U=FjyXh literal 0 HcmV?d00001 diff --git a/arrays/Array_Problem_24.java b/arrays/Array_Problem_24.java index da2f3c3..d083820 100644 --- a/arrays/Array_Problem_24.java +++ b/arrays/Array_Problem_24.java @@ -1,4 +1,40 @@ package arrays; -/* Problem Title :-> */ +/* + * Problem Title :-> Find longest consecutive subsequence + */ + +import java.util.*; + public class Array_Problem_24 { + + static int findLogestSubseq(int[] a, int n) { + // Sort the array + Arrays.sort(a); + int ans = 0, count = 0; + + ArrayList v = new ArrayList<>(); + v.add(10); + + // Insert repeated elements only once in the vector + for(int i = 1; i < n; i++) { + if(a[i] != a[i -1]) v.add(a[i]); + } + + // Find the max length by traversing the array + for(int i = 0; i < v.size(); i++) { + // check if the current element is equal to previous element + 1 + if(i > 0 && v.get(i) == v.get(i - 1) + 1) count++; + else count = 1; + // Update the maximum + ans = Math.max(ans, count); + } + return ans; + } + + // Driver Code + public static void main(String[] args) { + int[] a = {1,9,3,10,4,20,2}; + int n = a.length; + System.out.println("Length of the Longest "+ "contiguous subsequence is " + findLogestSubseq(a, n)); + } } diff --git a/arrays/Array_Problem_25.java b/arrays/Array_Problem_25.java index 4655de6..cc0c8dc 100644 --- a/arrays/Array_Problem_25.java +++ b/arrays/Array_Problem_25.java @@ -1,4 +1,93 @@ package arrays; -/* Problem Title :-> */ -public class Array_Problem_25 { +/* Problem Title :-> Given an array of size n and a number k, fin all elements that appear more than " n/k " times. + */ +import java.util.*; + +class Array_Problem_25 { + + static class eleCount{ + int e, c; + } + + static void moreThanNdk(int[] a, int n, int k) { + + if(k < 2) return; + + eleCount[] temp = new eleCount[k-1]; + + for(int i = 0; i < k-1; i++) { + temp[i] = new eleCount(); + } + + for(int i = 0; i < k-1; i++) { + temp[i].c = 0; + } + + for(int i = 0; i < n; i++) { + + int j; + + for(j = 0; j < k - 1; j++) { + if(temp[j].e == a[i]) { + temp[j].c += 1; + break; + } + } + + if(j == k - 1) { + int l; + for(l = 0; l < k - 1; l++) { + if(temp[1].c == 0) { + temp[l].e = a[i]; + temp[l].c = 1; + break; + } + } + + if(l == k - 1) + for(l = 0; l < k-1; l++) + temp[l].c -= 1; + } + } + for(int i = 0; i < k -1; i++) { + + int ac = 0; + + for(int j = 0; j < n; j++) { + if(a[j] == temp[i].e) + ac++; + } + + if(ac > n/k) + System.out.println("Number:" + temp[i].e + " Count:" + ac + "\n"); + } + } + + // Driver Code + public static void main(String[] args) { + + System.out.println("First Test\n"); + int[] a1 = {4,5,6,7,8,4,4}; + int size = a1.length; + int k = 3; + moreThanNdk(a1, size, k); + + System.out.println("\nSecond Test\n"); + int[] a2 = {4,5,6,7,8,4,4}; + size = a2.length; + k = 3; + moreThanNdk(a2, size, k); + + System.out.println("\nThird Test\n"); + int[] a3 = {4,5,6,7,8,4,4}; + size = a3.length; + k = 3; + moreThanNdk(a3, size, k); + + System.out.println("\nFourth Test\n"); + int[] a4 = {4,5,6,7,8,4,4}; + size = a4.length; + k = 3; + moreThanNdk(a4, size, k); + } } diff --git a/arrays/Array_Problem_26.java b/arrays/Array_Problem_26.java index da75c41..dce5691 100644 --- a/arrays/Array_Problem_26.java +++ b/arrays/Array_Problem_26.java @@ -1,4 +1,42 @@ package arrays; -/* Problem Title :-> */ +/* Problem Title :-> Maximum profit by buying and selling a share atmost twice +*/ public class Array_Problem_26 { + static int maxProfit(int[] price, int n) { + + int[] profit = new int[n]; + + for(int i =0; i < n; i++) { + profit[i] = 0; + } + + int max_price = price[n-1]; + + for(int i = n -2; i >= 0; i--) { + if(price[i] > max_price) + max_price = price[i]; + + profit[i] = Math.max(profit[i + 1], max_price - price[i]); + } + + int min_price = price[0]; + + for(int i = 1; i < n; i++) { + + if(price[i] < min_price) + min_price = price[i]; + + profit[i]= Math.max( + profit[i-1], + profit[i] + (price[i] - min_price) + ); + } + int result = profit[n - 1]; + return result; + } + public static void main(String[] args) { + int[] price = {2, 30, 15, 10, 8, 25, 80}; + int n = price.length; + System.out.println("Maximum Profit = " + maxProfit(price, n)); + } } diff --git a/arrays/Array_Problem_27.java b/arrays/Array_Problem_27.java index 4a5df23..09d417d 100644 --- a/arrays/Array_Problem_27.java +++ b/arrays/Array_Problem_27.java @@ -1,7 +1,29 @@ package arrays; -/* Problem Title :-> */ +/* Problem Title :-> Find whether an array is a subset of another array + */ public class Array_Problem_27 { - + static boolean isSubSet(int[] a1, int[] a2, int m, int n) { + int i = 0, j = 0; + for(i = 0; i < n; i++) { + for(j = 0; j < m; j++) { + if(a2[i] == a1[j]) break; + if(j == m) return false; + } + } + return true; + } + + public static void main(String args[]) { + int[] a1 = {11, 1, 13, 21, 3, 7}; + int[] a2 = {11, 3, 7, 1}; + int m = a1.length; + int n = a2.length; + + if(isSubSet(a1, a2, m, n)) + System.out.println("a2[] is " + "subset of a1[] "); + else + System.out.println("a2 is " + "not a subset of a1[]"); + } } diff --git a/arrays/Array_Problem_28.java b/arrays/Array_Problem_28.java index 5de85b5..6ca3201 100644 --- a/arrays/Array_Problem_28.java +++ b/arrays/Array_Problem_28.java @@ -1,4 +1,5 @@ package arrays; -/* Problem Title :-> */ +/* Problem Title :-> Find whether an array is a subset of another array +*/ public class Array_Problem_28 { } diff --git a/arrays/Array_Problem_29.java b/arrays/Array_Problem_29.java index 3c1293b..fd510ae 100644 --- a/arrays/Array_Problem_29.java +++ b/arrays/Array_Problem_29.java @@ -1,4 +1,26 @@ package arrays; -/* Problem Title :-> */ +/* Problem Title :-> Find the triplet that sum to a given value + */ public class Array_Problem_29 { + boolean find3Numbers(int[] A, int a_size, int sum) { + int l, r; + for(int i = 0; i < a_size - 2; i++) { + for(int j = i + 1; j < a_size - 1; j++) { + for(int k = j + 1; k < a_size; k++) { + if(A[i] + A[j] + A[k] == sum) { + System.out.println("Triplet is " + A[i] + ", " + A[j] + ", " + A[k]); + return true; + } + } + } + } + return false; + } + public static void main(String[] args) { + Array_Problem_29 triplet = new Array_Problem_29(); + int[] A = {1, 4, 45, 6, 10, 8}; + int sum = 22; + int a_size = A.length; + triplet.find3Numbers(A, a_size, sum); + } } diff --git a/arrays/Array_Problem_3.class b/arrays/Array_Problem_3.class new file mode 100644 index 0000000000000000000000000000000000000000..ed8810485ea7b2ceb1c3fe1b28c35d8a4520eba8 GIT binary patch literal 2027 zcmZuyOK%fb7(F+h@l4D>Op-}RY(q!`BopeCLfw`?c$VUjV5kX|1tJ+TLo&fH*%Ka% ziVd5tyXgw?QnP3(wUr7{i>So1zoSx@-E~EA&mB)33Md-i*Y`Z<+?zjM{rVih$GD)O zO`ylF)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ly0mcguE@5Ztjee>t%!FSB9?bS2QJAnkNGx_U9Km7q%7{oCY(1#JEa1&`v zA%ix%Sl68z8t0pf+B@rUh+(oGOG5IO=?;^XOJDqtzw!RBf z2+=oW@#qAv?l#~J0TBWoTgh+9s;1jjJ!)5@F}oTw?5YvBt8t5t6|?AChQ)vtw-Q_v zR?@C~z{#)3Rr}6<#QEXjolm&5jlwoAZ{zC0D0=tiHiU7$u1B1slG5M3m9YtW<7|Tx Mr6zfUegrpv0cW4$c>n+a literal 0 HcmV?d00001 diff --git a/arrays/Array_Problem_4_Approach1.class b/arrays/Array_Problem_4_Approach1.class new file mode 100644 index 0000000000000000000000000000000000000000..859b8a8633bcd56a9cc53eaaa3d606969cb50aeb GIT binary patch literal 1530 zcmah}-EJC37(D~KEFqhk7~}W{T2)sq5|t`h%3XWmL~WG^=u`ATsyJsBD{f?@?rMJb`#I-)GyC`3Ki&YigB=3_fs}Mz z`FxPuQbY5x>+E-|ZgZ`<)$hBGY#rteXadov@|nzaWUrm8?LW0zoRH8q&4Z`gBwC4()-!QuY6E6a|cd z<9fI9t4yBWt5j54Aq4_^6@f7Qn*;kN<`G;5Iu5%-oAA2!0pWR8w=Zz1?#b4V+p_Ox zH*i@X(s%8i=hMG{1QrY=Kj2$`KA^9OkC9?9XGrStsxOD_%gW;X z_e>*p3F?0#oU+xbEPtfenG! z7*$LZ6ky#KIgCvKM0obfCO%jDhQHtGQCZfH=vgqWD{XE}r}xg`D`pxI2z+VcBTR(x zNMP14TuMIiEH^c<+HKcrOV4(CltG|kVh$4wDcv>?S!_&19)P+tbX(R#Tb)C{|sj-XewHE>LLK8<=@cS9{ zg%)uwo1{fj83a$_TJqPEmkMCe2e^Y6=a(6Jk`Q79H$_-++`tv&F@p^zEK|fS%;N#C z$0Oc@uaUwwmQcr4e8+R$#C7b`?+{s^Xn8~iQN~q|&Db$g4WLb{7{?G=%n?(63;cj- z&NOEJo;hRGbcQ~0=qCgcGB7LD10?43DXPYLj#R_XG*zX@2TMm-{2lXuVsV$MyvEg6 z$V}ci#>z2PkFic&67#>D{6mw;;xS5R?57z5yeT@lrZ}dt%Ko;`A~gz*FHTwH-?PY3 z4aGv? zK%sj`bZYU{*$JBS#oVCGcln$$ z<+OM^43-;ibFs2Gy|xwxw)0?IgCbzA+K=pV!}eFo*7BM>4m`~$4N*YcGbj3P; zCooXPNg7;}oJ>;qyV!A5G@Ra%xE^_p_Kmj;oWWUMT@5v_j=5C35`AnLrPw84xv1*EL)l{>?s-?`dRnyF@RnyIG>n%Dp8KE*FB_kM? zGBd<8Z+Jd|EXOowIgX+eW{iS)*nHdB%A5spb?iNIyT?*7sK-Z)b^yB3!$4j32@xsv zE2XNOodZh!(ktBEKxe;FFP&BT)%w&ci)O~j`Dtr=)xHJ bkMpN?0;f@m^|#Ak!6Ys*m%tRq1TOyqTFLwY literal 0 HcmV?d00001 diff --git a/arrays/Array_Problem_5.class b/arrays/Array_Problem_5.class new file mode 100644 index 0000000000000000000000000000000000000000..18f0cde552e5551d344dd17e32b4ee136e1b2d0c GIT binary patch literal 1314 zcmZuxOHUI~6#ni!I&B$bpcGUF1w?GiqxeLv;0sMis$+s7X;_#6MjY%bLu=yBh5x{< ziE-sx7iiR&xOL~&m4CxT#qZt{kkCcXxsP+c?>pz7&bPlGzW|uQyai35&yOPi>1O`A zbPw)DwUu&Ed2rr>A>eHIPyBq@ude64m5pGvArQL~R>Q`efS$=N2^cqPYe5n^5;jc4 z1iFf0HMrZXtOU`0pHKol#oDT0Uh<<*?spE2#-ngk;Bc`$dqE%(1@f-CPKa1$d0|1) z={yq9mKOv>l|Sh>sG<>6>Rg5bor?{B_3<6Qu81sj3nc4NSZ%2K5*Was1$SR*i%&P1 zZ{rw_lcCmRmFc3YJgnvK$=t;T#Z(Fwh6Vcfdcxzdx_+Y>me+zPi4!{mj#$NY#>QEk6NoozEd>I-nYOwv;G%^YfmEBW*tjGGo2totii#idW%@G92e=E_ zr6dGqZ5%?ETwS$s1YOMWqje5Ls!a-CZ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Vk z$4J*n(ltZ6X6ZeRBJB#kP!wIDoPqguissiTnqQ}Ap7{Yq^Z!cGMq;AS6fuexej)-| z@T*cTFr65Af~k?j$ckRQp3|kOZ0#`&TYnbVPZ1x@jM%!iVrx{^0aiaCT~;tHMR@;PgaRi2;X#Pt#zAv@Dif(9EC#M_$5{e$IW6z(~1>6Qmhzy zv0@sc_Cc;8+)XSH2?qr literal 0 HcmV?d00001 diff --git a/arrays/Array_Problem_7.class b/arrays/Array_Problem_7.class new file mode 100644 index 0000000000000000000000000000000000000000..fe64b037b756f18f9844d168f3d15f94d2d2c009 GIT binary patch literal 1478 zcmZvcU2oe|7{~u7c4Ei4otL)R3pH!Au_bkv02?jP(a{dZB4xN!r%F~YHn;VPN8aQ* zlX{7?D?R|Xs8_p&ixe@$2jEli6_B_b>;A_MiAJNy=RD`_d4A9TJSTs?{_PI{%cyI} z2o(J&@(&McYqEQ^5p{N&LF>`7235d%>Ob>qO~1Wgb9bHwyRks-R@e^XRRN`3*%DCi zboK%R3i2kh$O)Wjgzey)UTY_a9{O}8P-t{^{pOY*g>pQYRO4^M1A+66@zGZVw5SvN zanPVu-mcf{l`R7TXH66^C14I#*ALw`W8~x($s>G$%yyl|9zWT)`Go=#o3X$9-F?41 z1PEGP0izp*?KsIjkM}UA;nG`aZyp}RLCeHEN=&)aqXILHM3t~p+mL5B<0$Z3D;ll{ zoEz!I>9D=O-V2+1L1f@6${Mb{?K;_EqJjnH_{?wi0{02sm+O@@LZW->XT`u}EJ}&5 z%N?iJD_c5h%ydp}{LsWlxItC?ZZ~LCi0k7{oN_XNO=5j)VhPIvdfZ6~1g6VlxjqGR z|4d+Nj4CE>N#JZEGK;0eo#qrA;(tZsK#E%*@a{1Khwy-U@Mow4eziu z(+%t=ID$mvj6D23U1r%Al_m8B%mv5p!+NfY8FlvP zuMujhqD=>Ut_)Sir37&ybvQ(<3=t~>#0+1d)J_>`mlZbh_#CSPuAk^c*2jaF5Z*Cv zH!S0K!&9=Zr)sX3wQ{bPvvk+fEW`D5%XB>}XHBxzEQ_sf71-vjY4^Ufn6r#NzHk<0 yw?3+=BFTX(&`Gm~Yp64W4gLv8ndj2r_!3`nq;u^qYlSZYR+3GI_Sam=;NBb3GX=H) literal 0 HcmV?d00001 diff --git a/arrays/Array_Problem_8.class b/arrays/Array_Problem_8.class new file mode 100644 index 0000000000000000000000000000000000000000..8dbdadf1700fd7f01870960ccce5982888d11077 GIT binary patch literal 1100 zcmZux+fEZv6kVq?(e8b=RyYGz`RGAS^Ik zwL8|sz*)7t$C9B05>>Y)+so3kmA?O|`x|ywV61v{_A(8%VO(g!|Sby2|EhmN%q{z<=NH^67+ivL*kv{R3bjl`11x62ty%X5&HOq_OguwWc zd|^9*lWVyh-(C;gpquMbwY#|}(wI=yW*9zy6uBq_PR4KwIe{TZzNiPQz3$cnN5IIh zR0`ILnsGtu3pwCXmTj3jf91XH`~+b1|GpULfMT{Z0ss}U}zHB{Pl3Ts0o47<&-3`2!^}trEF>+|>W))kUW*&{%K*@d~OleXp z@f19b;tnF8c?ls(sm!3mG0Irqf#)E#0SsZ7FADqyI{ktB@yKqpp~ZjK8hZR!tznq8 zMmSV!nCc~>*BbF~guk&~ginxL~ uQVDaPuJRUQlqp=}O{0H~KZiN?>jv{Bq5olc!^BO&4;VB;1m2=4gz{h9#^AgF literal 0 HcmV?d00001 diff --git a/arrays/Array_Problem_9.class b/arrays/Array_Problem_9.class new file mode 100644 index 0000000000000000000000000000000000000000..4fb79ba25ede09b1c5912269780c4f792c4edd91 GIT binary patch literal 1416 zcmZuw-*XdH6#j0qo127%#->}qBqXBMB-O+MZiSTA0;18>;?&7Zrw?V5-G(jsHJc41 zKI@Aw{0l11^o19FC>?b0o&Sg#6~DVF(-FE4_nv$9ob!F>JNG{O_sLTLi)cth1ZHjD zx9^Xtt7_Z6#be49SFphyuKGK3q*^hrhs;R;J8Ud zkuabmCNS0T`tDcbUd#2ru~|xBx-n?m-KOn(>U`+bf;-+w;7sFq^qN4j;|6P9|Ax1- zBOr@g^?JQjPvQ-vC8l3e8wXx@!hB?41||uO20m%(Oei&zIE}LsX9P|ib+Tp$cMQCV z414H#eHE)p^F%HJku92nZlU(O%H1bZeblqNU7lKAhbV#D8}hd&5Fd?Ofp05qqPF7* zoZJZP_T4pm7`7^rV|dS2K(ocI#u1N=!1wx{TB(`92dGL^UN#l#y>Wj;3^7t_?{W5l!!1Z8!Dl0+!u_A;LHC2q`?di literal 0 HcmV?d00001 diff --git a/arrays/Array_of_objects.class b/arrays/Array_of_objects.class new file mode 100644 index 0000000000000000000000000000000000000000..296a6df60e82d3a2bbc6f352336f5cb5f1caa0b9 GIT binary patch literal 1546 zcmaJ>-E!MR6#mwBEZK2eS7};W+*bX?j)_gnPa$ptvD-AMoz%o_N(d0v))H-FNgi2B z36~5nz#9NF9j;-RWQI=j0DTKCxPfQj=d2WlX&SiM)pyR>^Yfi^^z6@{cL7`j*N|X1 z!F``^4XZQiTJt_z^STd3FBob_G2|ceOA6uJG^iZeK7MEw9J>%iNa=?+H_ZEr$#zTmKQhMy?$$U54Yu)z-gh zbOK+x>$TFdhNG0<-s^@hdmADUzK$`5qf4GG1G8gu-{Hjvl}0IxJjPXm$CbbNgZ$}u ziQ#a^mK*fUylL}C+|_Z43R;#v56q@#_hqqBDd{LMWSW(hxy0?Tuj7o0D2F!h+Gd-( z0Yz+*l}YaAxNpe~CAIh#*KwZMsN3Ntcg4_tL~)v-!zt;DWV_(m+;N1Z@^++-%M|(! z9}avW0<#`EKDTugspggNi%sELzAzg$w>f1n!EmS<_AMa><_fp?W(KdKqG9s64tBPN zfpBuD;x+1?7X}RDF%#0Owu#n&$Q9hFX}C&rv7hsLC@BIZ`v%o}t1lek1||_BT}ym! zW^n~?DTc3+*Wy70D~oq>m;$vn%?AT2fuT^GFTG&A7pbP>1|@1vMb6(oQo-;Nv}C{ne7 z>QJ8+BE|i6TAi^2)`IAwjfiynH-lJbl4|J$ytlEy2hkpCSY^m|ywLB7S*ezFd}iN& zprTU3Igo4mYXAxQqD7}uBUGiE(LFM;1O10couyN$0Ry9S=3)c74-v}XFpiLf9_qrg`1C5X0CwV_b@1CVHDSUWs8gf}=)B!Q_qaQU4L;C%Cd=yuO1s3)^_x zxW0{PV}_1$;p$IlDA8>tn*T@Cq>pXf-A3oD1S^zxzx``hQIv$Ds7@0IoFWPe7{h6p zID<)?r6D(QoA|zu^RRFMLtMm{xP-598Q-9U$C$t`bpM8OM6VfBh!3zr{?hmrA7YgV e{tk2a2(#3$k4c_I;txF5@ClnH-5N;}`1EhZ>u|aN literal 0 HcmV?d00001 diff --git a/arrays/Candy_Distribution_Problem.class b/arrays/Candy_Distribution_Problem.class new file mode 100644 index 0000000000000000000000000000000000000000..0f2747c249ab972f89a2b10aa4d7a2550da623e7 GIT binary patch literal 1001 zcmah`%}x_x6g^*O+M&}H25KvaBSH~dT3T1Sz%-f~V`E`77?K7PnEnWZ)2SJzDr?~} zT;PTc8&?uT`T#zI3!lNYTF*=|Y&0(B{>}OBJ@?!%zdrW?+`*!Pkie|zy5{~~sbV^< z{mlo~p66PPo@aHP%_nZRVYfR9WC3m0d~KF&)7dT=joo(B6Nuck9Lp;UNZH)FfL!Ue z+A1VO;|L=nFjlji_G+)wXuHo$HWHYqb(^NWZn~DApBH6s$J!If)c#9kSs>i>Y0_sm zs=2C)aU>N?{GmtMcIkewPaKz!BB>XaZIdeD)!e#@%a~FyDKL7m&Wh>n#Bl}FT%=>Z z^?MUr6;NE$vz%>m3vKwRKiXE9t6i0~*->+oCzuFQ9OAjTV9V-yPd&fq#Z+`}Tf`H_t& zD(^>K&h~3E=EyCLSo9}G6=Xyr8X8NChkhU?qGUVIxx>pmCpJXvycRiA>yj2X>asRx y)Wh16QIBX9qpoOqqduZNHfk4#Q-e24+@cupP7ix<=bP-6VecVt!M*%r=Y9h!C%={e literal 0 HcmV?d00001 diff --git a/arrays/Cricketer.class b/arrays/Cricketer.class new file mode 100644 index 0000000000000000000000000000000000000000..4453e48988f85b006512a2fa9550f7ed9f2c3534 GIT binary patch literal 427 zcmZWl!AiqG5Ph4(#>TYOXshC-$F_($dQb!@2!*1DO2AXt#IxLvJQ5ai{6q^%w?_5C|z!^N7-EWG#2A<&)Kx^?Vd@ z45>VZ1qM^6LeeD#O2%*&BLaqNZ~K61!C%QTR=}) zR@zcJCt|pS6#b1B8IC1AW{Ss>CUM!olt5p=NyR6^F-#*v8C&W`jd^J)E9i>!s;q9` zDV1XZniYnQvO8HimRyiRSo|bmYszrgamp^X>H^V9%kykXQ-{u?FDtK?VmU!p7FoVJIqX;V|4)m=@PTJqiD54yuS zJ)Dc|Vbs*8%}C}|PB-vO@sNlo^u6Q+l`#^e^%QMNIx8>}@IB|PD@-ho zBCg^Z>(q}`%pu2j6SU{))5t!D>w%@vH)!enCW2@LH_4QQe#qx^19<~+VPJu!jQ-@G NBjO$8UnC}krQZ-<&iViV literal 0 HcmV?d00001 diff --git a/arrays/MultiDArray.class b/arrays/MultiDArray.class new file mode 100644 index 0000000000000000000000000000000000000000..dab8ae7ca8025f85636634ed341880e8ba78cc58 GIT binary patch literal 1018 zcmZuw+fEZv6kVq?(`oA<<&Ik9=A{K`6%~OPl(_V$ClN!i3L>qH003E8xQn6fa98v-G(-WH1D#?R!H#7z?^fj}8debf2>yDa{ z=s%N}RJT9Z+VUeFs;#|XXlw1!nJG53PR)rF?oq;VH>j8?GBhda+Jts;&4SfE1dh;zL_+(lOOK>vv~6HDR; PU-9U7!U-NyQm*^~36I{8 literal 0 HcmV?d00001 diff --git a/backtracking/N_Queen.class b/backtracking/N_Queen.class new file mode 100644 index 0000000000000000000000000000000000000000..a898f5df323e3259e6d457f33a39ce1830571c0d GIT binary patch literal 1900 zcmaJ>T~`}L7=9+Zn@z$(F*Nimp%iPI5BVrnD1}m56dMds3{Zg!U0|h)A&beT>OHsq zfLbr?6*t`IvEdx6-s=zW_y_dTAK>AL&rDW|f}Whr&b<51JI}{E`_rG_{s3SQOC~}B zr&sLN5B&-Ux4hmv{oZWNamprifz}QCk=i8AM-W)cO5;*gMdeP_0^}98{E0$#gz*EIFt=EO(^kj*LL}Nj3j>XU@W_=oX0h zUIPP-O&>pur}W~Qi9Uh06UbZWmy`^pt4w{(!t00$m?~1D#>R?gSI9-9)Re;Ie}hgG zeKydPy%jhYcB@7E1Ns_~mgMu9CGMzrA9GywN&-z)uk^^7o}Kqyu1uAbS&Fem?phee zh@8D);WozjHpu1PbcQ{9Paw3Mk6@BE{q23{n&(tI%bwrqeBxGp3B4epcgaH27EU8! zVvs$#X}cuRo?bqtrZSC8KDZ(@S!c4eIn*mgoTL6kodh!wqBW!0H*WfNP$?dg%y z;t~tVo541eUC*bbiIEY;1fQ|&9;~eS3@u-&yjG4as)7cczbNM~F=jQg z5l0(Wklcbw->5ubOuMy%8`|g&a$lqUIg*R104#pN&FGwjUvObm-9i!Z=+e^$?{a5d5C8W1AI??a0@rc zHN@OL3~{F6CNo>0@52!L{A67HL)E9@4F=*Av%}2U&<6A!#ECee_vl~3&~~?Vkb=dz)#6#oF(UTxW@S%q%cWU=5Y}ZIDd#PrNL+e^`QnEfd*tk6{H4oCbKmD z)|DhISv{#a(nkTw(8`-}F1YnDC&SLo|iI*?&cWzmitKSAA$^e}RroHO+C z<`IvF4*3lo@*7gDLhOwm#j4?P42CHUP8yOq?@~bFGg6R|LGydOwWyij#fpo%8Vxmu z#m|1D zDP;pjz~<{SF+d7W Lp1`|Yhp_k;$4gMy literal 0 HcmV?d00001 diff --git a/backtracking/N_Queen.java b/backtracking/N_Queen.java new file mode 100644 index 0000000..696068e --- /dev/null +++ b/backtracking/N_Queen.java @@ -0,0 +1,86 @@ +package backtracking; + +public class N_Queen { + final int N = 4; + + void printSolution(int board[][]) { + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) { + System.out.print(" " + board[i][j] + " "); + System.out.println(); + } + } + } + + boolean isSafe(int board[][], int row, int col) { + int i, j; + + for (i = 0; i < col; i++) { + if (board[row][i] == 1) + return false; + } + + for (i = row, j = col; i >= 0 && j >= 0; i--, j--) { + if (board[i][j] == 1) { + return false; + } + } + + for (i = row, j = col; j >= 0 && i < N; i++, j--) { + if (board[i][j] == 1) + return false; + } + + return true; + } + + boolean solveNQUtil(int board[][], int col) { + if (col >= N) + return true; + + for (int i = 0; i < N; i++) { + if (isSafe(board, i, col)) { + board[i][col] = 1; + + if (solveNQUtil(board, col + 1) == true) + return true; + + /* + If placing queen in board[i][col] doesn't lead to a solution then rempve queen from board[i][col] + */ + board[i][col] = 0; //"BACKTRACK" + } + } + + /* + * If the queen can not be palced in any row in this col, then return false + */ + return false; + } + + /* + * This function solves the N-Queen problem using "BACKTRACKING". + * It mainly uses solveNQUtil() to solve the problem. + * It return false if queens cannot placed, otherwise, + * return true & prints placement of queens in the form of 1's. + * Please note that there may be more than one solutions, + * this functionprints one of the feasible solutions. + */ + boolean solveNQ() { + int board[][] = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 } }; + + if (solveNQUtil(board, 0) == false) { + System.out.println("Solution does not exist"); + return false; + } + + printSolution(board); + return true; + } + + //Driver program to test above functions + public static void main(String[] args) { + N_Queen nq = new N_Queen(); + nq.solveNQ(); + } +} diff --git a/backtracking/Rat_In_A_Maze.class b/backtracking/Rat_In_A_Maze.class new file mode 100644 index 0000000000000000000000000000000000000000..39fb337a4793afcdf2e8ffb1914873d4798e3dcd GIT binary patch literal 1911 zcmaJ>+fv(B6kW%XEn@_v5U#O_2{+pi+;VA~kkAmw#f`y99H53yu>ggN`oh>ElXUu+ znSMi>mn1KF;ic(}=`?NL^3wi6KcSz{VcM=E3quO+*piO+*=O&y*4|sc{`J!v03TsV zgGZoi%~=1+F7aj+Hsf~nWcNiTFw+`P8QdV+@evk0I@-`qaK#;BZcREo ztYZAO6UQ!@Mt)L5r$GB5!?exK&8s_BZo@43afUp@0dycF8Fe#Cq#DMNqv|{vU6dYS z9X&WlSjP6YS=b<*NFsX7*^N9YPxQ$X{Q~Dtiuu1M2X#ac74X}|Dh7emk>kmjWeDdr z3=6cJKwig)q~vvUt%Jb(I=t}7L!&yzWC1m2FGsbNaxup{C8s17uPs(2ZL@3UjBU4$ zKC7HI?z75%S(-#5y3C%)vybThkk=!DI)-^*%HBFC;If8^0Fz(UF@sqKt$8fi7E{(& zW64@C`*B^M?Vtt18%48R7_`IYL#u4d7&mpC!h3S{sg4V{=%lxZzAdtHOi-t8jISXj z;8{t?V|R2+;S(M+N}KG+mJ?12SfW^L)pIinm>R<3+p zb1rzV<6E3h!KXL2hrst-c%ZvZG@^lPz3PBQH1Q3RoO}33sQdx5%H@~1s7$>?|0^`V zMn|T(YY)Mp;Am*1g0szC74%jxP(kdmB0{eafByIHbgbZm#~u-M-rvgHij%vW@W5u z9xRN@;v0HP7QMlz2un0C&>4D)RtfY48XXquGkDcqWtVPMkd2P2?F`j{vuHm8s<#HJ z7n2SshQ=ialw4h|fl?rP7?8Dgk$g+evRH%6%>P?l@yx}B6lJ)A>F>}$$(pZGL}fQd z%MJAqO&4PVeW=F(zcz#D=46H`Qa`6i$`!7Ltsxt9k<}yU2DU4jS9!R5isw}mdQg>rR!B7Q>Cm3^0G^p87r%DD-q=eEz%^tox zZc0iys_m%L2IDwG_0F-JeJs@o6`Y_@Gemcd*wVZ&;08X&O?-h{4$JW>&Kk>XP5*37 z|E#M&`8do~hq(`GU%1K7iMWNN%lkLBkSs?2HAH3)b4l$N%x4ts=RihLQyG<)S52ie z>c1=*pR{^UwE9l6&JDl$0r4T0^!C!>1P(akd542~m*q=ShI@pzK-hO-Urpoi-P?s%~H4;EBd;Q#;t literal 0 HcmV?d00001 diff --git a/backtracking/Sudoku_Solver.class b/backtracking/Sudoku_Solver.class new file mode 100644 index 0000000000000000000000000000000000000000..2f49fab55a8f17a34b559ccb236131c36e0c8180 GIT binary patch literal 2183 zcmZ`)OK($07(L_rw0(h#gL%b)@F=yD;_wWVgai^An%2aCX~1OB+&C9{!LcL92C~m@ zsFWR%DtVJlQz=A!Z7cN;v?^Uz>H>8|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#0sBb coR~c&G4g^61$Y#Zbv(0h)1u-Qw<9S22QN2}MgRZ+ literal 0 HcmV?d00001 diff --git a/backtracking/Sudoku_Solver.java b/backtracking/Sudoku_Solver.java new file mode 100644 index 0000000..e128705 --- /dev/null +++ b/backtracking/Sudoku_Solver.java @@ -0,0 +1,72 @@ +package backtracking; + +public class Sudoku_Solver { + + static int N = 9; + + static boolean solveSudoku(int grid[][], int row, int col) { + if (row == N - 1 && col == N) + return true; + + if (col == N) { + row++; + col = 0; + } + + if (grid[row][col] != 0) + return solveSudoku(grid, row, col + 1); + + for (int num = 1; num < 10; num++) { + + if (isSafe(grid, row, col, num)) { + + grid[row][col] = num; + if (solveSudoku(grid, row, col + 1)) + return true; + } + grid[row][col] = 0; + } + return false; + } + + static void print(int[][] grid) { + for (int i = 0; i < N; i++) { + for (int j = 0; j < N; j++) + System.out.println(grid[i][j] + " "); + System.err.println(); + } + } + + static boolean isSafe(int[][] grid, int row, int col, int num) { + for (int x = 0; x <= 8; x++) { + if (grid[row][x] == num) + return false; + } + + for (int x = 0; x <= 8; x++) { + if (grid[x][col] == num) + return false; + } + + int startRow = row - row % 3, startCol = col - col % 3; + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { + if (grid[i + startRow][j + startCol] == num) + return false; + } + } + + return true; + } + + public static void main(String[] args) { + int grid[][] = { { 3, 0, 6, 5, 0, 8, 4, 0, 0 }, { 5, 2, 0, 0, 0, 0, 0, 0, 0 }, { 0, 8, 7, 0, 0, 0, 0, 8, 0 }, + { 0, 0, 3, 0, 1, 3, 0, 0, 5 }, { 9, 0, 0, 8, 6, 0, 6, 0, 0 }, { 0, 5, 0, 0, 9, 0, 6, 0, 0 }, + { 1, 3, 0, 0, 0, 0, 2, 5, 0 }, { 0, 0, 0, 0, 0, 0, 0, 7, 4 }, { 0, 0, 5, 2, 0, 6, 3, 0, 0 }, }; + + if (solveSudoku(grid, 0, 0)) + print(grid); + else + System.out.println("No Solution exists"); + } +} diff --git a/backtracking/Word_Break_PUB.java b/backtracking/Word_Break_PUB.java new file mode 100644 index 0000000..5b48b5e --- /dev/null +++ b/backtracking/Word_Break_PUB.java @@ -0,0 +1,41 @@ +package backtracking; +import java.util.*; + +public class Word_Break_PUB { + + private static void backtrack(String sentence, String A, String sentence2, ArrayList result) { + + if(A.length() == 0) { + result.add(sentence); + return; + } + + for(int i = 0; i < A.length(); i++) { + + String substring = A.substring(0, i + 1); + + if(sentence2.contains(substring)) { + String newSentence = sentence + " " + substring; + backtrack(newSentence.trim(), A.substring( i + 1, A.length() ), sentence2, result); + } + } + } + + public static ArrayList wordBreak(String A, String sentence) { + ArrayList result = new ArrayList<>(); + backtrack("", A, sentence, result); + return result; + } + + public static void main(String[] args) { + + String sentence = "I Like mango icecream and SamSung Mobile"; + String A = null; + String[] result; + String[] dictionary = {"mobile", "samsung", "sam", "sung", "man", "mango", "icecream", "and", "go", "i", "like", + "icecream"}; + + System.out.println(wordBreak(A,sentence)); + } + +} diff --git a/basicProblems/Armstrong_Number.class b/basicProblems/Armstrong_Number.class new file mode 100644 index 0000000000000000000000000000000000000000..f8e502ae80f448266d96c46605ba1c013d001140 GIT binary patch literal 1055 zcmaJ=+int36kP`fh5~IVl!{7g>lJD(wkm3AX{)3O3B4p365~TNOeb{eFhgbrFJI6% z|G>nzKHCRtH1Pxc5I?{VP}dAdYtl#pXJ5`)d+oJ1-+z7i2H+u{$Os5bH5Er!cWkR^ zXl)GbwxXK?6S)_)Q#N(i z*3DKa-;gmTFy<$^u5J|Ss$!a&J%kj}GRFUDq5jr!wRRj6xF8VlK+`=)-6~YgPS+)> zrnE~@ByiDd=aN7sckY#Z!@HD?V-iyWvZ=jst0vW4j?XcIs+#;A`PlI7ioBpt(n8#fi1%Z@b zi4C236vqM<$+F|&7+%}`ru@MUq>SLc!0?vkP7mOzzGAmHr_?#(Q$t5(swdD{^*J@c zGNQ^}oNiknX4!g6Hx*;ov;?At;<&qejIhn&x~r%!Ho*yH5f=uo9CtO|$ma|3a2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P34ZCD|z*X zB=LgR@(g3yt{18+h9}<3l1HVey(O}KgVvWo+tk0mKqgl3h#Iv=jmr3Y8J2Ov3?oG~ zUKK^(v$=fZ$OBr1l6x{#!zh*JJI6t~BB?~Q4WG!=RW(;BX)(S!L<6g;nNJyJE?ebz zM}AebCf#Jw?CG(A0zIEi->)|63|2`^ujukH6h!S)dxaK8b8auVx9f^qXY{30 z`a$8Ne(~kv=Lr%M>2nysDUu3Vi;$<0jPNz`y@WqRWYR<@Lw=5`EmOTgibz4bAQLw* k#0+Tky6}sxVi=B~uHy-Llc=pBkH;9tP1+}EuM|!G0c+YBD*ylh diff --git a/basicProblems/Fibonacci_Series.class b/basicProblems/Fibonacci_Series.class new file mode 100644 index 0000000000000000000000000000000000000000..7b7260cf337a8956b3fbfc7b847931f68bbdbdeb GIT binary patch literal 1344 zcmaJ=TXzdl7~LnCWYTnyrX7lwxF@RO8kcBMlvHR*#lnN0Oh*mLBx^FUT$TrxM}CAS z&pf0SYxx1*{2}Z!i54xh)|okHzVGbs+xzVE_4}tU0FL3Nj*!5XiflU8j90Hz?OHQC z=~U{jv@GXt$@Uz(sY4S;JdlrMwkq9)>~!UUZTSMxQ;zHS;{xGyrYxYHtIykUgwbOl zf~df{qT||ETeXVq%}PQGB#U)RR?E_J)Vljq^Y1%NfmHGTUF2DzCLLE`efmyuxto&j zIqpI}Q`XTZ&=&++zEjPXEa|$o*MokTItKorPprqvaFT zmbH8w32an!HVF)-S53*3Rnm}wVQdl5UHh?LaH$SODX7{h1KY5j>w1fSm&?qs?O$bd z>=fAWH>Zh~Q=PZH7msn>=|xj zZ*qSd2iiE?#<5?aQw*8fidb@-IpJL79Y%*uZ7vt>=9|%vIKwT=NRy^EZboz3tB5co zLy`HnKfWmvVJH&0Zo|D?B}m2O`T*N6lE5tba2rX?@k%|#0G>1Yg8yD)Fd%)YLktB> z5vdn1ahdyQ4Q5`!RjQc8GfZ<9=FZ2M;Y`C#`t}-U5#nycbaFGW?r=op1vI^rC_;go(N2(iOtBV55{;r$~q5b+wod zpof+kOA_;FXJz!_mV`crkauijq=J4#8Kg2#W)faF-i%JdAVa4Y?^2CZIZd@J-R96k z3T|VV!N)ImNtdz8?q50?1GvjeJi-vE=O>J-TM~J`DXt)aB;i>4CnsakbxEj zdxv^0)TC*s<`s>WY7|#>p>AWO2FuWAPz4;`yu1QzkD)E+sM^OBwOsFJIahLRO*N1lIsVAX(^L0zMkiyP>~CvlLlIR!p8C@Woq}>Ccw|0XOKc)HaZ9qgg9% zqMbZE_{>WLygx=qu)B)LDF!x<5j(-1>}VDD=7ohL%tfaKVOl)GFzq_U=tfuwi@RSj zeuAmsqbg>qNLTUnKxARDLq5FtMcb-aJn*w<|KY_C&g2JYn($}>2#^gCO@v6I)XOoN zjnHdbBD;caHec dX(UoU9wnS3Dq(=J-v}@^c;*#gm6m*1`vZT1BeMVi literal 0 HcmV?d00001 diff --git a/basicProblems/Palindrome_Number.class b/basicProblems/Palindrome_Number.class new file mode 100644 index 0000000000000000000000000000000000000000..3ff500e28d48f4da92593d1fb65f9a5111dd0b38 GIT binary patch literal 422 zcmah_O-sW-5Pg%Tjg8f6E4@l@RlyuRRJ;hDf)*;hc#uiD#4X7NHmU#1li(4;x=B_ltqGlTZFGG>Xibh51pl&Jst_%7duXFW=*QZqjl?aBHenE#Dd!8e+U1`` zzkbjaVI2QsV=7M+tPNo_xr@K-%xkMnHf=1h%|vSWN1G7N%e76_m3B@>zqUMeiWo!I zk-q^vxyc%WfnN%%J_qb6sm%fG^s#R(*#_Q+hKwi+nHu&YIN^Y zxO2r?7A29y2k;$y1E0W!cGCP%Ca;nY{FWUyMSGgmked<)a*TQAUmj6qnKp+h+EQX=ntMVD4 zisuMxuaK{*=x6Bn11(R~^@_nQ%XA_bKtjdfg)S=ZUC(T27($XEAd4nCC55e*tY*uj zswQs~qKIKwb~M6}%3Ya~ugavfhA~`YP%ZPFSF&h8G?$XZ&S;pxb+YXidCy>I*47^w z6_X6fe|uVKiTbYTgfYc1P;xUo%(QDl*mO8Qohn&6-Hh(g^bx|J{cw~{83q(|)2Ve5=(Yb zi1A}&x8gUBaC5AU={9EDxF^wrkm$2MZiG&`XBy&!nL1~4cYZ6IJkx$1ko@3O{ zp6f87-+X~8bfbVrSR|e?(xiYTYCDcOETc#m35?(|`4l{%+$59}Dj!nuR7H$2>bzU| MN#z(;C>+4*Z+p`45&!@I literal 0 HcmV?d00001 diff --git a/basicProblems/Print_all_digits_of_positive_decimal_number_from_right_to_left.class b/basicProblems/Print_all_digits_of_positive_decimal_number_from_right_to_left.class new file mode 100644 index 0000000000000000000000000000000000000000..02dec175e63a75f1c5684691d46512cde4825b18 GIT binary patch literal 965 zcmb_aOHUI~6#i~o7+MBtDPUC|il{9p<743hVMAilqykAz6XRlXJ6y`ec{DS(M1Krx z*Rp^_6Muj|#(&`Bn<)`Y*y-k+dmi_E=X~dU`}z4RfaiE-At%u4%0zp+an$uykT|=s z4vi~)-`&$aZ4x)ycl%MIjXqNDp7L}ceK#BgT@}0gaTK_*?j0D{M6R#)jfH|h`A{B7 z$CqKx+36lC&j^gZ(4jV)0{MEQBT(3i_EZUZ6m5)PRA92DL$#e%eJ$CDz*H;pq~DRT zPVIAN!5rvBVEe!Jyv}|CsY8L;`rFn;?`=aWdh3mjg^EBW3k;0*owg^#P{l=5F=Ju+ zuYubi5~Bhev$!shON-77OX|pJhW&wIRV9P<63V!d4u4aiR=+Z((Mgl$Y|LXpzzWrS z(+tTaDQu?Lw{6_P676U}?*&Y@!9Os|xNqT}KsD>1U0e#=c!0XVNI%^!-^*RiB%vl(Kgb1_e%E9S66CBgV<9qb-LWGf4j1^bQTUz zEFLnDR?Fb~xm6m|@qQ9>kB#}yE z0+Rx>4ehJfF~mDbc!6xA?@F&F18wXJrxhLOP@vTKzmhGo^rZF$3gr)tv7%-aXurEv zY1x<)n2Q6$NPE?$D}7%DDddp1G5=2)%`ai3dTA7JT_9mV^CL*zuh#v+Fe0jwy)6eB zESi#T2rQJZ{8DL|Ps?en;HH4>tItv0XNTCBy5YW^#vK%C_lNY3Y4#|4OjE)=8+QeA zv3{z!6i(wl%7h-643Ao^ay@Rk47zMy?uu@(sL*9-r1)|>*hWDJQ72$98n}St$uMf~ z>#nB6nPw#2PrGt(F(aqh9|o>^sm&A@uUe7~BbrsRNNyL9;EP+p)23DBEqG6?onq>H z9Cmn`FkoStXL|I3_YAERu3?rQlYBo!N8F%-o;9zy1L50QW5z0*hT4X>TtKx;@p8 z>aGg4iuT>4zrSh06mSmZTUqZ(|DgV?d#JovVDh2%b^KUhqFU<+m`{RNDvJqB+sI&2 zV79G&^)%^sRrp*IR-n)hJlX5WP^aW_gqT{GE^)`t5IUUL2utf^vKP7?&R9n)Z(Q8BWD6nSQrf zGVSh;Su&SCeEf9!>j=x0W2~lR6G+KcFh!dsS&kc;L4gEio|frvGup!3P{`JZ3^lB= yK1aKbTa@CU!nzH1R=_GdxM)fq$2{R933 zUAS<|S{9IK;tz1`*1sa2HzffQT+F-ge!O$ey?1{7{r(fcT`XHL1SUH&^xXBJ-|4De zSa($5sc^%IdmD=uOo9BCd?)K&>2KDbb+(in2@Ku$d@p(+kg8PM0_Ma1E0sYC!#2_w z5*TTDzIqz>Ix2WB2`f-+^;DQ?iQbc*FECzt**a32oq1NKOk{eMEBwS1rs5 zj3)Z2;#k_oHB<<_tzUGh)vPpY literal 0 HcmV?d00001 diff --git a/basicProblems/Swap_two_numbers.class b/basicProblems/Swap_two_numbers.class new file mode 100644 index 0000000000000000000000000000000000000000..431db49df4aa857b184f041fbf4121fd358e5470 GIT binary patch literal 1142 zcmaJ=YflqV5IwgoY+F_-g#u#16+~MQ>H|S6pn`%;8pYH!A()VDx!{s^x7po_{w(=W z5=s04{3zqOEm9uU4?FiUbI+VPGkf~`=Pv*Yc&8yCFjg`>tGwwtrHZV2nZlu2+wl*b z9lKsFN!Qa55{Mm`U(HO#wD&U~N(Zv+3v@48w&kw~1XJmvKxoa`l~Du{(b0u&f!@4j z%lA!;PbQ%S;(4cRR*I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25p&Hfgz&hIH){aTGPavC*l(I8WA@bF>JO5 zh$v%)-Y{1A-yxp@v#epA<+&`@qm^ckdEBLCVFpFqqm{vZ-kLz_jG?TJ2Q~_VpFtOR J$XE&+zX5U6xo`jg literal 0 HcmV?d00001 diff --git a/basic_idea_of_DS/ArrayDequeDemo.class b/basic_idea_of_DS/ArrayDequeDemo.class new file mode 100644 index 0000000000000000000000000000000000000000..b66c5596da870a44f65fd8b5c25bc119ed82f1df GIT binary patch literal 1292 zcmah|T~8B16g^XlyRD0q7K)-mLB*CzD=4BAQJ~;g`OsnwF-oTG01It*X?IEZMLz38 zF_IYHO#BbVKVsB7+oEkD@#Wr`J2Q9BIeYH6U!Oh$m_$Z_i(w$kD|&82&kMd`Y;Gje z@!4{jA0)+|Es~;WC~!0QcKAMz7kFtazLMP$Ig8=Uv|iG!8HToSB*WmIH}b-ZHh46& z;|xP*N-v3JyO-PX2VVHiyP2S$QEQRI4wAsBw0`UfX% zmG#nAB0^-k7`mMU+tLdSEWGf+qoSLE&B}F9Lod!#Khv&kGxUTT+SS-mI~9F&e@?|E zO7klEDJ4~eC@pv}gsTd!H0hE)s92(?;TncX6T>EndTNbzBfd%?ErKd|F`*(%TC5tT zNx(zawg^=$p4*-BVgxr7L>U4Oi{@tWk?Uyb?3ir6Vn! zu*A*!aCp;(UCxO`U5-znc`jq}H)9Y4jiwoJ(TWC-qC&ekWk$JunAE=@y>c8N`i%z`k!~u#QFzCNtMdTfZ zXnBPAdbEnMFPQj<$wMUk_p5kN#XQ}h`lGMEztgQMo=Q}1NL1s50rX|nLE%L=;p?MX zh>#5vsu;R320vCQzoOGO2s#XcHI!JwGQC%k!3y1BcuqUXu2y+Lt29+SaQ(!X0$)EB J)~MjZ%Rj{BE+GH_ literal 0 HcmV?d00001 diff --git a/basic_idea_of_DS/ArrayListDemo.class b/basic_idea_of_DS/ArrayListDemo.class new file mode 100644 index 0000000000000000000000000000000000000000..b7ed0945140779946c491e977f6fa7a8c52858c9 GIT binary patch literal 1352 zcma)5T~8B16g^W4yREB~7K#W$@w25u#ShRHRG^~O@}V^t^npy<0herdo82u5y!ki$ z2fm39C6UA*;Eyui>9#L82x#a; z7ejYmH^p+TQWW+FUNi(lIB%7>vBqs(=FLUF`$cycV)=_vWax$p*G-0K{B!;oO~JKw zb1RcrQ_#Z@X>8P7-8kkDL$sw#p&wU?g;gU`eO_zbO07~~m%0mH z$tbwS(0}^U`I>H&g{@+UF3yn_IyYjDz9(YVW{ex@AOxG9Y;#RL`$u9 zt{U!3yh>HlH%t`|7}%Ty`bfiLOc6p}COB<`JWFH}pHw`d<4Y>i6qZ%YP$;M%llYuT z6)zYD3r7OQ_@*oD7_}qmEYnG=m?zsTSf(pX*EykLR*LbGVf>_utxGQuC4^TRUQ5tj zHaU4msCaW8gt9P%2Z7#!+gs$v$T=n>7Th@UNW06(pV4-E?^atDZ$3hM!OR)lnP=1_ zSg>k#Ni6D(foU7W328u#f}Vh;7x2*^O&Wa_%2E^=#m=zb%paV+qS7&kAKyIB#W@{utiTnh)>) E0kEn-`v3p{ literal 0 HcmV?d00001 diff --git a/basic_idea_of_DS/Graph.class b/basic_idea_of_DS/Graph.class new file mode 100644 index 0000000000000000000000000000000000000000..3a084b9adc3683e9fbe89ea2da3467a353832fd4 GIT binary patch literal 1775 zcmZuxTUQ%Z7~LngNy0#Y5TH%crWZ?~v{6*54MnBU5>25tNTs#nWM&8hVUjhOu=Ksp z{)ayG*)AJgvh)Y|KYaBki2KZh5?pzh%ej2}+uz>bIe-28`=0>rU{66nV7#ieEPdND zOl`Zdv%Op?Jan|?u7Z%j@Sb+473!K@E38-dOx+a-YQ~f0{ zeAfU^>Wb@FcC9ESymiXX^RJ?7wrx5w6!3w9_s`j0`Kjfa2P)?9p+G=_rhFz=qfoM& zZI`H~c2JCC79UHS=BZ?t?Ekh*Z^{gxsQ46jSy!XYZaM>dOme4SQ7i~tU14iDIotCu z*VxG&nvQGfW-F)JM$V+1>zO2MITu5 z0LHz$<+fB3SC~D>i-=(I(DJKr6hM@-yhk9}4RGdXguH!IGe=No(tjZF79+uXuaTVj z6(gBrB({!_th@|}O#0QyKff>}h%vq|5)=dq5k|!zMlgg+{NBJYQe4UTuo%Y#N5B*& zae+yP_`S%#0MeXIAaKIapaLO;9MVQ)yWDhck~L%{mGoTZH(cuA`cseCT)I1wi~=5` zA#Zb%8O8{b>S2+6$0Cco$AX}k_E^L)gPVRrF~w@4#M?i{?A9CHKEg-kH@Gue?BL$b z4(@xe#bb!A%n=^m4RP%lrLEDgj_@ek!TM;WgKs+cmfM5#;nzsZp!taRRxX56k(AQG zcQ3;t70$jo`J40Kp9wlo@j!6~C{L2&OnOROqHve7L_b$~zpddKHgFv;INssP9?Owp zKk;cpLzSZewwexuMNOi@M~aE#V0hA$rUcM)B+!m-eh8 UqM)W=RtRYm7%Q;LJONn$0ZJNt5&!@I literal 0 HcmV?d00001 diff --git a/basic_idea_of_DS/HashMapIntro.class b/basic_idea_of_DS/HashMapIntro.class new file mode 100644 index 0000000000000000000000000000000000000000..3b83041766b05ca981c06b63d7b47ddc0d0acbff GIT binary patch literal 1521 zcmah}*>2N76g^V{c7lO4-JmQrd(wrlFHKonmO@GkDS-k~G)bq)Kw?L>6RG?Op8*dk z0txZV7x91)cWkFPl;vf%yPb3H%zXXv@iTx+c&VX};b57&vQm<(f|u;I(p({XkGr)6 z-ki5Q$JP*INWS82o~?7Mnq4fv5*3eO$BeY3ca33NI#Xnb&DyIXfo+Hz*p3|xd-Bo} z4_l40aF%(wE*MgIyTa>5?nt!{4`W_Ux(s9ae}c$Sfd-cr!*KdV{uh{n=SZuX%M>;A zGxYn0mM8071_>k)*D*+N+tRJ^dIH1Pt6`+;>{BA1qADB%`!LF&wRycI7S~j*`Ano( z=$2DS4;VOzLqxvWA}ubbBW{5}xveMBT%nT=lc2f0Qj?aBBYtsNuJLvp$8bW!@gC_5 z>#ipn22LVPm2FjdC@3TC>=G&Aksg9KavH`NMt+y+R!i1bg`;DV*cap*VcKhEgEvj- zPEVN$WN=FLE=yUXd^R;!yw4aoi*wWsm*V~2&#S--1}@?fQQ^&|uvQrk^hy`x2mz3Q z8C)?i4Qi|I*@2N^FdbDWEStbpT-QMNY{2K!%hbRPg;#4T@^wo&-%@9@zi|lV&J-1g z+Xn97F2l}>ZFzL5+y`R)FaFP!|Ga_wctB*Uf)qay)ux+wYqNDMFpT(+QqROd+0<3e?!bq+Wv&($_D*H6RCk@ z;sb^{*#C4QHI_WIxjvj64A<{*^b;~Gsfi6tO>}U&gYz9+?qG%tw7*F?I+%M)8@0Ii z1;Y#7kUWJ8UXvh6A4xKO#5=xUWPNE;TkwP9rc!Cj>uoo?i`i#r~H6GzH qMeDFoz%p?v(HHgvMUv<#oh#mf?HR3Bd{6crEsZWN!*kmA;l)pH{B?5x literal 0 HcmV?d00001 diff --git a/basic_idea_of_DS/LinkedListDemo.class b/basic_idea_of_DS/LinkedListDemo.class new file mode 100644 index 0000000000000000000000000000000000000000..97d57f25a22dd5ab5240e7b8ea55eef6846757df GIT binary patch literal 1826 zcma)6ZBrXn7(JJ_UD8$3q@-_B7OgapwvlQ@38EB4(E!!dAVtMZaub$rcH?HlOvhj0 z*ZvE2W^wF{$g$bZn<4eI4%!T-oyNhV5F8S@qmNxZao?Byb-KDyPgqjNys$>c$5K zmhd5~!fLgoOIh#qll2s_$h#LoK|w4Vcz_iu8hDYB>CDcYbK%{O@ri~tfpnKpoT`CO zRis)=v3Fdh`ez0{SNR_CS9I2z|J%}^FBxs z)TB9E>NI8IY)?M1XL*P)VNWf{l@BSmvRj2vR!a6IwI8qia3lv^VLz(E} zE4uiqCh~kqU9X5u+%R!{K`ZZQlKP>IEo`%EJf&>)tXReFYmSg|5MPF!5^kYsq9IV5 z&$5`d(L!6mJk%8d#aK#RFF___idkDCl|U{C$UbZTpH`IFSzON1;ok+dmR9VZ(%@tn zdqgRD@iZCw&y?PGQLkY~&qHlEKffA~LG-%?9DO*g!XQGEm&c9eNgXJ9D0Q>1i@qcLi`L&>qe*KtB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b22m`o}GqhZY+2kOHE*^T4_~f{;x_3?SK?ILvo}jg|bl+n4nxEfm77D zbLhb`B6x!+iiqKWhUE(e@fAb(j*+@KG0y-xlO-Gl->`}`vS*z#X`HvRL4OQyY0Zas Fe*vy1KDYn? literal 0 HcmV?d00001 diff --git a/basic_idea_of_DS/MyHashMap.class b/basic_idea_of_DS/MyHashMap.class new file mode 100644 index 0000000000000000000000000000000000000000..e3e28bb52166bef5029ee3c631841dd6bcd72e78 GIT binary patch literal 1512 zcmah}*>Vy=6g?f$8OW%FY#O(5hitenA+Cu_l$a<9F=`dnkPfuM48;so;h*>!`amqL zvV8W7e6TEU&kS)eTE6slmpuQlw91)OUc&&x zfM;mBvYHN%#}G$U#}Hv{NvFcAF^u4VhS9FG$7jKEMOicq9K;xd*5cKsSlU!~Eu=!1 z1#TIY^ss>=I7-axO%mc-GUVo~li7I^&J{T6FbSH&OBHG9IN@C`ixu9A;uOwkINhUr zuI;#@X5cK6bhE8)9`>)1c6ynVa7horYZ(pW45NR_bhjz18=|3OlGx|uTVdLpW{uZP z>C8--F{Ci93YVs=VLsa$E8gb~T);)DhC}gQ;TKfkWdm1mm8kG~U054b%wFmI9033l zFoo*|W+#ehQxl?(? z;hur}c)-wKvMrY$mGfA%|Ka~a`7aoFgvUg-EJ*P)VQsp3cNSa6BK4H_l*~=LVZIS< z(|>}$18^*SpO* zvoq0bh;2}%&`GyTZc^60IhU8-&<_%HdMsx*8zpgHs=r|0_Wv@iDvRSF@bn=8eYBzv zghq{aX_^_$yT`YnzxT{B8kHFo&`+b`JJ7tBc2VrZemYUX-x2YWwmu`izD57fL}D-= z`-tHV4y{cjj>V5|uaC!vg7pWS{EXCkVqyzZ6CIrE;8F+II+!H`?e9>I4(8v{MlBwG z#mHheBugQa9X#><71{_C+Hr4;LMMzvgwiC8lNi7~B#^~0RxyeK4xouKkCEx4##20_ qXdM=ESRqaY`oC6@CyCbRT=Dj8&uO*pd9oj9YV>LuUeLY|FMk2~XK|PS literal 0 HcmV?d00001 diff --git a/basic_idea_of_DS/MyHashSet.class b/basic_idea_of_DS/MyHashSet.class new file mode 100644 index 0000000000000000000000000000000000000000..4272e4f69572e8b8edefd3c8146bc2db82b0be58 GIT binary patch literal 859 zcmZ`%+iuf95IyT8wUe4Q7h<5aKue)X4K=hN9#U1}R(J>$$tVbTh&IWRY~@R2J4pEu zJ_H_G2_!y%k3!7G0TNMO=DIU;=Is3V`Sm-12e_|8V_50%Sa#d8CwM#j(0<}NFUHS# zJa9##Bg;@c<{!D^@u2SJi$^_GqjLury2 zCDL=I$O|YUZ{R$YKN1O7u4Uo^E)r(m>oHVoGu_g?8ufPuRv2;*z2SfxSf%1;+$ZY_ zgYk6e$ykPgfot^S$QON{#|AcaT%Y5}9mk3AP29juniYBSKJ*BI%%as#U-`M3#sk)r1wNzbI>I>HG6Kttb z8K_YkFi7S}E>dF?7L8e>A)DmcC}9_s2@ES8h1=Mn_Xg!0+#w)$$x{&1$Szq7dlb`f F?-v9Pyi@=H literal 0 HcmV?d00001 diff --git a/basic_idea_of_DS/MyLinkedList.class b/basic_idea_of_DS/MyLinkedList.class new file mode 100644 index 0000000000000000000000000000000000000000..066f04976bc6ee6c80a8aa7d046c07b647fb6b19 GIT binary patch literal 1820 zcma)6ZBrXn7(F+(FG4UmP5WSu0Bau~l@WKr-i*ET>@kw%T_O2ZMdPAuyHu&mgjVpk~>wKx$?; zcN$DS@NKu6oh@h>6S&whGy~hooW>tV0wX#u3Wyc;pE7U>ml?KIE(=V|^q_^*va?Tg zT;=r*9dB^i)N!3lUWX|V%g-y2Hx0ann*usP)@;8)J^CUQbWAI!d&+6Xz^ro8=#;Y> zfsQn7D;>Z)DyqAR-g=*a3L|(2_cY8$GLb)Q1hQt}UA#v+UQ-1TI@@065rqjTkF;u8 z4etwFI;+})rtOrauj2!O%Uix(wOz|GOP(7@H)xn%#dMs-IPPOnWt16+Fg#IS-T27B zGCpQaSoOMeDeIknvi1-Qy}J=)6~u~x2Uw+|ffpK?&Y9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ZLEW2@e^oQL(z-A8uY7f9@RuEQwS1vJmLJcfb%!4{Zm zTYal7{e31`o@X(}zF}5!RXWoDgn5NdkIw_~Rf$5{gg&I!aT)$J4n&KpP}sa6F8 zQ{igHKq6edWDWdmts1hP%(*msA$UEBN0+U=4;uIaX|?zZJg^&M?${&=_{R0_Dp8B~|ZJ)%VI6f$5fSwZGf2`cVO04%T{orCYb1ASX=??--cF#T2So z&|#kPvb8_(?Vf=vSfqM)NIMJ7z-sB%w>;_iEuYr*R&>+_W{#V{ZRtF`Ih5Uw?WOT9 z-q-QoY3Lxsz*Sr$oyS&pXm9Qjp4NvIf@X#|D{0iQteWtl%6R#_x;=%D1fB;Qc87evlw5ILzq&1cA(kG8NWY5euSb~);c4U zO!E-AztSVjK4oGIuk$?{K&E&(%^x9y^Msrw=sZE+;CV3w#Ra^{FT$(eg(aZ|Eh^n) zjw+p9I7FUL?pGwVgZKfr;z5z{Lhb}$b_|%sB|;0l6=aKP2Kp5t-(gh98HN1wMAVrR zsF^Wp<}_-G7?;OZ{SsN#FwG;p{RG-mb0iOzA&Gr=5RWzB1>xg69n!i!OzNNhO7FT}nAy;S=z U`YO?{6aB`k&;{<2Z48^w0h$ULFaQ7m literal 0 HcmV?d00001 diff --git a/basic_idea_of_DS/SetExample.class b/basic_idea_of_DS/SetExample.class new file mode 100644 index 0000000000000000000000000000000000000000..e1fe2b03f0cfef1abf762f61eb3dbb95d5d75775 GIT binary patch literal 1553 zcmaJ>&u<$=6#m9ud+qI(Y?3zA4Q*X$A#ReILZMKnfsph^z)mU|i~B4#F;BcKzuW6J8@O@GH+(*ecyZYz4!Ll|9*M`;0ErSND0g~ z-JaLl_S(|j4m;ax^>SUtx4&__d%iSb2sjVieYfnp!A^Oz`9QW}f$WkOc=578dal$E zFjm91w2(&LMh01diK-XKjefT&qfgzYF9oKmVaxR!Zse)+;G+@mdOd-2)fc2tA$`~N z0)d&iFRMqX)Z@qtb}FTYiAjM;ebJ9SzkJW_?eYZ{9OO-$8s6#r*MnH@$jHJpW^BBS zGXmzm>-XhmNAa(hjs+O_RxF&wD<)=#Lg*kXQRE)a&0mi(#i2@5*BQ zby(EOUc=ia-V&JB`Hur_T*o^CnLWit^1&mL;KQ0(xP}`x-oyJWfcErR;4$B!dJQF4 z#m17-CLhU|y+C<#VE4_c8b!TCmuIq6un%pl3}D@GUuxJYC0p}49T~}>C7%JY*W74_ zEjj(1Rud4eYVEP2u{}kT&+RLr1Z+Nfl#zhd9z|k*jgP>=-f#>qjZ-cq$KwrKS!Nuo z9`>V_yyK~Pnm8KLt12N}1nbGM22$K{3b~p*m1zZS=E@;*Kj>?VtGZU}39feHKzov> zJYK>CzYr|`&_ocKpW$pBa){?0^A}8SrH#ipUEeaY+GH}?WKC^MC#P-B$!qIm)5<lUyz2DBmZPtxn;- z__41Plazw;OJC;t_H;XMAv1^k1eFjz4q{xXX|fw6|$Jmv5& z+3!;RIv(O4cPX-dg>~-I} literal 0 HcmV?d00001 diff --git a/basic_idea_of_DS/Stack$MyStack.class b/basic_idea_of_DS/Stack$MyStack.class new file mode 100644 index 0000000000000000000000000000000000000000..6c05e27007b9c397789d018a61398dce22658faf GIT binary patch literal 1110 zcmZ`&e@_!Z5Pe%}uRRZ23k3wN6{}vMP!R-d5fu<=Qhp>gHRvB?+b(c;y=(5SBzy8h6(+;piG4! zxNg@)1PnJd+(1ah00uQExWzD_%YbOfu*6QQQ5DX6UNr?nykyt7S>cW$&)v(Qq{NWA z2J2r%L@e0ghQ%hH*?#s%FbQCZiWKA0xPj z`wEgh4J)6yo@i)D;Q`fSx2SiC4ys}2_6X7=V8I&&1rHfU|L3#TGR(SgB;+FvkMV?( zH0`F}nxcvfrWH)}0{V4m$YO>;Ipt>d&*F}zx>ib>>Tvq{N>e$}6;gz=2}o!YaT zO;JxBI(8%F$^nrt7c@M_A_>jOY1J8K`lYy%wOdm`rdZbS0(pk8XLkf(7}om|UBRk? zmkdLGi+Y=<;gzgFY07?@ByEs8M>GpVeFSD;A;n_Rl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$oueo&Tb*nOnfP>s)2 z@WZFTZ}s8xV5E<$Idp|*X7*Q@S#b#KC8J#!;P*gya}+uf%pJoZV^)-nA)Muo?+7C? z(hjo~Q}Q>At`jX$&P^O*JeNIyb%@Dq?ihB0YJf@NrpR-N3?Fl*r$dfZgcEZRkvYkb zWds+gUn%B<#=P_VRn_$?qBrQ)_qBa)wXlSq@F>?Iy+4M%9Oel1FEK^#$c;y_8{^p{ zO#c)?9$NBFesJ@PPZ0j|-?>qMWWJvTa7#*ecM5`Xrc=NmCgGE!_Q^czRG z`7)~l2bheVib{x_x=o@xBv>HuGM&2DL6$sDHbk2?Xvl K@_>6??f(NsTtnpm literal 0 HcmV?d00001 diff --git a/basic_idea_of_DS/Tree.class b/basic_idea_of_DS/Tree.class new file mode 100644 index 0000000000000000000000000000000000000000..966264dc4bcb5cc2fcf520239202dd18839c3fb5 GIT binary patch literal 808 zcmZuu-AWrl7(J70vhKR-rfRgBn*OGVg6YpiFO=R?3PNfxA`9Y0n8Y!Tjk~aJ3WfSm zg_J;rK0xpKLZxRmTOu?UJG0-JbIy0>n_qu^`~>g@&u!!cR=e_A_d5Da$xd|MIcPVJ zW2J0Z0{*4^ESm!v_M0EOm#UWtSaB3_TWkHNI*QKJoZ^f!H;+3YAW8Fh{L}Ru#n?k z+8)E*zQw}H<`_%gQTj$Ohh?sdsbq!3Rrn}lg;;qaB2s2WIo7bAHsSO$>wR)eTQ{{9 zGd$Pnd7m*hQct5JJM(mSvXMFc&O+YYLY$1T+1fEdtx3?G5lW^kq-Et_Sxn2SDMzRn zf;}aSP<hT~3Pl6Itq#$^40~Ivq$Yom_=8++y%&c!C;UVHXEzBESo1yu??$zB8yB TJSGcN4DpmB{wG@~#d?@|UgmlE&GY>H{p~w|hv+)U39OH0swZiGJB~~e&q5=O znybj94hjO*efd`QXEK`hpO5#|#0acx>PVX{fqbVs5-4oPua$>9N);5bBCs~pk$Se6 zk5%$gj%P}sHjF27Hj;_9_OY{I_H-)H9R9EWfVJmRM*@E5)$oKPG>ML;gYKw=^Qb$h zouUlirR1;R0vaTY7X)r($vW=uGSe_$$@##=MS*gl1Dyu%RTB3+Ttdr1Q=qwLNz*PF}b)V;AK_gNcCK_8JgKs_BARA%$|&bjUK-zlPO0~KjU`-Li6kh zta2lhH&5lk@!Y&HUL+IsSlh|^|7@*i+0h0+&m{vnYFrC%hgP3bP!{igh5LE=?D4kG zU_zO9B@3WjrB%W?tkGkWf3R4NGR$ut;z{chRSbBtT%bw)7SH`JsMh==tRJFn)vHU@ zKk=5W8qoVeh*q`q@z0S($-|=bmJlwP%Ls_jA;3LUvB70OKpk7$>?8Qtfr}SxX_5U5 g3)gXjRt~$kNf3eCv?_3Zp(vW3=Q(y3ca{;Izo~bhvH$=8 literal 0 HcmV?d00001 diff --git a/basics/DoWhileLoop.class b/basics/DoWhileLoop.class new file mode 100644 index 0000000000000000000000000000000000000000..02e98f6ce84b8c0dc3da2495a3c57a303d638f71 GIT binary patch literal 764 zcmZva-)<5?6vn>++6CNNgqGSuEBJS*+SMyBXuMEk(gd{$24lP$mI({P}Q$f96l3CjYj9UZ8b>8P*b z*Rt;`!aJcS{ho}qiRXv8drxHA$g8(8^v`SH*ixRpMRE z!$!*(vm(=)&tc_cJmf?x7mQ3mFhLv$taKCUoxG6I{27YfFpWL+oR7|F{`35MrX-r+ zEcu@R8GiA7xmt`|?t=T$?kV!0r`JWU<{A`S;%d(lxUVoO;4)TuV#FzO!~xAxasLZS z-%x#9zIuwS+63DZG$*+AQJmF2o&7Z6EDU&yXi#j>n?%+L-R4b$SW~Pz17a6~59#I z@Zy6eLX9N)=7X<3`&Yy>yM;EUCXz5`X3m-KJLfxR`{VbQuK=d8E}?;;KdV|=&WbOo zmc5x?!3gzlyBAQ|F zE*N<(!-IeVKdv))BGHV57KV=c8Au2+gfD$HaBhM!TG1|`WDoETGMdpTj$I7x)hsH- zB%>KW7`hc)gHP;kD3H*|(45kAzE(QSax<-F3!EXCGIDAmqnesHS1!Hwo@Ox&rv5{6 zp@-$v%@C?92Z^EcBkDqXBWF-NVt1hcRjg9p%Dd93@|j3x_ME7j6n>E>W7K5 zQhhC^P8_zIc@5MO!m;86&ta5XP!qbP&>ertwBdL0uFy6AC6V#Sqw2 ztyRP1&K!_7)XrDJKdoR!8QQKIxqijTz)0{KjjApZF|cW?xr0@;Sm}Wz z0Fye&MpQ|en)pmXKL%thU{S(zhSq9%6vubDsbC2&NT;G|THJYCSDhq-ylIro9ADDJ z421svq(%iYgOb#BZY~s5%i@-V6hr4f27;lf<}0KO*0^Oa8N{}T^&_`T@Td_|FpW$8^G2%EuAa#xr zK_34`o}TX)zl1r%`0>S0clY1}L3t2D7iP(dgu0#T#^^Lb_mh;=6cLZnX{IKzL?y8> z)t`WR0tX^xX+!W%oo)6bZHPkXm`pL0Lw;3{rR1=oXRCn|}T QWQDp6D_A9lHRpci57x9dk^lez literal 0 HcmV?d00001 diff --git a/basics/Fast_Inputs_Main.class b/basics/Fast_Inputs_Main.class new file mode 100644 index 0000000000000000000000000000000000000000..4e07fc5406f529e05a70c0896de8ecb85472cffd GIT binary patch literal 1066 zcmZ`&-A)=o7(D|EtAN#l3;1uVwxCw}i)}Hc35^K}*hU(XrWab{fprV@yk+YQ;Q$*!&A%SFTcXuARvQ$dr8VWp|$*Ca&>EAZqKo?Bfe8-Q@FNvGiOJU6j}kDOfs07dG3G zz)01Tjl+uU_!nqm*+hOo?tr@jk!riwZKy31oNR_KKuR70Y%>4*#H0l literal 0 HcmV?d00001 diff --git a/basics/Operators.class b/basics/Operators.class new file mode 100644 index 0000000000000000000000000000000000000000..fd4d42b00e510ecfd46b8e4200e682c1fe8263e0 GIT binary patch literal 1078 zcmZuwTTc@~7(G+AyKPyaaw+OA2#VOEP_IQT7X_n%pcpYVMjo7&wO!bDo9&jwR}z1a zJ`|&gKfoVlJkuh#^6<@`nfbmmXU=^4=kL$o0Os)AKtv!}lnuAk$Zph~K!$$MFraaD zNAAh2Cu`;GMsdd}g#!A#TXVxjfu3}xAfT=I+fD*Kh?|H)7wBJiYtHLtwde%zWYKd3 z2G;$O^a?U?)%hvYIzAA~156cDd<#+fI5OR~g;=nL-TL1jM*XoHTI*Q?yjp>rQQ3VCKAvE|NpBc}0;{ z6d3{gJT)g1Z>hxFDsin__Q}Lq6It95h=qQ~a)F_AcL`6whX)4k3kEXs@uV@)8j={JLt^TJha)pyjYvq}Ia zz?Wx70}&$jB1eO>EWd)^==1?%-`d*=j%ph$=;dg368OEqSsZ=n=L(BO6dF|aZqk@f z>I;@#S+wj=InA=YT-37bIo-1NbB1m0f1QhcNAed^A4Y%R(gDT>CR(^YthI2ngQ7=B zKSIWTl!~=5-NH-@caJ4bQHm0(Q%V9cii)$rRg?B&jAAD#cZaL$3R~^mUF7&jt7}#8 z2#LY5 literal 0 HcmV?d00001 diff --git a/basics/VariablesandDataTypes.class b/basics/VariablesandDataTypes.class new file mode 100644 index 0000000000000000000000000000000000000000..007871dc66c4f874e85847b6cb5214d7018a38a8 GIT binary patch literal 1034 zcmaJ<>rN9v7(LSq+m;ou6p)JuURwkz3ZfK23L$}1F)3+c{59>4Wl6i+>~2YTARj<~ z6r+g`;6oYDED$UuZZb39&UfaV@Amu8k6!>*v11@2FjbYlUGwu5>DjW{P`-4m9T~{O z)0XlL!~}+p<%!HUq*KoyRF73H5a?UC9Xr?%h-PyYf!MZdsT86}nuw!MV6bF6>V3Oe zRoV;e-f!l;^HKh}0 zUi>EA1V#kfb?IW;Zdl4o;T~oU%yd(S!I`*^2Li^4Y_!$EXVPc)a=j^}Foj3Da*s8l*RNB| z3WymEoHOwh^K5}^wUlECEZp>>hvXvIf~Hv16nVBjyWbnlzrZCE&+$Sa5xD2o7RY3K zpOAC~s|H>Q42MPPE}w~4Iy0lCE81WmW74a$?ZY>8lYNkNj*HkM%#qD-a;_Ji6Vc~{ z!$sgenWbfU$|q&2?6$p{+O_q_ORD00w!ZAAdoNNMLg)y`CO=mqEIi&aB11Ve}`aK2Cne^cfze zpLCF$=L(J44i-XVJkF~Qo^`N%B|8z)85B;?N-~rb<@&KfX&uTkBc~i*V~uAN>nL!s bI=p#9ln#D{{2uI)d%LFiYs@ literal 0 HcmV?d00001 diff --git a/basics/WhileLoop.class b/basics/WhileLoop.class new file mode 100644 index 0000000000000000000000000000000000000000..753a253b84079e53f0200f56d01c0d7308269c1b GIT binary patch literal 761 zcmZuv%Wl&^6g@X_YA3i4k~S?(C~3>XDNw_TMJg5`Ayo3iIECM{_8^(%61$l zHZ1lYiFd*eMKthV_Kswr33GcYQu;9=?=`yw>uKDVCFD_bQNSEwv8^KcVm$20^g#4N zNhr7DK!jb9Dr3)_mOfM?6FXnG#hgQ-B0|-B+x}m_qf-?PTFq_|S5dK1KBKPlVWj2I z#WGe{Sv+Q;D;ZeD{wqdm#!E45*;pm4o~L~>R$*VJ4z6*74XuLXMhR8aOiy*D@-7o% zGB#Y?K!ZUdNo3R~)V=-Yh2$B1%OJK~Y~v=u(Q(!iVcEL~;oRHsY}_GKrfSdj;i74T z*@FWmyC=+oIv}8`HmLB@pF;PmQd=%<1~=Zc;$qJf2-d$1+fX9B>xZ~ z$1mP3pEg@Q-^6!e=LF7|X}H9v34;Mw_;j-bzUSF0VgZZnG2r*Gm=4%>_CBNj6-(by zeN$dL!Fp|i>l18FaO)$T);^v7GSqn(>UAau!*g(0M-eqHvcc~yrZ?rP86|dbm#rKt VzlZx=a5qE!MuFDY^ryiGe*t-Pqv!wt literal 0 HcmV?d00001 diff --git a/binaryTree/BT_Problem_06_a.java b/binaryTree/BT_Problem_06_a.java index 9886cdd..6d7c25c 100644 --- a/binaryTree/BT_Problem_06_a.java +++ b/binaryTree/BT_Problem_06_a.java @@ -1,7 +1,7 @@ package binaryTree; import java.util.*; /* - * Problem Title :- In-order Traversal of a tree both using Recursion + * Problem Title :- In-order Traversal of a tree without using Recursion */ // Class to print the in-order traversal public class BT_Problem_06_a { diff --git a/binaryTree/BT_Problem_06_b.java b/binaryTree/BT_Problem_06_b.java index 1bb728f..cdace6c 100644 --- a/binaryTree/BT_Problem_06_b.java +++ b/binaryTree/BT_Problem_06_b.java @@ -1,98 +1,48 @@ package binaryTree; /* - * Problem Title :- In-order Traversal of a tree both using Recursion + * Problem Title :- In-order Traversal of a tree using Recursion */ public class BT_Problem_06_b { - // Root of Binary Tree - Node root; + Node root; + + // Constructor + BT_Problem_06_b(){ + root = null; + } - // Constructor - BT_Problem_06_b(){ - root = null; - } - - /* - * Given a binary tree, - * print its nodes according to the - * "bottom-up" post-order traversal. - */ - void printPostorder(Node node) { - if(node == null) - return; - // first recur on left subtree - printPostorder(node.left); - - // then recur on right subtree - printPostorder(node.right); - - // now deal with the node - System.out.print(node.data + " "); - } - - /* - * Given a binary tree, - * print its nodes in in-order - */ - void printInorder(Node node) { + //Given a binary tree, print its nodes in in-order + void printInorder(Node node) { - if(node == null) return; + if(node == null) return; - /* first recur on left child */ - printPreorder(node.left); + /* first recur on left child */ + printInorder(node.left); - /* then print data of node */ - System.out.print(node.data + " "); + /* then print data of node */ + System.out.print(node.data + " "); - /* now recur on right child */ - printPreorder(node.right); - } + /* now recur on right child */ + printInorder(node.right); + } - /* - * Given a binary tree, - * print its nodes in preorder - */ - void printPreorder(Node node) { - - if(node == null) return; - - /* first print data of node */ - System.out.print(node.data + " "); - - /* then recur on left subtree */ - printPreorder(node.left); - - /* now recur on right subtree */ - printPreorder(node.right); - } + // Wrappers over above recursive function + void printInorder() { printInorder(root); } - // Wrappers over above recursive functions - void printPostorder() { printPostorder(root);} - void printInorder() { printInorder(root); } - void printPreorder() { printPreorder(root); } - // Driver method - public static void main(String[] args) { + // Driver method + public static void main(String[] args) { - BT_Problem_06_b tree = new BT_Problem_06_b(); - - tree.root = new Node(1); - tree.root.left = new Node(2); - tree.root.right = new Node(3); - tree.root.left.left = new Node(4); - tree.root.left.right = new Node(5); - - System.out.println("Preorder traversal of binary tree is "); - tree.printPreorder(); + BT_Problem_06_b tree = new BT_Problem_06_b(); - System.out.println("\nInorder traversal of binary tree is "); - tree.printInorder(); + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); - System.out.println("\nPostorder traversal of binary tree is "); - tree.printPostorder(); - - } - - + System.out.println("\nInorder traversal of binary tree is "); + tree.printInorder(); + } } diff --git a/binaryTree/BT_Problem_07_a.java b/binaryTree/BT_Problem_07_a.java new file mode 100644 index 0000000..0c42b27 --- /dev/null +++ b/binaryTree/BT_Problem_07_a.java @@ -0,0 +1,55 @@ +package binaryTree; +import java.util.*; + +/* + * Problem Title :- Preorder Traversal of a tree without using Recursion or Iteratively + */ +public class BT_Problem_07_a { + + // Root of Binary Tree + Node root; + + // Given a binary tree, print its nodes in pre-order + void preorder() { + + if(root == null) return; + + Stack s = new Stack<>(); + s.push(root); + + // traverse the tree + while(s.empty() == false) { + + Node mynode = s.peek(); + System.out.print(mynode.data + " "); + + s.pop(); + + //Push right child of popped node to stack + if(mynode.right != null) + s.push(mynode.right); + + //Push left child of popped node to stack + if(mynode.left != null) + s.push(mynode.left); + + } + } + + // Driver method + public static void main(String[] args) { + + // creating a binary tree and entering the nodes + BT_Problem_07_a tree = new BT_Problem_07_a(); + + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + + tree.preorder(); + + } + +} diff --git a/binaryTree/BT_Problem_07_b.java b/binaryTree/BT_Problem_07_b.java new file mode 100644 index 0000000..bb10987 --- /dev/null +++ b/binaryTree/BT_Problem_07_b.java @@ -0,0 +1,52 @@ +package binaryTree; + +/* + * Problem Title :- Pre-order Traversal of a tree using Recursion + */ +public class BT_Problem_07_b { + // Root of Binary Tree + Node root; + + // Constructor + BT_Problem_07_b(){ + root = null; + } + + /* + * Given a binary tree, + * print its nodes in preorder + */ + void printPreorder(Node node) { + + if(node == null) return; + + /* first print data of node */ + System.out.print(node.data + " "); + + /* then recur on left subtree */ + printPreorder(node.left); + + /* now recur on right subtree */ + printPreorder(node.right); + } + + // Wrappers over above recursive function + void printPreorder() { + printPreorder(root); + } + + //Driver Code + public static void main(String[] args) { + BT_Problem_07_b tree = new BT_Problem_07_b(); + + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + + System.out.println("Preorder traversal of binary tree is "); + tree.printPreorder(); + } + +} diff --git a/binaryTree/BT_Problem_08_a.java b/binaryTree/BT_Problem_08_a.java new file mode 100644 index 0000000..3c20961 --- /dev/null +++ b/binaryTree/BT_Problem_08_a.java @@ -0,0 +1,90 @@ +package binaryTree; +import java.util.*; +/* + * Post-order Traversal of a tree both using recursion and Iteration + */ +public class BT_Problem_08_a { + + Node root; + ArrayList list = new ArrayList(); + + // An iterative function to do postorder traversal + // of a given binary tree + ArrayList postOrderIterative(Node node) + { + Stack S = new Stack(); + + // Check for empty tree + if (node == null) + return list; + S.push(node); + Node prev = null; + while (!S.isEmpty()) + { + Node current = S.peek(); + + /* go down the tree in search of a leaf an if so process it + and pop stack otherwise move down */ + if (prev == null || prev.left == current || + prev.right == current) + { + if (current.left != null) + S.push(current.left); + else if (current.right != null) + S.push(current.right); + else + { + S.pop(); + list.add(current.data); + } + + /* go up the tree from left node, if the child is right + push it onto stack otherwise process parent and pop + stack */ + } + else if (current.left == prev) + { + if (current.right != null) + S.push(current.right); + else + { + S.pop(); + list.add(current.data); + } + + /* go up the tree from right node and after coming back + from right node process parent and pop stack */ + } + else if (current.right == prev) + { + S.pop(); + list.add(current.data); + } + + prev = current; + } + + return list; + } + + // Driver program to test above functions + public static void main(String args[]) + { + BT_Problem_08_a tree = new BT_Problem_08_a(); + + // Let us create trees shown in above diagram + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + tree.root.right.left = new Node(6); + tree.root.right.right = new Node(7); + + ArrayList mylist = tree.postOrderIterative(tree.root); + + System.out.println("Post order traversal of binary tree is :"); + System.out.println(mylist); + } + +} diff --git a/binaryTree/BT_Problem_08_b.java b/binaryTree/BT_Problem_08_b.java new file mode 100644 index 0000000..7929743 --- /dev/null +++ b/binaryTree/BT_Problem_08_b.java @@ -0,0 +1,47 @@ +package binaryTree; + +public class BT_Problem_08_b { + + // Root of Binary Tree + Node root; + + // Constructor + BT_Problem_08_b(){ + root = null; + } + + // Given a binary tree, print its nodes according to the "bottom-up" post-order traversal. + void printPostorder(Node node) { + //base case + if(node == null) + return; + // first recur on left subtree + printPostorder(node.left); + + // then recur on right subtree + printPostorder(node.right); + + // now deal with the node + System.out.print(node.data + " "); + } + + // Wrapper over above recursive function + void printPostorder() { + printPostorder(root); + } + + //Driver Code + public static void main(String[] args) { + BT_Problem_08_b tree = new BT_Problem_08_b(); + + tree.root = new Node(1); + tree.root.left = new Node(2); + tree.root.right = new Node(3); + tree.root.left.left = new Node(4); + tree.root.left.right = new Node(5); + + System.out.println("\nPostorder traversal of binary tree is "); + tree.printPostorder(); + } + +} diff --git a/binaryTree/BT_Problem_10.java b/binaryTree/BT_Problem_10.java index 5b9101a..01cea10 100644 --- a/binaryTree/BT_Problem_10.java +++ b/binaryTree/BT_Problem_10.java @@ -5,26 +5,47 @@ * The right view of a binary tree, is set of nodes visible when tree is visited from rights side * between two end nodes. */ +class Max_level{ + int max_level; +} public class BT_Problem_10 { Node root; - static int max_level = 0; - void leftViewUtil(Node node, int level) { + Max_level max_level = new Max_level(); + + void rightViewUtil(Node node, int level, Max_level max_level) { if(node == null) return; - if(max_level < level) { - System.out.print(" " + node.data); - max_level = level; + if(max_level.max_level < level) { + System.out.print(node.data + " " ); + max_level.max_level = level; } - + rightViewUtil(node.right, level+1,max_level); + rightViewUtil(node.left, level+1,max_level); + } + + void rightView() { + rightView(root); } + + void rightView(Node node) { + rightViewUtil(node, 1, max_level); + } + public static void main(String[] args) { + BT_Problem_10 tree = new BT_Problem_10(); + tree.root = new Node(12); + tree.root.left = new Node(10); + tree.root.right = new Node(30); + tree.root.right.left = new Node(25); + tree.root.right.right = new Node(40); + + tree.rightView(); - } } diff --git a/binaryTree/BT_Problem_15.java b/binaryTree/BT_Problem_15.java index 1b70b05..f0ad436 100644 --- a/binaryTree/BT_Problem_15.java +++ b/binaryTree/BT_Problem_15.java @@ -2,7 +2,7 @@ import java.util.*; import java.util.Map.Entry; /* - * Problem Title :- Diagnol Traversal of a Binary tree + * Problem Title :- Daignol Traversal of a Binary tree */ public class BT_Problem_15 { diff --git a/binaryTree/BT_Problem_17.java b/binaryTree/BT_Problem_17.java index 2bdcbd0..a1ff4a8 100644 --- a/binaryTree/BT_Problem_17.java +++ b/binaryTree/BT_Problem_17.java @@ -1,55 +1,86 @@ package binaryTree; -/* - * Problem Title :- Construct Binary Tree from String with Bracket Representation +import java.util.*; +/* + * Problem Title :- Construct Binary Tree from String with Bracket Representation. */ public class BT_Problem_17 { - + // Binary Tree node static class Node{ int data; - Node left,right; + Node left, right; }; - static String str; - + // Helper function that allocates a new node static Node newNode(int data) { Node node = new Node(); - node.data= data; + node.data = data; node.left = node.right = null; return(node); } - static void treeToString(Node root) { - if(root == null) + // function just for testing + static void preOrder(Node node) { + if(node == null) return; + System.out.printf("%d ", node.data); + preOrder(node.left); + preOrder(node.right); + } + + // function to return the index of close parenthesis + static int findIndex(String str, int si, int ei) { + // base case + if(si > ei) + return -1; + //Inbuilt Stack + Stack s = new Stack<>(); + // loop for iterations of the index + for(int i = si; i <= ei; i++) { + // if open parenthesis, push it to the stack + if(str.charAt(i) == '(') + s.add(str.charAt(i)); + // if close parenthesis, pop it and else stack is empty that will be the required index + else if(str.charAt(i) == ')') { + if(s.peek() == '(') { + // pop from stack + s.pop(); + //if stack is empty, this is the required index + if(s.isEmpty()) return i; + } + } + } + return -1; + } + + // function to construct tree from string + static Node treeFromString(String str, int si, int ei) { - str += (Character.valueOf((char)(root.data + '0'))); + // Base Case + if(si > ei) return null; - if(root.left == null && root.right == null) { - return; - } + // new root + Node root = newNode(str.charAt(si) - '0'); + int index = -1; - str += ('('); - treeToString(root.left); - str += ('('); + // if next char is '(' find the index of its complement + if(si + 1 <= ei && str.charAt(si+1) == '(') + index = findIndex(str, si + 1, ei); - if(root.right != null) { - str += ('('); - treeToString(root.right); - str += ('('); + // if index found + if(index != -1) { + // call for left subtree + root.left = treeFromString(str, si+2, index - 1); + // call for left subtree + root.right = treeFromString(str, index + 2, ei - 1); } + return root; } + //Driver Code public static void main(String[] args) { - Node root = newNode(1); - root.left = newNode(2); - root.right = newNode(3); - root.left.left = newNode(4); - root.left.right = newNode(5); - root.right.right = newNode(6); - str = " "; - treeToString(root); - System.out.println(str); - + String str = "4(2(3)(1))(6(5))"; + Node root = treeFromString(str, 0, str.length() - 1); + preOrder(root); } } diff --git a/binaryTree/BT_Problem_18.java b/binaryTree/BT_Problem_18.java index 3d9ae5a..9731805 100644 --- a/binaryTree/BT_Problem_18.java +++ b/binaryTree/BT_Problem_18.java @@ -1,9 +1,10 @@ package binaryTree; - +/* + * Problem Title :- Convert Binary tree into Doubly Linked List + */ public class BT_Problem_18 { public static void main(String[] args) { - } diff --git a/binaryTree/BT_Problem_19.java b/binaryTree/BT_Problem_19.java index 777ba6f..1aee9bb 100644 --- a/binaryTree/BT_Problem_19.java +++ b/binaryTree/BT_Problem_19.java @@ -1,5 +1,7 @@ package binaryTree; - +/* + * Problem Title :- Construct Binary Tree from String with Bracket Representation. + */ public class BT_Problem_19 { public static void main(String[] args) { diff --git a/binaryTree/BT_Problem_20.java b/binaryTree/BT_Problem_20.java new file mode 100644 index 0000000..11f5cfb --- /dev/null +++ b/binaryTree/BT_Problem_20.java @@ -0,0 +1,5 @@ +package binaryTree; + +public class BT_Problem_20 { + +} diff --git a/binaryTree/BT_Problem_21.java b/binaryTree/BT_Problem_21.java new file mode 100644 index 0000000..d928a7b --- /dev/null +++ b/binaryTree/BT_Problem_21.java @@ -0,0 +1,5 @@ +package binaryTree; + +public class BT_Problem_21 { + +} diff --git a/binaryTree/BT_Problem_22.java b/binaryTree/BT_Problem_22.java new file mode 100644 index 0000000..4d87770 --- /dev/null +++ b/binaryTree/BT_Problem_22.java @@ -0,0 +1,5 @@ +package binaryTree; + +public class BT_Problem_22 { + +} diff --git a/binaryTree/BT_Problem_23.java b/binaryTree/BT_Problem_23.java new file mode 100644 index 0000000..bf554c3 --- /dev/null +++ b/binaryTree/BT_Problem_23.java @@ -0,0 +1,5 @@ +package binaryTree; + +public class BT_Problem_23 { + +} diff --git a/binaryTree/BT_Problem_24.java b/binaryTree/BT_Problem_24.java new file mode 100644 index 0000000..07b9d8e --- /dev/null +++ b/binaryTree/BT_Problem_24.java @@ -0,0 +1,5 @@ +package binaryTree; + +public class BT_Problem_24 { + +} diff --git a/binaryTree/BT_Problem_25.java b/binaryTree/BT_Problem_25.java new file mode 100644 index 0000000..38bf165 --- /dev/null +++ b/binaryTree/BT_Problem_25.java @@ -0,0 +1,5 @@ +package binaryTree; + +public class BT_Problem_25 { + +} diff --git a/binaryTree/BT_Problem_26.java b/binaryTree/BT_Problem_26.java new file mode 100644 index 0000000..df387b4 --- /dev/null +++ b/binaryTree/BT_Problem_26.java @@ -0,0 +1,5 @@ +package binaryTree; + +public class BT_Problem_26 { + +} diff --git a/binaryTree/BT_Problem_27.java b/binaryTree/BT_Problem_27.java new file mode 100644 index 0000000..331c4a1 --- /dev/null +++ b/binaryTree/BT_Problem_27.java @@ -0,0 +1,5 @@ +package binaryTree; + +public class BT_Problem_27 { + +} diff --git a/binaryTree/BT_Problem_28.java b/binaryTree/BT_Problem_28.java new file mode 100644 index 0000000..ce61fed --- /dev/null +++ b/binaryTree/BT_Problem_28.java @@ -0,0 +1,5 @@ +package binaryTree; + +public class BT_Problem_28 { + +} diff --git a/binaryTree/BT_Problem_29.java b/binaryTree/BT_Problem_29.java new file mode 100644 index 0000000..54d7095 --- /dev/null +++ b/binaryTree/BT_Problem_29.java @@ -0,0 +1,5 @@ +package binaryTree; + +public class BT_Problem_29 { + +} diff --git a/binaryTree/BT_Problem_30.java b/binaryTree/BT_Problem_30.java new file mode 100644 index 0000000..ba65099 --- /dev/null +++ b/binaryTree/BT_Problem_30.java @@ -0,0 +1,5 @@ +package binaryTree; + +public class BT_Problem_30 { + +} diff --git a/binaryTree/BT_Problem_32.java b/binaryTree/BT_Problem_32.java new file mode 100644 index 0000000..233a48d --- /dev/null +++ b/binaryTree/BT_Problem_32.java @@ -0,0 +1,5 @@ +package binaryTree; + +public class BT_Problem_32 { + +} diff --git a/binaryTree/BT_Problem_33.java b/binaryTree/BT_Problem_33.java new file mode 100644 index 0000000..cbd980a --- /dev/null +++ b/binaryTree/BT_Problem_33.java @@ -0,0 +1,5 @@ +package binaryTree; + +public class BT_Problem_33 { + +} diff --git a/binaryTree/BT_Problem_34.java b/binaryTree/BT_Problem_34.java new file mode 100644 index 0000000..39333f5 --- /dev/null +++ b/binaryTree/BT_Problem_34.java @@ -0,0 +1,5 @@ +package binaryTree; + +public class BT_Problem_34 { + +} diff --git a/binary_search_tree/Deletion_of_a_node_in_bst.java b/binary_search_tree/Deletion_of_a_node_in_bst.java new file mode 100644 index 0000000..2ca3747 --- /dev/null +++ b/binary_search_tree/Deletion_of_a_node_in_bst.java @@ -0,0 +1,117 @@ +package binary_search_tree; + +/** + * Deletion_of_a_node_in_bst + */ +public class Deletion_of_a_node_in_bst { + class Node { + int key; + Node left, right; + + Node(int item) { + key = item; + left = right = null; + } + } + + Node root; + + Deletion_of_a_node_in_bst() { + root = null; + } + + void deleteKey(int key) { + root = deleteRec(root, key); + } + + Node deleteRec(Node root, int key) { + if (root == null) + return root; + if (key < root.key) + root.left = deleteRec(root.left, key); + else if (key > root.key) + root.right = deleteRec(root.right, key); + else { + if (root.left == null) + return root.right; + else if (root.right == null) + return root.left; + + root.key = minValue(root.right); + root.right = deleteRec(root.right, root.key); + } + return root; + } + + int minValue(Node root) { + int minv = root.key; + while (root.left != null) { + minv = root.left.key; + root = root.left; + } + return minv; + } + + void insert(int key) { + root = insertRec(root, key); + } + + Node insertRec(Node root, int key) { + if (root == null) { + root = new Node(key); + return root; + } + if (key < root.key) + root.left = insertRec(root.left, key); + else if (key > root.key) + root.right = insertRec(root.right, key); + return root; + } + + void inorder() { + inorderRec(root); + } + + void inorderRec(Node root) { + if (root != null) + inorderRec(root.left); + System.out.print(root.key + " "); + inorderRec(root.right); + + } + + public static void main(String[] args) { + Deletion_of_a_node_in_bst tree = new Deletion_of_a_node_in_bst(); + // * Let us create following BST + // ? 50 + // ? / \ + // ? 30 70 + // ? / \ / \ + // ?20 40 60 80 */ + tree.insert(50); + tree.insert(30); + tree.insert(20); + tree.insert(40); + tree.insert(70); + tree.insert(60); + tree.insert(80); + + System.out.println("Inorder traversal of the given tree"); + tree.inorder(); + + System.out.println("\nDelete 20"); + tree.deleteKey(20); + System.out.println("Inorder traversal of the modified tree"); + tree.inorder(); + + System.out.println("\nDelete 30"); + tree.deleteKey(30); + System.out.println("Inorder traversal of the modified tree"); + tree.inorder(); + + System.out.println("\nDelete 50"); + tree.deleteKey(50); + System.out.println("Inorder traversal of the modified tree"); + tree.inorder(); + } +} \ No newline at end of file diff --git a/binary_search_tree/Find_a_value_in_bst.java b/binary_search_tree/Find_a_value_in_bst.java new file mode 100644 index 0000000..e2beb8d --- /dev/null +++ b/binary_search_tree/Find_a_value_in_bst.java @@ -0,0 +1,66 @@ +package binary_search_tree; + +public class Find_a_value_in_bst { + + class Node { + int key; + Node left, right; + + public Node(int item) { + key = item; + left = right = null; + } + } + + Node root; + + // ! Constructor + Find_a_value_in_bst() { + root = null; + } + + // This method mainly calls insertRec() + void insert(int key) { + root = insertRec(root, key); + } + + // * A recursive function to insert a new key in BST + Node insertRec(Node root, int key) { + if (root == null) { + root = new Node(key); + return root; + } + if (key < root.key) + root.left = insertRec(root.left, key); + else if (key > root.key) + root.right = insertRec(root.right, key); + return root; + } + + // The method mainly calls InorderRec() + void inorder() { + inorderRec(root); + } + + // ? A utility function to do inorder traversal of BST + void inorderRec(Node root) { + if (root != null) { + inorderRec(root.left); + System.out.println(root.key); + inorderRec(root.right); + } + } + + public static void main(String[] args) { + Find_a_value_in_bst tree = new Find_a_value_in_bst(); + tree.insert(50); + tree.insert(30); + tree.insert(20); + tree.insert(40); + tree.insert(70); + tree.insert(60); + tree.insert(80); + // ? print inorder traversal of BST + tree.inorder(); + } +} diff --git a/bitManipulation/BM_02.java b/bitManipulation/BM_02.java index a23a8e5..a068892 100644 --- a/bitManipulation/BM_02.java +++ b/bitManipulation/BM_02.java @@ -1,52 +1,40 @@ package bitManipulation; - -// Problem Title :-> Find the two non-repeating elements in an array of repeating elements +/* + * Problem Title :- Find the two non-repeating elements in an array of repeating elements + */ public class BM_02 { - // This function sets the values of *x & *y to non-repeating elements in an array a[] of size n - public static void UniqueNumber(int[] a, int n) { + /* + * This function sets the values of *x & *y to non-repeating elements in an array a[] of size n + */ + public static void TwoUniqueNumbers(int[] a, int n) { int sum = 0; for(int i = 0; i < n; i++) { - // X-or all the elements of the array - // all the elements occur-i-n-g twice will + // XOR all the elements of the array + // all the elements occur-ing twice will // cancel out each other remaining - // two unique numbers will be x-o-red + // two unique numbers will be xor'ed sum = (sum^a[i]); } - - // Bitwise & the sum with it's 2's Complement - // Bitwise & will give us the sum containing - // only the rightmost set bit sum = (sum &- sum); - // sum1 & sum2 will contain 2 unique elements - // elements initialized with 0 box number - // x-o-red with 0 is number itself int sum1 = 0; int sum2 = 0; - // traversing the array again for(int i = 0; i < a.length; i++) { - - // Bitwise & the a[i] with the sum - // Two possibilities either result == 0 - // or result > 0 - if((a[i] & sum) > 0) - // if result >, 0 then a[i] x-o-red with sum1 - sum1 = (sum1^a[i]); - else - // if result == 0 then a[i] x-o-red with sum2 - sum2 = (sum2^a[i]); + if((a[i] & sum) > 0) { + sum1 = (sum1 ^ a[i]); + }else { + sum2 = (sum2 ^ a[i]); + } } - // print the two unique numbers - System.out.println("The non repeating elements are " + sum1 + " and " +sum2); + System.out.println("The non-repeating elements are " + sum1 + " and " + sum2); } public static void main(String[] args) { - - int[] a = new int[] {2, 3, 7, 9, 11, 2, 3, 11}; + int[] a = new int[] {2,3,7,9,11,2,3,11}; int n = a.length; - UniqueNumber(a, n); + TwoUniqueNumbers(a, n); } } diff --git a/bitManipulation/BM_03.java b/bitManipulation/BM_03.java index 697bacc..2747677 100644 --- a/bitManipulation/BM_03.java +++ b/bitManipulation/BM_03.java @@ -1,23 +1,21 @@ package bitManipulation; -/* - * Problem Title :-> Count number of bits to be flipped to convert A to B +/* + * Problem Title :- Count number of bits to be flipped to convert A to B */ public class BM_03 { - // Function that count set bits public static int countSetBits(int n) { int count = 0; while(n != 0) { count++; - n &= (n-1); + n &= (n - 1); } return count; } // Function that return count of flipped number public static int FlippedCount(int a, int b) { - // Return countof set bits in - // a XOR b - return countSetBits(a^b); + // Return count of set bits in a XOR b + return countSetBits(a ^ b); } // Driver Code public static void main(String[] args) { diff --git a/bitManipulation/BM_04.java b/bitManipulation/BM_04.java index e61a030..597d8b1 100644 --- a/bitManipulation/BM_04.java +++ b/bitManipulation/BM_04.java @@ -1,10 +1,32 @@ package bitManipulation; - +/* + * Problem Title :- Count total set bits in all numbers from 1 to n + */ public class BM_04 { + static int countBits(int n) { + int i = 0; + int ans = 0; + while((1 << i) <= n) { + boolean k = false; + int change = 1 << i; + for(int j = 0; j <= n; j++) { + if(k == true) ans += 0; + else ans+= 0; + if(change == 1) { + k = !k; + change = 1 << i; + } + else { + change--; + } + } + } + return ans; + } public static void main(String[] args) { - // TODO Auto-generated method stub - + int n = 17; + System.out.println(countBits(n)); } } diff --git a/bitManipulation/BM_05.java b/bitManipulation/BM_05.java index 8dd10a5..db59dad 100644 --- a/bitManipulation/BM_05.java +++ b/bitManipulation/BM_05.java @@ -1,10 +1,24 @@ package bitManipulation; - +/* + * Problem Title :- Program to find whether a no is power of two + */ public class BM_05 { + static boolean isPowerOf2(int n) { + if(n==0) + return false; + + return (int)(Math.ceil((Math.log(n) / Math.log(2)))) == + (int)(Math.floor(((Math.log(n) / Math.log(2))))); + } + public static void main(String[] args) { - // TODO Auto-generated method stub - + + if(isPowerOf2(31)) System.out.println("Yes"); + else System.out.println("No"); + + if(isPowerOf2(64)) System.out.println("Yes"); + else System.out.println("No"); } } diff --git a/bitManipulation/BM_06.java b/bitManipulation/BM_06.java index 9f93c54..2c79daa 100644 --- a/bitManipulation/BM_06.java +++ b/bitManipulation/BM_06.java @@ -1,9 +1,11 @@ package bitManipulation; - +/* + * Problem Title :- Find position of the only set bit + */ public class BM_06 { public static void main(String[] args) { - // TODO Auto-generated method stub + } diff --git a/bitManipulation/BM_07.java b/bitManipulation/BM_07.java index d4fedae..1c58cb8 100644 --- a/bitManipulation/BM_07.java +++ b/bitManipulation/BM_07.java @@ -1,5 +1,7 @@ package bitManipulation; - +/* + * Problem Title :- Copy set bits in a range + */ public class BM_07 { public static void main(String[] args) { diff --git a/bitManipulation/BM_08.java b/bitManipulation/BM_08.java index 196de0e..f0b2763 100644 --- a/bitManipulation/BM_08.java +++ b/bitManipulation/BM_08.java @@ -1,5 +1,7 @@ package bitManipulation; - +/* + * Problem Title :- Divide two integers without using multiplication, division and mod operator + */ public class BM_08 { public static void main(String[] args) { diff --git a/bitManipulation/BM_09.java b/bitManipulation/BM_09.java index 705e43d..2266941 100644 --- a/bitManipulation/BM_09.java +++ b/bitManipulation/BM_09.java @@ -1,5 +1,7 @@ package bitManipulation; - +/* + * Problem Title :- Calculate square of a number without using *, / and pow() + */ public class BM_09 { public static void main(String[] args) { diff --git a/bitManipulation/BM_10.java b/bitManipulation/BM_10.java index 7701b37..6dbde29 100644 --- a/bitManipulation/BM_10.java +++ b/bitManipulation/BM_10.java @@ -1,10 +1,27 @@ package bitManipulation; +/* + * Problem Title :- Divide two integers without using multiplication, division and mod operator + */ + public class BM_10 { + static void printPowerSet(char[] set, int set_size) { + long pow_set_size = (long)Math.pow(2, set_size); + int counter , j; + + for(counter = 0; counter < pow_set_size; counter++) { + for(j = 0; j < set_size; j++) { + if((counter & (1 << j)) > 0) System.out.print(set[j]); + } + System.out.println(); + } + } + + //Driver Program public static void main(String[] args) { - // TODO Auto-generated method stub - + char[] set = {'a','b','c'}; + printPowerSet(set, 3); } } diff --git a/dp/Coin_change_problem.java b/dp/Coin_change_problem.java new file mode 100644 index 0000000..61f0521 --- /dev/null +++ b/dp/Coin_change_problem.java @@ -0,0 +1,19 @@ +package dp; + +class Coin_change_problem { + static int count(int[] S, int m, int n) { + if (n == 0) + return 1; + if (n < 0) + return 0; + if (m <= 0 && n >= 1) + return 0; + return count(S, m - 1, n) + count(S, m, n - S[m - 1]); + } + + public static void main(String[] args) { + int[] a = { 1, 2, 3 }; + int m = a.length; + System.out.println(count(a, m, 4)); + } +} \ No newline at end of file diff --git a/dp/DP_Problem_01.java b/dp/DP_Problem_01.java new file mode 100644 index 0000000..ceb1257 --- /dev/null +++ b/dp/DP_Problem_01.java @@ -0,0 +1,46 @@ +package dp; + +import java.util.*; +/* + * Problem Title :- Coin Change Problem + */ +public class DP_Problem_01 { + + static int minCoins(int n, int a[], int dp[]) { + // Base Case + if(n == 0) return 0; + + int ans = Integer.MAX_VALUE; + + for(int i = 0; i= 0) { + int subAns = 0; + // If the value of array at this index is not empty then put the value in subAns variable. + if(dp[n-a[i]] != -1) subAns = dp[n-a[i]]; + // else it will case minCoins function recursively for n-a[i] position + else subAns = minCoins(n-a[i],a, dp); + // if conditions satisfies then put subAns + 1 in ans variable. + if(subAns != Integer.MAX_VALUE && subAns + 1 < ans) ans = subAns + 1; + } + } + // now return the answer + return dp[n] = ans; + } + + public static void main(String[] args) { + + int n = 18; + int a[] = {7, 5, 1}; + int dp[] = new int[n+1]; + + Arrays.fill(dp, -1); + dp[0] = 0; + + int ans = minCoins(n, a, dp); + System.out.println(ans); + + for(int x: dp) + System.out.println(x + " "); + } +} diff --git a/dp/DP_Problem_02.java b/dp/DP_Problem_02.java new file mode 100644 index 0000000..7ecb946 --- /dev/null +++ b/dp/DP_Problem_02.java @@ -0,0 +1,33 @@ +package dp; + +// Definition:- + +// ! Knapsack problem is a problem in combinatorial optimization. +// * Given a set of items, +// ? each with a weight and a value, +// * determine the number of each item to. + +public class DP_Problem_02 { + + static int max(int a, int b) { + return (a > b) ? a : b; + } + + static int knapSack(int W, int wt[], int[] val, int n) { + // ? Base Case + if (n == 0 || W == 0) + return 0; + if (wt[n - 1] > W) + return knapSack(W, wt, val, n - 1); + else + return max(val[n - 1] + knapSack(W - wt[n - 1], wt, val, n - 1), knapSack(W, wt, val, n - 1)); + } + + public static void main(String[] args) { + int[] val = new int[] { 60, 100, 120 }; + int[] wt = new int[] { 10, 20, 30 }; + int W = 50; + int n = val.length; + System.out.println(knapSack(W, wt, val, n)); + } +} diff --git a/dp/DP_Problem_03.java b/dp/DP_Problem_03.java new file mode 100644 index 0000000..fb89d9c --- /dev/null +++ b/dp/DP_Problem_03.java @@ -0,0 +1,24 @@ +package dp; + +/* + * Problem Title :- Binomial Coefficient Problem + */ + +public class DP_Problem_03 { + // Returns value of Binomial Coefficient C(n,k) + static int binomialCoeff(int n, int k) { + //Base Case + if(k > n) + return 0; + if(k == 0 || k == n) + return 1; + //Recursion + return binomialCoeff(n - 1, k - 1) + binomialCoeff(n -1 , k); + } + + // Driver Program + public static void main(String[] args) { + int n = 5, k = 2; + System.out.printf("Value of C(%d, %d) is %d", n, k, binomialCoeff(n,k)); + } +} diff --git a/dp/DP_Problem_04.java b/dp/DP_Problem_04.java new file mode 100644 index 0000000..631ee79 --- /dev/null +++ b/dp/DP_Problem_04.java @@ -0,0 +1,9 @@ +package dp; + +public class DP_Problem_04 { + + public static void main(String[] args) { + + } + +} diff --git a/dp/definition.txt b/dp/definition.txt new file mode 100644 index 0000000..90a43df --- /dev/null +++ b/dp/definition.txt @@ -0,0 +1,5 @@ +//! Definition of Dynamic Programming (DP) +Dynamic Programming(DP) : + DP is an algorithmic technique for solving an optimization problem by breaking it down into simpler subproblems and utilizing the fact that the optimal solution to the overall problem depends upon the optimal solution to its subproblems. + + Let's take the example of the fibonnaci numbers. \ No newline at end of file diff --git a/encapsulation/EncapIntro.class b/encapsulation/EncapIntro.class new file mode 100644 index 0000000000000000000000000000000000000000..af830bcfb563a7277f97a41859698ed5c72ecd49 GIT binary patch literal 805 zcmaKqYm3uB6o%jFwwpFa8@CsAUF%(wt!})pP!U8F3Uw7K1@Y6ghB_senxuk1OFv{m z!5`p{65mOcvTX6ooH;XR-t(L@=hyG=KLPCHv4N7nP8`qE7tut{(?uXN6-Qp-^`k6_ z4U`4!nfxrhKt@yV^?2q_GJ(w}DpJ`~feptU36!75AAA!Vs9C6BQ=mRjk$OsI`<;vG<0c8F76X_O$Lb3)gXj4AXxMO~*YBVZy<#0hh%URUcKd z&@JkiYw@6{?Y4zIc;uyS!OP$2Yn8h?n1z&OGG)ITYuc!($1_d6rjh&ta~Lm@iT_gR z&#bQ|WKW~9Y`*7E0VVD@0$dGx9<89Q>>i@}wYWC9>TB@939i;Mfc7N48cw0k6aDxT z#Y(j957_SxIYHg6Mvhk3wsV~Oh6~*sS99E4?r!C{vr4ed6rf185H!(bst!{)6xT`H WOJUr@eR@^$Kfpt#6?jCyg#ABrV62+} literal 0 HcmV?d00001 diff --git a/encapsulation/EncapIntro.java b/encapsulation/EncapIntro.java new file mode 100644 index 0000000..dda3649 --- /dev/null +++ b/encapsulation/EncapIntro.java @@ -0,0 +1,14 @@ +package encapsulation; + +public class EncapIntro { + + public static void main(String[] args) { + S obj = new S(); + + obj.setName("Milan"); + obj.setAge(16); + + System.out.println(obj.getName()); + System.out.println(obj.getAge()); + } +} diff --git a/encapsulation/S.class b/encapsulation/S.class new file mode 100644 index 0000000000000000000000000000000000000000..4f55d5f5d70d0f9a3f7f7115100b136c1c0ea9cc GIT binary patch literal 886 zcmZvZU279T7=_Oy+ud~Cq-j3Y_>oqvNvh4IV5K0UP>5An33%bfBwgax%}&^C1pklV zjTb6b!3%$YKT13^3D(#Un0;sRo@dT^=hyEaKLOmso`Z})S*gkNaXgfh=`50IsN$~g zz!E5)$hWc^$#~R#HaH1}sX$ha0s(O-V8wFGveY|k^3x=YNBaWygD?)$1Gcx?eYQSQ z$AOD1@*dXV3T*VkI5?V(2SM^e4kCk5LmBmD66*cp&`Mv2Q-Nx4g+YDGG)Nz6J67wk z-Csu)bqBR2+y1+08jL+$#3hg$6yGsjcmDuvWRNWY literal 0 HcmV?d00001 diff --git a/encapsulation/S.java b/encapsulation/S.java new file mode 100644 index 0000000..0fc2320 --- /dev/null +++ b/encapsulation/S.java @@ -0,0 +1,29 @@ +package encapsulation; + +//Student class short name as S +public class S { + + /*we have to put the variables private to achieve encapsulation*/ + private int age; + + private String name; + + //setter methods + public void setAge(int age) { + if(age>20) System.out.println(" You are to old:"); + else this.age = age; + } + + public void setName(String name) { + this.name = name; + } + + //getter methods + public int getAge() { + return age; + } + + public String getName() { + return name; + } +} diff --git a/exercise_and_practice_Problems/Cylinder.class b/exercise_and_practice_Problems/Cylinder.class new file mode 100644 index 0000000000000000000000000000000000000000..e6ad1bd335d4cd1b224a500d54594359b27a7bba GIT binary patch literal 1504 zcma)6=~B~B7(KTXn$`%lY%VBqCAC7`5VfcXh*m2UiYPAB&|b@xHo-J?%YDA%~A zSuZq)P83!19#OrjMWCZ!7HWWE=)0v+fsA3S8NMNk2aI?tJ zLxgvDsRK$$i_0pm;3|XSSbn7#I`o|;q&tl3AzWi<_xNpRuHuG799ogdD4Pmy)~POe zR;UjF^p3jnuJOJGDGBcDpY z;L}38E9-}?G8$-y=A!H*)jIB!Dah>2jfziy$ zzQEXBuPPIm5ttc@W)f-4B`|v;h0;&0KsHRA#|7r$xB_!w9*&nQxXpG@3Vdld@<~i% z!Nf%@3QTN8cg|-{wO!etguo>ebgKeOnZn9YI#D!v10S(3lj`7(I{2}`>S?b3!vUK*6$cwNHG?(q*#I83 zw#Gjnz@rA&`27JqYV#=RFHC%il7JC-A(sNPncpe`o9QOqTp zs#JB?z_;W^6(aBgyKcGOnkq(E6F{PNy}-mKIH2M#aCJJyE7b1 z%rAS&_G|3J^eHVRFs|um9|5;4&{5fi#_5$ReWBQ(25=z>r6Em=E2j-|WQ4j1H{(k(!Je^Z z#%Ur}NGy2+R!~sZ?IM*5qC1dy4#Ydq1>xLrnxs+}$kyEN@1E~`KljgnpZo^kDsCGX z5Gbf^6}n!eR;Axs?S|5gJy)$RhrwD~b)w4RfqU9ON?>GDZplhp`sJz_fz(3KQdtZlVL_M=$o;m4+*QUxgWr!8UO6g<={zQLH)^ zPT^I70S#*RA-$kd^Siy6s7iKbvlzj+F6@lJ>B37xicOv2oQ2nLo=pjQ?9ma}GRZv$ zGvToRi+-#^#}CR*@TH^JbLGd8vlH~3`_hjc&v#@P%AJ`k-oQlz7X-$Vn#k-Jn1wfS zNxUAj1Gx#1=;W2w7mhM+evYTwBfjI*U0@+5;3te^7)7yLE@I{pM954YQ@j(Ftl(_Qz z8q_L01<&;4W0(&Uca~r6228xduhkFWIZQ2s6UfoR%i?=NnzTI-b+PmdMm~Rp{9~NH zGgwVO!rA=mdziSqhqtOJJN0XJW=Pvgv<+5`U5t+p*@pJswbNQGe^E_;YY5x0Q$Otg z-4D?h7&5^#3E4yCASBiLY5%XwzoSI=^e!&eDQmRp($l5VA26rtyBID_{S31-wTJgg zPam@G9JcTc>89`c`vwu+SU}%(J*NlpKuW616f;ay4vx$R~G;@~0TbXN*|I zS!`0?!g>72Xx*kyl72qGEas@?@HKB;V-5#Re1z-Fnnw%sl+wgrX5Iz1`3n6vXfv?F zm(!OPdH*`H`%G;bxM`r8{6~Z^a7zHTW$*LxrjGkSU-cQxc^;X}KOB%CBR%cfe?ea; A%>V!Z literal 0 HcmV?d00001 diff --git a/exercise_and_practice_Problems/Getters_Setters_For_Cylinder.class b/exercise_and_practice_Problems/Getters_Setters_For_Cylinder.class new file mode 100644 index 0000000000000000000000000000000000000000..90b6ebe66c4fadd15154f2552ea160e7dd705f78 GIT binary patch literal 1210 zcmbtST~8B16g{(DcH6oXDBmKwfWlIg`jwbi~X(YezAWj+?c^=3E6DX zfo)R~@`mh2lx#3$I#N*Sk@RJ}Mya#B$DpqV4UtC%1q*pxVi>AQUp()&_eHqNi3UTl z8o1osYvm%=6k$#O1xq=oux?>B<#q1g2^QWHK`jy7^KZ7Ve`VZ0Yu4zb%s+wi Y;X?C#-{w1gn^!J2FZFG{n~b>k6aPBZ9{>OV literal 0 HcmV?d00001 diff --git a/graphs/Graph.class b/graphs/Graph.class new file mode 100644 index 0000000000000000000000000000000000000000..d5bfa95b4c681bf09b4752b007823bad1ad6461b GIT binary patch literal 1755 zcmZuxT~`}b6x}yplZ1glLVz|2O+PGw(ne9KHWZbXmS_sKK`O0Phs+QL!X#@lVd;CH z{SSTWvt1fovh)Y|KYaBki2L3NCAfH)xpVJ5XPm+{UhkfPh|ijn+=P z_)snyLIT6P#(`067*4&owzX^3Jb|EL?h1@Quc)hzXE%x!+u5_sirw}~02YkwW zY=Ob5XVmr{8Lgg=W|-!(Stn$;P$tsO0ZP-)C{(-Iacc}dU|Ma@rrdVZpLAutc?661gFn_lx*e4axkzj%7Tctz-S*u~@3X z%5k>Qip(jl;d6HSX+3@CrH-Z8+cxkj+mcue;&(`}4 zOeu%P- zGNT9i(;=7~RjwL$0YrJqzXv3{0iOJXkg}VaIfOow`2&exF%rD{8mXCIFp@n&V)GEG z>dS!0W?mit^D|w780GsSK|!DpVRQ^)1VfnQdL6?^^Cs`ZVhrQl0aKX31qL1BdXZlN zWO$lD;FzvK4MGUHWf_s{ajVft=8%(AGIQDAFxkbmr;6BIrni%f0*cX)GEOnVC_&PF zEOKvI2qTbqtP&$&S)kbac!B literal 0 HcmV?d00001 diff --git a/graphs/Graph.java b/graphs/Graph.java new file mode 100644 index 0000000..11b1c23 --- /dev/null +++ b/graphs/Graph.java @@ -0,0 +1,42 @@ +package graphs; + +import java.util.*; + +public class Graph { + + private LinkedList adj[]; + + @SuppressWarnings("unchecked") + public Graph(int v) { + // array of Linked List + adj = new LinkedList[v]; + + for (int i = 0; i < v; i++) { + adj[i] = new LinkedList(); + } + } + + public void addEdge(int source, int destination) { + adj[source].add(destination); + adj[destination].add(source); + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + + System.out.println("Enter number of vertices and edges"); + int v = sc.nextInt(); + int e = sc.nextInt(); + + Graph graph = new Graph(v); + System.out.println("Enter " + e + " edges"); + + for (int i = 0; i < e; i++) { + int source = sc.nextInt(); + int destination = sc.nextInt(); + graph.addEdge(source, destination); + } + + sc.close(); + } +} diff --git a/graphs/Graph_Traversal_DFS.class b/graphs/Graph_Traversal_DFS.class new file mode 100644 index 0000000000000000000000000000000000000000..3f1783249365f6332682eef47e651fe05582ddb1 GIT binary patch literal 2133 zcmZ`*TUQ%Z6#h;!FeD75ka8)(l3s))TvF%_8`^41Q={QhLsKa#4rB-exjC88_T6WH zKz;J5&vj|2qAs8P5x)5DFK~(9nGA%u=$gfuIcJ}}&-ZbV_(fwi== zrDmIjc-k!O8o9JtwG#rqjF~U#cFi&bCQjcq*YI`1r%JYwH>|`Ry0*`mCDXnmphQy9 zEMND_Il~Vx0vbAThG$2jSrxqkXHPra2O2b}=Nod)urE45!~N3c(3epetkRo4X5o#r0J6T<$?G&%kYw6e0UDf(t6b0zFLu zU4|Mi;*x;6rx$9*(w0C!NuDBv#Qv^^QH(iS=LGs9C$=@xk%&GeqGt@pj6G%!C|)GB z_B5LHVFFVsCR=itc~P~EqJ}uGFlf2PboMo3n&tSiWtQxWZ5etop<;%)ZDQxLS<2t5 znT4ET`Ed<5R9tTj?d*``Zc3yrlp5X%Kc?}X%;2s6adGX@YzO8@CoDJK(Qp^shiDjo_19mcI%Xh=!GYDLOZ zD9N;ZtRamB0jpG#;;8dG>Sgl+#I-Qus6Fnzd;pO?f2@o^l6H$z!d0L1 z?dPhHJUDi7&u6atTN%p_$<~IA6!*ClZ6l!Qkf`=w-~{i8BMoX9nCeW#9<$%H6CzH~e43-o};X ziIB4LJ;o0(y&8IhtNWPkP1JF_jt}a1&^Wt}j}~8HWb!903jB_dI#zBd6Mf3nm+;5> zl!-b%rH#e<^6*cIPjT>#I->V;Hb7G6sKF3V4`G%h?{X!{`4YQD>UFJwjP89vjv&gT~Y aO^`D7Hz1&l3THmrzoPJLAy}MyQ2h^^w7aGN literal 0 HcmV?d00001 diff --git a/graphs/Graph_Traversal_DFS.java b/graphs/Graph_Traversal_DFS.java new file mode 100644 index 0000000..a8ec9fb --- /dev/null +++ b/graphs/Graph_Traversal_DFS.java @@ -0,0 +1,57 @@ +package graphs; +import java.util.*; + +public class Graph_Traversal_DFS{ + + @SuppressWarnings("unused") + private int v; + private LinkedList adj[]; + + @SuppressWarnings("unchecked") + public Graph_Traversal_DFS(int v){ + adj = new LinkedList[v]; + for(int i = 0 ; i < v ; ++i) + adj[i] = new LinkedList(); + } + + void addEdge(int v, int w) { + adj[v].add(w); + } + + void DFSUtil(int v, boolean visited[]) { + visited[v] = true; + System.out.println(v + " "); + + Iterator i = adj[v].listIterator(); + while(i.hasNext()) { + int n = i.next(); + if(!visited[n]) + DFSUtil(n,visited); + } + } + + void DFS(int v) { + boolean visited[] = new boolean[v]; + DFSUtil(v,visited); + } + + public static void main(String[] args) { + + Graph_Traversal_DFS d = new Graph_Traversal_DFS(4); + + d.addEdge(0, 1); + d.addEdge(0, 2); + d.addEdge(1, 2); + d.addEdge(2, 0); + d.addEdge(2, 3); + d.addEdge(3, 3); + + System.out.println( + "Following is Depth First Traversal " + + "(starting from vertex 2)"); + + d.DFS(2); + + } + +} diff --git a/inheritance/MainClass.class b/inheritance/MainClass.class new file mode 100644 index 0000000000000000000000000000000000000000..b48e58a3c2078a718c9d511c29715ebea67de87f GIT binary patch literal 782 zcmZ`%+iuf95Ivhq9S4(!6w)^3V$3Z!nii0FDB^)i2%!WX5=BBhZOkg&;@HS`Kzs*Z z!b4k$N_+qxg*fX}RBAxh?t0GInK?7FzkdJt3E(N7SjY)%M$xB4hX*RwsSJJ98%Q1Q z2Qo=46a=b=^0Vv(GMx6_P7aly3amWSp-!I*dkyM zQSnGl0wqxEN4^ZkGS%1K zv-Xdg1;mImTk6?a&Fq+<=f)DhP(r#qjOMYgUTQO!%HLUUn6Lj|!)psX+3!U295w3NPvB`Cv z>((heGIs~v+Pxz@=pLiV)j3bphDm3k#IM5OHQIHiZ7`Wfq{(Dm&SZy-5#ufr5_?Fi Vgci258a&?H!ERRFBQiNW{sYp2pi2M% literal 0 HcmV?d00001 diff --git a/inheritance/MainClass.java b/inheritance/MainClass.java new file mode 100644 index 0000000..b13c4cf --- /dev/null +++ b/inheritance/MainClass.java @@ -0,0 +1,20 @@ +package inheritance; + +public class MainClass { + + public static void main(String[] args) { + //Object of teacher class + Teacher T = new Teacher(); + T.name = "Mr Harry "; + T.eat(); + T.walk(); + T.teach(); + //Object of singer class + Singer s = new Singer(); + s.name = "Justin B "; + s.sing(); + s.eat(); + + } + +} diff --git a/inheritance/Person.class b/inheritance/Person.class new file mode 100644 index 0000000000000000000000000000000000000000..ff00e65f74af1e5d69340452b29c4499607abdfe GIT binary patch literal 907 zcma))+ip@p6o&s{QwDaYR_TGNMO&*C&~|&S3C0Ueyph-@7?NHNFt$@Sv&lZx_*fc4 zjV3;T4`p1#CIu7|Z)VmU*1x{>&;0!L?FWE8JmttRtOh|p(&ku&I+muRyaN?Rf#Jw9 zTs)Dd((|P`^7h*&suMG0jqE9gVq<*Nj6-dX>I}JO+UWQ>gHx%t=<3U$t6Vsk7vRV< zEH<=JZ<1bHg>PlsAIbzB>9=I4?RvDCjgNK2u-2GOMuoB;r2oEvB9=LprZAfyqgeF> zR<1LBN{R>@wSV~wHoXA>_H?RQmJ0K*l5Ipkcd;~GbKy2!9$f$P{{ z;HT10)c!k$?aG8HsbBT##Ma0s7bV=Vj%*RzWXkBg+REb=gR7$r+a_6SGj0o1P$iFL zzpqS}VP{tAU)4qp)vd%GfxFmY$j3oiieb4j6VStbj(ZGCLw}~76L?_BdEc7p8**96 zIFH8+1tO-HfQh~tBwmT=TCBCY6Y&XZr0s7)?^#-;Bl9oD|!@>g6v!)Ed30NVr92G|{o ix+D%tUZ=`q;qtlg!~YR}^iN?y!V5EnpHSHh_I?9>*~5GQ literal 0 HcmV?d00001 diff --git a/inheritance/Person.java b/inheritance/Person.java new file mode 100644 index 0000000..10654d0 --- /dev/null +++ b/inheritance/Person.java @@ -0,0 +1,12 @@ +package inheritance; + +public class Person { + protected String name; + public void walk() { + System.out.println(name + "is walking"); + } + public void eat() { + System.out.println(name + "is eating"); + } + +} diff --git a/inheritance/Singer.class b/inheritance/Singer.class new file mode 100644 index 0000000000000000000000000000000000000000..a5a11476e7028c9bb110b095d5159345735f54c6 GIT binary patch literal 795 zcmZuvT~8B16g{^sY`d(2g@Pzm5X80u>j%b%8Xq+A#Rf=fn)o_kR!s0s70lvd_7Az!O^2!*#{U%JSnBpv~k3H;RpHMX6#EP&|%M9q_se>nk<&3U+cxID3BirbJC&F!q zNz{|?l>ONYlNma&L~L=3^E_}sj^B7ZxH`P^c_m)w8kZGw00g{{Hjh7l2oIX(2~g4Z~rqf^!)uEdo!vCsKHvStt-z zrom$w#bH30d#wVc-w^WkMwd`{7xtx%JjxD=m?JE-RUkhmgPx2|M9-ImN;~v~-xZNE zd3IRP=PD+wwWoD56D>kf8$V?%qGI6=Vevv-3fC9GncMjsYdLVRgk?4oCYn%fr?3j$ z<46U%qa!H>Eek8$=mb$Sc=k3?eqTmq5bioy!#(aJ5QEg~^xc+?bv&?8``18P$H7Bv z5Ufk#C-UeMVXr=Rk(xZ}T}V&28WTtCisiXv6p?7V2+{e zJE)_e~)wxap literal 0 HcmV?d00001 diff --git a/inheritance/Teacher.java b/inheritance/Teacher.java new file mode 100644 index 0000000..3e9f746 --- /dev/null +++ b/inheritance/Teacher.java @@ -0,0 +1,7 @@ +package inheritance; + +public class Teacher extends Person { + public void teach() { + System.out.println(name + "is teaching"); + } +} diff --git a/linkedList/.cph/.Reverse_a_LL.java_5317e4db975f6452a2d44820a699b094.prob b/linkedList/.cph/.Reverse_a_LL.java_5317e4db975f6452a2d44820a699b094.prob new file mode 100644 index 0000000..6e2527d --- /dev/null +++ b/linkedList/.cph/.Reverse_a_LL.java_5317e4db975f6452a2d44820a699b094.prob @@ -0,0 +1 @@ +{"name":"Local: Reverse_a_LL","url":"c:\\Users\\AmanSoni\\Desktop\\Java Program's\\Java-Eclipse\\Placement Prepration\\src\\linkedList\\Reverse_a_LL.java","tests":[],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"c:\\Users\\AmanSoni\\Desktop\\Java Program's\\Java-Eclipse\\Placement Prepration\\src\\linkedList\\Reverse_a_LL.java","group":"local","local":true} \ No newline at end of file diff --git a/linkedList/Problem_1_1.java b/linkedList/Problem_1_1.java index 52087d6..060090d 100644 --- a/linkedList/Problem_1_1.java +++ b/linkedList/Problem_1_1.java @@ -3,6 +3,7 @@ /* * Write a Program to Reverse the Linked List Iteratively */ + public class Problem_1_1 { static Node head; diff --git a/linkedList/Reverse_a_LL.java b/linkedList/Reverse_a_LL.java new file mode 100644 index 0000000..4a1749d --- /dev/null +++ b/linkedList/Reverse_a_LL.java @@ -0,0 +1,57 @@ +package linkedList; + +class Reverse_a_LL { + + static Node head; + + static class Node { + int data; + Node next; + + Node(int d) { + data = d; + next = null; + } + } + + Node reverse(Node node) { + Node prev = null; + Node current = node; + Node next = null; + while (current != null) { + next = current.next; + current.next = prev; + prev = current; + current = next; + } + node = prev; + return node; + } + + void printList(Node node) { + while (node != null) { + System.out.println(node.data + " "); + node = node.next; + } + } + + public static void main(String[] args) { + Reverse_a_LL list = new Reverse_a_LL(); + Reverse_a_LL.head = new Node(85); + Reverse_a_LL.head.next = new Node(15); + Reverse_a_LL.head.next.next = new Node(4); + Reverse_a_LL.head.next.next.next = new Node(20); + + System.out.println("Given Linked list"); + list.printList(head); + head = list.reverse(head); + System.out.println(""); + System.out.println("Reversed linked list "); + list.printList(head); + + } +} + +/* + * output: ! Given Linked List ? 85 15 4 20 ! Reversed Linked List ? 20 4 15 85 + */ diff --git a/list/Insertion_in_Linked_List$Node.class b/list/Insertion_in_Linked_List$Node.class new file mode 100644 index 0000000000000000000000000000000000000000..0c5ff7bc04a8b5eab276f80a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C!ORPh!g?u*yz+hyiR; wrN_u%i!wZ+w#F%-_`32@X=Q2o+C-x;s$*qjU#sHiv;LQ-~9snRpgmPx$xU>&Z+` zH6iW_EeO7fku zRS;_IF})aH+k9rr5{4__IA$;Qh<^??>ovCSU`4r=&fyaI&KsOgeTj01mZ-imZeg8e xjeCLf6I_=;o?iiFIM|3Vi)96yW=dpj@m$k&n>`D4?6A)AJVJx{0sB$B@eLfCXfOZ( literal 0 HcmV?d00001 diff --git a/list/LinkedList.class b/list/LinkedList.class new file mode 100644 index 0000000000000000000000000000000000000000..f521333476896e3a7d44eb116f684ce2d484533c GIT binary patch literal 1834 zcmZuxT~ixn6n)_%Nq~%rmqm*)=p8OCwEMLWT{-#(+ZIp*K_@=3ZcYk zf$H-Vn+T!Jf`KS;2%(qiI~%&X>THy>LOfUAbV>!M>dL(-4Ex(|O`-ER3=zVWdTpCq zB0E|z(4}zpG%6=&H?)mGq0d4qA~EU?SQtcvZaw`i!;E_RoAsjOI|?e> zym|~p!7S>M_O*mdd8J%)eYfn<(APT^YP$;UE55V&DDPC7!Ne+6*YhQ-F}#a}f%jfZ z?aFsG+FBSzl4&c~3E!OyGVhi%x5RYCuWDy!+CW;N_oyZmyWZCIx?3vhssu4^A%kIZ z5#}b|#|H)`UdIYdEKK5}g7MfX)%EfN$xwE*0T~p#;dt6a3YR2@mxCN02c8}+L@~vX zZBd-D@DW(|h*PO(k1aBmIO*{uNRxelHEUrG*O^tn++e`kCQh1AcL9qAK33>DB~2D? z2;tTs>D>KB-NHML%QE#O?wvxbV6qw7WXW6TKxY)o3jO9h)9&k{-53j7`pkA~Q;c^3 zpIP`^aEt(_#DsVJ;b)L9p8S{LiXg8&C)s5 zEjE7FDJ&UFNhq)fSIYJ3re1VqeuiE-TX((n1{AlNKQ6gZu(F<~tMetNR?~DGZZvM& zlCJrAEn`@NO~N6*1&SZXAy^^fN=b~j4ENx_a&RAK^XcR+dY_{|nSPGmBY$yf0(~$!iE*4mFHb;1F|$nVuy1jS)G6eq6u+r|LW|vIQnFfy*3+E4a#a z5!Y}Nvq3DAOfb3q7fX)ONi6Nuc{7M*2t9aFVM{8;CE(msjQoUm4v<<)?PBa_T-e8l@hf|n-ov#$%v0E(OTBpc$5Chl zgaScZIX_Wk>G@MWNjDf^E}-7i@ZO}}%Ktv0g$l^U&~k_9erE)|v~B1@|*9Z{}i8(-SPt<)Y?Qq=lF1h<=lqb8XM%CJg?1v0tKwA^7s ztTADC$>csCqAyvFb(X-v44ZEjoBv}!N6ot=6lH1du~nt-@AKY5tFO4r=*Ic2^ZYfx Hu-yLzq{eQ_ literal 0 HcmV?d00001 diff --git a/list/MainList.class b/list/MainList.class new file mode 100644 index 0000000000000000000000000000000000000000..b84c7fd8d180765b0ec8276394e89d1988375c5b GIT binary patch literal 534 zcmZutO-lk%6g^Kz#~C%vO8fqTLJM-)!e|o&!BmSvh*nP>?8!97Gz$K#HVFm&fPPeT zZW2VLIi!$QD0n9HuLh4TKf2Yez*i`F{k9I8IxaFIw^3`_m{)KnJ0s6?QG_F~n8OmvG^INoa#SyBO=&OZup*{X zPu!<@OGjO*F8sqS%A+7q$WASho_5@u{vc}m=SF^#|2@u;Si=q|$O8fiX8b+TW>sfY zjH!b$GA}>RE>WIkG)v4)1{m|K9L%A>jw}y3kzm|^NAYgV;~genv2bV!qy*9ew!kYY tGxl9%xRoY4"); + node = node.next; + } + System.out.printf("\n"); + } + + public static void main(String[] args) { + Node first = null; + Node second = null; + first = push(first, 6); + first = push(first, 4); + first = push(first, 9); + System.out.printf("First list is: "); + printList(first); + + second = push(second, 4); + second = push(second, 8); + System.out.printf("Second list is: "); + printList(second); + + System.out.printf("Result is: "); + System.out.println(mul2Lists(first, second)); + } +} diff --git a/list/MyLL$Node.class b/list/MyLL$Node.class new file mode 100644 index 0000000000000000000000000000000000000000..c5c248b45d7257eb12fa9c7017e0e766232a72a2 GIT binary patch literal 422 zcmY*V!A`5t0HKBnQ43fB^~pia{>Q0U1f81rLEAj=1;9j^kZKrP#vq>T&KCgF&&io86_SXBEs4s@~O1!6KlLpsIZ#G;0?i`yJjNR y*m@;Z!Zxu5hv*S~Vhwc!*df#YX~S+Ylmm)2c4@ol-NQbkT_eyzm#V{p?|cJ8(MIe5 literal 0 HcmV?d00001 diff --git a/list/MyLL.class b/list/MyLL.class new file mode 100644 index 0000000000000000000000000000000000000000..289008636cac16710eb7f899b2d1b1e99edbaf52 GIT binary patch literal 1471 zcmZuxZBrXn6n<`AcC%q=Dk-2)Ds5>^7DCXfRjJg1tzwhV4xP-@ZwtA$Ta(>PcEiXI z@JILu?3aGQL2&GhUzzbo_&5B*Sf8`m2{2`L_TGE$J?A{nea_ka`@cW`0&p9TO{5g8 zwiia#`fjaeBBOBeg}dWc+phnty0P^_Z$}E5=h|)Yq&D=NYXmL5tdQ#lp%;09uVCEq zd@ov2NSDe@#;nmJk2Gu>IamsXn&<0Azq6%#Pu#7xRv4=V+itt*_B^qZ%}n&%3l&CA zun3cOTg14o<@-Do#v^u5KC%QmtwEP7wD z@jeWu^z~12!Im4j3Tj;;8wK}but;~h3Zt8myZvL`?I!fH-Ja)17Cu1PMCpuLo4X-n zY&e)FWYA~c@megV7gQff*k;tzZfDs)WZt0$|tJ;{w)jU4LEfXJ| z1&Muae2h7;_>!*xtYTky!Na(-m&o|SU$t; zcC}BrE9XVLl_a4ZV|``g9#+{EQ7~YjaH(`IudngI#C?V0Ir`Z6MhKg+(rxLip6&!Y zY#3IwDL0l{KD1#<1@oIhzqhR)c+ydpbn&9(RIt~5U-#D9ZWwAdR7N_MebvxmRM*ml zA+9n{nqNYSFB^j+Bq>LOC+u2|d0JJ@igVUE#K;~ODU2pgV1f%=+XDv_aFG`94#tw; zJ$hugv-BFpr_+ZRuR8~r`~{Y?@H?jWoPA6;ULsf7$4oWG@mQDjO&~ouBz;5;o=PNhFq4Uo5)7G_8PC2qW?If4CbGse*x)ZOqeJh z!{jJrZw&ALGn0uvi$b*a5_7-d=4&iGo!`geA6PoXr(>TVVEF)d53t6~ncDo(n}1Ho zPsMs(qrTUv=p3ILD05vwDJDBH$exhR#%H3w5VMdvMvjzbY4Dp)6kXvg>CLVkMAIdld z#2}mOW@oSp~}J%sEp;4Yy~nLwQl{f8pHzDP{vZA z>i#cXvAd^7p^TGA37DQo#tPLln+opAmt^G+wW;cm%CvQ;QHr)M_)yr^aDnzx|4wn`ZCffUXoV)pl1U0_1eqy zw{G_)NiKh+1aFU%2+0U*WhM0qU;>yc;;cRaDg|$*KAX{ zP?S)n#wSjD?dCfw&9gV`z7mmGG-^@SSy^iG$(oO-ZUE39fcPBm~y KY~W})`S=Inv1XY7 literal 0 HcmV?d00001 diff --git a/list/Problem_1_1$Node.class b/list/Problem_1_1$Node.class new file mode 100644 index 0000000000000000000000000000000000000000..c012ef14eaa6112595053a6602f094e2ead33c3c GIT binary patch literal 454 zcmZutJx>Bb6r6>V13dXsL_rOO1yD$+EHpMGMiK%h8d|czMwc9S$?akMTNcE`!XMy| zGR~eB##roov$ONwo3|gIZ|?xkapEE+Q1!KmySGs|^VMqFoAype;X=7^1WHT!B)h&0 z9=hY%Qq5xlXCY%LAO?hidL~mF{@dU}Aakh$9bZw|8nh=&eKyV`jU5j;6a><(_9O?+ z@vw!AMHLS&vI51S4%BG9nyKhs(imTc;avI?8EJd}A)WY98@gEt99$%N4+>?q#J?n>#BhT zu)eoZw^XZBXfqtC{{82@E zi|Wh;izRT|Ko5GOxFc|U+1`{+lFj=>){?4s)HBn-X`E4~l7SeGM{$>lx)-#kQrp!| z(yZmKv!xS9kl>{*#VKGE97noKb*tT$v=vc9NA@Mz_KH%? zRGW>&KH_LIi;6u@5uQ1FT>B{HxC`z*Q`^vA@eqQ+wbutV9OKyt6z~-WC_zO=L_K~* z?H=yqqL?X(g~&@JvTqPyh-9b#L_AwO6)9!kef)3Q%=}KRuy1(={X7rz22iVb6c3-!j&y75{#RfcOU;%`3a&J z_8Co5x`4AtVFHs}r+l_5HX7Y!o9?nzeCRNoWbUrxMwi6`xNGb}^_5)okHuyg{8ZRi?RNul+!B+IGjjE^?8EbrHPhqd>bAE+# zY>rtBVvbXM3G@6EILbfs-{B#yU=3HX!MSvi$8%iU7x4?~++&PU-j$ho)p++QhwuOu R?rJa+{QW|Whkh<7e*zsIRXP9w literal 0 HcmV?d00001 diff --git a/list/Problem_1_1.java b/list/Problem_1_1.java new file mode 100644 index 0000000..0247116 --- /dev/null +++ b/list/Problem_1_1.java @@ -0,0 +1,63 @@ +package list; + +/* + * Write a Program to Reverse the Linked List Iteratively + */ + +public class Problem_1_1 { + + static Node head; + + static class Node{ + int data; + Node next; + Node(int d){ + data = d; + next = null; + } + } + + Node reverse (Node node) { + + Node prev = null; + Node current = node; + Node next = null; + + while(current != null) { + next = current.next; + current.next = prev; + prev = current; + current = next; + } + + node = prev; + return node; + } + + void printList(Node node) { + while(node != null) { + System.out.println(node.data + " "); + node = node.next; + } + } + + @SuppressWarnings("static-access") + public static void main(String[] args) { + + Problem_1_1 list = new Problem_1_1(); + + list.head = new Node(85); + list.head.next = new Node(15); + list.head.next.next = new Node(4); + list.head.next.next.next = new Node(20); + + System.out.println("Given Linked list"); + list.printList(head); + head = list.reverse(head); + System.out.println(" "); + System.out.println("Reversed linked list "); + list.printList(head); + + } + +} diff --git a/list/Problem_1_2$Node.class b/list/Problem_1_2$Node.class new file mode 100644 index 0000000000000000000000000000000000000000..92c3dcc580ee570dbdeb48511840f7973a93c963 GIT binary patch literal 454 zcmZutJx>Bb6r6>V13dXsL_rOO1yD$|vC!C%7)c12XlTg-8(nhTCAWw1Z&?r%3x9w= z$~b#k7-O;T&CbqyZ{B`)K|;N>E!Hq7|xXoN1(KjPqORF z;GsL3F4Qa*aON_W0-{eCsAn>@!M_bI1TvR8(D4jXVMKg7+t+@1S zofEr+fY%QK74>{+j50176#ey0hjw*=>`BlNVoQFIL|6@-ejf{p-fz1BE!9@dO7$j>)KJj%395s-{5gJ_SG5g_~Z*DzaG24BX z18vuG`~)3O8W_M}0-xZNhU^E@)qeDR*)(t(XQ)c6!#J60psdxRrU1>JU8YZdi zp5`=L&i3t&WjCa&n4dF{M}ce_rf&*}B^^_k)^Pqqyx^LF8I-71*R(rw?FVA!mkJ?l z@StJvvW^@ssHd4z9tY10^*AmODytl?7%Z4;d}FiSmJZ8c`mh@Zg7h;8ux=PAV_qQc zw?YO2qxnO5Rq&aHn*!-Wq%v?Eb2=)xZD2uFl@>gN?NA$P-R9Kpcsrb!bX})(U#c7z zX=s`jy~gqn4$v$sPl2j|FR&QLs=$#uR#!S%+j1Vu1}Bd-QNdk>NpyjGibp(-`%L0q zSd)z`>-#@%!kO+i%Q$@qnt)zwb=)nvXsIqpzSn#+DrEs<$#JB+V4I#N86>7UOkil0 zrMMzh19><_7E$&w1y%LO)d1IQG>!@GN}PqV7GFaDnTrSvj)Q?w!!XxI=zxzf!d+a| zJ1y#Rm);T1x#FMDi@zfEnsJ`1#V-E<)Li_HpWra{oPNXh? zxZK0_9zIo!mW!|7{!OPIZmD!bN)uFsX)x3zS7&hs=h#S-IFAD6P<$stjCy?@&{t#< zi2MUhLpn<~EQvm&bp}8A@8hC}!VFKcgBs zz%T+tCHNA)>O=fQfFSAQ=q{Eue#sFvtaD&)sg)kqcJVb~`4B`^wpwW0BT$4+fJ@Z* zGJ{{?`(9-qT&K1-FoAhWP$8|G6yVl70jM+9QRlrVzTp_bx7gsUiapKmJ1X&jd-W#i Fe*t9KJOcm# literal 0 HcmV?d00001 diff --git a/list/Problem_1_2.java b/list/Problem_1_2.java new file mode 100644 index 0000000..e3ad43a --- /dev/null +++ b/list/Problem_1_2.java @@ -0,0 +1,68 @@ +package list; + +/* + * Write a Program to Reverse the LinkedList Recursively + */ + +public class Problem_1_2 { + + static Node head; + + static class Node{ + int data; + Node next; + // Constructor + Node(int d){ + data = d; + next = null; + } + } + + static Node reverse(Node head) { + if(head == null || head.next == null) { + return head; + } + + Node rest = reverse(head.next); + head.next.next = head; + + + head.next = null; + + return rest; + } + + + static void print() { + Node temp = head; + while(temp != null) { + System.out.print(temp.data + " "); + temp = temp.next; + } + System.out.println(); + } + + static void push(int data) { + Node temp = new Node(data); + temp.next = head; + head = temp; + } + + public static void main(String[] args) { + + push(20); + push(4); + push(15); + push(85); + + System.out.println("Given linked list"); + print(); + + head = reverse(head); + + System.out.println("Reversed Linked list"); + print(); + + } + +} diff --git a/list/Queue.class b/list/Queue.class new file mode 100644 index 0000000000000000000000000000000000000000..8937034127d92960e73c31ee58f24aa9eacb34a7 GIT binary patch literal 1649 zcmaJ=O>Yxd6g|%~j=B%nl*!UiVx5C)R5vBzyf zL29YGY1Pj~zgFFK!vdtBNFc$Uf5Jatg*bQK5IeYHF*En$ymRk6_s+{VPoD!ggUJM9 z3aJ&Z6^vbJyKOfCQz3iH`O+C%as1`6*`-@{3= z)8(N~W^#UhVv1?A={ik*THaj()Fp+!NzeC!DFvfcUSQ@tc~UTtwP0aq5(>L5#L*{K zzlEf>1}vnIR>)L5-<@f%F1gKlXK96;yDRmov$EhcJ@KQU8Qk<*3YKmtycU}o*bZH9 zyo2YuaPK;2d+avhwJxkSg7vW7s|q{k0;hU=+G#|E`b*`?`%cU#pZ3JH3ZzXU< zVNXZikZvnYSxaSVmBJ9RNt9qGP^PL|5?dI-amrM40!J?UKgANRe@6zVP$>20MdZE` zOOzK<$(S3YOKn-WaF=0>b$;I1}!r@4B&S#>XZqIxRS zbX2-gC{50v>n%Lh8^R$D)!^D0h{=rUCFsSlgAXUY&F8$ClNk4c?_Kn+6Q}s?w>Oco z)f438mA8#2C_HA|z#!iPiq~$ysidBom8r1dD&oH#OiDNJ5<~A_=C_E&3?IH!x;Nd&Spw-pG zU{4Pc>FOcF9!_ACm2~B?u<~mX3gwKhJoF5u#gR>%oVJh4$oR_Jixk1U&bj@Eaworm zJhS6A59T*8z6~e?)?$r@tFgwK>&W6R3iz7iyoV#Wk70a+llT^A@c`%X9j5Vpcp;l- z*->;MvG`-L`z-qLDc3BuUUGTX@1IDb)`ze90~;kafaaSkF!gotyN4B8S&Iw+AuqeK#o6068Kg~$|n&ChAa Ja4uSmiMR1-1t0(b literal 0 HcmV?d00001 diff --git a/list/Queue.java b/list/Queue.java new file mode 100644 index 0000000..41008f2 --- /dev/null +++ b/list/Queue.java @@ -0,0 +1,157 @@ +package list; +import java.util.*; + +/* + * Code: Queue Using LL + * + * Send Feedback: + * You need to implement a Queue class using linked list. + * All the required data members should be private. + * + * Implement the following public functions: + * 1. Constructor - Initialise's the data members. + * 2. enqueue - This function should take one argument of type T and has return type void. + * This function should insert an element in the queue. + * Time complexity should be O(1). + * 3. dequeue - This function takes no arguments and has return type T. + * This should removes the first element which is entered and return that element as an answer. + * Time complexity should be O(1). + * 4. front - This function takes no input arguments and has return type T. + * This should return the first element which is entered and return that element as an answer. + * Time complexity should be O(1). + * 5. size - Return the size of stack i.e. count of elements which are present ins stack right now. + * Time complexity should be O(1). + * 6. isEmpty - Checks if the queue is empty or not. + * Return true or false + * + */ + +class QueueEmptyException extends Exception { + + private static final long serialVersionUID = 7243921724361015813L; + + public static void main(String[] args) { + + @SuppressWarnings("resource") + Scanner s = new Scanner(System.in); + + Queue st = new Queue(); + + int choice = s.nextInt(); + int input; + + while (choice !=-1) { + + if(choice == 1) { + input = s.nextInt(); + st.enqueue(input); + } + + else if(choice == 2) { + + try { + System.out.println(st.dequeue()); + }catch (QueueEmptyException e) { + System.out.println(-1); + } + } + + else if(choice == 3) { + + try { + System.out.println(st.front()); + } catch (QueueEmptyException e) { + System.out.println(-1); + } + } + + else if(choice == 4) + System.out.println(st.size()); + + else if(choice == 5) + System.out.println(st.isEmpty()); + + choice = s.nextInt(); + } + } +} + +class Node { + T data; + Node next; + + public Node(T data) { + this.data = data; + } +} + +public class Queue { + + private Node front; + private Node rear; + private int size; + + + public Queue() { + front=null; + rear=null; + size=0; + + } + + public int size() { + return size; + } + + public boolean isEmpty() { + return (size==0); + } + + public T front() throws QueueEmptyException { + + if(size==0) + throw new QueueEmptyException(); + + return front.data; + } + + public void enqueue(T data) { + + if(size==0){ + Node newnode=new Node(data); + front=newnode; + rear=newnode; + size++; + } + + else{ + Node newnode=new Node(data); + rear.next=newnode; + rear=rear.next; + size++; + } + } + + + public T dequeue() throws QueueEmptyException { + + if(size==0) + throw new QueueEmptyException(); + + if(size==1){ + T temp=front.data; + front=null; + rear=null; + size=0; + return temp; + } + + else{ + T temp = front.data; + front = front.next; + size--; + return temp; + } + } + +} \ No newline at end of file diff --git a/list/QueueEmptyException.class b/list/QueueEmptyException.class new file mode 100644 index 0000000000000000000000000000000000000000..3d9db66657b0ff6ec25069c299079793150a5fe3 GIT binary patch literal 1489 zcmZ`&T~iZR7=BLJWMx^94}*xNjY>5L5^F0|p{RUGFnl$d7ObO7IN)lso9=EL>GY!0 z8OO`sc%xUD-Y~t?i_obv{Q>?c+vjY8q%$~~>^bNCc;5GY&U4;>`1>CKW4Ny)BG6Z~ z{UE(skrg>xDhE5W&kC{}*sh~P6Xpfn|3#)ffjU_FwiD&G;2F@sZ!dI z-W_YBC zDuG>0=L(kNNUs%r=+|+AlQkvn_<<~$IEhmN5d|8rL)vaS6sY9FcY3C zl9#vCteL^4VH;uWD~S;kXk7XesFN%Q6CceVgtnXIX#lfsA zf$_D1KRCE0XsDW#k(7`LIYly5hA({9#?5nK6i;fDuu534WgB&NX znx8T;tqMiAJl6@7W!A);B1`k_pDCau=1pXrkW>v8Dh)*iaCcV)XD?D=T0;v=k_GT+3aL;q^|24Z)-q-EvCV+`UZfcUK z?YY1zJXy5L4XqnFx8fD#oULAi5kAimrA-daA^Cp!4iH6*tIksdNBD<&PPCZZrMU{O z(F=QMe-nlrLW%44JkCQT(`AH6q2 z@1-X1Ktivgvz|K>#&;)q5#~s5>%&_CTcz_MA8q|baIKl4# zi8#lJQdIU3-|$5eH$qEVJqTRpZwyzMKT1W7VG&ocf^i~E66-oPaRW~<1&8=PX7MX- z;W_5DwlRDx$lA?E2hiD5wT^$-@?=d2RAO8c<=tWup literal 0 HcmV?d00001 diff --git a/matrix/Matrix_Problem_01.class b/matrix/Matrix_Problem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=%EgxjB8@0)JeHK*V-EVG)^5f|9~ymPAU+S1uIyHd6qLF{9yvHDuA zoHU(eDufu4vgiX0m-6Dde0g5E^sKaaD~v;UTR<~cR;*fCAf6geZ!`8&T^x>%DF&Jwm!YS_IE^#hJ+raI-RpRb14mz|uQe8}FMpM`&^f> zXMkOZ(l98A@}2*M;+A1HQHUo>YGpvp#QF_2YbbY+{u#zY#EQ|x1MH7&;$XCA6DdQL z(mRwkaby$6HntpoK%1c|<&h?We3ypfiF;4)GemSiS}}3J?Invg%7=LBK?o@rNMjHg zv_pYMiuaOH=R56RsiQl63HnsP06%X+#{^q>@!GdUkC1SWHdSQzkmc;~W;uF-}{h8swIpD4R zp)}_052Xv<{!o%z6F`T!gp2O}bc<2eqOsD1IPGqd#>y_@5_P(}Q@ha?d4hH!#A6JK zU5^kLIvGpvZ|7zHfGv2J`Z0}Fw*0+56daBONAy21Squb!4;7V&mM^N2V7{nDTJuFc z(v~k26^R5Qoq57t5{^qaA>sXmRS!NS;T{S1OL$nqrwD5vd|JY1C0v&9EyBC-Wxg<| z>``KIZg>9qm*Su#2Mt!aioOqtP1&d$P-y@M4}~O9Gg_=t*DgM|4p}MFTymw zWB*JDKFpy?<*Tws!oO4t8wfM7J^uh^vbKyqtEka{H$S0s3jA!DzpJ?1_u J!hq4i@CLdvJ177E literal 0 HcmV?d00001 diff --git a/polymorphism/Animal.java b/polymorphism/Animal.java new file mode 100644 index 0000000..faa7eb0 --- /dev/null +++ b/polymorphism/Animal.java @@ -0,0 +1,7 @@ +package polymorphism; + +public class Animal { + public void walk() { + System.out.println("Animal is walking"); + } +} diff --git a/polymorphism/Dog.class b/polymorphism/Dog.class new file mode 100644 index 0000000000000000000000000000000000000000..4f02caabe90af51ac5492b8a6084287b184c95e8 GIT binary patch literal 499 zcmZvYxlY4C5QhKFfe#D`xws*8fdZE)f@nZg7K#*cg*;w33v!6{DyEHVMfhMBk z0tI@}ImlWR`Q#b-^2I0Yx4G<+H8QARldQM+Kz@rNntNH?ox=d<9hF-11G_7LOOnCZ P)MW*6mXKpo3pn`$TKi_T literal 0 HcmV?d00001 diff --git a/polymorphism/Dog.java b/polymorphism/Dog.java new file mode 100644 index 0000000..0037a45 --- /dev/null +++ b/polymorphism/Dog.java @@ -0,0 +1,7 @@ +package polymorphism; + +public class Dog extends Pet{ + public void walk() { + System.out.println("dog is walking"); + } +} diff --git a/polymorphism/Main.java b/polymorphism/Main.java new file mode 100644 index 0000000..dcd322d --- /dev/null +++ b/polymorphism/Main.java @@ -0,0 +1,25 @@ +package polymorphism; + +public class Main { + + public static void greetings() { + System.out.println("Hi, there"); + } + public static void greetings(String s) { + System.out.println(s); + } + public static void greetings(String s, int count) { + for(int i = 0; i < count; i++) + System.out.println(s); + } + public static void main(String[] args) { + greetings("Good Mornig"); + Dog d = new Dog(); + Pet p = d; + @SuppressWarnings("unused") + Animal a = d; + d.walk(); + p.walk(); + } + +} diff --git a/polymorphism/MainClass.class b/polymorphism/MainClass.class new file mode 100644 index 0000000000000000000000000000000000000000..5e443cbf683b717595dd2f3b4dc35834dba06d48 GIT binary patch literal 1148 zcmZ`&TW=CU6#fP%%Wk1m3cX^jcM7z4uZo(O8e(n-- z<*wVZ+trW|m^_d#WzCjuyY_VVz-$Eq$$OS-1rG$`rR5!g#Jaa<8i+$rV+=`wY{PQR zt)8=M`p@L9Z3^TXUQ60L(znz)+DrtL6DT(R@1QQAw|&zLEVtd&F^QapQ~!8s9(4oL zNn;9m`tf?SS7?NmEw8riTW-({d{a906s84IPpoRNZ~C-5i+K%m0#hTB(^x=JK3=BLEu;G1l^WE=`IJ{w;w_Gmx#rP1*U~6o=hc_!q;p z%R2@HE~hbpq=sdI{7~l}d2ItF=xV5@v7(M6@k-i<25P8kxH1Z~ZPHLe`fXM-HA0t8 z_h@POoT$bV5}lDjvZ|mIm>WhubS+2Pj2lg_=eNwqmbxYrf3DuDIu)E{xpCfA@LsWX zNOIJ;s_`woem9ARG9R*%tw)*KGkj)kPm^mRZ!jOg( zA4Q@P6|@*ZZ*fOSqzEmKKpGSn|4TlF(^!l+&O{tGIaE!B`2BatL_}|5qPXz(=Qm{~ z9@dgWg7XZEo(OBmBO4Mg4ZsmGX|NQwDTW-*aTddQ;`n8M$C%LR{sJyW%C8wzq_ZD! z=`%{tk5O(^HY;0|J}T8dR!{n{7&aDogb>+$M{_9p=Pv_ZLw}-v|Hz literal 0 HcmV?d00001 diff --git a/polymorphism/Pet.class b/polymorphism/Pet.class new file mode 100644 index 0000000000000000000000000000000000000000..4b2992d3f549fe13a293cf81e24e14a955d67988 GIT binary patch literal 502 zcmZvYyG{c!5Jj)^+6M~>dGaQ7fr2el1R)_LsuhY9l->zeFzl{ZyACLy1qDbHd;lMX z7$+zxLNnu;>p64n@1M^v09_ng$T8HFO0q9tZ6Mrzvw1_;^P$v^=su>!=T$al3r!v+9oeCcHY&03R z5~15NYa5)5CoXodXJMD2_RolieH<`YiJ^osfjbNGVzH+7q-S334%9RqiyLX)XOrV| zL&FKk5&bWaqZ54xMT;t*GNW8P`+)sAmtBfR1`TXb^cEK=Z&F3Rm&4sT3~=61t~TD$ VS^->=492D{D~Pj%9Fm&D(J$gjXdM6m literal 0 HcmV?d00001 diff --git a/polymorphism/Pet.java b/polymorphism/Pet.java new file mode 100644 index 0000000..7e00f0a --- /dev/null +++ b/polymorphism/Pet.java @@ -0,0 +1,7 @@ +package polymorphism; + +public class Pet extends Animal { + public void walk() { + System.out.println("pet is walking"); + } +} diff --git a/practiceProblems/Cylinder.class b/practiceProblems/Cylinder.class new file mode 100644 index 0000000000000000000000000000000000000000..a5b1aae7f739ca3ddda239c6c4af6bc81f06586d GIT binary patch literal 1448 zcmaJ>=~B~B7(KTZnqrhv7B`eAExa!&$TPX^uSCE z9Reqt?8l|&Nw+$eudic{JJ%r9h6Lhj>eA7T9)WmOdK1zvE|OW)%nZ!54rvSzKc%%- z$3FCiS`VxRyGF!Ob5v=?4}8D>`+c9%GIShNTCMbzvt=CpI12)Y&N0pHQb2dxSBO;e0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fb z|4i!(9lfY^yQAON`ck5|vE9Z_;(U+J=eTteeMpoSd>^6R)E1ZmFoj9-GlOZSHG^$3 r(xChl^Y|4P@jH1_Y*|ryIDkWK62IY)r4u~y3(7bm=K_*D19I zG!aioJn|2Cf`angKBN*L`UVoe1Mwf=fpBJ>CaF|pYv<0~JLjHz&z(R1{pnW#*YKf% zA%UrWD4p1K)M^;4d#V@Jmv>a?xRIJQkP#T$lH0QGNq?h$XMIaKvB1cJ>$~xFf#Gtc zBam4Nx+;%huem3LNQmWa#Ss;bA7;bR&WDt^a2*PxPL2 zeStIOyRBm;?KpJ(jrmH)z_`G8>PTYOtG6BL`zp*~0+xZ(PtkAhMzQJ@a0br{3~5kn z0OE~{s8!R%3`-i2k)CJAo9c+ooNb~;HI@hLY#G~q8FDZZ zPljaJRXZuY*EEZ()TP|4bablM3wT4To^`w+;v6*amVs+eDoClVZHB=;t$YD*V@_aH zcDwDQ-w#z3sqS%?pAM$HOe4b$4#~tb)TfA%L)So|lk#(H1luE;EIUeiv=$kBms{a7 zdpnlS7b~)#&Y^(?14{z=c94XQy6Nh9J$3X3YFY!wq8(lanKsp}lvktTt<(HL_nD!ZNJPcL#qBLi7cOOmj^` z_EA3!$#j1>`18tdsM0;Vhl?%R8f~`vc%}L~%$e36MyoSF!mQ5hh2duk@ZG1(# z8GOSZNM4uv9wz`Sw8#QWEN+UHjd5J!u7=Yb4GZt^$=#y;5hn35BR<7BY|-Av1$@tF z-KG!He%{AC7Pu?oOWwN995y<57dM!-gf13oWr@AYyi08JRr=rOnSnLFoPo8>`!|q3 sU~1FAO#_YeKPH5MTLQ2O)&U=H=A;kwHU5FQ$R(Hin*s?k(rP#V1DUiPVE_OC literal 0 HcmV?d00001 diff --git a/practiceProblems/Getters_Setters_For_Cylinder.class b/practiceProblems/Getters_Setters_For_Cylinder.class new file mode 100644 index 0000000000000000000000000000000000000000..d0a3dfb7738a35683f0de16e4817369fc7d456df GIT binary patch literal 1182 zcmb7CT~E|N6g|@|ExVTG`%6RzP$-K~zY-HMJP1KaRwXXs&5)rCyMx_!({@StKPJAI z7!7FRgFnC@WxUg^pky^M+4Ro6JNMjk&YkZ+zJ3Gn5D#n^49l%p_^I;cb{y>ovYB{K zWtz%3*{kJoGm7`tPXZMl$k>L-FmNP}g%^mh?!DYUl77lyHKeLH=)krpiN%3xCzNb3 z6k1AB>9Gn`x<;wHxXWO!M+dTm0?H0bxWdq1RiS**Ztlx?M-UB$p=#udU{}OS=Xudg z8;Wqf>VJ`5Whf>xeU?)+-L1vlBE~RbWBd;_wUZ>3O$U>>N=&0R=^3qNVpZgA$0|%~ zX)Hx^wHMbIp75Q9zN)1#+;q?bi=nTU3jfV>(aH_ex?knn zFx`#Lyr{!MrF&%>SbW`j=J{8P9eE;Y|~ZNA&JdFgWV MLf7Vd*@*i;0V9dYvj6}9 literal 0 HcmV?d00001 diff --git a/recursion/Factorial.class b/recursion/Factorial.class new file mode 100644 index 0000000000000000000000000000000000000000..8d80eddca161d8e6113f1f15f4307196e22d46b1 GIT binary patch literal 1198 zcmZ`&?NZY~6g}Gp(}qAl__S6nD%utyet@V2R8X`vpfhzk!}x1S0|wKilO~QlfIoc* zAAle7qc}3-1NcymchmBrl*!C)cK6(K?w))1_n)7?0L)`uMucI=GmXG&S+1k4a>I8$ zi`z0JhU5bVn)YsoiI7shT&O5uNU0b^g7lrB z!NAH4167|JAJ=&Eh`Yfphha4TUO&md>U);6T`JUMj1x(C5crm@RSoVqrWZ#BSs9o9 zxpZ~6<(mx^mvMz5B1lI%l$NWNoo3(@tH~QB1!Kqw111>8^F1MjngCr_aRZYKvSWVs z%MSTTHkO6#o zF?Q1mi+OB@K-^PtAG1_h-fWsqogqtBpK-3MQi|aLC7D|c$sdZ)M-0=w$j_w^q9qZz zAhasyYYE_ziYIu=5cAzm)(pe>vmsQ1WjvR$Lfsr1L=`$^or)L21i2~Pw5g5~_qM64 zhI+IJRk~%+Q78Y?JwlBc-#U6A)O!^MrRoNrVXj)D(+7{;pAk7=g4#7o?+i3D@jPgh zX{FK3XznW>AoiVpB2Z`)$AE->8r2Sf<^fv8Ma$EU2-XQ9aH)*+4Fj1k8L9pQNo!Bp zqs?eYG#IMNq!^8}k!wJZ@vLjb|s<7!64hq?)8JMFMHelB&2?kt9d}t9VIs bKdoP(O!7%ghM7eOokIn$L&tQ&M6mW3E4l=+ literal 0 HcmV?d00001 diff --git a/recursion/Factorial_using_Recursion.class b/recursion/Factorial_using_Recursion.class new file mode 100644 index 0000000000000000000000000000000000000000..3bb5894139cc5c6c753178d90ed3fa315038cac2 GIT binary patch literal 1246 zcma)5?M@Rx6g|@}Y`ZMIaBgKm|ox3mR*h5Py(iyWrw>x7qF*c>sU< z5Iz7upkxHIeYo6&Eb#u4HOp#K$ zkSQu)h^gp9gz~Yx8UrgZ^p;(&eO%@Bj#iBu7Q;~bed+iRh|m{8trxOz>+6^t?j1nFRl(y(&{tM0kPs`FZ2!7x(7kTHgl^tq5s zMS#XtT*m~1Z0Voff<^w4tp%ZdQ$-pXTH7A&9?QI;v^z2~CK-lL-)YG+%&P8$Fhy1z z)i-5tr4(e56KUNh#&%kMagWRph`TE8VTLNr>vi3#G9=0BGtRYD@*&)(BvT7M`2!L9 zkYVaP@(U@1XkJ9l3$5bCS^~JJ;xV2ugj~CoHN!yqYzUQL3D0CKGxYlgQH4%er{cLV zL9PooO{$~Boo(u>{&QM{D&5fNsFnZ89-+nzZ*?9J^6P^WE0mGk|eOSj~j=`uE%d3U^>~vo%n1Mb7M_BYGR>@r^nYA@<}438l^8r q0&&ccs<>8`BuD@&ctLXytzV)*@=;9qnFR=)LJ_Zg$4Z0=VD&FK(HOe` literal 0 HcmV?d00001 diff --git a/recursion/NRaiseP.class b/recursion/NRaiseP.class new file mode 100644 index 0000000000000000000000000000000000000000..3c4dc942975301505a427ab2ff3e0ca2549b4b7e GIT binary patch literal 668 zcmZuu%Wl&^6g`tTc4M42eGnkw(UwA;F7UDvL2QtaEQL}L$cEL#9i>weJ93;#{gr-0 zH?V-Ji+%tfg*Y<_Diti|&fLd2_uM-_e_dSz*hlE0B(R#RWR_2LmPQ93q@Jon4~{_n zM4rlMB-3H^esH3aLco2cQ(e3kD2MI7fb%9hQa;M42B^RlSn29i9n8i9m4B3jkrG(z zW{Dj2Wv-3C2s*{Fo(imY|7qM2@KUQ`B2WqAxE=eT!T`%y5fCX)%)@N0SIFecJ30A7 zI+mL0M)KV4AV$>Sgt1+Z%!g*o{|FNBd)X{c)LU(~6fE}s!mwkD6PNiv zpyd|e(t7kF-hy{!?+2E?@==0MYtp9l4s9?m;9a9vHCtoEfIq=uJy36*qvBjNn=R+) z67}N?#>$pw**0}q=aF;C@-^ldtYMvXL}P<5uF0Z=%N7mXTeNs-^-{z)+;=^af5+n+ YnZBh8NL%|$YJeR)BbmT++7fnu1K~q>#sB~S literal 0 HcmV?d00001 diff --git a/recursion/NaturalNoSum.class b/recursion/NaturalNoSum.class new file mode 100644 index 0000000000000000000000000000000000000000..573879742b1da7d2daf803c9b99b7d15d6119fed GIT binary patch literal 659 zcmZuu%Wl&^6g@X_>cnx|q@ksRSIaYDftLscu|Wbw3IWL|8#YYbQJCUK<=B<_H+(=h zumHq@58$H^XOc*1rONWXb7#&u_spHY|9<}g@C=V#R0Mmuj>>#)vNRa0qRdr1&cZTr z;RssC>Qn`>N@u~l>9LLq!Nv=dn&PFP+UrjQ&a3Q5d#Iw}qlOK^_Q<4qTqaYUe^Ap{ z3wB0Xq~eLnjjdOkPVw2y1^c6`yAP|F8~p3MuL z__&5$`pZh%-CdGR7Q833AYZFw;6ZTR$3AWlH!l-*>ka!u4>xh!#VtW+(eg6O#~s`i zxF=R9rZvm4BT)H_SLs~gQy^phL&0WPsOZaEb+Wp@7iMK1>DR_isC{wpPi<=)(qWaa z1V*uwWpr5u%)(rI@)PxMTvXsO+G87=jQ$e9yveG8Eo^hglAjZ8an0{&)qi2{2fAws zkB1iS@mtF@aX>FX-41Id^Jd`*Xmy>hs5$4|u5(1SPv^u{7j~9fTWs3Cpw+@X+$ZM2 N0w*rz9&%a1qyKSue5(Ke literal 0 HcmV?d00001 diff --git a/recursion/Problem_01.class b/recursion/Problem_01.class new file mode 100644 index 0000000000000000000000000000000000000000..ca50119836377feab9f5e08d2ddb6f97d4041ae2 GIT binary patch literal 653 zcmZuu!EVz)5Pg$4b>g^9nzRK1rO*~gI1o5hD2NLZC{k!E1?AEMY}{44CAK5SM&fVy zfL`DLhyx$ck3zgnBBhlo%QHJWZ{EC_z5Ms*FMtC)agh^jBs$2FsfnZZaS{*5I{f(j zg$qYeJy%~;d#s{S`)GKsgH*8c%0wo8Eyy=p1A+4Nkf z1n$HVjVaC6*afI$#6jve=oH8y|E^%QpQ_;Vdo@{1@Acy>3G`cI_fuIe{h4iyht!wn z`+!#LR%u;EZF-?EJpF~@cOG)^Xl>fsGOa%c(62HoVGR}D*y5K&TU_}Es>R>f`iaJp z!ei3HJ$_4?G9FM1P_(OB(7c;z0;&z?8w$=vqv4#A?b8Ku`I($K*BYCyU*W1^7kk9) O&v4?B?h%hUJpK=!{CNEU literal 0 HcmV?d00001 diff --git a/recursion/Subsequences.class b/recursion/Subsequences.class new file mode 100644 index 0000000000000000000000000000000000000000..23cbd05cafbe4dd461025ee7be2c4b1fa76e2705 GIT binary patch literal 1374 zcmZuw%Tg0T6g`~`P7((pfgmbDP?Wqdh!0c{1r$YtS`~{b%8ip`NCqd9IGI@L+P!;s zuH2%FKxxSb_znJqRj$#~6GR@VO6GRozK?TG-~O@vbql~G9;xsN^f^YM;ndBloyj%w zb>n5junR_Ag(A?sroYlNmTs3akMnCr!4)_%ZQ7l& zX)5vTurGu#dQ?RA5opD0=tYz)EW<9jWsk*T0LKL&lTK(jiBkf>I+gJ13q<3KiFPdn zVj7O2OT}q{;|FogHB75$II`%lhBG+Jo`tgR%u+&y73by2ISuDADxkj7t%mV!VnQI`R$Foj^v2r& zqHdH&UhP5Nyg0vZ^JaV6+zSiWE4pRP$^c>VzbMd|bM?ZDCB5cNhKj2csG^%TCo|rr zMq)XDTWs?B&D$VmF|T57|24m)?8?^#euaDy{Hok#XgOr) zNNynTnF}8W4&E`K;3(HxD}c6>yP%w{RG#a(4xEqoZdVQ594Ci9l$G7^c~&CFgs_OGSnv zGuaf`d#t;@;C5OPT9CxkB>qb(-Qsf6!<6JMMMh~d8ABiKX^eZAldXDqNPIFU=Aq}r dqJIZzh>ZUs1@nE|=u{Dw@QxBzmT5jL{RN)gBOd?& literal 0 HcmV?d00001 diff --git a/recursion/Tower_Of_Hanoi.class b/recursion/Tower_Of_Hanoi.class new file mode 100644 index 0000000000000000000000000000000000000000..84e5032be0eaf1a04486efbfb5ce1e51aaf3c2aa GIT binary patch literal 1180 zcmZ`&e^1j;6g_Vnw3`LS1_QRCML;_gCjLSlqEJPb3}-SjV*GkY97Pjs<4H(#t=4gRfdS^)U6o8h-w(XAj3#W*w(vF zbI)?O`Ch|fNR*r!Z&bM}bH0b?SNyDP&}iSwa{=YG0TjK_OR_i0c||Kqr-Wt7X}BhOA-c`oL$^ z3My_gsJiFuo>!QY@$(FemsPkjkF0!KgMl2S^PGSY!*fB8N(=dz?755opJ!NFchm!0g*<-Q4P_M@o3iNgKyHxQs=-F45f!XvH$t9JR z2s)Z1U?2)n;hismd#K{^+R+woosUqH3kpsdANz!%uR){9-2)o2`!%7YirpNIjFC{(<~CaG8MVE*>Nv z6VQ)%axsEZhkZI}q5>i_KqTgf#ysNmX-82-(x$SITyH2_Z4K|qcYi*}-DPW*(ZJLToQC*DWD(W^;)wR7OTh_bQ zdX1Vl$}cGr5-)jyheV>NuSon3#E(D-IM;SdN-JT>cjn&loH=u5{OeyoJp=F|HgqTg zrLpJ6{aruYxgP99v7hV?$F&VVbmP75G@?TlFdw>KxwXIzcWRy9L$99*q_6s+pELzh zc6m!cy%7yO11V&4(2y25+4e*4v&pdM#dq9Z;0Y|WqrMw#xv?+r^G7w=^~VCM?f>J^ z5Xkk8@Dj+_+nfB9Hw_5nb2x#MWaGxMfU>|I6F%=sAI* z>xTkM_ICTa3Vb9e`E8K~lt99BhomveXz?{lo~Xyk>|sbFuGUnw}p zZODvzj!X0r$B;xbxdcwxucmNrsvGZc#*42}n4^k%91r_TQ3>Uf>x^>BJ%?s1qM$U22>p5nVbE9_Bd~li^CV0 z{L2&wXcY_JqERRo23qi-u2n5<-BO<*ZE5>6|2vqKYQfUffu$b6+^_IieNdcTlzl>_ zre#-=p>GiO*tE%8i{o6g)~c0{w8QzM^lH;(Gr5|utbzk Ih^gTEKcgZ3O8@`> literal 0 HcmV?d00001 diff --git a/searchingAlgorithms/BinarySearch.java b/searchingAlgorithms/BinarySearch.java index 3eda77a..9b5be7a 100644 --- a/searchingAlgorithms/BinarySearch.java +++ b/searchingAlgorithms/BinarySearch.java @@ -3,7 +3,7 @@ //Binary Search Algorithm public class BinarySearch { - // Returns index of x if it is present in arr[l.. + // Returns index of x if it is present in a[l.. // r], else return -1 int binarySearch(int arr[], int l, int r, int x) { @@ -16,7 +16,7 @@ int binarySearch(int arr[], int l, int r, int x) return mid; // If element is smaller than mid, then - // it can only be present in left subarray + // it can only be present in left sub array if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x); diff --git a/searchingAlgorithms/LinearSearch.class b/searchingAlgorithms/LinearSearch.class new file mode 100644 index 0000000000000000000000000000000000000000..81c8aaf7b9a6f592b76a382eacd41936a56bf29e GIT binary patch literal 1162 zcmah}+int36kTTqm|>uHN-x?{EcMob+T#62X}rWHjVLA<656LJOz2b?$S@fDZv2k= zmWtz>n}FeD|^rv|6=^klAOSv-e(mt$il*`TP4%0Is5-K@muI9ow&Mx?bZ} zv(fh5V6)ZD6~<$gp%NWk2(pV+yk?KN_xjV-4Z2t<}#&kdFZR4Y>v2;FJd9Rn(& zafA^O7?vOpdaVt|e`Ieo9f3r#U9+1N+jr%D?=Tc>x?O=2#sBfhv*jR%jOb-LmyAGvybT!Eo-VAmesw>$fdTDHs3gtcD$Ev6j!RG!aN3z8bOuNBrFNdrz_2qQVQ%-Bbxs)kC{P`FeLM@rR*R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-s ztU+p27cq_+cNxw?T2niS|H4HCI!Ad7s5rpU2pu@Lb0;J(j`H#!^oVkvvR_OlqNS-P zXiwP*tBKBs%C7ap?!O6jgGS3%(plA3Y%86&EmO^>Y)ff5{kZ#=%&G)g(?Py?u+zEj zqP3q{2bl8&v!>8Vz}?8wHi_QAdx}_zpoLDZdSMcuf^i%|ANgpE)6bQH1Z4kI`+L(X?%<>7SvQ z(X495LSyWWF-D_m{X_+73_aYSbWMsuW?5y<`RAQ;19_t}a*@#xXw5A^wer z$>$`daSC%tVv&D`0)GQ52sOJM;(VjRYD)!TZ>bOtoJyphA-RKe_n9Wn zHF2?t@rMzSIQnS!Pr5X5WsmQXpmOIJ=R9Lyz;VttYkP)lW#0{k83HDt>Ig|N_utN6Hu?{E6c&YXXa+2yC0-@%OqyNR2ViQn{_N>+V>gJY&DE%}G4 zFxAAP-G81#Ebrjv$1Db-UA)VJwiW3KP&8Jo&W#< literal 0 HcmV?d00001 diff --git a/sortingAlgorithms/InsertionSort.class b/sortingAlgorithms/InsertionSort.class new file mode 100644 index 0000000000000000000000000000000000000000..7fec3bc177d220adeec635e204874007de70eb3e GIT binary patch literal 1372 zcmah|O>Yxd6g|%~6;4u$u%zuw!ELQ9{9qi-FQcGM!4UB3apVk_=&jJrj+` zNRhhCFX*-_#3F0Da1fyUfc7tR(PjTa7c@O@Y&ArQR9SxazW46E=iKw|{Pxeg0|0mN zt&W7iWH$&S&)=-KH-pfNo_D&HWxwn4EbyDW(xD2Zx15(wrS15e6?<*VU5^Bki=OXA zH36kiToF(o1skpj1tS(TBn3trp6`Cw>#Vuq56)WK6&Py->rQ*c2|c+V9;(rEuPZR! z_#YZoLdXySt+2W*5fvv41rn>v0>bBCT93ys+#Pyb0;y)?tiO2bY!9K#?a=e1dKfx8 zBbY!=$E9PPHFvs^+p&J;ROKM(@kyIcq;?#SX1uU^f={)$VnSd`7Sk-JaO?q<9w(Hm&RvC8&}wu0Fy7Efz~m~g!Gtqhtw8{7 ziaSVhJdw$Nuvn6|UOHG(YkOEI<;x3dUfo#G_K+@RHT6d>WqVgU%xb^DlAEmh`tYy# zDy!PNipb|)9sVwXl^D1jLmKi!g29s%_hVeMgqU|jm`COy^kAxe6gDlxl6AO|71uX_l{bdh-qG6or|nJ zfh)8n7?Cw57F93?dkPWA77Q;qJH$=<3s_)&0&VWt0>|c=27^BR~e7+ Ym@zrB8pu0CjlQO!337PCn*_f37uSjg&Hw-a literal 0 HcmV?d00001 diff --git a/sortingAlgorithms/MergeSort.class b/sortingAlgorithms/MergeSort.class new file mode 100644 index 0000000000000000000000000000000000000000..672ac311d90d3b59539ebcd51d58528c55d3d240 GIT binary patch literal 2009 zcmaJ>TTdHD6#m9ud+qfC24|B3b_(QX>|i&PIBm$K2`z-y#z~+g4!yA8Em`6VS`1QN zBP#W&4}EBrM^aVvt!*Bhs6BBY?MG&5(;IdkSa-#N3-|M_(b zz&XsQ@CbA-SDl(&S-4VKs5*A-Zh1MKvz!HMl4=!-KzPwyHPa=tvXIWtEn4$60sjTN zV%IJSc;o%k0?J6WXld{wsKW=pKwH+XSQ9JdIm?+c=Sr49N47d|mZnX|miwkssok}g z1!CF%fiNuKD@!~Af%wcgKY63qbQ}TC%(#FkamcmIA(fRgavJ0=%W;##=2+yoC(trk zGw1K+%q16sigu!xw+pCl^!{lL0)0B(M30n?>u5!rfVSk=mD&}@G4B%)UHhklh$Eq* z|22jt?=RP^vW_H96J>RUfsL$7pj}O0moX-5j%AjIRip%tyrPzB7UAlOT`F3RhPN=N zf{E-Qzu}?dZ443Zs##jG@?S7~e7wJLgIl78*RX~GWMnnYNss;Z{^~qQ1 zFoJ73#$`jPuBKEWVh*Kj+FTCDXZB$lmWfRWgvRVutJ32ZOa{6x1D%r|smE;wq-Iz^05G5Sx8fontRdR#%*PYt)vF-Maf&QZga*GO(A=3*?@e zz|UFbF3nX)ZQ=<6zfkZ%<1EeKfe>fC;lQktm%JPeF+y@4*=LJW6s6ra*#k!P35_$vBv zAII^4mHiT@@D=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0)seDkTN-{>!+UZDR;AJz zkEAPxJH;VaUnWJ2)FTu1K^Q^8gB;1+I-J1*k&#T+O_|3mIYsry2lQ^4U5*(>!)XpE zJaGc^tMV4-F1S~9ETZ}w9x4#wSN>T-*YK+a0PbsftCn@i7b*NccZut3`HElQ09O@P z2UibQC)XaXU4=c)UB17{wNF{7S_myvEbv^Jx7nDNRng7cURv3YS{y_}i4T3K;TurL z6@t<&1ZRq5An-^0MNPCXB1_Q6>zWp^A-ROs@kMMJtUNT2dmU{#Y~HKr%3W-|iIyeA z#yjt#a}jY}$>GTyx|8#`p({1fTd3)hu>Cpoo}P!tx7aNV&tpT0P*)Dm=8%wLJRbWD zb=*#Thiy3wQpNIb5h zLN-6eZhT1=zvoc=iL$?v#ozgl!5`%4PY!E=9#Ks#vRb+W1~87ZyhT_Z=Xl~o!ryoq zudu!v@B=I0Jh|G0ukjigRbUV+>nuP`5G6U@jI|HYq(WEGD*oXQVtrWGRej@qX!jAR z)e%MtlL7g-MuiH6b}qpjzk{ho%p^N=a0ZtkSOVV3JMg>iVm602_n*G$;0V1> zu)dBlPsf>$0mgqKA5ll3meqcZxHXLbIzFJ$8s<<&SwV^Q_>kRE$=4giRN$k30qx5d A_y7O^ literal 0 HcmV?d00001 diff --git a/stack/Infix_To_Postfix.java b/stack/Infix_To_Postfix.java new file mode 100644 index 0000000..d8548c5 --- /dev/null +++ b/stack/Infix_To_Postfix.java @@ -0,0 +1,76 @@ +package stack; +import java.util.*; + +public class Infix_To_Postfix { + + static int Prec(char ch){ + switch(ch){ + case '+': + case '-': + return 1; + + case '*': + case '/': + return 2; + + case '^': + return 3; + } + + return -1; + } + + static String infixToPostfix(String exp){ + + String result = new String(" "); + Stack stack = new Stack<>(); + + for(int i = 0 ; i < exp.length() ; ++i){ + char c = exp.charAt(i); + + if(Character.isLetterOrDigit(c)) + result += c; + + else if(c == '(') + stack.push(c); + + else if (c == ')'){ + while (!stack.isEmpty() && stack.peek() != '(') + result += stack.pop(); + + stack.pop(); + } + + else{ + while(!stack.isEmpty() && Prec(c) <= Prec(stack.peek())){ + result += stack.pop(); + } + } + + stack.push(c); + } + + while (!stack.isEmpty()) { + + if(stack.peek() == '(') + return "Invalid Expression"; + + result += stack.pop(); + } + + return result; + } + + public static void main(String[] args) { + + Scanner sc = new Scanner(System.in); + String exp = sc.nextLine(); + + @SuppressWarnings("unused") + Infix_To_Postfix post = new Infix_To_Postfix(); + + System.out.println(infixToPostfix(exp)); + sc.close(); + } + +} diff --git a/stack/MYStackByList.class b/stack/MYStackByList.class new file mode 100644 index 0000000000000000000000000000000000000000..2dc7c0fce7853aadc791117021185f025839d4c4 GIT binary patch literal 961 zcmZ`&ZEw<06n-wS6}sxWF;H6=?7*s z>UV#X@!Zm6kjxJ~=broWoaZ^`^v~b#zW_XhE+N5?4ML+c&|b9~!apC?%^;MJVo>|W zk)c_J)6;g_eclNf=C@7944*P2%atZWYRBzz8A)Um%we8kv2Hs2_0Vo}f6r)JoME}{ zb_}a&_@;>C%~W`31`N6SDXDdWwGGo@$d}*MPbf4(-*kFx3N8q;Qr8ST%NS*F5tk&a&M0n-f{@z^F5?QR zb%!KAH(_JC+8d%05+QEbdKx9Fp}gmMMQ(AMJ7Libifdh2q`IcyI@SaQ&IeJ|YBFx3 zBB9K%bRw?iguKUn1?#91u_MD8^4$Ybf?8#&2Jtmr#w}A4DgAxddMifZUiYAM!M3F|Gk)K;XM*2&1ERz+-zNnhIjIps# z>#g|v-<1A8bVScKRTgd2H1r7n2kYO6uh=4s9N(wllxkcRrJKQRqa0xWV4O5>eWf%0qC5=P^&GB4H%Otge zA=g`*4l8XG1p@K^4P=l`vYKHE91PCIcLPdT1;bn#3?&sb2{cs>N|uocCsLYe>IFAi z;8$>9PZo*QqNQh59K<03nX68#4S#>Qt=z$MyGNUI1T7!>;gpv}}uHs2N zC7_u4TUN|ufmoNAJn2x;i7tUUc_ND;Rd3 z0H;(uivbenOU1Onv8@`^NMW$nxT=ndMQ`cAa zS7V2v4=<>A5u*ZbnO#zbTj5}S0Yp`tl^phbE-&kIUd07je^*8~m#nmGdQ8R3c!iK$ ziIv&y?-cd2-QPNl3wVs;n8u7!`l1JucvZpFcIhaG8n}v!NHC+kWXMR-)RtpMh;_Iu zpqe?WV_}PyxoU+a>b&JK%B28{DIQfNQ7c_aUNCeK|Im(FKg4-T(uH!vILTl)fn`gd4Ul}95;2Ko9 z9wWMnnj`9+eW>e?pazJ#vJXY~`?wl!x`f|FN9R7;j8|g04HskaJ8z-k9$spWmoc#p zubf`uwEd=S^Y*4!*3bc2!%q<6*TWim`6Q{l9Svw@?K;tfZmxRZ$4S117jTFgZ^dOC z#uc>VO}=U=bYPjtx6y@ndG&74;(Z*&2ju*amTTxG{|S7`XXi8Y<8v~VaSC7a<@go@ z_zn?#&;K|-(9cg8#xEGbuNcK|7{i~4;xC*P4yeM5Sf$4ot9?Wg(~Q|G1YW}oyX+%! z7IPF$EA3xre0E0lGv2^Fv+Tx?7-zgrJ_h%p5$9qYA7g>>D_A6x)J_$z6MvOE5%~T_ tivpk6WbTTBB{^4cTtR?t>91YX*B^26?;)JFhp6*3{y{c@G_7qg{sl**suchL literal 0 HcmV?d00001 diff --git a/stack/Postfix.class b/stack/Postfix.class new file mode 100644 index 0000000000000000000000000000000000000000..027ac23d9450cdf4050232038228bf2380fae87e GIT binary patch literal 2335 zcmaJ?+iw(Q6#sqgbf>!v(A&196sTOvZd+K8a&19i%cZ!zU~8e^ZMq%Wf$i)tGmEV^ zR8TZA@fn{m(e%NZAP-wY6Qe%rlZnyzADH;yt09K^`(_q)OREpxWxhR^-#Nc?&i?r5 z!M6bR<6{+N0;^q5PhUw4W?k=+IjuqwsJg6Q(-Rrpnn(7Mg-*uYp6g-U~S5@jQ-rznBffTV;MuBCY4R=nGxMF<#*vx@g_}IN-uHRMT3Km zk>(Lg#(M?I(vt!rNpM3FT%T?i^w*dcK@MjNXa!nhsUp}R&oQluuK4mN74=KP3M4Dh zNH;AJMA0PUST7J=$=-;H4Fv5w%6Voc;iHP68DXj0qTv~AW{%R6x^s-lQewUFWCUB$ zs$!c!Z4qIT5_;M*91YtMqfOII86Lj}oE~$+^mUW*3o6{c9<_znp)E;afjdQ`r0eH3q@-)bHjFDW)P4;E z7!(Lg_D3WgzA*V0ctOJ&td)cfYj_cCoKVKFCOk&VKI*N+dG<-KMH0>NmJ`#qW4NxF zwfL(s&A@7w@xe|BQ7D&TrBwJmBv2hl6$_I>!sH@;!JevL+K4mu<7O;mrKs3l;;%^6 z5!s$ox=C2|v5O@lLE5_FY!4P-bxC`qb;~lGFeY(X1)-D-l%W~dGp00LL56)UjYb2L zW;W4l**T9^4Sk9%7_ekhW@QzvC=wr$LRU37epy<^v?r&KeDpNr{aIcejhDJQ2^m~J~|MmbuDm-8A>c;m3;uJS9vQ}C>4 zn@8n0yp$orUH&ZhRot~efahv{RmxiAi&TD}rgkM!|0@^eW=0#X73Q{OE7fvwVLuZTp=i(LU4}A90z#B zU$jL3BC>$!XidXB)}3FK&Py%vp{N$Qj+6MSp5hMDxxZy#XtNLtPMw_YIOZWXb%yojv|aS#sl(kg9a5U zZC`*fdJhxxm`b(hVfS%!7a&*$*ZS|_^^W^^Gmp26wcf;90!|YBDc09%;yWWJH1m=2 nBWerGvf6J@ZWVvKi4W+siaC@~mhoj3K4f>4^Ys>G%J9*@)20kv literal 0 HcmV?d00001 diff --git a/stack/Postfix.java b/stack/Postfix.java new file mode 100644 index 0000000..dc1fb7a --- /dev/null +++ b/stack/Postfix.java @@ -0,0 +1,77 @@ +package stack; + +import java.util.*; + +//Program to convert infix to postfix +public class Postfix { + + static int Prec(char ch) { + switch (ch) { + case '+': + case '-': + return 1; + + case '*': + case '/': + return 2; + + case '^': + return 3; + } + + return -1; + } + + static String infixToPostfix(String exp) { + + String result = new String(" "); + Stack stack = new Stack<>(); + + for (int i = 0; i < exp.length(); ++i) { + + char c = exp.charAt(i); + + if (Character.isLetterOrDigit(c)) + result += c; + + else if (c == '(') + stack.push(c); + + else if (c == ')') { + while (!stack.isEmpty() && stack.peek() != '(') + result += stack.pop(); + + stack.pop(); + } + + else { + while (!stack.isEmpty() && Prec(c) <= Prec(stack.peek())) { + result += stack.pop(); + } + } + + stack.push(c); + } + + while (!stack.isEmpty()) { + + if (stack.peek() == '(') + return "Invalid Expression"; + + result += stack.pop(); + } + + return result; + } + + public static void main(String[] args) { + + //Taking String "exe" input + Scanner sc = new Scanner(System.in); + String exp = sc.nextLine(); + sc.close(); + @SuppressWarnings("unused") + Postfix p = new Postfix(); + System.out.println(infixToPostfix(exp)); + } +} \ No newline at end of file diff --git a/stack/StackUsingLinkedlist$Node.class b/stack/StackUsingLinkedlist$Node.class new file mode 100644 index 0000000000000000000000000000000000000000..af980348fffaa7f54adfa17b51a6d2e062a8fbb0 GIT binary patch literal 520 zcmah`O-sW-5Pg%@rj60Y`q^4hp@&+*dJsG)9xRB3SP#{L$8EaQZDRu2RPbkc5W#~# zz#k>f2Cvq`zMVI`oqaR&_5JY);1oMHEW)l%MKEpm4c==NjeQkO-iw2>!x z6Y(tCp@_!q+u=k8DIq@+sUT37!;qg4_WgfKoe>J@qtcCILVb?d=+0H7(hIiNoF_aO z@b4XVSpuQ#q6Ei54l6DeQ6c1-Mo{LCWN-E~l*yeKhLTY6<3NN1ktoA|lX+u};Pm5J z638o+32z>-yed?&&6#?Zul@km9CjlB literal 0 HcmV?d00001 diff --git a/stack/StackUsingLinkedlist.class b/stack/StackUsingLinkedlist.class new file mode 100644 index 0000000000000000000000000000000000000000..94b06a75df7e593720c2f22c4fa4d201836eefcb GIT binary patch literal 1604 zcmah}VN(-V6g`h!SXfp-z#tMztXh*0O;QGzX}>ztztMlu>9jrX?N-AK+7H>hci(;IoO|xw{r&Hse*-Xs`xd$cPKA-X z@uXN&&y~;%Hp^b{MAm&Tj4YS}LtE}sx9GdUW^s9aOKwC0M$~8uoG!op=GkhaE@uUL z=Dfg*=6NNXTNN-D8Ma}d-+_hRJ_sCh(2X8}LDI@gPXKwvmHL>U$&H6wQxdU>VK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+Gf3GIAKgNZp%I~ zGBvYxoLSBsICdlB*tJXq38Z9yX(Fh-)gYBSVGsX49~00_m)l>j9rv zD}-@FAe?dSy^9KSGJalQv0sJ%=8=_esmLP7bgu0);+tlBOBW)zjYS1_1mb<^;aY1YCujYpx1UdG3Pyz`_~Ar!)eHaFy3`y~FMvtUjUa0Om=WT_J}|) z;_>AOrVe^^lB5EX86b%{(wIk-PdkbV;vU5Xp9Y?yKpY8S70*1{yI7+Y@O;l{1@VG5 zHJHaB*0FKkNs$R8Xh>O2Mc1QRbb~y*att#9m?UJ13{qargdYG6FL@WBPga*|zVgnS F{{S;*`XT@T literal 0 HcmV?d00001 diff --git a/stack_and_queue/.cph/.Stack_Queue_Problem_03.java_4cd5b7badd85dac4f4b1d9cce25274ef.prob b/stack_and_queue/.cph/.Stack_Queue_Problem_03.java_4cd5b7badd85dac4f4b1d9cce25274ef.prob new file mode 100644 index 0000000..a5fc956 --- /dev/null +++ b/stack_and_queue/.cph/.Stack_Queue_Problem_03.java_4cd5b7badd85dac4f4b1d9cce25274ef.prob @@ -0,0 +1 @@ +{"name":"Local: Stack_Queue_Problem_03","url":"c:\\Users\\AmanSoni\\Desktop\\Java Program's\\Java-Eclipse\\Placement Prepration\\src\\stack_and_queue\\Stack_Queue_Problem_03.java","tests":[{"id":1609222893914,"input":"","output":""}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"c:\\Users\\AmanSoni\\Desktop\\Java Program's\\Java-Eclipse\\Placement Prepration\\src\\stack_and_queue\\Stack_Queue_Problem_03.java","group":"local","local":true} \ No newline at end of file diff --git a/stack_and_queue/Stack_Queue_Problem_03.class b/stack_and_queue/Stack_Queue_Problem_03.class new file mode 100644 index 0000000000000000000000000000000000000000..a4f4b590a97abcf58ba39810bdea2bbef503d979 GIT binary patch literal 1836 zcmai!TXWk)6vzK-%kd?O?WQ=PH3T=L!Iw0*w)EnV(i%dXtBX@Qojw>P-X>~n$yjnA zd;z`!GraM_OJ87`lnD$UfDgs+U&%BM$t0uES?$@~^V|Q~v-+?!GzGGTnI&WXrj)*p%!#S0q+UORjaAo3g!OY&Pf#wK~oY z0}NDMV{3QSX!ZITQEPeegV~&dv7>xV!?Xm3vd>pu8hgf6!?3oes&3n~wu=fDtJ#ZGS@IF zkbGp@uH&|i)~a-O?7EZa!(s$w9ZOi&@gYVdSmCr|)$5xt<(4bJ{7`t$Ky}}7Ws?JT zhr=m9QKmgrVU}FxN*c|gz-2GeNw+|_r6x6);#BtR3~TZ`(~V&jYXX^y-D=5tMl!L| zax*X5b~EE;Av2RPos19|ZW_C?WLsN?`_y!I_{DL{brhhSJB>Iu=&TnsjCGZjs=(NB zHcV^J-c>1ArQq`xj4ju0?}zb(MY&?zyPcMRUbZaRE;S6tk=(?Oy(+sg`~z6zIX0v- z<}WOs-f55L#KMjJmONv6Z^8OUSL~JF4N)>0jjHL&Vi-Ks>!j%h*lbAq~PYRbfrhX-?_-@>71iiR3jG*xiY4x9RHUEq~?Q0eJH9730 z*MC9cH}nmL4-wIRM^vE#J*X66L%g-a7~{4l2$<&R2b`rLFxJnOH|#wa KpT44J=l=!x@p)zd literal 0 HcmV?d00001 diff --git a/trie/Trie_Problem_01.java b/trie/Trie_Problem_01.java new file mode 100644 index 0000000..ae8ab93 --- /dev/null +++ b/trie/Trie_Problem_01.java @@ -0,0 +1,35 @@ +package trie; + +public class Trie_Problem_01 { + static final int ALPHABET_SIZE = 26; + + static class TrieNode{ + TrieNode[] children = new TrieNode[ALPHABET_SIZE]; + + boolean isEndOfWord; + TrieNode() { + isEndOfWord = false; + for(int i = 0; i < ALPHABET_SIZE; i++) { + children[i] = null; + } + } + } + + static TrieNode root; + + static void insert(String key) { + int level; + int length = key.length(); + int index; + + TrieNode pCrawl = root; + + for(level = 0; level < length; level++) { + + } + } + public static void main(String[] args) { + + } + +} From 3f9cce578e813167060a0579a6724300a983140d Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Sun, 16 May 2021 16:07:53 +0530 Subject: [PATCH 39/56] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e557f61..5e41a21 100644 --- a/README.md +++ b/README.md @@ -5,4 +5,7 @@ This is a repository where, I will upload and keep up to date my Java, DataStruc 2. Java The Complete Reference by Herberth Schildt. 3. Algorithms by Sedwig. 4. Algorithms by Cormen. - java +
+

+ +

From 7c7486974fe29bcbcf3ed8bdb97b9c4cd3d25805 Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Sun, 16 May 2021 16:14:46 +0530 Subject: [PATCH 40/56] Update README.md --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 5e41a21..f7b6f61 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # Java-Programs -This is a repository where, I will upload and keep up to date my Java, DataStructure and algorithms code and question regarding to them,which i practiced on eclipse & IntelliJ with help of Books and programming websites. The books I prefer and use for learning java and algorithms are: - -1. Java for Dummies. -2. Java The Complete Reference by Herberth Schildt. -3. Algorithms by Sedwig. -4. Algorithms by Cormen. +This is a full fledged repository for learning Java Language and DSA in it for Placement Prepration. +Here, I will upload the solutions of 450 Questions of (DataStructure & Algorithms Cracker Sheet) By LOVE BABBAR Bhaiya. +I have practiced all my codes on Eclipse. You can also practice some beginner problems which are also included in it. +Along with 450 Questions i have also include OOP's Concept's Code in this repo. +help of Books and programming websites. The books I prefer and use for learning java and algorithms are: +

-

- -

+ +
+
From 16457f9b5c89b3fde982e8c0593fa0977abe6b36 Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Sun, 16 May 2021 16:15:35 +0530 Subject: [PATCH 41/56] Update README.md --- README.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/README.md b/README.md index f7b6f61..babbc1e 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,4 @@ This is a full fledged repository for learning Java Language and DSA in it for Placement Prepration. Here, I will upload the solutions of 450 Questions of (DataStructure & Algorithms Cracker Sheet) By LOVE BABBAR Bhaiya. I have practiced all my codes on Eclipse. You can also practice some beginner problems which are also included in it. -Along with 450 Questions i have also include OOP's Concept's Code in this repo. -help of Books and programming websites. The books I prefer and use for learning java and algorithms are: -
-
- -
-
+Along with 450 questions, I have also include OOP's Concept's Code in this repository. From 1abb22103c7350280adb5c9ce5402b72ff9a3e27 Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Sun, 16 May 2021 16:17:38 +0530 Subject: [PATCH 42/56] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index babbc1e..83ac0ae 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Java-Programs -This is a full fledged repository for learning Java Language and DSA in it for Placement Prepration. -Here, I will upload the solutions of 450 Questions of (DataStructure & Algorithms Cracker Sheet) By LOVE BABBAR Bhaiya. -I have practiced all my codes on Eclipse. You can also practice some beginner problems which are also included in it. -Along with 450 questions, I have also include OOP's Concept's Code in this repository. +- This is a full fledged repository for learning Java Language & DSA for Placement Prepration. +- Here, I will upload the solutions of 450 Questions of (DataStructure & Algorithms Cracker Sheet) By LOVE BABBAR Bhaiya. +- I have practiced all my codes on Eclipse. You can also practice some beginner problems which are also included in it. +- Along with 450 questions, I have also include OOP's Concept's Code in this repository. From 8a434c13aada94b6c907ae34f17cd94d17185a87 Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Sun, 16 May 2021 20:19:51 +0530 Subject: [PATCH 43/56] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 83ac0ae..49c03ae 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,5 @@ - Here, I will upload the solutions of 450 Questions of (DataStructure & Algorithms Cracker Sheet) By LOVE BABBAR Bhaiya. - I have practiced all my codes on Eclipse. You can also practice some beginner problems which are also included in it. - Along with 450 questions, I have also include OOP's Concept's Code in this repository. + +![logo512](https://user-images.githubusercontent.com/65482419/118401608-f1490e80-b683-11eb-9e58-af14ae9a5cab.png) From 18c4b1cbfac876ff20670e02a778874a3fc04355 Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Fri, 21 May 2021 17:02:48 +0530 Subject: [PATCH 44/56] #Modification 36 Trie Completed --- trie/Trie_Problem_01.java | 132 ++++++++++++++++++++++------- trie/Trie_Problem_02.java | 106 +++++++++++++++++++++++ trie/Trie_Problem_03.java | 130 ++++++++++++++++++++++++++++ trie/Trie_Problem_04.java | 89 ++++++++++++++++++++ trie/Trie_Problem_05.java | 173 ++++++++++++++++++++++++++++++++++++++ trie/Trie_Problem_06.java | 59 +++++++++++++ 6 files changed, 658 insertions(+), 31 deletions(-) create mode 100644 trie/Trie_Problem_02.java create mode 100644 trie/Trie_Problem_03.java create mode 100644 trie/Trie_Problem_04.java create mode 100644 trie/Trie_Problem_05.java create mode 100644 trie/Trie_Problem_06.java diff --git a/trie/Trie_Problem_01.java b/trie/Trie_Problem_01.java index ae8ab93..5fa07ef 100644 --- a/trie/Trie_Problem_01.java +++ b/trie/Trie_Problem_01.java @@ -1,35 +1,105 @@ package trie; public class Trie_Problem_01 { - static final int ALPHABET_SIZE = 26; - - static class TrieNode{ - TrieNode[] children = new TrieNode[ALPHABET_SIZE]; - - boolean isEndOfWord; - TrieNode() { - isEndOfWord = false; - for(int i = 0; i < ALPHABET_SIZE; i++) { - children[i] = null; - } - } - } - - static TrieNode root; - - static void insert(String key) { - int level; - int length = key.length(); - int index; - - TrieNode pCrawl = root; - - for(level = 0; level < length; level++) { - - } - } - public static void main(String[] args) { - - } - + // Alphabet size (# of symbols) + static final int ALPHABET_SIZE = 26; + + // trie node + static class TrieNode + { + TrieNode[] children = new TrieNode[ALPHABET_SIZE]; + + // isEndOfWord is true if the node represents + // end of a word + boolean isEndOfWord; + + TrieNode(){ + isEndOfWord = false; + for (int i = 0; i < ALPHABET_SIZE; i++) + children[i] = null; + } + }; + + static TrieNode root; + + // If not present, inserts key into trie + // If the key is prefix of trie node, + // just marks leaf node + static void insert(String key) + { + int level; + int length = key.length(); + int index; + + TrieNode pCrawl = root; + + for (level = 0; level < length; level++) + { + index = key.charAt(level) - 'a'; + if (pCrawl.children[index] == null) + pCrawl.children[index] = new TrieNode(); + + pCrawl = pCrawl.children[index]; + } + + // mark last node as leaf + pCrawl.isEndOfWord = true; + } + + // Returns true if key presents in trie, else false + static boolean search(String key) + { + int level; + int length = key.length(); + int index; + TrieNode pCrawl = root; + + for (level = 0; level < length; level++) + { + index = key.charAt(level) - 'a'; + + if (pCrawl.children[index] == null) + return false; + + pCrawl = pCrawl.children[index]; + } + + return (pCrawl != null && pCrawl.isEndOfWord); + } + + // Driver + public static void main(String args[]) + { + // Input keys (use only 'a' through 'z' and lower case) + String keys[] = {"the", "a", "there", "answer", "any", + "by", "bye", "their"}; + + String output[] = {"Not present in trie", "Present in trie"}; + + + root = new TrieNode(); + + // Construct trie + int i; + for (i = 0; i < keys.length ; i++) + insert(keys[i]); + + // Search for different keys + if(search("the") == true) + System.out.println("the --- " + output[1]); + else System.out.println("the --- " + output[0]); + + if(search("these") == true) + System.out.println("these --- " + output[1]); + else System.out.println("these --- " + output[0]); + + if(search("their") == true) + System.out.println("their --- " + output[1]); + else System.out.println("their --- " + output[0]); + + if(search("thaw") == true) + System.out.println("thaw --- " + output[1]); + else System.out.println("thaw --- " + output[0]); + + } } diff --git a/trie/Trie_Problem_02.java b/trie/Trie_Problem_02.java new file mode 100644 index 0000000..57bf8ff --- /dev/null +++ b/trie/Trie_Problem_02.java @@ -0,0 +1,106 @@ +package trie; +/* + * Problem Title :-Find shortest unique prefix for every word in a given list + */ +public class Trie_Problem_02 { + + static final int MAX = 256; + + // Maximum length of an input word + static final int MAX_WORD_LEN = 500; + + // Trie Node. + static class TrieNode + { + TrieNode[] child = new TrieNode[MAX]; + int freq; // To store frequency + TrieNode() { + freq =1; + for (int i = 0; i < MAX; i++) + child[i] = null; + } + } + static TrieNode root; + + // Method to insert a new string into Trie + static void insert(String str) + { + // Length of the URL + int len = str.length(); + TrieNode pCrawl = root; + + // Traversing over the length of given str. + for (int level = 0; level { + public int compare(Word a, Word b) + { + return a.str.compareTo(b.str); + } + } + + // Given a list of words in wordArr[], + static void printAnagramsTogether(String wordArr[], + int size) + { + // Step 1: Create a copy of all words present + // in given wordArr. The copy will also have + // original indexes of words + DupArray dupArray = new DupArray(wordArr, size); + + // Step 2: Iterate through all words in + // dupArray and sort individual words. + int i; + for (i = 0; i < size; ++i) { + char[] char_arr = dupArray.array[i].str.toCharArray(); + Arrays.sort(char_arr); + dupArray.array[i].str = new String(char_arr); + } + + // Step 3: Now sort the array of words in + // dupArray + Arrays.sort(dupArray.array, new compStr()); + + // Step 4: Now all words in dupArray are together, + // but these words are changed. Use the index + // member of word struct to get the corresponding + // original word + for (i = 0; i < size; ++i) + System.out.print(wordArr[dupArray.array[i].index] + " "); + } + + // Driver program to test above functions + public static void main(String args[]) + { + String wordArr[] = { "cat", "dog", "tac", "god", "act" }; + int size = wordArr.length; + printAnagramsTogether(wordArr, size); + } +} +// This code is contributed by Sumit Ghosh diff --git a/trie/Trie_Problem_05.java b/trie/Trie_Problem_05.java new file mode 100644 index 0000000..7129432 --- /dev/null +++ b/trie/Trie_Problem_05.java @@ -0,0 +1,173 @@ +package trie; +import java.util.*; +/* + * Problem Title :-Implement a Phone Directory + */ +class TrieNode{ +//Each Trie Node contains a Map 'child' +// where each alphabet points to a Trie +// Node. +HashMap child; + +// 'isLast' is true if the node represents +// end of a contact +boolean isLast; + +// Default Constructor +public TrieNode() +{ + child = new HashMap(); + + // Initialize all the Trie nodes with NULL + for (char i = 'a'; i <= 'z'; i++) + child.put(i,null); + + isLast = false; +} +} + +class Trie +{ +TrieNode root; + +// Insert all the Contacts into the Trie +public void insertIntoTrie(String contacts[]) +{ + root = new TrieNode(); + int n = contacts.length; + for (int i = 0; i < n; i++) + { + insert(contacts[i]); + } +} + +// Insert a Contact into the Trie +public void insert(String s) +{ + int len = s.length(); + + // 'itr' is used to iterate the Trie Nodes + TrieNode itr = root; + for (int i = 0; i < len; i++) + { + // Check if the s[i] is already present in + // Trie + TrieNode nextNode = itr.child.get(s.charAt(i)); + if (nextNode == null) + { + // If not found then create a new TrieNode + nextNode = new TrieNode(); + + // Insert into the HashMap + itr.child.put(s.charAt(i),nextNode); + } + + // Move the iterator('itr') ,to point to next + // Trie Node + itr = nextNode; + + // If its the last character of the string 's' + // then mark 'isLast' as true + if (i == len - 1) + itr.isLast = true; + } +} + +// This function simply displays all dictionary words +// going through current node. String 'prefix' +// represents string corresponding to the path from +// root to curNode. +public void displayContactsUtil(TrieNode curNode, + String prefix) +{ + + // Check if the string 'prefix' ends at this Node + // If yes then display the string found so far + if (curNode.isLast) + System.out.println(prefix); + + // Find all the adjacent Nodes to the current + // Node and then call the function recursively + // This is similar to performing DFS on a graph + for (char i = 'a'; i <= 'z'; i++) + { + TrieNode nextNode = curNode.child.get(i); + if (nextNode != null) + { + displayContactsUtil(nextNode, prefix + i); + } + } +} + +// Display suggestions after every character enter by +// the user for a given string 'str' +void displayContacts(String str) +{ + TrieNode prevNode = root; + + // 'flag' denotes whether the string entered + // so far is present in the Contact List + + String prefix = ""; + int len = str.length(); + + // Display the contact List for string formed + // after entering every character + int i; + for (i = 0; i < len; i++) + { + // 'str' stores the string entered so far + prefix += str.charAt(i); + + // Get the last character entered + char lastChar = prefix.charAt(i); + + // Find the Node corresponding to the last + // character of 'str' which is pointed by + // prevNode of the Trie + TrieNode curNode = prevNode.child.get(lastChar); + + // If nothing found, then break the loop as + // no more prefixes are going to be present. + if (curNode == null) + { + System.out.println("nNo Results Found for "+ prefix + ""); + i++; + break; + } + + // If present in trie then display all + // the contacts with given prefix. + System.out.println("nSuggestions based on "+ prefix + " are"); + displayContactsUtil(curNode, prefix); + + // Change prevNode for next prefix + prevNode = curNode; + } + + for ( ; i < len; i++) + { + prefix += str.charAt(i); + System.out.println("nNo Results Found for " + prefix + ""); + } +} +} + +//Driver code +public class Trie_Problem_05 { + public static void main(String args[]) + { + Trie trie = new Trie(); + + String contacts [] = {"gforgeeks", "geeksquiz"}; + + trie.insertIntoTrie(contacts); + + String query = "gekk"; + + // Note that the user will enter 'g' then 'e' so + // first display all the strings with prefix as 'g' + // and then all the strings with prefix as 'ge' + trie.displayContacts(query); + } +} diff --git a/trie/Trie_Problem_06.java b/trie/Trie_Problem_06.java new file mode 100644 index 0000000..0492ed4 --- /dev/null +++ b/trie/Trie_Problem_06.java @@ -0,0 +1,59 @@ +package trie; +/* + * Problem Title :-Find shortest unique prefix for every word in a given list + */ +public class Trie_Problem_06 { + + static int ROW = 4; + static int COL = 5; + + // Function that prints all + // unique rows in a given matrix. + static void findUniqueRows(int M[][]) + { + + // Traverse through the matrix + for(int i = 0; i < ROW; i++) + { + int flag = 0; + + // Check if there is similar column + // is already printed, i.e if i and + // jth column match. + for(int j = 0; j < i; j++) + { + flag = 1; + + for(int k = 0; k < COL; k++) + if (M[i][k] != M[j][k]) + flag = 0; + + if (flag == 1) + break; + } + + // If no row is similar + if (flag == 0) + { + + // Print the row + for(int j = 0; j < COL; j++) + System.out.print(M[i][j] + " "); + + System.out.println(); + } + } + } + + // Driver Code + public static void main(String[] args) + { + int M[][] = { { 0, 1, 0, 0, 1 }, + { 1, 0, 1, 1, 0 }, + { 0, 1, 0, 0, 1 }, + { 1, 0, 1, 0, 0 } }; + + findUniqueRows(M); + } + +} From cc847f3400592dcd6b43078c6f2e05d4466c013a Mon Sep 17 00:00:00 2001 From: Aman Soni <65482419+gitaman8481@users.noreply.github.com> Date: Fri, 21 May 2021 17:05:08 +0530 Subject: [PATCH 45/56] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 49c03ae..e0430d4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Java-Programs +# Java-Programs[101/450] - This is a full fledged repository for learning Java Language & DSA for Placement Prepration. - Here, I will upload the solutions of 450 Questions of (DataStructure & Algorithms Cracker Sheet) By LOVE BABBAR Bhaiya. - I have practiced all my codes on Eclipse. You can also practice some beginner problems which are also included in it. From bc1fe1d55e280bf6f5d9bb2121840381a48afc72 Mon Sep 17 00:00:00 2001 From: Aman Soni Date: Thu, 24 Jun 2021 12:26:25 +0530 Subject: [PATCH 46/56] #Modification 40 --- ...java_858444b12c007c82eb6499b9a4c4308f.prob | 1 + ssp/SSP_Problem_01_1.java | 28 +++++++++++ ..._Problem_01.java => SSP_Problem_01_2.java} | 45 ++++++------------ ssp/SSP_Problem_02_1.java | 17 +++++++ ..._Problem_02.java => SSP_Problem_02_2.java} | 20 ++++---- ssp/SSP_Problem_03.java | 7 +-- ssp/ssp/SSP_Problem_01_1.class | Bin 0 -> 1391 bytes ssp/ssp/SSP_Problem_01_2.class | Bin 0 -> 1393 bytes 8 files changed, 70 insertions(+), 48 deletions(-) create mode 100644 ssp/.cph/.SSP_Problem_01_1.java_858444b12c007c82eb6499b9a4c4308f.prob create mode 100644 ssp/SSP_Problem_01_1.java rename ssp/{SSP_Problem_01.java => SSP_Problem_01_2.java} (55%) create mode 100644 ssp/SSP_Problem_02_1.java rename ssp/{SSP_Problem_02.java => SSP_Problem_02_2.java} (66%) create mode 100644 ssp/ssp/SSP_Problem_01_1.class create mode 100644 ssp/ssp/SSP_Problem_01_2.class diff --git a/ssp/.cph/.SSP_Problem_01_1.java_858444b12c007c82eb6499b9a4c4308f.prob b/ssp/.cph/.SSP_Problem_01_1.java_858444b12c007c82eb6499b9a4c4308f.prob new file mode 100644 index 0000000..994edb7 --- /dev/null +++ b/ssp/.cph/.SSP_Problem_01_1.java_858444b12c007c82eb6499b9a4c4308f.prob @@ -0,0 +1 @@ +{"name":"Local: SSP_Problem_01_1","url":"c:\\Users\\gitam\\Desktop\\Java Program's\\Placement Prepration\\src\\ssp\\SSP_Problem_01_1.java","tests":[{"id":1624446124341,"input":"8","output":"First Occurence = 8\nLast Occurence = 9"}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"c:\\Users\\gitam\\Desktop\\Java Program's\\Placement Prepration\\src\\ssp\\SSP_Problem_01_1.java","group":"local","local":true} \ No newline at end of file diff --git a/ssp/SSP_Problem_01_1.java b/ssp/SSP_Problem_01_1.java new file mode 100644 index 0000000..2e3b858 --- /dev/null +++ b/ssp/SSP_Problem_01_1.java @@ -0,0 +1,28 @@ +package ssp; +import java.util.*; + +class SSP_Problem_01_1{ + + static void findFirstAndLast(int[] a, int x){ + int n = a.length; + int first = -1, last = -1; + + for(int i = 0; i < n-1; i++){ + if(x != a[i]) continue; + if(first == -1) first = i; + last = i; + } + if(first != -1){ + System.out.println("First Occurrence = " + first); + System.out.println("Last Occurrence = " + last); + } + else System.out.println("Not Found"); + } + + public static void main(String[] args){ + Scanner sc = new Scanner(System.in); + int[] arr = { 1, 2, 2, 2, 2, 3, 4, 7, 8, 8 }; + int x = sc.nextInt(); + findFirstAndLast(arr, x); + } +} \ No newline at end of file diff --git a/ssp/SSP_Problem_01.java b/ssp/SSP_Problem_01_2.java similarity index 55% rename from ssp/SSP_Problem_01.java rename to ssp/SSP_Problem_01_2.java index 552380b..9cfd0e2 100644 --- a/ssp/SSP_Problem_01.java +++ b/ssp/SSP_Problem_01_2.java @@ -1,8 +1,8 @@ package ssp; - +//! Method 2 // Problem Title :- Find first and last positions of an element in a sorted array // An optimized approach using binary search in O(n) Time Complexity. -public class SSP_Problem_01 { +public class SSP_Problem_01_2 { /* * if x is present in a[] then returns the index of @@ -10,19 +10,11 @@ public class SSP_Problem_01 { * otherwise returns -1. */ public static int first(int[] a, int low, int high, int x, int n) { - if(high >= low) { - int mid = low + (high - low)/2; - - if( (mid == 0 || x > a[mid - 1]) && a[mid] == x) - return mid; - - else if(x > a[mid]) - return first(a, (mid + 1), high, x, n); - - else - return first(a, low, (mid - 1 ), x, n); + if( (mid == 0 || x > a[mid - 1]) && a[mid] == x) return mid; + else if(x > a[mid]) return first(a, (mid + 1), high, x, n); + else return first(a, low, (mid - 1 ), x, n); } return -1; } @@ -32,35 +24,26 @@ else if(x > a[mid]) * LAST occurrence of x in a[0..n-1], * otherwise returns -1 */ - public static int last(int a[], int low, int high, int x, int n) { + public static int last(int[] a, int low, int high, int x, int n) { if(high >= low) { - int mid = low + (high - low)/2; - - if((mid == n-1 || x < a[mid + 1]) && a[mid] == x) - return mid; - - else if(x < a[mid]) - return last(a, low, (mid - 1), x, n); - - else - return last(a, (mid + 1), high, x, n); + if((mid == n-1 || x < a[mid + 1]) && a[mid] == x) return mid; + else if(x < a[mid]) return last(a, low, (mid - 1), x, n); + else return last(a, (mid + 1), high, x, n); } - return -1; } // Driver Code public static void main(String[] args) { - + // Array int[] a = {1, 2, 2, 2, 2, 3, 4, 7, 8, 8}; - + // Numbers int n = a.length; int x = 8; - - System.out.println("First Occurence = " + first(a, 0, n - 1, x, n)); - System.out.println("last Occurence = " + last(a, 0, n-1, x, n)); + // Printing Result + System.out.println("First Occurrence = " + first(a, 0, n - 1, x, n)); + System.out.println("last Occurrence = " + last(a, 0, n-1, x, n)); } - } diff --git a/ssp/SSP_Problem_02_1.java b/ssp/SSP_Problem_02_1.java new file mode 100644 index 0000000..37645d2 --- /dev/null +++ b/ssp/SSP_Problem_02_1.java @@ -0,0 +1,17 @@ +package ssp; + +public class SSP_Problem_02_1 { + static int linearSearch(int[] arr, int n){ + int i; + for(i = 0; i Find a Fixed Point (Value equal to index) in a given array -public class SSP_Problem_02 { +// Algorithmic Paradigm: Divide & Conquer +// Time Complexity: O(Log n) +public class SSP_Problem_02_2 { + static int binarySearch(int[] a, int low, int high) { - if(high >= low) { - /* low + (high - low)/2;*/ int mid = (low + high)/2; - - if(mid == a[mid]) - return mid; - - if(mid > a[mid]) - return binarySearch(a, (mid + 1), high); - - else - return binarySearch(a, low, (mid - 1)); + if(mid == a[mid]) return mid; + if(mid > a[mid]) return binarySearch(a, (mid + 1), high); + else return binarySearch(a, low, (mid - 1)); } /* Return -1 if there is no Fixed Point */ return -1; } + // Driver Code public static void main(String[] args) { int[] a= {-10, -1, 0, 3, 10, 11, 30, 50, 100}; diff --git a/ssp/SSP_Problem_03.java b/ssp/SSP_Problem_03.java index d940050..5a493de 100644 --- a/ssp/SSP_Problem_03.java +++ b/ssp/SSP_Problem_03.java @@ -8,12 +8,9 @@ public class SSP_Problem_03 { * otherwise returns -1. */ static int search(int[] a, int l, int h, int key) { - if(l > h) - return -1; - + if(l > h) return -1; int mid = (l + h) / 2; - if(a[mid] == key) - return mid; + if(a[mid] == key) return mid; /* If a[1...mid] first sub-array is sorted */ if(a[l] <= a[mid]) { diff --git a/ssp/ssp/SSP_Problem_01_1.class b/ssp/ssp/SSP_Problem_01_1.class new file mode 100644 index 0000000000000000000000000000000000000000..c8d8b4f3f5705301ea5ae491281105c1ad3409cc GIT binary patch literal 1391 zcmaJ>Uvt|;5dWPm>10J|TqjEZIu($%j$7iS&=hc!lA0RCICVPilree8DE85+u_cdm z?vQsr1aD<{$uoUunE?F&dwIN7|0EVbYbZcgI0;!f?=i> zgyMd`yC>p@{$7VP+3$j|T@B(yZielepGYz-?0B9snr=wHwZG-}26s8Glb^01gbeeA zo!V3XnP2Mo;p0+6#zFYFtW2y%)Q?-D8YtgRqp`ia9Y++XySuWwySl7wY@EUj$A>nS zQ6d0$qevz)_Iq1GK8f1NjDZyst2S=nBaV-4+{BuRTMU`|k#wt3KWsCc9z^fUpi^qJ z{4f-;jZg5Y^8J~OGH%<*VU}SoNqVLK!l0nX;Ol!&MT=OccDxh%#z7)Qm+}|&>C_q0 z4WiOEah1ea_}#LFbx?}u2KjUAtyVvdMc5MVy2}{Obp3r%iNcmIzX{|MS|!pCWkTKx z-qK|L7-k2sP6lD%Jr%M;X?F^fRx0bWs&EtWQ>s$Oz`d~7e+!)9?8p@b8$VFqcqqP? zUP!E|cRY?esuUH5#p9#};j?I8j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~!Shn;d7WgAO2Za$S4-vY*lK;ZxY literal 0 HcmV?d00001 From 27f0aba0930bec083e699a57e04353ee8de3b895 Mon Sep 17 00:00:00 2001 From: Aman Soni Date: Mon, 19 Jul 2021 17:11:04 +0530 Subject: [PATCH 47/56] #Modification 40 --- array/Candy_Distribution_Problem.java | 3 +- array/Problem1.java | 40 +++++++++ array/Problem2.java | 49 +++++++++++ array/Problem3.java | 120 ++++++++++++++++++++++++++ array/Problem4.java | 56 ++++++++++++ array/Problem5.java | 37 ++++++++ arrays/Array_Problem_1.java | 8 +- arrays/Array_Problem_3.java | 39 ++++----- arrays/Array_Problem_4_Approach1.java | 63 +++++++------- linkedList/LL.java | 59 +++++++++++++ oops/Watches.java | 7 ++ stack/Infix_To_Postfix.java | 2 +- 12 files changed, 418 insertions(+), 65 deletions(-) create mode 100644 array/Problem1.java create mode 100644 array/Problem2.java create mode 100644 array/Problem3.java create mode 100644 array/Problem4.java create mode 100644 array/Problem5.java create mode 100644 linkedList/LL.java create mode 100644 oops/Watches.java diff --git a/array/Candy_Distribution_Problem.java b/array/Candy_Distribution_Problem.java index 8a56be7..3cb4167 100644 --- a/array/Candy_Distribution_Problem.java +++ b/array/Candy_Distribution_Problem.java @@ -2,7 +2,7 @@ import java.util.*; //Language: Java -//Time Complexity: O(n) 3 Linear traversals. +//Time Complexity: O(n)3 Linear traversals. //Space Complexity: O(n) Array of candies. public class Candy_Distribution_Problem{ @@ -41,7 +41,6 @@ public int candy(int[] ratings) { } public static void main(String[] args) { - @SuppressWarnings("unused") int[] ratings = {12 , 34 , 45 , 67 , 43 , 75}; } diff --git a/array/Problem1.java b/array/Problem1.java new file mode 100644 index 0000000..46e56c8 --- /dev/null +++ b/array/Problem1.java @@ -0,0 +1,40 @@ +package array; +import java.util.Scanner; +//Title :- Java program to reverse the given array +class Problem1{ + + static void reverseArray(int[] a, int start, int end){ + int temp; + while(start < end){ + temp = a[end]; + a[end] = a[start]; + a[start] = temp; + start++; + end--; + } + } + + static void printArray(int[] a, int n){ + for (int i = 0; i < n; i++){ + System.out.print(a[i] + " "); + } + System.out.println(); + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + + int[] a = new int[n]; + for(int i = 0; i < n; i++){ + a[i] = sc.nextInt(); + } + System.out.println("Array before Reversing is "); + printArray(a, n); + + reverseArray(a,0,n-1); + + System.out.println("Reversed Array is "); + printArray(a, n); + } +} \ No newline at end of file diff --git a/array/Problem2.java b/array/Problem2.java new file mode 100644 index 0000000..c81d676 --- /dev/null +++ b/array/Problem2.java @@ -0,0 +1,49 @@ +package array; + +import java.util.Scanner; + +//Title : Java program to find the maximum & minimum element in given array +class Problem2{ + + static class Pair{ + int min, max; + } + static Pair getMinMax(int[] a, int n){ + Pair minMax = new Pair(); + int i; + // BASE CASE + if(n == 1) { + minMax.max = a[0]; + minMax.min = a[0]; + return minMax; + } + + //IF their are more than one elements THEN initialize min and max + if (a[0] > a[1]){ + minMax.max = a[0]; + minMax.min = a[1]; + }else { + minMax.max = a[1]; + minMax.min = a[0]; + } + + //IF their are so many or more than 2 elements in array THEN following loop will work + for (i = 0; i < n; i++){ + if(a[i] > minMax.max) minMax.max = a[i]; + else if(a[i] < minMax.min) minMax.min = a[i]; + } + + return minMax; + } + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int[] a = new int[n]; + for(int i = 0; i < n; i++){ + a[i] = sc.nextInt(); + } + Pair minMax = getMinMax(a, n); + System.out.printf("\nMinimum element is %d", minMax.min); + System.out.printf("\nMaximum element is %d", minMax.max); + } +} \ No newline at end of file diff --git a/array/Problem3.java b/array/Problem3.java new file mode 100644 index 0000000..13d5556 --- /dev/null +++ b/array/Problem3.java @@ -0,0 +1,120 @@ +package array; + +/* + * TITLE ==> (Find K^th smallest element) + * + * Problem Statement ==> + * Given an array array[] and a number K where K is smaller than size of array, + * the task is to find the K^the smallest element in the given array. + * It is given that all array elements are distinct. + */ + +import java.util.Arrays; +import java.util.Scanner; + +class Problem3{ + // int partition(int array[], int l, int r, int k); + // A simple function to find median of arr[]. + // This is called only for an array of size 5 in this program. + static int findMedian(int[] arr, int i,int n) { + if(i <= n) + // Sort the array + Arrays.sort(arr, i, n); + else + Arrays.sort(arr, n, i); + return arr[n/2]; // Return middle element + } + + // Returns k^th smallest element + // in arr[l..r] in worst case + // linear time. ASSUMPTION: ALL + // ELEMENTS IN ARR[] ARE DISTINCT + static int kthSmallest(int[] arr, int l, int r, int k) + { + // IF k is smaller than the number of elements in array + if (k > 0 && k <= r - l + 1) { + int n = r - l + 1 ; // Number of elements in arr[l..r] + + // Divide arr[] in groups of size 5, + // calculate median of every group and store it in median[] array. + int i; + + // There will be floor((n+4)/5) groups; + int []median = new int[(n + 4) / 5]; + for (i = 0; i < n/5; i++) + median[i] = findMedian(arr,l + i * 5, 5); + + // For last group with less than 5 elements + if (i*5 < n) { + median[i] = findMedian(arr,l + i * 5, n % 5); + i++; + } + + // Find median of all medians using recursive call. + // IF median[] has only one element, + // then their is no need of recursive call + int medOfMed = (i == 1)? median[i - 1]: + kthSmallest(median, 0, i - 1, i / 2); + + // Partition the array around a random element and get position of pivot element in sorted array + int pos = partition(arr, l, r, medOfMed); + + // IF position is same as k + if (pos-l == k - 1) + return arr[pos]; + if (pos-l > k - 1) + // IF position is more, recur for left + return kthSmallest(arr, l, pos - 1, k); + + // ELSE recur for right sub array + return kthSmallest(arr, pos + 1, r, k - pos + l - 1); + } + + // IF k is more than number of elements in array + return Integer.MAX_VALUE; + } + + static void swap(int []arr, int i, int j) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + + // It searches for x in arr[l..r], and partition's the array around x. + static int partition(int[] arr, int l, int r, int x) { + // Search for x in arr[l..r] and move it to end + int i; + for (i = l; i < r; i++) + if (arr[i] == x) break; + swap(arr, i, r); + + // Standard partition algorithm + i = l; + for (int j = l; j <= r - 1; j++) { + if (arr[j] <= x) { + swap(arr, i, j); + i++; + } + } + swap(arr, i, r); + return i; + } + + // Driver code + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + // Input Size of Array + System.out.println("Input total no of element's in the array "); + int n = sc.nextInt(); + //Array Input + System.out.println("Input element's of the array "); + int[] arr = new int[n]; + for(int i = 0; i < n; i++) + arr[i] = sc.nextInt(); + // K Input + System.out.println("Input K to find out K^th Element "); + int k = sc.nextInt(); + //"K^th smallest element is " + + System.out.println(kthSmallest(arr, 0, n - 1, k)); + } +} \ No newline at end of file diff --git a/array/Problem4.java b/array/Problem4.java new file mode 100644 index 0000000..e571b08 --- /dev/null +++ b/array/Problem4.java @@ -0,0 +1,56 @@ +package array; +// TITLE => * Java program to solve that, +// Given an array A of size N containing 0s, 1s, and 2s; +// you need to sort the array in ascending order without using any sorting algorithm + +import java.util.Scanner; + +class Problem4{ + /* Function to sort the array of 0's,1's,2's */ + static void sort012(int[] a, int n){ + int low = 0, high = n-1, mid = 0, temp; + while (mid <= high){ + switch (a[mid]){ + case 0: { + temp = a[low]; + a[low] = a[mid]; + a[mid] = temp; + low++; + mid++; + break; + } + case 1:{ + mid++; + break; + } + case 2:{ + temp = a[mid]; + a[mid] = a[high]; + a[high] = temp; + high--; + break; + } + } + } + } + + /* Utility function to print array arr[] */ + static void printArray(int[] a,int n) { + int i; + for (i = 0; i < n; i++) + System.out.print(a[i] + " "); + System.out.println(); + } + + /* Driver Function */ + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int[] a = new int[n]; + for (int i = 0; i < n; i++) + a[i] = sc.nextInt(); + sort012(a, n); + System.out.println("Array after segregation"); + printArray(a, n); + } +} \ No newline at end of file diff --git a/array/Problem5.java b/array/Problem5.java new file mode 100644 index 0000000..d0782d0 --- /dev/null +++ b/array/Problem5.java @@ -0,0 +1,37 @@ +package array; + +import java.util.Scanner; + +// TITLE => Move all negative elements to one side of array. +public class Problem5{ + + static void rearrange(int[] a, int n){ + int j = 0, temp; + for(int i = 0; i < n; i++){ + if(a[i] < 0){ + if(i != j){ + temp = a[i]; + a[i] = a[j]; + a[j] = temp; + } + j++; + } + } + } + + static void printArray(int[] a, int n){ + for(int i = 0; i < n; i++) + System.out.print(a[i] + " "); + System.out.println(); + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int[] a = new int[n]; + for (int i = 0; i < n; i++) + a[i] = sc.nextInt(); + rearrange(a,n); + printArray(a,n); + } +} \ No newline at end of file diff --git a/arrays/Array_Problem_1.java b/arrays/Array_Problem_1.java index 7b5effb..24c3dd6 100644 --- a/arrays/Array_Problem_1.java +++ b/arrays/Array_Problem_1.java @@ -3,7 +3,7 @@ //Java program to reverse the given array public class Array_Problem_1 { - static void rvereseArray(int arr[], int start, int end) { + static void revereseArray(int[] arr, int start, int end) { int temp; while (start < end) { temp = arr[end]; @@ -17,7 +17,7 @@ static void rvereseArray(int arr[], int start, int end) { /* * Utility that prints out an array on a line */ - static void printArray(int arr[], int size) { + static void printArray(int[] arr, int size) { for (int i = 0; i < size; i++) System.out.print(arr[i] + " "); @@ -27,9 +27,9 @@ static void printArray(int arr[], int size) { // Driver code public static void main(String args[]) { - int arr[] = { 1, 2, 3, 4, 5, 6 }; + int[] arr = { 1, 2, 3, 4, 5, 6 }; printArray(arr, 6); - rvereseArray(arr, 0, 5); + revereseArray(arr, 0, 5); System.out.print("Reversed array is \n"); printArray(arr, 6); diff --git a/arrays/Array_Problem_3.java b/arrays/Array_Problem_3.java index 0a9c3ad..48b1076 100644 --- a/arrays/Array_Problem_3.java +++ b/arrays/Array_Problem_3.java @@ -14,7 +14,7 @@ public class Array_Problem_3 { // A simple function to find median of arr[]. This is called // only for an array of size 5 in this program. - static int findMedian(int arr[], int i,int n) + static int findMedian(int[] arr, int i,int n) { if(i <= n) Arrays.sort(arr, i, n); // Sort the array @@ -23,11 +23,11 @@ static int findMedian(int arr[], int i,int n) return arr[n/2]; // Return middle element } - // Returns k'th smallest element + // Returns k^th smallest element // in arr[l..r] in worst case // linear time. ASSUMPTION: ALL // ELEMENTS IN ARR[] ARE DISTINCT - static int kthSmallest(int arr[], int l, int r, int k) + static int kthSmallest(int[] arr, int l, int r, int k) { // If k is smaller than // number of elements in array @@ -68,7 +68,7 @@ static int kthSmallest(int arr[], int l, int r, int k) if (pos-l > k - 1) // If position is more, recur for left return kthSmallest(arr, l, pos - 1, k); - // Else recur for right subarray + // Else recur for right sub array return kthSmallest(arr, pos + 1, r, k - pos + l - 1); } @@ -76,32 +76,25 @@ static int kthSmallest(int arr[], int l, int r, int k) return Integer.MAX_VALUE; } - static int[] swap(int []arr, int i, int j) - { + static void swap(int []arr, int i, int j) { int temp = arr[i]; arr[i] = arr[j]; - arr[j] = temp; - return arr; - } + arr[j] = temp; + } // It searches for x in arr[l..r], and // partitions the array around x. - static int partition(int arr[], int l, - int r, int x) - { + static int partition(int[] arr, int l, int r, int x) { // Search for x in arr[l..r] and move it to end int i; for (i = l; i < r; i++) - if (arr[i] == x) - break; + if (arr[i] == x) break; swap(arr, i, r); // Standard partition algorithm i = l; - for (int j = l; j <= r - 1; j++) - { - if (arr[j] <= x) - { + for (int j = l; j <= r - 1; j++) { + if (arr[j] <= x) { swap(arr, i, j); i++; } @@ -111,12 +104,10 @@ static int partition(int arr[], int l, } // Driver code - public static void main(String[] args) - { - int arr[] = {12, 3, 5, 7, 4, 19, 26}; + public static void main(String[] args) { + int[] arr = {12, 3, 5, 7, 4, 19, 26}; int n = arr.length, k = 3; - System.out.println("K'th smallest element is " + System.out.println("K^th smallest element is " + kthSmallest(arr, 0, n - 1, k)); - } - + } } diff --git a/arrays/Array_Problem_4_Approach1.java b/arrays/Array_Problem_4_Approach1.java index b3c5c4d..d9fb328 100644 --- a/arrays/Array_Problem_4_Approach1.java +++ b/arrays/Array_Problem_4_Approach1.java @@ -11,54 +11,49 @@ @SuppressWarnings("unused") public class Array_Problem_4_Approach1 { - // Sort the input array, the array is assumed to - // have values in {0, 1, 2} - static void sort012(int a[], int arr_size) - { + // Sort the input array, the array is assumed they have values in {0, 1, 2} + static void sort012(int[] arr, int arr_size) { int lo = 0; - int hi = arr_size - 1; - int mid = 0, temp = 0; + int hi = arr_size - 1; + int mid = 0, temp; while (mid <= hi) { - switch (a[mid]) { - case 0: { - temp = a[lo]; - a[lo] = a[mid]; - a[mid] = temp; - lo++; - mid++; - break; - } - case 1: - mid++; - break; - case 2: { - temp = a[mid]; - a[mid] = a[hi]; - a[hi] = temp; - hi--; - break; - } + switch (arr[mid]) { + case 0: { + temp = arr[lo]; + arr[lo] = arr[mid]; + arr[mid] = temp; + lo++; + mid++; + break; + } + case 1: + mid++; + break; + case 2: { + temp = arr[mid]; + arr[mid] = arr[hi]; + arr[hi] = temp; + hi--; + break; + } } } } /* Utility function to print array arr[] */ - static void printArray(int arr[], int arr_size) - { + static void printArray(int[] arr, int arr_size) { int i; for (i = 0; i < arr_size; i++) System.out.print(arr[i] + " "); - System.out.println(""); + System.out.println(); } /*Driver function to check for above functions*/ - public static void main(String[] args) - { - int arr[] = { 0, 1, 1, 0, 1, 2, 1, 2, 0, 0, 0, 1 }; + public static void main(String[] args) { + int[] arr = { 0, 1, 1, 0, 1, 2, 1, 2, 0, 0, 0, 1 }; int arr_size = arr.length; sort012(arr, arr_size); - System.out.println("Array after seggregation "); + System.out.println("Array after segregation "); printArray(arr, arr_size); - } - + } } diff --git a/linkedList/LL.java b/linkedList/LL.java new file mode 100644 index 0000000..6b0188b --- /dev/null +++ b/linkedList/LL.java @@ -0,0 +1,59 @@ +package linkedList; + +class LL{ + + // class to create a node of linked list + static class Node{ + int data; + Node next; + Node(int data){ + this.data = data; + next = null; + } + } + + Node head; + Node position; + + void add(int data) { + LL.Node toAdd = new LL.Node(data); + if(isEmpty()) { + head = toAdd; + return; + } + LL.Node temp = head; + while(temp.next != null) { + temp = temp.next; + } + temp.next = toAdd; + } + + boolean isEmpty() { + return head == null; + } + + void remove(int data) { + head = null; + } + + void print() { + LL.Node temp = head; + while(temp != null) { + System.out.println(temp.data + " "); + temp = temp.next; + } + } + + void isValue() { + } + + public static void main(String[] args) { + LL l = new LL(); + l.add(7); + l.add(9); + l.print(); + l.remove(7); + l.print(); + l.isValue(); + } +} \ No newline at end of file diff --git a/oops/Watches.java b/oops/Watches.java new file mode 100644 index 0000000..09eab9f --- /dev/null +++ b/oops/Watches.java @@ -0,0 +1,7 @@ +package oops; + +public abstract class Watches { + public void Digital() { + + } +} diff --git a/stack/Infix_To_Postfix.java b/stack/Infix_To_Postfix.java index d8548c5..1dc4005 100644 --- a/stack/Infix_To_Postfix.java +++ b/stack/Infix_To_Postfix.java @@ -29,7 +29,7 @@ static String infixToPostfix(String exp){ char c = exp.charAt(i); if(Character.isLetterOrDigit(c)) - result += c; + result = result + c; else if(c == '(') stack.push(c); From 62ac6fb5b52013ec808e1ded23cc7ce3e545c5a6 Mon Sep 17 00:00:00 2001 From: Aman Soni Date: Wed, 21 Jul 2021 21:31:51 +0530 Subject: [PATCH 48/56] #Modification 41 --- array/Problem6.java | 84 +++++++++++++++++++++++++++++++++++++ array/Problem7.java | 29 +++++++++++++ arrays/Array_Problem_6.java | 30 ++++++------- arrays/Array_Problem_7.java | 60 ++++++++++++-------------- 4 files changed, 154 insertions(+), 49 deletions(-) create mode 100644 array/Problem6.java create mode 100644 array/Problem7.java diff --git a/array/Problem6.java b/array/Problem6.java new file mode 100644 index 0000000..4873819 --- /dev/null +++ b/array/Problem6.java @@ -0,0 +1,84 @@ +package array; + +// TITLE => Find Union and Intersection of Two sorted arrays. + +import java.util.Arrays; + +class Problem6{ + // Function to printUnion + static void printUnion(int[] a1, int[] a2, int m, int n){ + if(m > n){ + int[] temp1 = a1; + a1 = a2; + a2 = temp1; + + int temp2 = m; + m = n; + n = temp2; + } + Arrays.sort(a1); + for (int i = 0; i < m; i++) + System.out.print(a1[i] + " "); + + // Search every element of bigger array in smaller array + // and print the element IF not found + for (int i = 0; i < n; i++) { + if (binarySearch(a1, 0, m - 1, a2[i]) == -1) + System.out.print(a2[i] + " "); + } + } + + // Function to printIntersection + static void printIntersection(int[] a1, int[] a2, int m, int n) { + if(m > n){ + int[] temp1 = a1; + a1 = a2; + a2 = temp1; + + int temp2 = m; + m = n; + n = temp2; + } + Arrays.sort(a1); + + // Search every element of bigger array in smaller + // array and print the element if found + for (int i = 0; i < n; i++) { + if (binarySearch(a1, 0, m - 1, a2[i]) != -1) + System.out.print(a2[i] + " "); + } + } + + // Function to binary Search + static int binarySearch(int[] a, int l, int r, int x){ + if(r >= l){ + int mid = l + (r - 1) /2; + if(a[mid] == x) + return mid; + if(a[mid] > x) + return binarySearch(a,mid - 1, r, x); + + return binarySearch(a,mid + 1, r, x); + } + return -1; + } + + // DRIVER CODE + public static void main(String[] args) { + + int[] a1 = { 7, 1, 5, 2, 3, 6 }; + int[] a2 = { 3, 8, 6, 20, 7 }; + + int m = a1.length; + int n = a2.length; + + // Function call + System.out.println("Union of two arrays is "); + printUnion(a1, a2, m, n); + + System.out.println(); + + System.out.println("Intersection of two arrays is "); + printIntersection(a1, a2, m, n); + } +} \ No newline at end of file diff --git a/array/Problem7.java b/array/Problem7.java new file mode 100644 index 0000000..36fd324 --- /dev/null +++ b/array/Problem7.java @@ -0,0 +1,29 @@ +package array; + +import java.util.Arrays; +import java.util.Scanner; + +class Problem7{ + static void rotate(int[] a){ + int x = a[a.length-1], i; + for (i = a.length-1; i > 0; i--) + a[i] = a[i-1]; + a[0] = x; + } + public static void main(String[] args) { + + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int[] a = new int[n]; + for (int i = 0; i < n; i++) + a[i] = sc.nextInt(); + + System.out.println("Given Array is"); + System.out.println(Arrays.toString(a)); + + rotate(a); + + System.out.println("Rotated Array is"); + System.out.println(Arrays.toString(a)); + } +} \ No newline at end of file diff --git a/arrays/Array_Problem_6.java b/arrays/Array_Problem_6.java index 5552ee1..3eb4ed5 100644 --- a/arrays/Array_Problem_6.java +++ b/arrays/Array_Problem_6.java @@ -10,12 +10,11 @@ public class Array_Problem_6 { - void printUnion(int arr1[], int arr2[], int m, int n) - { + void printUnion(int[] arr1, int[] arr2, int m, int n) { // Before finding union, make sure arr1[0..m-1] // is smaller if (m > n) { - int tempp[] = arr1; + int[] tempp = arr1; arr1 = arr2; arr2 = tempp; @@ -41,13 +40,13 @@ void printUnion(int arr1[], int arr2[], int m, int n) } // Prints intersection of arr1[0..m-1] and arr2[0..n-1] - void printIntersection(int arr1[], int arr2[], int m, - int n) + void printIntersection(int[] arr1, int[] arr2, int m, + int n) { // Before finding intersection, make sure // arr1[0..m-1] is smaller if (m > n) { - int tempp[] = arr1; + int[] tempp = arr1; arr1 = arr2; arr2 = tempp; @@ -71,8 +70,7 @@ void printIntersection(int arr1[], int arr2[], int m, // A recursive binary search function. It returns // location of x in given array arr[l..r] is present, // otherwise -1 - int binarySearch(int arr[], int l, int r, int x) - { + int binarySearch(int[] arr, int l, int r, int x) { if (r >= l) { int mid = l + (r - l) / 2; @@ -97,21 +95,23 @@ int binarySearch(int arr[], int l, int r, int x) } // Driver code - public static void main(String[] args) - { + public static void main(String[] args) { + Array_Problem_6 u_i= new Array_Problem_6(); - int arr1[] = { 7, 1, 5, 2, 3, 6 }; - int arr2[] = { 3, 8, 6, 20, 7 }; + int[] arr1 = { 7, 1, 5, 2, 3, 6 }; + int[] arr2 = { 3, 8, 6, 20, 7 }; + int m = arr1.length; int n = arr2.length; // Function call System.out.println("Union of two arrays is "); u_i.printUnion(arr1, arr2, m, n); - System.out.println(""); - System.out.println( - "Intersection of two arrays is "); + + System.out.println(); + + System.out.println("Intersection of two arrays is "); u_i.printIntersection(arr1, arr2, m, n); } } diff --git a/arrays/Array_Problem_7.java b/arrays/Array_Problem_7.java index 948018d..aee849f 100644 --- a/arrays/Array_Problem_7.java +++ b/arrays/Array_Problem_7.java @@ -4,39 +4,31 @@ * Write a program to cyclically rotate an array by one. */ +import java.util.Arrays; +import java.util.Scanner; + public class Array_Problem_7 { - - //function to rotate the elements of an array - - void rotateL(int a[], int d, int n) { - for(int i= 0;i 0; i--) + a[i] = a[i-1]; + a[0] = x; + } + public static void main(String[] args) { + + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int[] a = new int[n]; + for (int i = 0; i < n; i++) + a[i] = sc.nextInt(); + + System.out.println("Given Array is"); + System.out.println(Arrays.toString(a)); + + rotate(a); + + System.out.println("Rotated Array is"); + System.out.println(Arrays.toString(a)); + } } From d673c59ce539cc7dce6cf930c13f64d33cf7fafa Mon Sep 17 00:00:00 2001 From: Aman Soni Date: Thu, 22 Jul 2021 11:37:37 +0530 Subject: [PATCH 49/56] #Modification 42 --- array/Problem8.java | 30 +++++++++++++++++++++ array/Problem9.java | 64 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 array/Problem8.java create mode 100644 array/Problem9.java diff --git a/array/Problem8.java b/array/Problem8.java new file mode 100644 index 0000000..7c40ba6 --- /dev/null +++ b/array/Problem8.java @@ -0,0 +1,30 @@ +package array; + +import java.util.Scanner; + +// TITLE => find Largest sum contiguous Sub-array [V. IMP] +public class Problem8{ + static int maxSumSubArray(int[] a){ + int maxSum = 0; + int currSum = 0; + for(int i = 1; i < a.length; i++){ + currSum = currSum + a[i]; + if(currSum > maxSum){ + maxSum = currSum; + } + if(currSum < 0){ + currSum = 0; + } + } + return maxSum; + } + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int n = sc.nextInt(); + int[] a = new int[n]; + for (int i = 0; i < n; i++){ + a[i] = sc.nextInt(); + } + System.out.println(maxSumSubArray(a)); + } +} \ No newline at end of file diff --git a/array/Problem9.java b/array/Problem9.java new file mode 100644 index 0000000..6275bb0 --- /dev/null +++ b/array/Problem9.java @@ -0,0 +1,64 @@ +package array; + +import java.util.Arrays; +import java.util.Scanner; + +// TITLE => Minimise the maximum difference between heights [V.IMP] +public class Problem9{ + + // Modifies the array by subtracting/adding k to every element + // such that the difference between maximum and minimum is minimized + static int getMinDiff(int[] a, int n, int k){ + if(n == 1) + return 0; + + // Sort all elements + Arrays.sort(a); + + // Initialize result + int ans = a[n-1] - a[0]; + + // Handle corner elements + int small = a[0] + k; + int big = a[n-1] - k; + int temp; + + if (small > big) { + temp = small; + small = big; + big = temp; + } + + // Traverse middle elements + for (int i = 1; i < n-1; i ++) { + int subtract = a[i] - k; + int add = a[i] + k; + + // If both subtraction and addition + // do not change diff + if (subtract >= small || add <= big) + continue; + + // Either subtraction causes a smaller number or addition causes a greater number. + // Update small or big using greedy approach (If big - subtract causes smaller difference , + // update small Else update big) + if (big - subtract <= add - small) + small = subtract; + else + big = add; + } + + return Math.min(ans, big - small); + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + int k = 10; + int n = sc.nextInt(); + int[] a = new int[n]; + for (int i = 0; i < n; i++) + a[i] = sc.nextInt(); + + System.out.println("Maximum difference is " + getMinDiff(a, n, k)); + } +} \ No newline at end of file From cc2d804bffe773f1acfefa57f5b8bbef2c4d66c2 Mon Sep 17 00:00:00 2001 From: Aman Soni Date: Thu, 22 Jul 2021 11:40:16 +0530 Subject: [PATCH 50/56] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e0430d4..403c407 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Java-Programs[101/450] +# Java-Programs πŸ’»πŸ¦Έβ€β™‚οΈπŸ±β€πŸ‘€[101/450] - This is a full fledged repository for learning Java Language & DSA for Placement Prepration. - Here, I will upload the solutions of 450 Questions of (DataStructure & Algorithms Cracker Sheet) By LOVE BABBAR Bhaiya. - I have practiced all my codes on Eclipse. You can also practice some beginner problems which are also included in it. From 3189fa0e0c9538676b1acfa648e35c1158d65176 Mon Sep 17 00:00:00 2001 From: Aman Soni Date: Thu, 22 Jul 2021 11:41:06 +0530 Subject: [PATCH 51/56] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 403c407..013ae6a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Java-Programs πŸ’»πŸ¦Έβ€β™‚οΈπŸ±β€πŸ‘€[101/450] +# Java Placement Prepration DSA CRACKER SHEET πŸ’»πŸ¦Έβ€β™‚οΈπŸ±β€πŸ‘€[101/450] - This is a full fledged repository for learning Java Language & DSA for Placement Prepration. - Here, I will upload the solutions of 450 Questions of (DataStructure & Algorithms Cracker Sheet) By LOVE BABBAR Bhaiya. - I have practiced all my codes on Eclipse. You can also practice some beginner problems which are also included in it. From c67a4ac6d1932f0fed5f0b8a4084ebca726e4f08 Mon Sep 17 00:00:00 2001 From: Aman Soni Date: Thu, 22 Jul 2021 11:43:56 +0530 Subject: [PATCH 52/56] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 013ae6a..204876b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Java Placement Prepration DSA CRACKER SHEET πŸ’»πŸ¦Έβ€β™‚οΈπŸ±β€πŸ‘€[101/450] -- This is a full fledged repository for learning Java Language & DSA for Placement Prepration. -- Here, I will upload the solutions of 450 Questions of (DataStructure & Algorithms Cracker Sheet) By LOVE BABBAR Bhaiya. -- I have practiced all my codes on Eclipse. You can also practice some beginner problems which are also included in it. -- Along with 450 questions, I have also include OOP's Concept's Code in this repository. +🐼 This is a full fledged repository for learning Java Language & DSA for Placement Prepration. +πŸ’ͺ Here, I will upload the solutions of _450 Questions of (Data Structure & Algorithms Cracker Sheet)_ By **LOVE BABBAR** Bhaiya. +πŸ‘Š You can also practice some beginner problems which are also included in it. +🎁 Along with 450 questions, I have also include OOP's Concept's Code in this repository. ![logo512](https://user-images.githubusercontent.com/65482419/118401608-f1490e80-b683-11eb-9e58-af14ae9a5cab.png) From 95e5f31ba7636e21ed0c25173e78dd8f19f98d42 Mon Sep 17 00:00:00 2001 From: Aman Soni Date: Thu, 22 Jul 2021 11:45:06 +0530 Subject: [PATCH 53/56] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 204876b..2f6de23 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,10 @@ # Java Placement Prepration DSA CRACKER SHEET πŸ’»πŸ¦Έβ€β™‚οΈπŸ±β€πŸ‘€[101/450] 🐼 This is a full fledged repository for learning Java Language & DSA for Placement Prepration. -πŸ’ͺ Here, I will upload the solutions of _450 Questions of (Data Structure & Algorithms Cracker Sheet)_ By **LOVE BABBAR** Bhaiya. + +πŸ’ͺ Here, I will upload the solutions of **_450 Questions of (Data Structure & Algorithms Cracker Sheet)_** By **LOVE BABBAR** Bhaiya. + πŸ‘Š You can also practice some beginner problems which are also included in it. + 🎁 Along with 450 questions, I have also include OOP's Concept's Code in this repository. ![logo512](https://user-images.githubusercontent.com/65482419/118401608-f1490e80-b683-11eb-9e58-af14ae9a5cab.png) From 45dfa5fe5282e099a4e7633d3ebea1839e3dafc3 Mon Sep 17 00:00:00 2001 From: Aman Soni Date: Thu, 22 Jul 2021 11:46:05 +0530 Subject: [PATCH 54/56] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2f6de23..7477ced 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Java Placement Prepration DSA CRACKER SHEET πŸ’»πŸ¦Έβ€β™‚οΈπŸ±β€πŸ‘€[101/450] 🐼 This is a full fledged repository for learning Java Language & DSA for Placement Prepration. -πŸ’ͺ Here, I will upload the solutions of **_450 Questions of (Data Structure & Algorithms Cracker Sheet)_** By **LOVE BABBAR** Bhaiya. +πŸ’ͺ Here you can find will the solutions of **_450 Questions of (Data Structure & Algorithms Cracker Sheet)_** By **LOVE BABBAR** Bhaiya in proper format. πŸ‘Š You can also practice some beginner problems which are also included in it. From 1df4b48439c3f869322a606979e0658dacc8051b Mon Sep 17 00:00:00 2001 From: Aman Soni Date: Thu, 22 Jul 2021 11:46:24 +0530 Subject: [PATCH 55/56] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7477ced..a1e9e30 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Java Placement Prepration DSA CRACKER SHEET πŸ’»πŸ¦Έβ€β™‚οΈπŸ±β€πŸ‘€[101/450] 🐼 This is a full fledged repository for learning Java Language & DSA for Placement Prepration. -πŸ’ͺ Here you can find will the solutions of **_450 Questions of (Data Structure & Algorithms Cracker Sheet)_** By **LOVE BABBAR** Bhaiya in proper format. +πŸ’ͺ Here you can find will the solutions of **_450 Questions of (Data Structure & Algorithms Cracker Sheet)_** By **LOVE BABBAR** Bhaiya. πŸ‘Š You can also practice some beginner problems which are also included in it. From 6ca04b91de90e2f2bc90dd4a80e19ad043065f12 Mon Sep 17 00:00:00 2001 From: Aman Soni Date: Thu, 22 Jul 2021 11:49:26 +0530 Subject: [PATCH 56/56] Update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 38 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/custom.md | 10 ++++++ .github/ISSUE_TEMPLATE/feature_request.md | 20 ++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/custom.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..dd84ea7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,38 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/custom.md b/.github/ISSUE_TEMPLATE/custom.md new file mode 100644 index 0000000..48d5f81 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/custom.md @@ -0,0 +1,10 @@ +--- +name: Custom issue template +about: Describe this issue template's purpose here. +title: '' +labels: '' +assignees: '' + +--- + + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..bbcbbe7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here.