<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>brian kernighan’s algorithm - Wikitechy</title>
	<atom:link href="https://www.wikitechy.com/interview-questions/tag/brian-kernighans-algorithm/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.wikitechy.com/interview-questions/tag/brian-kernighans-algorithm/</link>
	<description>Interview Questions</description>
	<lastBuildDate>Mon, 13 Sep 2021 06:17:20 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.wikitechy.com/interview-questions/wp-content/uploads/2025/10/cropped-wikitechy-icon-32x32.png</url>
	<title>brian kernighan’s algorithm - Wikitechy</title>
	<link>https://www.wikitechy.com/interview-questions/tag/brian-kernighans-algorithm/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Count number of bits to be flipped to convert A to B ?</title>
		<link>https://www.wikitechy.com/interview-questions/data-structure/how-to-count-number-of-bits-to-be-flipped-to-convert-a-to-b/</link>
					<comments>https://www.wikitechy.com/interview-questions/data-structure/how-to-count-number-of-bits-to-be-flipped-to-convert-a-to-b/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 17:48:41 +0000</pubDate>
				<category><![CDATA[Data Structure]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></category>
		<category><![CDATA[Altimetrik India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Applied Materials interview questions and answers]]></category>
		<category><![CDATA[Bharti Airtel interview questions and answers]]></category>
		<category><![CDATA[bit flipping game code]]></category>
		<category><![CDATA[bit manipulation in c]]></category>
		<category><![CDATA[BMC Software interview questions and answers]]></category>
		<category><![CDATA[brian kernighan’s algorithm]]></category>
		<category><![CDATA[c program to count number of ones and zeros]]></category>
		<category><![CDATA[c program to toggle a bit]]></category>
		<category><![CDATA[Capgemini interview questions and answers]]></category>
		<category><![CDATA[CASTING NETWORKS INDIA PVT LIMITED interview questions and answers]]></category>
		<category><![CDATA[CGI Group Inc interview questions and answers]]></category>
		<category><![CDATA[Chetu interview questions and answers]]></category>
		<category><![CDATA[Ciena Corporation interview questions and answers]]></category>
		<category><![CDATA[Collabera Te interview questions and answers]]></category>
		<category><![CDATA[count number of 1s in a binary number java]]></category>
		<category><![CDATA[count set bits]]></category>
		<category><![CDATA[count set bits in a number c++]]></category>
		<category><![CDATA[count total set bits in all numbers from 1 to n]]></category>
		<category><![CDATA[counting bits]]></category>
		<category><![CDATA[counting bits set by lookup table]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[flip all bits in c]]></category>
		<category><![CDATA[flip bits]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[flipped mountain code in c]]></category>
		<category><![CDATA[flipped mountain code in java]]></category>
		<category><![CDATA[flipped mountain in c]]></category>
		<category><![CDATA[flipped mountain pattern program in java]]></category>
		<category><![CDATA[flipped mountain program in c]]></category>
		<category><![CDATA[flipped mountain program in java]]></category>
		<category><![CDATA[flipped mountain program in python]]></category>
		<category><![CDATA[flipping bits in c]]></category>
		<category><![CDATA[flipping bits in java]]></category>
		<category><![CDATA[flipping bits program in c]]></category>
		<category><![CDATA[flipping bits solution]]></category>
		<category><![CDATA[flipping bits solution in c]]></category>
		<category><![CDATA[Genpact interview questions and answers]]></category>
		<category><![CDATA[Globallogic India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[how to count number of 1's in binary representation in c]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[Mphasis interview questions and answers]]></category>
		<category><![CDATA[NetApp interview questions and answers]]></category>
		<category><![CDATA[Oracle Corporation interview questions and answers]]></category>
		<category><![CDATA[reverse bytes in c]]></category>
		<category><![CDATA[samsung interview questions and answers]]></category>
		<category><![CDATA[SAP Labs India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Sapient Consulting Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Tech Mahindra interview questions and answers]]></category>
		<category><![CDATA[toggle all bits in c]]></category>
		<category><![CDATA[Tracxn Technologies Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[UnitedHealth Group interview questions and answers]]></category>
		<category><![CDATA[Wipro Infotech interview questions and answers]]></category>
		<category><![CDATA[WM Global Technology Services India Pvt.Ltd Limited (WMGTS) interview questions and answers]]></category>
		<category><![CDATA[Xoriant Solutions Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Yodlee Infotech Pvt Ltd interview questions and answers]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=513</guid>

					<description><![CDATA[Answer : Write the program to count number of bits needed to be flipped...]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="how-to-count-number-of-bits-to-be-flipped-to-convert-a-to-b" class="color-pink" style="text-align: justify;">How to Count number of bits to be flipped to convert A to B ?</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Write the program to count number of bits needed to be flipped to convert ‘a’ to ‘b’. For Example given two numbers a = 6 and b = 12; then the output is 2
<ul>
<li><a href="https://www.wikitechy.com/technology/check-binary-representation-number-palindrome/" target="_blank" rel="noopener">Binary representation</a> of a is 00000<b>11</b>0</li>
<li>Binary representation of b is 00001100</li>
<li>We need to flip highlighted two bits in a</li>
<li>To make it b.</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="explanation" class="color-purple">Explanation</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Calculate XOR of A and B.</li>
</ul>
</div>
</div>
<div class="Output" style="text-align: justify;">
<div class="hddn">
<figure class="highlight">
<pre><code class="hljs" data-lang=""><span class="nt">a_xor_b = A ^ B</span></code></pre>
</figure>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Count the set bits in the above Calculated XOR result.</li>
</ul>
</div>
</div>
<div class="Output" style="text-align: justify;">
<div class="hddn">
<figure class="highlight">
<pre><code class="hljs scss" data-lang=""><span class="nt"><span class="hljs-function">CountSetBits</span>(a_xor_b)</span></code></pre>
</figure>
</div>
</div>
<div class="TextHeading">
<div class="hddn">
<h2 id="sample-code-in-c" class="color-purple" style="text-align: justify;">Sample Code in C#</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-c code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-c code-embed-code">/ Count number of bits to be <br/>// flipped to convert A into B <br/>using System; <br/><br/>public class Count { <br/>	<br/>	// Function that count set bits <br/>	public static int countSetBits(int n) <br/>	{ <br/>		int count = 0; <br/>		while (n != 0) { <br/>			count += n & 1; <br/>			n >>= 1; <br/>		} <br/>		return count; <br/>	} <br/><br/>	// Function that return <br/>	// count of flipped number <br/>	public static int FlippedCount(int a, int b) <br/>	{ <br/>	// Return count of set <br/>	// bits in a XOR b <br/>		return countSetBits(a ^ b); <br/>	} <br/>	<br/>	// Driver code <br/>	public static void Main() <br/>	{ <br/>		int a = 17; <br/>		int b = 55; <br/>		Console.WriteLine(FlippedCount(a, b)); <br/>	} <br/>} <br/><br/>// This code is contributed by vt_m. </code></pre> </div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="output" class="color-purple">Output</h2>
</div>
</div>
<div class="Output">
<div class="hddn">
<figure class="highlight" style="text-align: justify;">
<pre><code class="hljs" data-lang=""><span class="nt">3</span></code></pre>
</figure>
</div>
</div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/data-structure/how-to-count-number-of-bits-to-be-flipped-to-convert-a-to-b/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
