Manchester Coding of Bits

For Complete YouTube Video: Click Here

In this class, we will understand Manchester Coding of Bits.

The entire course of C Programming with more than 110+ videos of content or playlist has already been published.

We have covered all the concepts of C Programming in a very detailed way.

C Programming Complete Playlist on YouTube: Click Here

All the concepts discussed in this course are the models frequently asked in Campus Placements Questions, either in multiple-choice questions or as programming questions.

This entire course will help a Computer Science Engineering Student or a student in any other stream crack the campus placements drives held by Service-based Software or IT companies like TCS, Infosys, CTS, Wipro, Accenture, etc.

Manchester Coding of Bits

Question:

The following are the Manchester function. For each element of the input array arr a counter is incremented if the bit in arr[i] is the same as the bit in arr[i-1]. Then the incremented counter is added to the output array to store the result.

If the bits arr[i] and arr[i-1] are different then 0 is added to the output array. For the first bit in the input array, assume its previous bit to be 0.

Example1:

Input: 6, [1, 1, 0, 0, 1, 0]

Output: 0 1 0 2 0 0

Example2:

Input: 8, [0, 0, 0, 1, 0, 1, 1, 1]

Output: 1 2 3 0 0 0 4 5

Given Code:

void manchester(int size, int* arr)
{
	int result;
	int* res=(int*)malloc(sizeof(int)*size);
	int count=0;
	for(int i=0;i<size; i++)
	{
		if(i==0)
			result=(arr[i]==0);
		else
			result=(arr[i]==arr[i-1]);
		res[i]=(result)?(0): (++count);
	}
	for(int i=0;i<size; i++)
	{
		printf(“%d ”,res[i]);
	}
}

In the above code, there are some mistakes in the problem.

The explanation of the question is provided in the above YouTube link.