Advertisement
silentkiler029

ArrayManipulation-FrequencyOfElements

Sep 6th, 2020
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.84 KB | None | 0 0
  1. //              ******    Array Manipulation     ******
  2.  
  3.  
  4. #include <stdio.h>
  5.  
  6. int main()
  7. {
  8.     //int count[]={1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  9.  
  10.     int chngIdx[14+1]
  11.               = {0, 2, 4, 7, 9, 10, 11, 14, -1, -1, -1, -1, -1};
  12.     int ara[14] = {1, 1, 2, 2, 3, 3, 3, 4, 4, 5, 7, 15, 15, 15};
  13.  
  14.     int idx[6+1] = {0, 1, 2, 3, 4, 5, 6};
  15.     int new[6]   = {1, 2, 3, 4, 5, 6};
  16.  
  17.     /*  output ::
  18.         1  -> 2
  19.         2  -> 2
  20.         3  -> 3
  21.         4  -> 2
  22.         5  -> 1
  23.         7  -> 1
  24.         15 -> 1
  25.     */
  26.  
  27.     int ara[] = {1, 2, 0, 3, 4, 1, 0, 2, 3, 4, 5, 3, 7, 15};
  28.  
  29.     //Frequency of each element.
  30.  
  31.     /*
  32.             BIJON -> sort and count.
  33.  
  34.             MOJU  -> use count array and increase corresponding index by 1.
  35.  
  36.             MEEM  -> Cumulative Summation
  37.     */
  38.  
  39.  
  40.     return 0;
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement