Monday, 13 May 2019

Understand Arrays & Matrix

Array

Array in C# MSDN
Arrays -Geeks
Array - HackerEarth

Let size of array be n.
Accessing Time: O(1) [This is possible because elements
                      are stored at contiguous locations]   
Search Time:   O(n) for Sequential Search: 
               O(log n) for Binary Search [If Array is sorted]
Insertion Time: O(n) [The worst case occurs when insertion 
                     happens at the Beginning of an array and 
                     requires shifting all of the elements]
Deletion Time: O(n) [The worst case occurs when deletion 
                     happens at the Beginning of an array and 
                     requires shifting all of the elements]
Notes

Problem 1. To change row to column and vica versa.
  Original Array = arr[N,M];
1. Take another array with changed dimension - arr2[M,N];
2. store all elements of original array to new array as per dimensions - means columns of original array to rows  and rows to columns of new array.
3. Print the output as per new dimension lengths.

No comments:

Post a Comment