Skip to content

Two Dimensional Arrays - Mapping - Searching (all techniques) - Sorting (all techniques) - Hashing

Notifications You must be signed in to change notification settings

Himanshutiwari15/DataStructures

Repository files navigation

Two Dimensional Arrays - Mapping - Searching (all techniques) - Sorting (all techniques) - Hashing

2D Arrays Included

  1. Diagonal matrix
  2. Lower triangular Matrix
  3. Upper triangular Matrix
  4. Symmetric Matrix
  5. Tridiagonal Matrix

2D-Array Mapping

The Code File is basically written in C++ and consists of code to map the content of 2D array into 1D array.

What is a 2D Array

Two dimensional array is an array within an array. It is an array of arrays. In this type of array the position of an data element is referred by two indices instead of one.

Difference B/W Array and Matrix

Arrays have only one dimension, a row of elements while a matrix has more dimensions, mostly 2 but can have more than that, and its elements are either column or row arrays which are here called vectors for a matrix with two dimensions or matrices with dimension n-1 for a matrix of n dimensions.

Searching Techniques

Searching involves deciding whether a search key is present in the data. For example, looking up a phone book or address book. The searching algorithm includes:

Linear Search

The worst-case and average-case time complexity is O(n). The best-case is O(1).

Binary Search for sorted list

The worst-case and average-case time complexity for binary search is O(log n). The best-case is O(1).

Sorting Techniques

Sorting involves arranging data in ascending or descending order, according to a certain collating sequence (or sorting sequence). The sorting algorithm includes:

Insertion Sort

The average-case and worst-case time complexity is O(n2).

Selection Sort

The average-case and worst-case time complexity is O(n2).

Bubble Sort

The average-case and worst-case time complexity is O(n2).

Merge Sort

The worst-case and average-case time complexity is O(n log n). The best-case is typically O(n log n). However, merge sort requires a space complexity of O(n) for carrying out the merge-sorting.

Quick Sort

The worst-case time complexity is O(n2). The average-case (typical) and best-case is O(n log n). In-place sorting can be achieved without additional space requirement.

Heap Sort

Will Continue Adding. Himanshu Tiwari