# One Dimensional Array - 114

## Problem Set 7.1: Array (One Dimensional Array)

Write a C program that declares a one-dimensional integer array size of one hundred (100) and initializes the array with ten (10) values. Then write a program that does the following operations. \[Write each program in a different file.] (Solve all the problems in three different ways 1. basic array inside main function, 2. function, and 3. pointer and function) \[Write each program in a different file. The file name will be the problem number]

1. Declaration
   1. Declare an Array
2. Initialization
   1. Initialize Full Array
   2. Initialize Partial Array
   3. Initialize without specifying the Array Size
   4. Initialize using Loop (Assign Element(s)/Item(s)/Value(s) to Array)
   5. Initialize from user input
      1. User Input to Array with N number of elements. (Where N is a predefined number)
      2. User Input to Array using size (Number of Element(s) to Insert) (Overflow, Invalid Size)
      3. User Input to Array until End of File (Overflow)
   6. Declare One-Dimensional Array using Dynamic Memory Allocation
      1. Allocate Memory using calloc() \[why not malloc]
         * Deallocate Memory using free()
      2. Reallocate Memory using realloc()
3. Function
   1. Pass an Array to a Function (Pass by Reference)
   2. Return an Array from a Function (Dangling Pointer, Pass By Reference)
4. Printing Elements and Address
   1. Print the entire array. (Each element should be separated by space.)
   2. Print the entire array using the recursive function. (Each element should be separated by space.)
   3. Print the array elements in reverse order. (Each element should be separated by space)
   4. Print the array elements in reverse order using a recursive function. (Each element should be separated by space.)
   5. Print the array elements in a given range. (Take user input of start index and end index)
   6. Print the Address of each Array Index. (Sequential Storage)
   7. Print only the odd elements in an Array.
   8. Print only the even elements in an Array.
5. Searching Element
   1. Print the First Element from the Array.
   2. Print the Last Element from the Array.
   3. Print the Middle Element (Median) from the Array.
   4. Linear Search
      1. Search a value X (take input X from the user) in the array and print "Element Found" if X is found in the array otherwise print "Element Not Found".
      2. Search a value X (take input X from the user) in the array and print the index if X is found in the array otherwise print -1.
   5. Binary Search
      1. Search a value X (take input X from the user) in the array and print "Element Found" if X is found in the array otherwise print "Element Not Found".
      2. Search a value X (take input X from the user) in the array and print the index if X is found in the array otherwise print -1.
      3. Search a value X (take input X from the user) using the bsearch() library function. \[Library: stdlib.h]
   6. Find the Maximum value from the Array.
   7. Find the Minimum value from the Array.
   8. Find the Second Maximum value from the Array.
   9. Find the Second Minimum value from the Array.
   10. Find the Nth Maximum value from the Array.
   11. Find the Nth Minimum value from the Array.
6. Update (Valid Index for Update (Index = 0 to Array\_Current\_Size-1))
   1. Update by Index
      1. Update the value of an Index
      2. Update value before an Index
      3. Update value after an Index
      4. Update value at the Beginning (Update at Index 0)
      5. Update value at the End (Update at Index of Array\_Current\_Size-1)
   2. Update By Element (Value)
      1. Update For Single instance of an Element
         1. Update an Element
         2. Update value before an Element
         3. Update value after an Element
      2. Update For Multiple instances of an Element
         1. Update first/last/all Element
         2. Update value before/after the first Element
         3. Update value before/after the last Element
         4. Update value before/after all Elements
   3. Swap two elements of an Array when two valid indexes are given.
7. Delete (Valid Index for Deletion (Index = 0 to Array\_Current\_Size-1), Array Underflow (Deleting from an Empty Array))
   1. Delete by Index
      1. Delete the value of an Index
      2. Delete value before an Index
      3. Delete value after an Index
      4. Delete value at the Beginning (Delete value of Index 0)
      5. Delete value at the End (Insert at Index of Array\_Current\_Size-1)
   2. Delete by Element (Value)
      1. Delete For Single instance of an Element
         1. Delete an Element
            * Delete a value X (take input X from the user) from the array and shift all other values to the left. If X is not present in the given array print “Element Not Found”. Only delete the first occurrence of the value.
         2. Delete value before an Element
         3. Delete value after an Element
      2. For Multiple instances of an Element
         1. Delete first/last/all Element
         2. Delete value before/after the first Element
         3. Delete value before/after the last Element
         4. Delete value before/after all Elements
   3. Delete All the Elements (Clear)
8. Insertion (Valid Index for Insertion (Index = 0 to Array\_Current\_Size), Array Overflow (Insert into a Full Array))
   1. Insert by Index
      1. Insert value at an Index
         * Insert a value X (take input X from the user) in the array at Kth (take input K from the user) index and shift all other values to the right.
      2. Insert value before an Index
      3. Insert value after an Index
      4. Insert value at the Beginning (Insert at Index 0)
      5. Insert value at the End (Insert at Index of Array\_Current\_Size)
   2. Insert By Element (Value)
      1. Insert For Single instance of an Element
         1. Insert value before an Element
         2. Insert value after an Element
      2. Insert For Multiple instances of an Element
         1. Insert value before/after the first Element
         2. Insert value before/after the last Element
         3. Insert value before/after all Elements
   3. Insert an element in a sorted Array thus the Array remains sorted after insertion.
9. Sorting (Ascending Order, Descending Order)
   1. Sort an Array of elements using Selection Sort.
   2. Sort an Array of elements using Insertion Sort.
   3. Sort an Array of elements using Bubble Sort.
   4. Sort an Array of elements using Merge Sort.
   5. Sort an Array of elements using Quick Sort.
   6. Sort an Array of elements using Heap Sort.
   7. Sort an Array of elements using Shell Sort.
   8. Sort an Array of elements using Counting Sort.
   9. Sort an Array of elements using Radix Sort.
   10. Sort an Array of elements using Bucket Sort.
10. Array Operation
    1. Test whether a given array is sorted (ascending order, or descending order) or not.
    2. Copy a given array to another array. (Print both arrays before and after this operation.)
    3. Reverse a given array to another array. (Print both arrays before and after this operation.)
    4. Reverse a given array within the same array. (Print the whole array before and after this operation.)
    5. Merge the Elements of Two Arrays into an Array. (Print the initial and merged array before and after this operation.)
    6. Merge the Elements of Two Sorted Arrays, the final array must be sorted. (Print the initial and merged array before and after this operation.)
    7. Split an Array into two Arrays.  (Print the initial and split array before and after this operation.)
    8. Cyclically permute the elements of an array. (Print the initial array and result array after this operation.)
    9. Compare two Arrays to test whether they are the same or not. (Print both arrays before this operation.) (Consider both arrays are sorted.)
    10. Test whether any duplicate element is in an Array.
        * Test whether all the elements of an Array are unique or not.
    11. Remove Duplicate Elements from an Array.
        * Print all unique elements in an Array.
    12. Separate odd and even integers in separate arrays.
11. Statistical Operation
    1. Calculate the Summation for all array elements.
    2. Calculate the Average (Mean) for all array elements.
    3. Find the Frequency of each unique element in an Array.
    4. Calculate the Mode for all array elements.
    5. Calculate the Variance for all array elements.
    6. Calculate the Standard Deviation for all array elements.
    7. Calculate the Covariance of two array elements.
    8. Calculate the Correlation of two array elements.
