Posts

Showing posts from July, 2018

TO PRINT PATTERN TYPE 11

* ** *** **** *** ** * class Pattern11 { public static void main(String[] args) {  int k=0; for(int i=1;i<=7;i++) {  if(i<=4) k++; else k--; for(int j=1;j<=7;j++) {  if(j<=k) { System.out.print("*"); }     else System.out.print(" "); } System.out.println(); } } }

TO PRINT PATTERN TYPE 10

        *       ***     *****   *******     *****       ***         * class Pattern10 { public static void main(String[] args) {  int k=0; for(int i=1;i<=7;i++) {  if(i<=4) k++; else k--; for(int j=1;j<=7;j++) {  if(j>=5-k && j<=3+k) { System.out.print("*"); }     else System.out.print(" "); } System.out.println(); } } }

PROGRAM TO IMPLEMENT FIBONACCI SERIES WITH THE HELP OF TABULATION

import java.util.Scanner; class Tabulation { public static void main(String[] args) {   Scanner s=new Scanner(System.in); int n=s.nextInt(); fib(n);      }     static void fib(int n) { int f[]=new int[n+1]; f[1]=1;f[0]=0; for(int i=2;i<=n;i++) { f[i]=f[i-1]+f[i-2]; } for(int i=0;i<=n;i++) { System.out.println(f[i]); } } }

TO PRINT PATTERN TYPE 27

           1           212         32123      4321234 class Pattern27 { public static void main(String[] args) {        for(int i=1;i<=4;i++)       {     int k=i;       for(int j=1;j<=7;j++)       {       if(j>=5-i&&j<=3+i)       {   if(j<4)                      System.out.print(k--);                      else                      System.out.print(k++);       }       else       {       System.out.print(" ");       }       }       System.out.println();       } } }

TO PRINT PATTERN TYPE 26

 A   BA   CBA  DCBA class Pattern26 { public static void main(String[] args) {          for(int i=1;i<=4;i++)       {     char x=(char)(64+i);       for(int j=1;j<=4;j++)       {       if(j<=i)        {                         System.out.print(x--);        }       else       {       System.out.print(" ");       }       }       System.out.println();       } } }

TO PRINT PATTERN TYPE 23

1    10    101  1010  10101 101010 class Pattern23 { public static void main(String[] args) {        for(int i=1;i<=6;i++)       {        for(int j=1;j<=6;j++)       {       if(j<=i)       {  if(j%2==0)                      System.out.print("0");                      else                      System.out.print("1");       }       else       {       System.out.print(" ");       }       }       System.out.println();       } } }

TO PRINT PATTERN TYPE 22

             1             12A           123AB        1234ABC class Pattern22 { public static void main(String[] args) {          for(int i=1;i<=4;i++)       {    int x=1;             char y='A';       for(int j=1;j<=7;j++)       {       if(j>=5-i && j<=3+i)       {  if(j<=4)                         {                           System.out.print(x);                           x++;                         }                        else                        {                         System.out.print(y);                         y++;                        }       }       else       {       System.out.print(" ");       }       }       System.out.println();       } } }

TO PRINT PATTERN TYPE 21

   ****   ****  ****  **** class Pattern21 { public static void main(String[] args) {        for(int i=1;i<=4;i++)       {        for(int j=1;j<=7;j++)       {       if(j>=5-i && j<=8-i)       {              System.out.print("*");       }       else       {       System.out.print(" ");       }       }       System.out.println();       } } }

TO PRINT PATTERN TYPE 20

            A1           AB12        ABC123    ABCD1234 class Pattern20 { public static void main(String[] args) {        for(int i=1;i<=4;i++)       {  char x='A';             int k=1;       for(int j=1;j<=8;j++)       {       if(j>=5-i && j<=4+i)       {             if(j<=4)             {              System.out.print(x);              x++;             }              else              {                  System.out.print(k);                  k++;              }       }       else       {       System.out.print(" ");       }       }       System.out.println();       } } }

TO PRINT PATTERN TYPE 19

                        A                       ABA                    ABCBA                ABCDCBA  class Pattern19 { public static void main(String[] args) {          for(int i=1;i<=4;i++)       {           char x='A';         for(int j=1;j<=7;j++)       {       if(j>=5-i &&j<=3+i)       {                          System.out.print(x);                        if(j<4)                         x++;                   else                         x--;       }       else       {       System.out.print(" ");                                }       }       System.out.println();       } } }

TO PRINT PATTERN TYPE 18

* * * * * * * * *    * * * * * * *       * * * * *           * * *              * class Pattern18 { public static void main(String[] args) {        for(int i=1;i<=5;i++)       {        for(int j=1;j<=9;j++)       {       if(j>=i && j<=10-i)       {              System.out.print("*");       }       else       {       System.out.print(" ");       }       }       System.out.println();       } } }

TO PRINT PATTERN TYPE 17

********* ****  **** ***      *** **          ** *              * **          ** ***      *** ****  **** ********* class Pattern17 { public static void main(String[] args) {   int k=0;       for(int i=1;i<=9;i++)       {          if(i<=5)           k++;         else           k--;       for(int j=1;j<=9;j++)       {       if(j<=6-k || (j>=4+k && j<=9))       {              System.out.print("*");       }       else       {       System.out.print(" ");       }       }       System.out.println();       } } }

TO PRINT PATTERN TYPE 16

                        \ * * * * * /                         * \ * * * / *                         * * \ * / * *                         * * * \ * * *                         * * / * \ * *                         * / * * * \ *                         / * * * * * \ class Pattern16 { public static void main(String[] args) {       for(int i=1;i<=7;i++)       {       for(int j=1;j<=7;j++)       {       if(j==i || j==8-i)       {                         if(j==i)                  System.out.print("\\");              else                   System.out.print("/");       }       else       {       System.out.print("*");       }       }       System.out.println();       } } }

TO PRINT PATTERN TYPE 15

                                  1                               1  2                           1  2  3                       1  2  3  4                   1  2  3  4  5                       1  2  3  4                           1  2  3                               1  2                                   1 class Pattern15 { public static void main(String[] args) {  int k=0,x;       for(int i=1;i<=9;i++)       {  if(i<=5)          k++;          else             k--;          x=1;       for(int j=1;j<=5;j++)       {       if(j>=6-k)       {                System.out.print(x);                x++;                             }                       else       {       System.out.print(" ");                                }       }       System.out.println();       } } }

TO PRINT PATTERN TYPE 14

6543210 543210 43210  3210  210    10    0        class Pattern14 { public static void main(String[] args) {        for(int i=1;i<=7;i++)       {   int k=7-i;       for(int j=1;j<=7;j++)       {       if(j>=1 && j<=8-i)       {                      System.out.print(k);                      k--;                   }                       else       {       System.out.print(" ");                                }       }       System.out.println();       } } }

TO PRINT PATTERN TYPE 13

                                     1                                   2  3  2                              3   4  5  4  3                         4  5   6  7  6  5  4 class Pattern13 { public static void main(String[] args) {       for(int i=1;i<=4;i++)       {   int k=i;       for(int j=1;j<=7;j++)       {       if(j>=5-i && j<=3+i )       {                      System.out.print(k);                                               if(j<4)                         {                               k++;                         }                         else                                k--;                                            }                       else       {       System.out.print(" ");                                }       }       System.out.println();       } } }

TO PRINT PATTERN TYPE 12

                                    * * * * * * *                                        * * * * *                                            * * *                                              * class Pattern12 { public static void main(String[] args) {       for(int i=1;i<=4;i++)       {       for(int j=1;j<=7;j++)       {       if(j>=i && j<=8-i )       {                      System.out.print("*");                         }       else       {       System.out.print(" ");                               }       }       System.out.println();       } } }                                                         

TO PRINT PATTERN TYPE 9

                           A B C D C B A                            A B C     C B A                     A B         B A                     A                A      class Pattern9 { public static void main(String[] args) {       for(int i=1;i<=4;i++)       {    char k='A';       for(int j=1;j<=7;j++)       {       if(j<=5-i || j>=3+i)       {                      System.out.print(k);                      if(j<4)                         k++;                   else                         k--;       }       else       {       System.out.print(" ");                         if(j==4)                               k--;       }       }       System.out.println();       } } }

TO PRINT PATTERN TYPE 8

         1        1 2 1     1 2 3 2 1 1 2 3 4 3 2 1  class Pattern8 { public static void main(String[] args) {       for(int i=1;i<=4;i++)       {   int k=1;       for(int j=1;j<=7;j++)       {       if(j>=5-i && j<=3+i)       {                  System.out.print(k);                  if(j<4)                   k++;                  else                   k--;       }       else       {       System.out.print(" ");       }       }       System.out.println();       } } }

TO PRINT PYRAMID TYPE 2

         *        *  *      *  *  *    *  *  *  *  *  *  *  *  * class Pattern6 { public static void main(String[] args) { boolean k; for(int i=1;i<=5;i++) {    k=true ; for(int j=1;j<=9;j++)             {             if(j>=6-i && j <= 4+i && k){ System.out.print("*"); k=false;}     else{ System.out.print(" "); k=true;} } System.out.println(); } } }

TO PRINT PYRAMID TYPE 1

         *        ***      *****    *******  *********      class Pattern5 { public static void main(String[] args) { for(int i=1;i<=5;i++) { for(int j=1;j<=9;j++) {  if(j>=6-i && j<=4+i) System.out.print("*");     else System.out.print(" "); } System.out.println(); } } }

TO PRINT PATTERN TYPE 4

***** **** *** ** * class Pattern4 { public static void main(String[] args) { for(int i=1;i<=5;i++) { for(int j=1;j<=5;j++) {  if(j<=6-i) System.out.print("*");     else System.out.print(" "); } System.out.println(); } } }

TO PRINT PATTERN TYPE 3

 *****    ****      ***        **          class Pattern3 { public static void main(String[] args) { for(int i=1;i<5;i++) { for(int j=1;j<=5;j++) {  if(j>=i) System.out.print("*");     else System.out.print(" "); } System.out.println(); } } }

TO PRINT PATTERN TYPE 2 IN JAVA

           *          **        ***      ****    ***** class Pattern2 { public static void main(String[] args) { for(int i=1;i<=5;i++) { for(int j=1;j<=5;j++) {  if(j>=6-i) System.out.print("*");     else System.out.print(" "); } System.out.println(); } } }

TO PRINT PATTERN1

                                                      *                                                       **                                                       ***                                                       ****                                                       ***** class Pattern1 { public static void main(String[] args) { for(int i=0;i<5;i++) { for(int j=0;j<=i;j++) { System.out.print("*"); } System.out.println(); } } }     

SUM OF TWO DIMENSIONAL ARRAY OF ELEMENTS

import java.util.Scanner; class SumofTwoDArray { public static void main(String[] args) { Scanner s=new Scanner(System.in); System.out.println("Enter  row and columns of Array"); int x=s.nextInt(); int y=s.nextInt(); int[][] arr=new int[x][y]; for(int i=0;i<x;i++) { for(int j=0;j<y;j++) { arr[i][j]=s.nextInt();     } } int sum=0; for(int i=0;i<x;i++) { for(int j=0;j<y;j++) { sum=sum+arr[i][j]; } } System.out.println("Sum of Array:"+sum); } }

AVERAGE OF ARRAY ELEMENT WITH THE HELP OF JAVA

import java.util.Scanner; class AverageofArray { public static void main(String[] args) { Scanner s=new Scanner(System.in); System.out.println("enter size of Array"); int n=s.nextInt(); int[] arr=new int[n]; for(int i=0;i<n;i++) { arr[i]=s.nextInt(); } AverageofArray(arr,n); } public static void AverageofArray(int[] a,int size) {   double sum=0; double Avg;        for(int i=0;i<size;i++)        {         sum=sum+a[i];        }       Avg=(sum/size);       System.out.println("Average of Array:"+Avg+"  "+sum); } }

REAL ESTATE ANALYSIS WITH HIVE

Image
Hive Use Case – Real Estate Data Analysis Due to an industry, real estate activity is outlined as any economic dealings associated with the acquisition, sale, owner-operation or lease of property. This in addition includes income-generating residential properties, like flat, buildings and single-room rentals. Real estate services are not enclosed within the sector. Also, samples of real estate services embrace brokerages, property management, appraisers, investment property analysts and different consultants. All analysts, working with Big Data are using Hive or some other tool to query dataset and get results with ease. Although other querying languages exists, Hive gives us a variety of new features when compared to traditional approaches. So,On demand of accelerating consumers in real estate field, filtered series of information was collected and handed over to data analyst team.                                               SOLUTION OF REAL ESTATE USE CASE creat

Find the largest sum contiguous subarray.

Given an array of positive and negative integer s, find a contiguous subarray whose sum (sum of elements) is maximized. · Maximum subarray in an array is found in a single scan. We keep track of global maximum sum so far and the maximum sum, which include the current element. · When we find global maximum value so far is less than the maximum value containing current value we update the global maximum value. · Finally return the global maximum value.Concept of Stack A stack is a memory in which values are stored and retrieved in “last in firs import java.util.*; class SumOfArray { public static void main(String[] args) { Scanner s=new Scanner(System.in); System.out.println("enter size of Array"); int a=s.nextInt(); int[] arr=new int[a]; System.out.println("enter element of Array"); for(int i=0;i<a;i++) {                 arr[i]=s.nextInt(); }         System.out.println("Max sub Array sum:"+SumArray(arr,a))

IMPLEMENT ROTATING AN ARRAY BY K POSITIONS IN JAVA

How to find rotating an Array by K positions. 1.   Rotating array is done in two parts trick. In the first part, we first reverse elements of array first half and then second half. 2.    Then we reverse the whole array there by completing the whole rotation.  import java.util.Scanner; class ArrayRotation { public static void main(String[] args) { Scanner s= new Scanner(System.in); int n=s.nextInt(); int arr[] =new int[n]; for(int i=0;i<n;i++) { arr[i]=s.nextInt(); } System.out.println("enter positions to rotate"); int p=s.nextInt();         ArrayRotate(arr,n,p);         for(int i=0;i<n;i++)         {         System.out.println(arr[i]);         }       } public static void ArrayRotate(int[] a,int n,int k ) {         reverseArray(a,0,k-1);         reverseArray(a,k,n-1);               reverseArray(a,0,n-1);       } public static void reverseArray(int[] a, int start,int end) { for(int i=start,j=end;i<

IMPLEMENT PROGRAM OF BINARY SEARCH DATA STRUCTURE IN JAVA

import java.util.Scanner; class BinarySearch { public static void main(String[] args) { Scanner s= new Scanner(System.in); int n=s.nextInt(); int arr[] =new int[n]; for(int i=0;i<n;i++) { arr[i]=s.nextInt(); } System.out.println("enter value which is find"); int value=s.nextInt(); System.out.println(BinarySearch(arr,n,value)); } static int BinarySearch(int a[],int size,int value) { int mid; int low=0; int high=size-1; while(low<=high) { mid=low+(high-low)/2; if(a[mid]==value) { return mid; } else if(a[mid]<value) low=mid+1;              else               high=mid-1; } return -1; } }