C language

Difference Between structure and Union

In C/C++, Structures and Union are two user-defined data types. In this blog post, we will try to understand how they both work and how exactly are they different from each other.

Understanding a Structure (struct)

Struct is a user-defined data-type that’s used to store a combination of data which can potentially belong to different data-types. To explain further, think about how you can store information about a student in C/C++, where, you need to store the following parameters:

Read more

Merge Sort in C

Merge sort is one of the most powerful sorting algorithms. Merge sort is widely used in various applications as well. The best part about these algorithms is that they are able to sort a given data in O(nLogn) complexity as against O(n2) complexity (we will soon see how) of bubble sort and selection sort. Moreover, merge sort is of interest because it creates an excellent case study for one of the widely used techniques in Computer Science – divide and conquer.

Read more

Bubble Sort in C

Sorting of data is one of the most fundamental, yet an important problem in computer science. Sorting forms a great case study for those who want to learn Data Structures and Algorithms.

What is Sorting – Definition

Often in real life, we are supposed to arrange data in a particular order. For instance, during our school days, we are told to stand in the queue based on our heights. Another example is of the attendance register at school/college which contains our names arranged in the alphabetical order.

Read more