# Counting Sort — Simple Explainer

Consider this array. What is the first thing you notice? Yes, right. This array has repeating values in a small range. Counting array uses the idea of storing the frequencies of elements. This is a non-comparison based sorting. It doesn’t compare its elements with each other. Let’s see how it goes!

# Thinking

What can we use to store the frequencies? A map? yes, we can use a map. But we will use an array. You can ask why? In maps, hashing functions are used. These functions are used to translate a key to a value. This is costly in terms of…

# Linked Lists — Idea

In the array, all the elements need to be stored continuously. Let’s see some of the shortcomings of the array —

1. Increasing the array is time-consuming; whenever size increases, the previous elements are copied into a new location so that elements are continuous.
2. On deletion, the element after the deleted numbers is shifted to one position earlier.

# Hashing

What do we mean by the Hash Value of some data? It is a value that uniquely identifies a large data. When we are searching for a value in an array, searching traditionally will take linear time. This can be reduced to logarithmic time if the data is sorted. But most data is not sorted, and sorting it will take more than linear time. There is a ton of data being produced every second. Searching through it linearly could take several days. What can we do to do this search in constant time? …

# Variable Number of Arguments in C and C++

All this time I kept using printf and writing functions but never gave it much thought that printf accepts as many arguments as you want. How about we write a function that does the same?

The header file we’re going to use is cstdarg in C++ and stdarg.h in C. This header provides us one type and some macro functions to handle the argument list.

• va_list : type to hold the argument list
• va_start : macro to initialize the argument list
• va_end : macro to end using the argument list
• va_arg : macro to retrieve the next argument in …

## Nidhi Kesarwani

Programmer, Loves to Code, Psychology Enthusiast, Believes in “Brevity is the soul of wit” !

Get the Medium app