/* * Name: Abir Ahammed Bhuiyan * ID: 20101197 * Section: 06 */ public class Assignment1{ public static void main(String args[]){ /* ####################### #### Linear Arrays #### ####################### */ //1. Shift Left k Cells int source1[] = {10, 20, 30, 40, 50, 60}; shiftLeft(source1, 3); printArray(source1); //2. Rotate Left k Cells int source2[] = {10, 20, 30, 40, 50, 60}; rotateLeft(source2, 3); printArray(source2); //3. Remove an element from an array int source3[] = {10, 20, 30, 40, 50, 0, 0}; remove(source3, 5, 2); printArray(source3); //4. Remove all occurrences of a particular element from an array int source4[] = {10, 2, 30, 2, 50, 2, 2, 0, 0}; removeAll(source4, 7, 2); printArray(source4); //5. Splitting an Array int source5[] = {1, 1, 1, 2, 1}; //int source5[] = {2, 1, 1, 2, 1}; //int source5[] = {10, 3, 1, 2, 10}; System.out.println(SplitArray(source5)); //6. Array series //printArray(ArraySeries(2)); //printArray(ArraySeries(3)); printArray(ArraySeries(4)); //7. Max Bunch Count int source7[] = {1, 2, 2, 3, 4, 4, 4}; //int source7[] = {1, 1, 2, 2, 1, 1, 1, 1}; System.out.println(MaxBunchCount(source7)); //8. Repetition int source8[] = {4, 5, 6, 6, 4, 3, 6, 4}; //int source8[] = {3, 4, 6, 3, 4, 7, 4, 6, 8, 6, 6}; System.out.println(Repetition(source8)); /* ######################### #### Circular Arrays #### ######################### */ //1. Palindrome int source9[] = {20, 10, 0, 0, 0, 10, 20, 30}; System.out.println(Palindrom(source9, 5, 5)); //int source9[] = {10, 20, 0, 0, 0, 10, 20, 30}; //System.out.println(Palindrom(source9, 5, 5)); //2. Intersection int c_arr1[] = {40, 50, 0, 0, 0, 10, 20, 30}; int c_arr2[] = {10, 20, 5, 0, 0, 0, 0, 0, 5, 40, 15, 25}; printArray(Intersection(c_arr1, c_arr2, 5, 7, 5, 8)); //3. The Musical Chair Game char participants[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G'}; mcg_Game(participants); } public static void printArray(int arr[]){ System.out.print("["); for(int i=0; isource.length || k<0){ System.out.println("Invalid 'k'"); }else{ while(k>0){ for(int i=0; i0){ int temp = arr[0]; for(int i=0; i=size){ System.out.println("Invalid index deletion incomplete"); }else{ for(int i=index; i=i*n+jog; j--){ arr[j] = val++; } } return arr; } public static int MaxBunchCount(int arr[]){ int max = 0; int count = 1; for(int i=1; i=arr2_size ? arr1_size : arr2_size]; int k = 0; for(int i=0; i0; i--){ arr[i] = arr[i-1]; } arr[0] = temp; } //utility function of mcg_Game for removing the middle element from an array public static char[] mid_remove(char[] arr){ char done_arr[] = new char[arr.length-1]; int done_arr_i = 0; for(int i=0; i