# Category Archives: Algorithm

## Merge Sort

Algorithm Video:

https://youtu.be/TzeBrDU-JaY

Merge Sort Combines Two Sorted file in a large bigger sorted files:
This Merge sort happens in a two steps:

This sorting is a example of divide and conquer approach:
1. Selection: Splits a list into two lists (This process is recursive approach)
2. Merging: It joins two list in a one list (It follows the pesudocode in itertive manner)

Pseudocode:

Implementation:
code with extra malloc declaration:

code by me without  extra malloc:

output:

Analysis of Running Time Complexity:
https://youtu.be/0nlPxaC2lTw
Worst case, Best case, Avergae case: Theta(nlogn)
Space Complexity: Theta(n)

This link can help to solve problems:
https://gist.github.com/mycodeschool/9678029
https://www.hackerearth.com/practice/algorithms/sorting/merge-sort/tutorial/

http://www.sanfoundry.com/cpp-program-implement-merge-sort/

## Merge Sort

Algorithm Video:

https://youtu.be/TzeBrDU-JaY

Merge Sort Combines Two Sorted file in a large bigger sorted files:
This Merge sort happens in a two steps:

This sorting is a example of divide and conquer approach:
1. Selection: Splits a list into two lists (This process is recursive approach)
2. Merging: It joins two list in a one list (It follows the pesudocode in itertive manner)

Pseudocode:

Implementation:
code with extra malloc declaration:

code by me without  extra malloc:

output:

Analysis of Running Time Complexity:
https://youtu.be/0nlPxaC2lTw
Worst case, Best case, Avergae case: Theta(nlogn)
Space Complexity: Theta(n)

This link can help to solve problems:
https://gist.github.com/mycodeschool/9678029
https://www.hackerearth.com/practice/algorithms/sorting/merge-sort/tutorial/

http://www.sanfoundry.com/cpp-program-implement-merge-sort/

## Merge Sort

Algorithm Video:

https://youtu.be/TzeBrDU-JaY

Merge Sort Combines Two Sorted file in a large bigger sorted files:
This Merge sort happens in a two steps:

This sorting is a example of divide and conquer approach:
1. Selection: Splits a list into two lists (This process is recursive approach)
2. Merging: It joins two list in a one list (It follows the pesudocode in itertive manner)

Pseudocode:

Implementation:
code with extra malloc declaration:

code by me without  extra malloc:

output:

Analysis of Running Time Complexity:
https://youtu.be/0nlPxaC2lTw
Worst case, Best case, Avergae case: Theta(nlogn)
Space Complexity: Theta(n)

This link can help to solve problems:
https://gist.github.com/mycodeschool/9678029
https://www.hackerearth.com/practice/algorithms/sorting/merge-sort/tutorial/

http://www.sanfoundry.com/cpp-program-implement-merge-sort/

## Bubble Sort

This video is good to help:

I have also taken help from DS Made Easy by Karumanchi book to find the algo pesudocode.

Pseudocode:

Implementation:

I need to improve this algorithm as it is not passing all the sizes of array so there will be some vacant position in array which increases the complexity in the running time so we need to out of the loop when it has nothing to swap, so our improvised algorithm will be:

Pseudocode:

Implementation:

This below video can help for better optimization that implemented in the above code:

Time Complexity in Running Time:

Worst Case: O(n^2)
BEst Case without improve: O(n^2)
Best Case(Improvised): O(n)
Average Case: O(n^2)
Space Complexity: O(1)
Simulation Tried to be drawn by me:

## Selection Sort

https://youtu.be/GUDLRan2DWM?list=PL2_aWCzGMAwKedT2KfDMB9YA5DgASZb3U

PSeudoCode:

Implemented Code:

output:

## Selection Sort

https://youtu.be/GUDLRan2DWM?list=PL2_aWCzGMAwKedT2KfDMB9YA5DgASZb3U

PSeudoCode:

Implemented Code:

output:

## Selection Sort

https://youtu.be/GUDLRan2DWM?list=PL2_aWCzGMAwKedT2KfDMB9YA5DgASZb3U

PSeudoCode:

Implemented Code:

output:

## QuickSort

Analaysis though it seems little bit tough to me:

HackerRank video:

Pseudo Code from upper Youtube vid:

Implementation:

Slightly edited in *A to A[]:

Some change with before and after show:

Complete Quicksort Implementation and taking user input:

Output from the above code:

From geeks for geeks but may be there might be some problems there

Another good one for understanding(I think it’s the best one):

Pseudocode available in the above video:

implemented code:

Quick Sorting in Process

Time and Space complexity: Best Case : omega(nlogn)
Worst case: O(n^2)

See this video to clear up the skills:

code:

## Basics of Implementation – Hackerearth

Vowel count in a string:
code:

Count Digit:

## C++ Vector push_back()…pop_back()

Best Video Explained:

code:

some bugs  here but understood the implementation:

## Algorithm: Euler’s GCD

code:

more optimized:

Recursive:

http://www.progkriya.org/gyan/basic-number-theory.html#section3