All Articles

Binary Tree Sort in C

Binary Tree Sort uses a Binary search tree. The various steps involved in such a sort would be – Construct a binary tree with the given data (integers) such that all numbers to the left of a particular node say ‘nd’ is less than the number contained within the node and to the right, the numbers…

All Articles

Selection Sort

A Selection sorting technique uses a general algorithm which uses an ascending or descending priority queue. The idea would be to pre-process input array X[i] into the descending or ascending priority queues by the functions dpqinsert(dpq, x) or apqinsert(apq, x) respectively. Now, the next and final step would be to select data in appropriate order from…

All Articles

Quick Sort

The popular exchange sort mechanisms are Mean sort, Quick Sort and BSort and Quick sort is the most simple one. Quick sort is most applicable exchange sorting technique for practical applications since it uses relatively less time-space resources. Lets illustrate finding Order of a Quick sort algorithm in C. Lets start with the below list…

All Articles

Bubble Sort in C

Lets explain Bubble sort by illustrating tow specific examples involving steps where smaller numbers bubbles to first and when larger numbers bubbles to last. Number list to sort: 2   5   3   0   6   1 Case 1: Smaller numbers bubbles to first Step 1:    0  5  3  2  6  1 Step 2:   0  3  5  2 …

All Articles

Efficiency and Order of a Sorting Program

Efficiency Considerations The following are the efficiency considerations while planning for a sorting program / algorithm – Time required to code the program and the type of sorting technique to be selected Execution time Amount of space required by program In cases where the type of data to be sorted is known, it is easier…

All Articles

Efficiency of Recursion

In general cases, a non-recursive program runs more efficiently than a recursive program since a recursive program requires more execution time to enter and exit from a function. Recursive programs flows directly from the definitions and are easy to implement while a corresponding non-recursive program may involve expensive use of stacks which are difficult to…

All Articles

Recursion in C

Recursion Recursion and Iteration are two different concepts of achieving a result by a number of repeated operations. Iteration involves use of for, while and do-while loops for the repeated operation until specified condition. Recursion involves a recursive function calling itself several times until specified condition. A recursive function represents the most simpler form of…

All Articles

Doubly Linked Lists

Doubly Linked lists eliminates below drawbacks of circular lists – not able to traverse backward not able to delete and node given only points to that node. In a doubly linked list, every node has three fields – left, right and info. Each node has two pointers left and right which points to the left…

All Articles

Dynamic Circular Linked Lists in C

Circular lists eliminates same drawbacks of linear lists. In as circular list it is assumed that items are inserted at the front and the list pointer points to the currently inserted node. Now, in this currently inserted circular list items, node or item is the last node of the list (and is this the rear…

All Articles

Dynamic Linked Lists as Queues in C

When Dynamic Linked Lists are represented as Queues, the first node represents front of queue given by q.front and last node represents the rear of the queue given by q.rear where q.front and q.rear are pointers. Thus Qinsert(q,x) and Qdelete(q) could be implemented as below – Qinsert(q,x){ p = getnode(); info(p) = x; next(p) =…

All Articles

Implementing Dynamic Linked Lists in C

List is a type of dynamic data structure which rectifies certain drawbacks of Stacks and Queues. Lists generally uses the concept of pointers which points to a memory location containing data. The basic structure of a linear linked list is a as follows –   Each item in a list is called NODE. Each NODE…

All Articles

Game Trees

Game Tree is one of the applications of Binary Trees. For example the one implemented for the Tic-Tac-Toe Game. X | X | X O | O |     O |   | The game is between two players who makes moves ‘X’ and ‘O’ on a board of 3×3 positions. The players who wins is…

All Articles

HUFFMAN Algorithm and its implementation in C

Huffman trees are used as message encoding and message decoding trees which is the basic construct of compression and de. The specialty of Huffman tree is that – it helps to reduce the bit codes of each symbol in the message according to their relative frequency of occurrence. the same tree constructed could be used for…

All Articles

Traversing a Binary Tree in C

There are generally 3 traversal strategies for Binary Trees – INORDER, PREORDER and POSTORDER. For eg:, the inorder, preorder and postorder traversal of an expression tree gives the infix, prefix and postfix forms of the expression. Such a traversal could be used to evaluate the value of expression. Example 1 : Consider the following Binary Tree –…

All Articles

C program for Hailstones series

Hailstones is a sequence of numbers that could be generated from any positive number by performing a specific operation on it until it reaches 1. The fact is that any positive number will reach 1 if we perform this operation. If the number is even, we divide it by 2, otherwise we multiply the number…

All Articles

C program to generate random numbers in any range

Here is a C program to generate random numbers between any range of two digit numbers – #include #include main(){ int s, a, b, n, ran; srand(time(0)); // this is to set the seed to current time so we get different random numbers in each try printf(“\nEnter lower limit>>”); scanf(“%d”,&a); printf(“\nEnter upper limit>>”); scanf(“%d”,&b); printf(“\nEnter…

All Articles

for loops in C

The ‘for’  loop is another important looping structure which could replace ‘while’  and ‘do .. while’ loops. It has a special feature that the initialization, test condition and the increment or decrements of test variable could be placed in a single line following the ‘for’ keyword as shown below – for (initialization; test condition; change…

All Articles

C program to implement Russian Peasant

Here is a C program that I wrote years back to implement Russian Peasant method of an interesting multiplication technique – main(){ int a, b, sum = 0; printf(“\nEnter the two digits to be multiplied separated by space>> “); scanf(“%d %d”, &a, &b); printf(“%d “,a); printf(” %d\n”,b); do{ if(a % 2) sum += b; else…

All Articles

While Loop in C

Like do-while loop, While loop is the most commonly used looping construct to repeat a process or calculation for a set or collection of inputs or storage based on a condition. It is a looping technique when you want to execute the required process based on a condition for the entire input collection. Below is…

All Articles

Do – While Loops in C

Looping constructs is an important programming language technique to repeat a process or calculation for a set or collection of inputs or storage based on a condition. Do – While is a looping technique when you want to execute the required process for at least once and then check the condition for the rest of the…

All Articles

C Program to check for leap year

Here is a C program to check for leap year – main () { int year; printf(“Please enter any year as 4 digits>> “); scanf(“%d”, &year); if(year % 4 ==0 && year % 100 !=0 || year % 400 == 0) printf(“%d is a leap year \n”, year); else printf(“%d is not a leap year…

All Articles

Making decision in C program

Decision making is an important aspect of programming language that enables the programmer to arrive at a conclusion based on certain data processing, comparisons and conditional situations. In most programming language there are inbuilt functions and language constructs that enable implicit decision making. In other situations, it offers a combination of language constructs such as comparison…

All Articles

Declaring variables in C language

C programming language allows to define and classify data so we can use it appropriately in various parts of the program in the correct form with or without changing the original value or just copying the original value. Any data that we need to use in the program need to be stored in the memory….

All Articles

C Programming Language

C language developed at Bell lab by Dennis Ritchie on UNIX environment. UNIX was later rewritten in C. An earlier version of C is BCPL (Basic Combined Programming Language) developed by Ken Thompson. When it was later improvised by Dennis, it became C (‘C’ from BCPL) programming language. C program could be written either in…

All Articles

File Operation in C

Below is a simple C program to perform file operation – include <stdlib.h> main() { FILE * file_source char * file_name = (char*) malloc (sizeof (char)* 13); char * file_content= (char*) malloc (sizeof (char)* 100); printf(“Enter File Name>”); gets (file_name); file_source = fopen(file_name, “r+”); if(file_source == NULL) { printf(“File doesn’t exist”); } else{ while (…

All Articles

Mobile Communication Services

One of the fastest growth rates in the telecommunications industry anywhere in the world is that of mobile radio communication devices. The basic architecture of such a mobile communication network is shown below –   Radio telephones or cell phones provide a switched two-way channel between two conversing parties like a conventional telephone. Telephones may…

All Articles

Digitized Phone Services (E-10B)

Olden form of phone systems involved manual exchanges which involved a great task in switching and routing of calls to various subscribers that increased network traffic and longer setup times. Also, fault checking and identification was very difficult. With the introduction of electronic exchanges which used a stored program concept of switching and routing of…

All Articles

Early Evolution of Data Commmunication Systems

It’s helpful for data communication and IT students to understand the evolution of Data communication systems. The first phase in the evolution of data communication systems was Telegraph Systems. Later, with developments in the telephone systems, it was then possible to interconnect various computer terminals for data communication. With the advancements in network computing and the…

All Articles

Data Communication and its basic setup

Data Communications is the function of transferring a digital signal from one digital device to another. Data transmission and data communications mean two different things. Data communication has a much wider meaning which embraces not just electrical transmission but, any other factors involved in controlling, checking and handling the movement in a communication-based computer system….

All Articles

Binary Tree

Binary Tree is a basic data structure that is used behind the scenes of all major technologies whether it’s a Database system or operating system, search engine, Bleeding edge AI systems, Big data or cloud based architectures.