Posts

Design a way to sort the list of positive integers in the descending order according to frequency of elements. The elements with integers with higher frequency come before with lower frequency elements with same frequency come in the same order as they appear the values.

Image
          Consider the following I/O samples. SAMPLE INPUT:       6                                            2 2 4 9 9 9 SAMPLE OUTPUT:     9 9 9 2 2 4   C PROGRAM:    #include <stdio.h> #include<limits.h> #include<malloc.h> int * frequencySortArray( int *arr,int size) {      int** occurence = NULL;      int maxpos, count = 0, count_flag, o_row, index,max;      int newindex = 0, num, ctr;      occurence = (int**)calloc(1,sizeof(int*));      occurence[0] = (int*)calloc(2,sizeof(int));      occurence[0][0] = arr[0];      occurence[0][1]++;      count++;      for(index = 1 ; index < size ; index++)      {   ...

HOLLOW INVERTED PYRAMID STAR

Image
Consider the following I/O samples. SAMPLE INPUT:   3 SAMPLE OUTPUT:      * * * * *                                               *     *                                                  *          C PROGRAM:    #include <stdio.h> int main() {     int row,col,spc,n;     scanf("%d",&n);     for(row=n; row>=1; --row)     {         for(spc=n; spc>row; spc--)         {             printf("  ");         }         for(col=1; col<2*row; col++)     ...

HOLLOW PYRAMID STAR PATTERN

Image
Consider the following I/O samples. SAMPLE INPUT:   3 SAMPLE OUTPUT:                      *                                           *     *                                         *         *                                       *             *                                     * * * * * * * * *           C PROGRAM:    #include <stdio.h> int main() {     int row,col,spc,n;   ...

HOLLOW SQUARE PATTERN

Image
     Consider the following I/O samples. SAMPLE INPUT:  4 SAMPLE OUTPUT:                                               * * * *                                                       *         *                                                                                 *       *                         ...

INVERTED PYRAMID STAR PATTERN

Image
Consider the following I/O samples. SAMPLE INPUT:   3 SAMPLE OUTPUT:                                                         * * *                                              *   *                                                 *                                                                                 ...

PYRAMID STAR PATTERN

Image
Consider the following I/O samples. SAMPLE INPUT:   3 SAMPLE OUTPUT:                                                 *                                                        * *                                                  * * *              C PROGRAM:    #include <stdio.h> int main() {     int row,col,spc,n;     scanf("%d",&n);     for(row=1; row<=n; ++row)     {         for(spc=1; spc<=n-row; spc+...

SQUARE STAR PATTERN

Image
Consider the following I/O samples. SAMPLE INPUT:   3 SAMPLE OUTPUT:                                                                                         * * *                                                                            * * *                                                               ...