Attempt to understand the basics of Algorithms after 16yrs when last studied at college.
Note: There are specific questions folder which are based on one or the other concepts.
-
Finding Pairs: For a given array with 'n' values, find if a pair exists with exact sum equal to 'x'.
Input: List of Array
A(n)& Exact Sum ValuexOutput:
trueif pair exists /falseif pair doesn't exists.i. Tag: Sorting
ii. Compelxity: O(nlogn) - if using merge sort.
-
Inversion: For a given array with
A(n)values, find the total number of pairs where for indexi < jfind values whereA[i] > A[j]Input: List of Array
A(n)Output: Count of number of pairs
i. Tag: Merge Sort
ii. Complexity: O(nlogn)
Trick: Check each time the
rightis swapped withleftor therightstack is done andleftstack has values remaining. -
Multiplying String Numbers: Give two large enough numbers in string representation, give multiplcation output.
Input: Two strings with only digits in it. Output: String representation of the multiplication.
Trick: Number of length
m&n, results in number with lengthm+n. Use Array of lengthm+n. O(n^2)` complexity
-
Insertion Sort: Remember using the cards in hand.
i. Insertion Sort Descending
ii. Insertion Sort using Merge Sort like principle of recursion or Inserting
A(n)value can be done by recursively doing it forA(n-1). -
Selection Sort: Traversing over twice, swapping outer value with least of inner values.
-
Merge Sort: Using Divide and Conquire where then each element is compared with neighbour. Then merged back in sorted order.
-
Bubble Sort: Even though it is useless just keeping it around to be aware of it.
- Binary Search : Same as Merge Sort of Divide and Conqure.