January 2017 - Coding Bot

# Armstrong Number C Code

Armstrong number is a number that is equal to the sum of the digits raised to the power of the number of digits. So for example:

371 = 3^3 + 7^3 + 1^3 = 27 + 343 + 1 = 371

There are other such numbers as well: 150, 370, 407, 8208, 1741725, etc.

According to Wikipedia Narcissistic Number or Armstrong Number is a number that is the sum of its own digits each raised to the power of the number of digits. This definition depends on the base b of the number system used, e.g., b = 10 for the decimal system or b = 2 for the binary system.

# Quick Sort Algorithm And C++ Code

Quicksort, or partition-exchange sort, is a sorting algorithm that, on average, makes O(n log n) comparisons to sort n items.  It was developed by Tony Hoare. Quicksort is faster in practice than other O(n log n) algorithms such as Bubble sort or Insertion Sort. Quicksort can be implemented with an in-place partitioning algorithm, so the entire sort can be done with only O(log n) additional space.
Quicksort is a comparison sort and is not a stable sort.

Its complexity is as follows:
Best Case - O(n log n)
Worst Case - O(n^2)
Average Case - O(n log n)

Quicksort is a divide and conquer algorithm. Quicksort first divides a large list into two smaller sub-lists: the low elements and the high elements.