<?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>Tracxn Technologies Pvt Ltd interview questions and answers - Wikitechy</title>
	<atom:link href="https://www.wikitechy.com/interview-questions/tag/tracxn-technologies-pvt-ltd-interview-questions-and-answers/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.wikitechy.com/interview-questions/tag/tracxn-technologies-pvt-ltd-interview-questions-and-answers/</link>
	<description>Interview Questions</description>
	<lastBuildDate>Mon, 13 Sep 2021 07:26:17 +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>Tracxn Technologies Pvt Ltd interview questions and answers - Wikitechy</title>
	<link>https://www.wikitechy.com/interview-questions/tag/tracxn-technologies-pvt-ltd-interview-questions-and-answers/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>What is the default port for MySQL Server ?</title>
		<link>https://www.wikitechy.com/interview-questions/mysql/what-is-the-default-port-for-mysql-server/</link>
					<comments>https://www.wikitechy.com/interview-questions/mysql/what-is-the-default-port-for-mysql-server/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 20 Jul 2021 08:18:59 +0000</pubDate>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></category>
		<category><![CDATA[Allstate Solutions Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Amdocs interview questions and answers]]></category>
		<category><![CDATA[Atos interview questions and answers]]></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[change mysql port]]></category>
		<category><![CDATA[change mysql port centos]]></category>
		<category><![CDATA[change mysql port centos 7]]></category>
		<category><![CDATA[change mysql port mac]]></category>
		<category><![CDATA[change mysql port ubuntu]]></category>
		<category><![CDATA[change mysql port xampp]]></category>
		<category><![CDATA[check mysql port]]></category>
		<category><![CDATA[Chetu interview questions and answers]]></category>
		<category><![CDATA[Collabera Technologies interview questions and answers]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[export mysql database command line]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[how to change port number in mysql workbench]]></category>
		<category><![CDATA[how to check mysql port number in windows]]></category>
		<category><![CDATA[how to free port 3306 for mysql]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[import database mysql command line]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[Infosys Technologies interview questions and answers]]></category>
		<category><![CDATA[L&T Infotech interview questions and answers]]></category>
		<category><![CDATA[Mphasis interview questions and answers]]></category>
		<category><![CDATA[ms sql port]]></category>
		<category><![CDATA[mssql default port]]></category>
		<category><![CDATA[mssql port]]></category>
		<category><![CDATA[mysql 5.7 change port]]></category>
		<category><![CDATA[mysql command line]]></category>
		<category><![CDATA[mysql command line cheat sheet]]></category>
		<category><![CDATA[mysql command line client]]></category>
		<category><![CDATA[mysql command line connect]]></category>
		<category><![CDATA[mysql command line download]]></category>
		<category><![CDATA[mysql command line linux]]></category>
		<category><![CDATA[mysql command line mac]]></category>
		<category><![CDATA[mysql command line options]]></category>
		<category><![CDATA[mysql commands]]></category>
		<category><![CDATA[mysql connect command line]]></category>
		<category><![CDATA[mysql connect to remote database command line]]></category>
		<category><![CDATA[mysql connect with port]]></category>
		<category><![CDATA[mysql default port]]></category>
		<category><![CDATA[mysql host port command line]]></category>
		<category><![CDATA[mysql import command line]]></category>
		<category><![CDATA[mysql port]]></category>
		<category><![CDATA[mysql port 3306]]></category>
		<category><![CDATA[mysql port command line]]></category>
		<category><![CDATA[mysql port number]]></category>
		<category><![CDATA[mysql port number other than 3306]]></category>
		<category><![CDATA[mysql server name]]></category>
		<category><![CDATA[mysql tcp port]]></category>
		<category><![CDATA[Oracle Corporation interview questions and answers]]></category>
		<category><![CDATA[Persistent Systems interview questions and answers]]></category>
		<category><![CDATA[phpmyadmin port]]></category>
		<category><![CDATA[port 1433]]></category>
		<category><![CDATA[port 3306]]></category>
		<category><![CDATA[port mysql]]></category>
		<category><![CDATA[Prokarma Softech Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[RBS India Development Centre Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[SAP Labs India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Societe Gen interview questions and answers]]></category>
		<category><![CDATA[sql default port]]></category>
		<category><![CDATA[sql port]]></category>
		<category><![CDATA[sql port number]]></category>
		<category><![CDATA[sql server default port]]></category>
		<category><![CDATA[sql server port]]></category>
		<category><![CDATA[sql server port number]]></category>
		<category><![CDATA[Tata Consultancy Service interview questions and answers]]></category>
		<category><![CDATA[Tech Mahindra interview questions and answers]]></category>
		<category><![CDATA[Tracxn Technologies Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[UnitedHealth Group interview questions and answers]]></category>
		<category><![CDATA[ValueLabs interview questions and answers]]></category>
		<category><![CDATA[Virtusa Consulting Services Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Wells Fargo interview questions and answers]]></category>
		<category><![CDATA[What is the default port for MySQL Server]]></category>
		<category><![CDATA[yahoo interview questions and answers]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=1112</guid>

					<description><![CDATA[Answer : If you want to check the port...]]></description>
										<content:encoded><![CDATA[<h2 id="what-is-the-default-port-for-mysql-server" class="color-purple">What is the default port for MySQL Server ?</h2>
<ul>
<li>If you want to check the port number just type status on the MySQL command prompt. It would display all the server details along with the Port number.(default port is 3306).</li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/mysql/what-is-the-default-port-for-mysql-server/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What is Binary Search Tree ?</title>
		<link>https://www.wikitechy.com/interview-questions/data-structure/what-is-binary-search-tree/</link>
					<comments>https://www.wikitechy.com/interview-questions/data-structure/what-is-binary-search-tree/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 17:58:10 +0000</pubDate>
				<category><![CDATA[Data Structure]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></category>
		<category><![CDATA[allevel order traversal]]></category>
		<category><![CDATA[Altimetrik India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Applied Materials interview questions and answers]]></category>
		<category><![CDATA[balanced binary search tree]]></category>
		<category><![CDATA[Bharti Airtel interview questions and answers]]></category>
		<category><![CDATA[binary numbers list]]></category>
		<category><![CDATA[binary search]]></category>
		<category><![CDATA[binary search algorithm]]></category>
		<category><![CDATA[binary search code]]></category>
		<category><![CDATA[binary search in data structure]]></category>
		<category><![CDATA[binary search program]]></category>
		<category><![CDATA[binary search python]]></category>
		<category><![CDATA[binary search tree algorithm]]></category>
		<category><![CDATA[binary search tree c++]]></category>
		<category><![CDATA[binary search tree definition]]></category>
		<category><![CDATA[binary search tree delete iterative]]></category>
		<category><![CDATA[binary search tree delete node c++]]></category>
		<category><![CDATA[binary search tree deletion]]></category>
		<category><![CDATA[binary search tree deletion algorithm in c]]></category>
		<category><![CDATA[binary search tree deletion in c]]></category>
		<category><![CDATA[binary search tree example]]></category>
		<category><![CDATA[binary search tree insertion]]></category>
		<category><![CDATA[binary search tree insertion and deletion program in c]]></category>
		<category><![CDATA[binary search tree java]]></category>
		<category><![CDATA[binary search tree program in c]]></category>
		<category><![CDATA[binary search tree program in c++ using linked list]]></category>
		<category><![CDATA[binary search tree python]]></category>
		<category><![CDATA[binary search tree python library]]></category>
		<category><![CDATA[binary search tree recursive delete c++]]></category>
		<category><![CDATA[binary search tree traversal]]></category>
		<category><![CDATA[binary search tree traversal inorder preorder postorder example]]></category>
		<category><![CDATA[binary tree]]></category>
		<category><![CDATA[binary tree program in data structure]]></category>
		<category><![CDATA[binary tree traversal program in cinorder traversal iterativebinary tree traversal program in c++]]></category>
		<category><![CDATA[binary tree vs binary search tree]]></category>
		<category><![CDATA[BMC Software interview questions and answers]]></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[construct binary tree from inorder and postorder travers]]></category>
		<category><![CDATA[delete node from binary search tree]]></category>
		<category><![CDATA[deletion by merging in binary search tree]]></category>
		<category><![CDATA[deletion in binary search tree examples]]></category>
		<category><![CDATA[deletion in binary search tree in c++ program]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[difference between binary tree and binary search tree]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[Genpact interview questions and answers]]></category>
		<category><![CDATA[Globallogic India Pvt Ltd interview questions and answers]]></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[optimal binary search tree]]></category>
		<category><![CDATA[Oracle Corporation interview questions and answers]]></category>
		<category><![CDATA[polaris financial technology interview questions and answers]]></category>
		<category><![CDATA[recursive binary search]]></category>
		<category><![CDATA[recursive binary search tree python]]></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[Tracxn Technologies Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[tree traversal examples]]></category>
		<category><![CDATA[tree traversal questions]]></category>
		<category><![CDATA[UnitedHealth Group interview questions and answers]]></category>
		<category><![CDATA[validate binary search tree]]></category>
		<category><![CDATA[what is binary]]></category>
		<category><![CDATA[what is binary search]]></category>
		<category><![CDATA[what is binary search algorithm]]></category>
		<category><![CDATA[what is binary search in data structure]]></category>
		<category><![CDATA[what is binary search tree]]></category>
		<category><![CDATA[what is binary search tree in data structure]]></category>
		<category><![CDATA[what is optimal binary search tree]]></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=515</guid>

					<description><![CDATA[Answer : The Binary search tree is a node-based on the binary tree data structure...]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="what-is-binary-search-tree" class="color-pink" style="text-align: justify;">What is binary search tree ?</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>The <a href="https://www.wikitechy.com/technology/category/data-structures/binary-search-tree/" target="_blank" rel="noopener">Binary search tree</a> is a node-based on the binary tree data structure has the following properties,
<ul>
<li>The left-side sub tree of a node contains only nodes with keys lesser than the node’s key.</li>
<li>The right-side sub tree of a node contains only nodes with keys greater than the node’s key.</li>
<li>The left-side and right-side subtree each must also be a binary search tree.</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="ImageContent" style="text-align: justify;">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/interview-questions/data-structure/what-is-binary-search-tree.gif" alt="Binary Search Tree" /></div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="binary-search-tree-traversing" class="color-green">Binary Search Tree Traversing</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li><a href="https://www.wikitechy.com/technology/c-programming-tree-traversals-inorder-preorder-postorder/" target="_blank" rel="noopener">Pre-order</a> traversal.</li>
<li><a href="https://www.wikitechy.com/technology/java-programming-tree-traversals-inorder-preorder-postorder/" target="_blank" rel="noopener">Post-order</a> traversal.</li>
<li><a href="https://www.wikitechy.com/technology/python-programming-tree-traversals-inorder-preorder-postorder/" target="_blank" rel="noopener">In-order</a> traversal.</li>
</ul>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="pre-order-traversal" class="color-purple">Pre-order traversal</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>This traversal technique it may be traversal order is root-left-right.
<ul>
<li>Visit the node.</li>
<li>Call itself to traverse the node&#8217;s left subtree.</li>
<li>Call itself to traverse the node&#8217;s right subtree.</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="TextHeading">
<div class="hddn">
<h2 id="algoithm" class="color-green" style="text-align: justify;">Algoithm</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-markdown code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-markdown code-embed-code">preOrder (t)<br/>     {<br/>       if (t is not empty)<br/>        {<br/>              access the root element of t;<br/>              preOrder (leftTree (t));<br/>              preOrder (rightTree (t));<br/>       } // if<br/>    } // preOrder traversal</code></pre> </div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="post-order-traversal" class="color-purple">Post-order traversal</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>This traversal technique the traversal order is left-right-root.
<ul>
<li>Call itself to traverse the node&#8217;s left subtree.</li>
<li>Call itself to traverse the node&#8217;s right subtree.</li>
<li>Visit the node.</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="TextHeading">
<div class="hddn">
<h2 id="algoithm-2" class="color-green" style="text-align: justify;">Algoithm</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-markdown code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-markdown code-embed-code">postOrder (t)<br/> { <br/>   if (t is not empty) <br/>    { <br/>       postOrder(leftTree(t));<br/>       postOrder(rightTree(t)); <br/>       access the root element of t;<br/>    } // if <br/>} // postOrder traversal</code></pre> </div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="n-order-traversal" class="color-purple">n-order traversal</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>An <a href="https://www.wikitechy.com/technology/python-programming-inorder-predecessor-successor-given-key-bst/" target="_blank" rel="noopener">in-order</a> traversal of a binary search tree will cause all the nodes to be visited in ascending order, based on their key values. If you want to create a sorted list of the data in a binary tree, this is one way to do it.
<ul>
<li>Call itself to traverse the node&#8217;s left subtree.</li>
<li>Visit the node.</li>
<li>Call itself to traverse the node&#8217;s right subtree</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="TextHeading">
<div class="hddn">
<h2 id="algoithm-3" class="color-green" style="text-align: justify;">Algoithm</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-markdown code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-markdown code-embed-code">private void inOrder(node localRoot) <br/>{ <br/>  if(localRoot != null) <br/>   {<br/>      inOrder(localRoot.leftChild);<br/>      localRoot.displayNode(); <br/>      inOrder(localRoot.rightChild); <br/>   }<br/> }</code></pre> </div>
<p style="text-align: justify;"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/interview-questions/data-structure/binary-tree-traversing.png" alt="Binary Tree Traversing" /></p>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="advantages" class="color-blue">Advantages</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Binary Search Tree is fast in insertion and deletion etc when balanced.</li>
<li>It is very efficient and its code is easier than Linklists.</li>
</ul>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="disadvantages" class="color-blue">Disadvantages</h2>
</div>
</div>
<div class="Content">
<div class="hddn">
<ul>
<li style="text-align: justify;">The main disadvantage is that we should always implement a balanced binary search tree &#8211; AVL tree, Red-Black tree, Splay tree. Otherwise the cost of operations may not be logarithmic and degenerate into a linear search on an array.</li>
<li style="text-align: justify;">Shape of the tree depends upon order of insertion and it can be degenerated.</li>
<li style="text-align: justify;">Searching takes long time.</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/data-structure/what-is-binary-search-tree/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<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 &amp; 1; <br/>			n &gt;&gt;= 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>
		<item>
		<title>What are the Minimum Initial Points to Reach Destination ?</title>
		<link>https://www.wikitechy.com/interview-questions/data-structure/what-are-the-minimum-initial-points-to-reach-destination/</link>
					<comments>https://www.wikitechy.com/interview-questions/data-structure/what-are-the-minimum-initial-points-to-reach-destination/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 17:44:33 +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[BMC Software interview questions and answers]]></category>
		<category><![CDATA[bottom and up moves allowed]]></category>
		<category><![CDATA[bottom moves allowed]]></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[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[find minimum moves to reach target on an infinite line]]></category>
		<category><![CDATA[find shortest path in 2d array in c]]></category>
		<category><![CDATA[find shortest path in matrix python]]></category>
		<category><![CDATA[find the minimum number of moves needed to move from one cell of matrix to another]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[Genpact interview questions and answers]]></category>
		<category><![CDATA[Globallogic India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[maximum cost path dynamic programm]]></category>
		<category><![CDATA[min cost flow]]></category>
		<category><![CDATA[minimum cost path]]></category>
		<category><![CDATA[minimum cost path dijkstra]]></category>
		<category><![CDATA[minimum cost path graph]]></category>
		<category><![CDATA[minimum cost path matrix java]]></category>
		<category><![CDATA[minimum cost path with left]]></category>
		<category><![CDATA[minimum cost path with right]]></category>
		<category><![CDATA[minimum number of jumps to reach end in java]]></category>
		<category><![CDATA[minimum number of jumps to reach end python]]></category>
		<category><![CDATA[minimum number of steps to reach a given number]]></category>
		<category><![CDATA[minimum steps to one dynamic programming]]></category>
		<category><![CDATA[minimum steps to reach a destination java]]></category>
		<category><![CDATA[minimum sum descent dynamic programming]]></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[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[shortest distance between two cells in a matrix or grid java]]></category>
		<category><![CDATA[shortest path between two points in a grid java]]></category>
		<category><![CDATA[shortest path from source to destination in matrix java]]></category>
		<category><![CDATA[shortest path in grid with obstacles]]></category>
		<category><![CDATA[shortest path in grid with obstacles python]]></category>
		<category><![CDATA[shortest path in matrix]]></category>
		<category><![CDATA[Tech Mahindra interview questions and answers]]></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=511</guid>

					<description><![CDATA[Answer : To begin from the upper left corner of a given framework...]]></description>
										<content:encoded><![CDATA[<div>
<div class="hddn">
<h2 id="what-are-the-minimum-initial-points-to-reach-destination" class="color-pink" style="text-align: justify;">What are the Minimum Initial Points to Reach Destination ?</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>To begin from the upper left corner of a given framework, one needs to achieve the base right corner.</li>
<li>Every cell in the grid contains a number, the number may positive or negative.</li>
<li>We can move across a cell only if we have positive points ( &gt; 0 ). Whenever we pass through a cell, points in that cell are added to our overall points.</li>
<li>We need to find minimum initial points to reach cell (m-1, n-1) from (0, 0) by following these certain set of rules :</li>
</ul>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li style="list-style-type: none;">
<ul>
<li>From a cell (i, j) we can move to (i+1, j) or (i, j+1).</li>
<li>We cannot move from (i, j) if your overall points at (i, j) is &lt;= 0.</li>
<li>We have to reach at (n-1, m-1) with minimum positive points i.e., &gt; 0.</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="syntax" class="color-purple">Syntax</h2>
</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">minInitTokens</span>(matrix) </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-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">#include&lt;iostream&gt;<br/>#include&lt;cmath&gt;<br/>#define ROW 3<br/>#define COL 3<br/>using namespace std;<br/><br/>int tokens[ROW][COL] = {<br/>   {-2,-3,3},<br/>   {-5,-10,1},<br/>   {10,30,-5}<br/>};<br/><br/>int max(int a, int b) {<br/>   return (a&gt;b)?a:b;<br/>}<br/><br/>int minInitPoints() {<br/>   int minToken[ROW][COL];<br/>   int m = ROW, n = COL;<br/>   <br/>   minToken[m-1][n-1] = tokens[m-1][n-1] &gt; 0? 1: abs(tokens[m-1][n-1]) + 1;<br/>   <br/>   for (int i = m-2; i &gt;= 0; i--)    //from last row to first row, fill points<br/>      minToken[i][n-1] = max(minToken[i+1][n-1] - tokens[i][n-1], 1);<br/>   <br/>   for (int j = n-2; j &gt;= 0; j--)    //fill last column to first column, fill points<br/>      minToken[m-1][j] = max(minToken[m-1][j+1] - tokens[m-1][j], 1);<br/><br/>   for (int i=m-2; i&gt;=0; i--) {<br/>      for (int j=n-2; j&gt;=0; j--) {<br/>         int remPoint = min(minToken[i+1][j], minToken[i][j+1]);    //calculate remaining points<br/>         minToken[i][j] = max(remPoint - tokens[i][j], 1);<br/>      }<br/>   }<br/>   return minToken[0][0];<br/>}<br/><br/>int main() {<br/>   cout &lt;&lt; &quot;Least Points Required: &quot; &lt;&lt; minInitPoints();<br/>}</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">Least Points Required: 7</span></code></pre>
</figure>
</div>
</div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/data-structure/what-are-the-minimum-initial-points-to-reach-destination/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Delete all occurrences of a given key in a linked list ?</title>
		<link>https://www.wikitechy.com/interview-questions/data-structure/delete-all-occurrences-of-a-given-key-in-a-linked-list/</link>
					<comments>https://www.wikitechy.com/interview-questions/data-structure/delete-all-occurrences-of-a-given-key-in-a-linked-list/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 17:39:53 +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[BMC Software interview questions and answers]]></category>
		<category><![CDATA[c program to delete first node in linked list]]></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[delete a specific node in linked list java]]></category>
		<category><![CDATA[delete all nodes in doubly linked list c++]]></category>
		<category><![CDATA[delete at position in a doubly linked list]]></category>
		<category><![CDATA[delete first node in linked list c++]]></category>
		<category><![CDATA[delete last node in doubly linked list in c++]]></category>
		<category><![CDATA[delete last node in linked list c++]]></category>
		<category><![CDATA[delete last node in linked list in c]]></category>
		<category><![CDATA[delete node at given position in a linked list in c++]]></category>
		<category><![CDATA[delete node from doubly linked list java]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[doubly linked list geeksforgeeks]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[Genpact interview questions and answers]]></category>
		<category><![CDATA[Globallogic India Pvt Ltd interview questions and answers]]></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[remove element from doubly linked list 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[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[write a program to delete a node from linked list in c++]]></category>
		<category><![CDATA[write ac program to delete a particular element in the doubly linked list]]></category>
		<category><![CDATA[write an algorithm to delete duplicate elements in a singly linked list]]></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=509</guid>

					<description><![CDATA[Answer : Given a singly linked list, delete all occurrences...]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="delete-all-occurrences-of-a-given-key-in-a-linked-list" class="color-pink">Delete all occurrences of a given key in a linked list ?</h2>
</div>
</div>
<div class="CodeContent">
<div class="hddn">
<ul>
<li>Given a singly linked list, delete all occurrences of a given key in it. For example,</li>
</ul>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-markdown code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-markdown code-embed-code">Input:  2 -&gt; 1 -&gt; 8 -&gt; 2 -&gt;  3 -&gt;  2 -&gt; 7<br/>       Key to delete = 2<br/>Output:  1 -&gt; 8 -&gt; 3 -&gt; 7 </code></pre> </div>
<h2 id="sample-code-in-c" class="color-purple">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">#include &lt;stdio.h&gt; <br/>#include &lt;stdlib.h&gt; <br/>// A linked list node <br/>struct Node <br/>{ <br/>    int data; <br/>    struct Node *next; <br/>}; <br/>/* Given a reference (pointer to pointer) to the head of a list <br/>   and an int, inserts a new node on the front of the list. */<br/>void push(struct Node** head_ref, int new_data) <br/>{ <br/>    struct Node* new_node = (struct Node*) malloc(sizeof(struct Node)); <br/>    new_node-&gt;data  = new_data; <br/>    new_node-&gt;next = (*head_ref); <br/>    (*head_ref)    = new_node; <br/>} <br/>/* Given a reference (pointer to pointer) to the head of a list and <br/>   a key, deletes all occurrence of the given key in linked list */<br/>void deleteKey(struct Node **head_ref, int key) <br/>{ <br/>    // Store head node <br/>    struct Node* temp = *head_ref, *prev; <br/>    // If head node itself holds the key or multiple occurrences of key <br/>    while (temp != NULL &amp;&amp; temp-&gt;data == key) <br/>    { <br/>        *head_ref = temp-&gt;next;   // Changed head <br/>        free(temp);               // free old head <br/>        temp = *head_ref;         // Change Temp <br/>    } <br/>    // Delete occurrences other than head <br/>    while (temp != NULL) <br/>    { <br/>        // Search for the key to be deleted, keep track of the <br/>        // previous node as we need to change &#039;prev-&gt;next&#039; <br/>        while (temp != NULL &amp;&amp; temp-&gt;data != key) <br/>        { <br/>            prev = temp; <br/>            temp = temp-&gt;next; <br/>        } <br/>        // If key was not present in linked list <br/>        if (temp == NULL) return; <br/>        // Unlink the node from linked list <br/>        prev-&gt;next = temp-&gt;next; <br/>        free(temp);  // Free memory <br/>        //Update Temp for next iteration of outer loop <br/>        temp = prev-&gt;next; <br/>    } <br/>} <br/>// This function prints contents of linked list starting from <br/>// the given node <br/>void printList(struct Node *node) <br/>{ <br/>    while (node != NULL) <br/>    { <br/>        printf(&quot; %d &quot;, node-&gt;data); <br/>        node = node-&gt;next; <br/>    } <br/>} <br/>   /* Drier program to test above functions*/<br/>int main() <br/>{ <br/>    /* Start with the empty list */<br/>    struct Node* head = NULL; <br/>    push(&amp;head, 7); <br/>    push(&amp;head, 2); <br/>    push(&amp;head, 3); <br/>    push(&amp;head, 2); <br/>    push(&amp;head, 8); <br/>    push(&amp;head, 1); <br/>    push(&amp;head, 2); <br/>    push(&amp;head, 2); <br/>    int key = 2; // key to delete <br/>    puts(&quot;Created Linked List: &quot;); <br/>    printList(head); <br/>    deleteKey(&amp;head, key); <br/>    puts(&quot;\nLinked List after Deletion: &quot;); <br/>    printList(head); <br/>    return 0; <br/>}</code></pre> </div>
<div class="TextHeading">
<div class="hddn">
<h2 id="output" class="color-purple">Output</h2>
</div>
</div>
<div class="Output">
<div class="hddn">
<figure class="highlight">
<pre><code class="hljs" data-lang=""><span class="nt">Created Linked List:
 2  2  1  8  2  3  2  7
Linked List after Deletion:
 1  8  3  7 </span></code></pre>
</figure>
</div>
</div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/data-structure/delete-all-occurrences-of-a-given-key-in-a-linked-list/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Inorder Tree Traversal without recursion and without stack ?</title>
		<link>https://www.wikitechy.com/interview-questions/data-structure/inorder-tree-traversal-without-recursion-and-without-stack/</link>
					<comments>https://www.wikitechy.com/interview-questions/data-structure/inorder-tree-traversal-without-recursion-and-without-stack/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 17:29:55 +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[binary search tree inorder traversal]]></category>
		<category><![CDATA[binary search tree traversal inorder preorder postorder example]]></category>
		<category><![CDATA[binary tree inorder traversal]]></category>
		<category><![CDATA[BMC Software interview questions and answers]]></category>
		<category><![CDATA[bst inorder traversal]]></category>
		<category><![CDATA[c# tree traversal without recursion]]></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[construct binary tree from preorder and inorder traversal]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[Genpact interview questions and answers]]></category>
		<category><![CDATA[Globallogic India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[inorder preorder postorder traversal]]></category>
		<category><![CDATA[inorder preorder postorder traversal examples pdf]]></category>
		<category><![CDATA[inorder preorder postorder traversal without recursion in c]]></category>
		<category><![CDATA[inorder traversal]]></category>
		<category><![CDATA[inorder traversal algorithm]]></category>
		<category><![CDATA[inorder traversal example]]></category>
		<category><![CDATA[inorder traversal iterative python]]></category>
		<category><![CDATA[inorder traversal java]]></category>
		<category><![CDATA[inorder traversal python]]></category>
		<category><![CDATA[inorder traversal with recursion]]></category>
		<category><![CDATA[inorder traversal without recursion]]></category>
		<category><![CDATA[inorder traversal without recursion and stack]]></category>
		<category><![CDATA[inorder traversal without recursion in c]]></category>
		<category><![CDATA[inorder traversal without recursion using stack in c]]></category>
		<category><![CDATA[inorder tree traversal]]></category>
		<category><![CDATA[inorder tree traversal without recursion]]></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[postorder traversal algorithm using stack]]></category>
		<category><![CDATA[postorder traversal without recursion]]></category>
		<category><![CDATA[preorder traversal without recursion]]></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[Tracxn Technologies Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[UnitedHealth Group interview questions and answers]]></category>
		<category><![CDATA[what is inorder traversal]]></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=507</guid>

					<description><![CDATA[Answer : To traverse the tree using Morris Traversal...
]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="inorder-tree-traversal-without-recursion-and-without-stack" class="color-pink" style="text-align: justify;">Inorder Tree Traversal without recursion and without stack ?</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>To traverse the tree using Morris Traversal is based on <a href="https://www.wikitechy.com/technology/threaded-binary-tree/" target="_blank" rel="noopener">Threaded Binary Tree</a> which means without using stack and recursion. In this traversal, we first create links to <a href="https://www.wikitechy.com/technology/python-program-inorder-successor-binary-search-tree/" target="_blank" rel="noopener">Inorder successor</a> and print the data using these links, and finally revert the changes to restore original tree.</li>
</ul>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li style="list-style-type: none;">
<ul>
<li>If current does not have left child
<ul>
<li>Print current’s data</li>
<li>Go to the right, i.e., current = current-&gt;right</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li style="list-style-type: none;">
<ul>
<li>Else
<ul>
<li>Make current as right child of the rightmost</li>
<li>node in current&#8217;s left subtree</li>
<li>Go to this left child, i.e., current = current-&gt;left</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>When the tree is modified through the traversal, it is reverted back to its original shape after the completion.</li>
<li>Unlike Stack based traversal, no extra space is required for this traversal.</li>
</ul>
</div>
</div>
<div class="read-also" style="text-align: justify;"></div>
<div class="text-center row" style="text-align: justify;"></div>
<div class="TextHeading">
<div class="hddn">
<h2 id="sample-code-in-c" class="color-red" style="text-align: justify;">Sample Code in C++</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">#include &lt;stdio.h&gt; <br/>#include &lt;stdlib.h&gt; <br/><br/>/* A binary tree tNode has data, pointer to left child <br/>and a pointer to right child */<br/>struct traversalNode { <br/>	int data; <br/>	struct traversalNode* left; <br/>	struct traversalNode* right; <br/>}; <br/><br/>/* Function to traverse binary tree without recursion and <br/>without stack */<br/>void MorrisTraversal(struct traversalNode* root) <br/>{ <br/>	struct traversalNode *current, *pre; <br/><br/>	if (root == NULL) <br/>		return; <br/><br/>	current = root; <br/>	while (current != NULL) { <br/><br/>		if (current-&gt;left == NULL) { <br/>			printf(&quot;%d &quot;, current-&gt;data); <br/>			current = current-&gt;right; <br/>		} <br/>		else { <br/><br/>			/* Find the inorder predecessor of current */<br/>			pre = current-&gt;left; <br/>			while (pre-&gt;right != NULL &amp;&amp; pre-&gt;right != current) <br/>				pre = pre-&gt;right; <br/><br/>			/* Make current as right child of its inorder <br/>			predecessor */<br/>			if (pre-&gt;right == NULL) { <br/>				pre-&gt;right = current; <br/>				current = current-&gt;left; <br/>			} <br/><br/>			/* Revert the changes made in if part to restore <br/>			the original tree i.e., fix the right child <br/>			of predecssor */<br/>			else { <br/>				pre-&gt;right = NULL; <br/>				printf(&quot;%d &quot;, current-&gt;data); <br/>				current = current-&gt;right; <br/>			} /* End of if condition pre-&gt;right == NULL */<br/>		} /* End of if condition current-&gt;left == NULL*/<br/>	} /* End of while */<br/>} <br/><br/>/* UTILITY FUNCTIONS */<br/>/* Helper function that allocates a new tNode with the <br/>given data and NULL left and right pointers. */<br/>struct traversalNode* newtraversalNode(int data) <br/>{ <br/>	struct traversalNode* node = new traversalNode; <br/>	node-&gt;data = data; <br/>	node-&gt;left = NULL; <br/>	node-&gt;right = NULL; <br/><br/>	return (node); <br/>} <br/><br/>/* Driver program to test above functions*/<br/>int main() <br/>{ <br/><br/>	/* Constructed binary tree is <br/>			12 <br/>		/ \ <br/>		13	 14 <br/>	/ \ <br/>	15	 16 <br/>*/<br/>	struct traversalNode* root = newtraversalNode(12); <br/>	root-&gt;left = newtraversalNode(13); <br/>	root-&gt;right = newtraversalNode(14); <br/>	root-&gt;left-&gt;left = newtraversalNode(15); <br/>	root-&gt;left-&gt;right = newtraversalNode(16); <br/><br/>	MorrisTraversal(root); <br/><br/>	return 0; <br/>} </code></pre> </div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="output" class="color-red">Output</h2>
</div>
</div>
<div class="Output" style="text-align: justify;">
<div class="hddn">
<figure class="highlight">
<pre><code class="hljs" data-lang=""><span class="nt">15 13 16 12 14 
</span></code></pre>
</figure>
</div>
</div>
<div class="Content">
<div class="hddn">
<ul>
<li style="text-align: justify;">Time Complexity : O(n) If we investigate, we can see that each edge of the tree is crossed at-most multiple times.</li>
<li style="text-align: justify;">Also, in most pessimistic scenario same number of additional edges (as info tree) are made and evacuated.</li>
</ul>
</div>
</div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/data-structure/inorder-tree-traversal-without-recursion-and-without-stack/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to make linked list program for the given list ?</title>
		<link>https://www.wikitechy.com/interview-questions/data-structure/how-to-make-linked-list-program-for-the-given-list/</link>
					<comments>https://www.wikitechy.com/interview-questions/data-structure/how-to-make-linked-list-program-for-the-given-list/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 17:24:03 +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[BMC Software interview questions and answers]]></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[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[doubly linked list implementation in java]]></category>
		<category><![CDATA[ecare technology labs interview questions and answers]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[Genpact interview questions and answers]]></category>
		<category><![CDATA[Globallogic India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[how to create a linked list in java]]></category>
		<category><![CDATA[how to create a node in linked list in java]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[insert a node at a specific position in a linked list in java]]></category>
		<category><![CDATA[insert node at beginning of linked list in java]]></category>
		<category><![CDATA[insert node at beginning of linked list java program]]></category>
		<category><![CDATA[insertion in linked list algorithm]]></category>
		<category><![CDATA[java program to insert a node at the end in linked list]]></category>
		<category><![CDATA[linked list add method implementation]]></category>
		<category><![CDATA[linked list data structure in java]]></category>
		<category><![CDATA[linked list implementation in java]]></category>
		<category><![CDATA[linked list in java]]></category>
		<category><![CDATA[linked list in java program]]></category>
		<category><![CDATA[linked list insertion]]></category>
		<category><![CDATA[linked list java]]></category>
		<category><![CDATA[linked list java code]]></category>
		<category><![CDATA[linked list java program]]></category>
		<category><![CDATA[linked list node java]]></category>
		<category><![CDATA[linked list program in java]]></category>
		<category><![CDATA[linked list program in java for insertion and deletion]]></category>
		<category><![CDATA[linked list program in java with explanation]]></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[SAP Labs India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Sapient Consulting Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[singly linked list algorithm]]></category>
		<category><![CDATA[singly linked list in data structure]]></category>
		<category><![CDATA[singly linked list java]]></category>
		<category><![CDATA[singly linked list program in java]]></category>
		<category><![CDATA[Tech Mahindra interview questions and answers]]></category>
		<category><![CDATA[Tracxn Technologies Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[UnitedHealth Group interview questions and answers]]></category>
		<category><![CDATA[user defined linked list in java]]></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=505</guid>

					<description><![CDATA[Answer : Linked List is a type of Linear Data Structure that is mostly used data structure....
]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="how-to-make-linked-list-program-for-the-given-list" class="color-pink" style="text-align: justify;">How to make linked list program for the given list ?</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li><a href="https://www.wikitechy.com/interview-questions/data-structure/what-is-linked-list-in-data-structure-with-example/" target="_blank" rel="noopener">Linked List</a> is a type of Linear <a href="https://www.wikitechy.com/interview-questions/data-structure/what-is-data-structure/" target="_blank" rel="noopener">Data Structure</a> that is mostly used data structure after array, which allocates memory dynamically at run time that is it doesn’t require any size initialization as in case of array.</li>
<li>Linked List stores data in the forms of nodes, which is divided into two parts, first part stores the data and second part points to the next node by storing the address of that node.</li>
<li>We have first node which contains Data and Address to next node, and similarly second and third node forming a chain.</li>
</ul>
</div>
</div>
<div class="ImageContent" style="text-align: justify;">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/interview-questions/data-structure/linked-list-in-data-structure.png" alt="Linked List in Data Structure" /></div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="syntax" class="color-blue">Syntax</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>To create code, pattern required is:</li>
</ul>
</div>
</div>
<div class="CodeContent" style="text-align: justify;">
<div class="hddn">
<figure class="highlight">
<pre><code id="code1" class="hljs javascript" data-lang=""><span class="nt">LinkedList&lt;<span class="hljs-built_in">String</span>&gt; linkedList=<span class="hljs-keyword">new</span> LinkedList&lt;<span class="hljs-built_in">String</span>&gt;()</span></code></pre>
</figure>
</div>
</div>
<div class="TextHeading">
<div class="hddn">
<h2 id="sample-code-in-java" class="color-purple" style="text-align: justify;">Sample Code in Java</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-java code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-java code-embed-code">import java.util.Iterator;<br/><br/>import java.util.LinkedList;					<br/><br/>public class LinkedListDemo <br/>{<br/><br/>  public static void main (String[] args) {<br/><br/>  LinkedList&lt;String&gt; linkedList=new LinkedList&lt;String&gt;();<br/><br/>  linkedList.add(&quot;java&quot;);<br/><br/>  linkedList.add(&quot;Is&quot;);<br/><br/>  linkedList.add(&quot;High&quot;);<br/><br/>  linkedList.add(&quot;Level&quot;);<br/><br/>  linkedList.add(&quot;Language&quot;);<br/><br/>  Iterator&lt;String&gt; itr=linkedList.iterator();<br/><br/>  while(itr.hasNext())<br/>  {<br/><br/>   System.out.print(itr.next());<br/><br/>   System.out.print(&quot;\t&quot;);<br/><br/>  }<br/><br/> }<br/><br/>}</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">java Is High Level Language</span></code></pre>
</figure>
</div>
</div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/data-structure/how-to-make-linked-list-program-for-the-given-list/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Difference between Array and Linked List ?</title>
		<link>https://www.wikitechy.com/interview-questions/data-structure/difference-between-array-and-linked-list/</link>
					<comments>https://www.wikitechy.com/interview-questions/data-structure/difference-between-array-and-linked-list/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 17:09:42 +0000</pubDate>
				<category><![CDATA[Data Structure]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></category>
		<category><![CDATA[advantages and disadvantages of linked list over array]]></category>
		<category><![CDATA[advantages of linked list over array]]></category>
		<category><![CDATA[Altimetrik India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Applied Materials interview questions and answers]]></category>
		<category><![CDATA[array and linked list]]></category>
		<category><![CDATA[array linked list]]></category>
		<category><![CDATA[array of linked list]]></category>
		<category><![CDATA[array of linked lists java]]></category>
		<category><![CDATA[array vs linked list]]></category>
		<category><![CDATA[array vs list c#]]></category>
		<category><![CDATA[arraylist and linked list]]></category>
		<category><![CDATA[arraylist and linkedlist]]></category>
		<category><![CDATA[arraylist and linkedlist in java]]></category>
		<category><![CDATA[arraylist linkedlist]]></category>
		<category><![CDATA[arraylist vs linkedlist]]></category>
		<category><![CDATA[arraylist vs linkedlist in java]]></category>
		<category><![CDATA[Bharti Airtel interview questions and answers]]></category>
		<category><![CDATA[BMC Software interview questions and answers]]></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[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[difference between array and arraylist]]></category>
		<category><![CDATA[difference between array and linked list]]></category>
		<category><![CDATA[difference between array and linked list in java]]></category>
		<category><![CDATA[difference between array and list]]></category>
		<category><![CDATA[difference between array and list c#]]></category>
		<category><![CDATA[difference between array and list in c++]]></category>
		<category><![CDATA[difference between array and list in java]]></category>
		<category><![CDATA[difference between array and list python]]></category>
		<category><![CDATA[difference between arraylist and linked list]]></category>
		<category><![CDATA[difference between arraylist and linkedlist]]></category>
		<category><![CDATA[difference between arraylist and linkedlist in java]]></category>
		<category><![CDATA[difference between singly linked list and doubly linked list]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[Genpact interview questions and answers]]></category>
		<category><![CDATA[Globallogic India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[infozech interview questions and answers]]></category>
		<category><![CDATA[java linkedlist vs arraylist]]></category>
		<category><![CDATA[linked list array]]></category>
		<category><![CDATA[linked list using array]]></category>
		<category><![CDATA[linked list vs array performance]]></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[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[Tracxn Technologies Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[UnitedHealth Group interview questions and answers]]></category>
		<category><![CDATA[what is the difference between array and pointer?]]></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=503</guid>

					<description><![CDATA[Answer : Arrays are index-based data structure...]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="difference-between-array-and-linked-list" class="color-pink">Difference between Array and Linked List ?</h2>
</div>
</div>
<div class="table-responsive">
<table class="table-bordered table-striped table table-responsive">
<tbody>
<tr>
<th>Array</th>
<th>Linked List</th>
</tr>
<tr>
<td class="text-leftalign">Arrays are index-based data structure where each element<br />
associated with an index.</td>
<td class="text-leftalign"><a href="https://www.wikitechy.com/technology/quicksort-doubly-linked-list-3/" target="_blank" rel="noopener">Linked list</a> relies on references where each node consists of the data and the references to the previous and next element (in case of a doubly linked list) or the next element (in case of a singly linked list).</td>
</tr>
<tr>
<td class="text-leftalign">Array provides fast and random access.</td>
<td class="text-leftalign">Elements can’t be accessed randomly but can be<br />
accessed only sequentially and accessing element takes 0(n) time.</td>
</tr>
<tr>
<td class="text-leftalign">Elements are stored in consecutive manner in memory.</td>
<td class="text-leftalign">Elements can be stored at any available place as<br />
address of node is stored in previous node.</td>
</tr>
<tr>
<td class="text-leftalign">Insertion &amp; deletion takes more time in array as elements<br />
are stored in consecutive memory locations.</td>
<td class="text-leftalign">Insertion &amp; deletion are fast &amp; easy in linked list<br />
as only value of pointer is needed to change.</td>
</tr>
<tr>
<td class="text-leftalign">In array, memory is allocated at compile time<br />
i.e. Static Memory Allocation.</td>
<td class="text-leftalign">Memory is allocated at run time<br />
i.e. Dynamic Memory Allocation.</td>
</tr>
<tr>
<td class="text-leftalign">Array can be single dimensional, two dimensional<br />
or multidimensional.</td>
<td class="text-leftalign">Linked list can be singly, doubly or circular<br />
linked list.</td>
</tr>
<tr>
<td class="text-leftalign">Each element is independent, no connection with previous<br />
element or with its location.</td>
<td class="text-leftalign">Location or address of elements is stored in the<br />
link part of previous element/node.</td>
</tr>
</tbody>
</table>
</div>
<div class="text-center row">
<div class="col-sm-12">
<div id="bsa-zone_1590522538159-8_123456"></div>
</div>
</div>
<div class="ImageContent">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/interview-questions/data-structure/difference-between-array-and-linked-list.jpg" alt="Difference between Array and Linked List" /></div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/data-structure/difference-between-array-and-linked-list/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Write a function to get the intersection point of two Linked Lists</title>
		<link>https://www.wikitechy.com/interview-questions/data-structure/write-a-function-to-get-the-intersection-point-of-two-linked-lists/</link>
					<comments>https://www.wikitechy.com/interview-questions/data-structure/write-a-function-to-get-the-intersection-point-of-two-linked-lists/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 17:04:15 +0000</pubDate>
				<category><![CDATA[Data Structure]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></category>
		<category><![CDATA[add two numbers represented by linked lists]]></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[BMC Software interview questions and answers]]></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[compro technologies interview questions and answers]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[detect loop in linked list]]></category>
		<category><![CDATA[find the merge point of two linked lists in c++]]></category>
		<category><![CDATA[find the merge point of two linked lists in data structure]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[Genpact interview questions and answers]]></category>
		<category><![CDATA[Globallogic India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[how to move a node in a linked list java]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[intersection of two linked lists]]></category>
		<category><![CDATA[intersection of two linked lists c++]]></category>
		<category><![CDATA[intersection of two linked lists in c]]></category>
		<category><![CDATA[intersection of two lists java]]></category>
		<category><![CDATA[intersection point in y shapped linked lists]]></category>
		<category><![CDATA[list intersection c++]]></category>
		<category><![CDATA[merge sort for linked list]]></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[pairwise swap of a linked list]]></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[swap nodes doubly linked list c++]]></category>
		<category><![CDATA[Tech Mahindra interview questions and answers]]></category>
		<category><![CDATA[Tracxn Technologies Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[union and intersection of two linked lists in c++]]></category>
		<category><![CDATA[union and intersection of two linked lists in python]]></category>
		<category><![CDATA[union and intersection of two linked lists using c++]]></category>
		<category><![CDATA[union find linked list java]]></category>
		<category><![CDATA[union of two linked lists c++]]></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=501</guid>

					<description><![CDATA[Answer : Intersection point means end of one linked list is linked..]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="write-a-function-to-get-the-intersection-point-of-two-linked-lists" class="color-pink" style="text-align: justify;">Write a function to get the intersection point of two Linked Lists</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Intersection point means end of one <a href="https://www.wikitechy.com/tutorials/csharp/csharp-linked-list" target="_blank" rel="noopener">linked list</a> is linked with some node in another linked list.</li>
</ul>
</div>
</div>
<div class="ImageContent" style="text-align: justify;">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/interview-questions/data-structure/intersection-linked-list.png" alt=" data- linked-list" /></div>
</div>
<p style="text-align: justify;">Given two Linked Lists, create intersection lists that contain intersection of the elements present in the given lists.</p>
<div class="TextHeading">
<div class="hddn">
<h2 id="example" class="color-pink" style="text-align: justify;">Example</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-markdown code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-markdown code-embed-code">Input:<br/>   List1: 20-&gt;25-&gt;4-&gt;30<br/>   lsit2:  8-&gt;4-&gt;2-&gt;20<br/>Output:<br/>   Intersection List: 4-&gt;20</code></pre> </div>
<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">/ C program to get intersection point of two linked list  <br/>#include&lt;stdio.h&gt; <br/>#include&lt;stdlib.h&gt; <br/>  <br/>/* Link list node */<br/>struct Node <br/>{ <br/>  int data; <br/>  struct Node* next; <br/>}; <br/>  <br/>/* Function to get the counts of node in a linked list */<br/>int getCount(struct Node* head); <br/>  <br/>/* function to get the intersection point of two linked <br/>   lists head1 and head2 where head1 has d more nodes than <br/>   head2 */<br/>int _getIntesectionNode(int d, struct Node* head1, struct Node* head2); <br/>  <br/>/* function to get the intersection point of two linked <br/>   lists head1 and head2 */<br/>int getIntesectionNode(struct Node* head1, struct Node* head2) <br/>{ <br/>  int c1 = getCount(head1); <br/>  int c2 = getCount(head2); <br/>  int d; <br/>  <br/>  if(c1 &gt; c2) <br/>  { <br/>    d = c1 - c2; <br/>    return _getIntesectionNode(d, head1, head2); <br/>  } <br/>  else<br/>  { <br/>    d = c2 - c1; <br/>    return _getIntesectionNode(d, head2, head1); <br/>  } <br/>} <br/>  <br/>/* function to get the intersection point of two linked <br/>   lists head1 and head2 where head1 has d more nodes than <br/>   head2 */<br/>int _getIntesectionNode(int d, struct Node* head1, struct Node* head2) <br/>{ <br/>  int i; <br/>  struct Node* current1 = head1; <br/>  struct Node* current2 = head2; <br/>  <br/>  for(i = 0; i &lt; d; i++) <br/>  { <br/>    if(current1 == NULL) <br/>    {  return -1; } <br/>    current1 = current1-&gt;next; <br/>  } <br/>  <br/>  while(current1 !=  NULL &amp;&amp; current2 != NULL) <br/>  { <br/>    if(current1 == current2) <br/>      return current1-&gt;data; <br/>    current1= current1-&gt;next; <br/>    current2= current2-&gt;next; <br/>  } <br/>  <br/>  return -1; <br/>} <br/>  <br/>/* Takes head pointer of the linked list and <br/>   returns the count of nodes in the list */<br/>int getCount(struct Node* head) <br/>{ <br/>  struct Node* current = head; <br/>  int count = 0; <br/>  <br/>  while (current != NULL) <br/>  { <br/>    count++; <br/>    current = current-&gt;next; <br/>  } <br/>  <br/>  return count; <br/>} <br/>  <br/>/* IGNORE THE BELOW LINES OF CODE. THESE LINES <br/>   ARE JUST TO QUICKLY TEST THE ABOVE FUNCTION */<br/>int main() <br/>{ <br/>  /* <br/>    Create two linked lists <br/>  <br/>    1st 3-&gt;6-&gt;9-&gt;15-&gt;30 <br/>    2nd 10-&gt;15-&gt;30 <br/>  <br/>    15 is the intersection point <br/>  */<br/>  <br/>  struct Node* newNode; <br/>  struct Node* head1 = <br/>            (struct Node*) malloc(sizeof(struct Node)); <br/>  head1-&gt;data  = 10; <br/>  <br/>  struct Node* head2 = <br/>            (struct Node*) malloc(sizeof(struct Node)); <br/>  head2-&gt;data  = 3; <br/>  <br/>  newNode = (struct Node*) malloc (sizeof(struct Node)); <br/>  newNode-&gt;data = 6; <br/>  head2-&gt;next = newNode; <br/>  <br/>  newNode = (struct Node*) malloc (sizeof(struct Node)); <br/>  newNode-&gt;data = 9; <br/>  head2-&gt;next-&gt;next = newNode; <br/>  <br/>  newNode = (struct Node*) malloc (sizeof(struct Node)); <br/>  newNode-&gt;data = 15; <br/>  head1-&gt;next = newNode; <br/>  head2-&gt;next-&gt;next-&gt;next  = newNode; <br/>  <br/>  newNode = (struct Node*) malloc (sizeof(struct Node)); <br/>  newNode-&gt;data = 30; <br/>  head1-&gt;next-&gt;next= newNode; <br/>  <br/>  head1-&gt;next-&gt;next-&gt;next = NULL; <br/>  <br/>  printf(&quot;\n The node of intersection is %d \n&quot;, <br/>          getIntesectionNode(head1, head2)); <br/>  <br/>  getchar(); <br/>} </code></pre> </div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="code-explanation" class="color-purple">Code Explanation :</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Get count of the nodes in the first list, let count be c1.</li>
<li>Get count of the nodes in the second list, let count be c2.</li>
<li>Get the difference of counts d = abs (c1 &#8211; c2)</li>
<li>Now traverse the bigger list from the first node till d nodes so that from here onwards both the lists have equal no of nodes.</li>
<li>Then we can traverse both the lists in parallel till we come across a common node. (Note that getting a common node is done by comparing the address of the nodes)</li>
</ul>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<p align="justify">Time Complexity: O(m+n)<br />
Auxiliary Space: O(1)</p>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="output" class="color-blue">Output :</h2>
</div>
</div>
<div class="Output">
<div class="hddn">
<figure class="highlight" style="text-align: justify;">
<pre><code class="hljs javascript" data-lang=""><span class="nt">The node <span class="hljs-keyword">of</span> intersection is <span class="hljs-number">15</span></span></code></pre>
</figure>
</div>
</div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/data-structure/write-a-function-to-get-the-intersection-point-of-two-linked-lists/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to delete an element in a linked list ?</title>
		<link>https://www.wikitechy.com/interview-questions/data-structure/how-to-delete-an-element-in-a-linked-list/</link>
					<comments>https://www.wikitechy.com/interview-questions/data-structure/how-to-delete-an-element-in-a-linked-list/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 16:57:20 +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[BMC Software interview questions and answers]]></category>
		<category><![CDATA[c program to delete first node in linked list]]></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[compro technologies interview questions and answers]]></category>
		<category><![CDATA[delete a node from linked list algorithm]]></category>
		<category><![CDATA[delete a node in linked list with single pointer]]></category>
		<category><![CDATA[delete a specific node in linked list c++]]></category>
		<category><![CDATA[delete first node in linked list c++]]></category>
		<category><![CDATA[delete node at given position in a linked list]]></category>
		<category><![CDATA[delete node at given position in a linked list c++]]></category>
		<category><![CDATA[delete node at given position in a linked list in c++]]></category>
		<category><![CDATA[delete node linked list c++]]></category>
		<category><![CDATA[deletion in linked list in data structure]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[Genpact interview questions and answers]]></category>
		<category><![CDATA[Globallogic India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[linked list delete node c++]]></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[remove element from linked list c++]]></category>
		<category><![CDATA[remove middle element linked list c++]]></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[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=499</guid>

					<description><![CDATA[Answer : To delete a node from linked list....]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="how-to-delete-an-element-in-a-linked-list" class="color-pink" style="text-align: justify;">How to delete an element in a linked list ?</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>To delete a node from <a href="https://www.wikitechy.com/tutorials/java/java-linked-list" target="_blank" rel="noopener">linked list</a>, we need to do following steps:
<ul>
<li>Find previous node of the node to be deleted.</li>
<li>Change the next of previous node.</li>
<li>Free memory for the node to be deleted</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="ImageContent" style="text-align: justify;">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/interview-questions/data-structure/linkedlist-deletion.png" alt=" " /></div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="example" class="color-purple">Example</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-markdown code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-markdown code-embed-code">Input: position = 1, Linked List = 9-&gt;2-&gt;3-&gt;7-&gt;6<br/>Output: Linked List =  9-&gt;3-&gt;7-&gt;6<br/><br/>Input: position = 0, Linked List = 9-&gt;2-&gt;3-&gt;7-&gt;6<br/>Output: Linked List = 2-&gt;3-&gt;7-&gt;6</code></pre> </div>
<h2 id="sample-code" class="color-purple">Sample code</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-java code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-java code-embed-code">#include &lt;stdio.h&gt; <br/>#include &lt;stdlib.h&gt; <br/><br/>// A linked list node <br/>struct Node <br/>{ <br/>	int data; <br/>	struct Node *next; <br/>}; <br/><br/>/* Given a reference (pointer to pointer) to the head of a list <br/>and an int, inserts a new node on the front of the list. */<br/>void push(struct Node** head_ref, int new_data) <br/>{ <br/>	struct Node* new_node = (struct Node*) malloc(sizeof(struct Node)); <br/>	new_node-&gt;data = new_data; <br/>	new_node-&gt;next = (*head_ref); <br/>	(*head_ref) = new_node; <br/>} <br/><br/>/* Given a reference (pointer to pointer) to the head of a list <br/>and a position, deletes the node at the given position */<br/>void deleteNode(struct Node **head_ref, int position) <br/>{ <br/>// If linked list is empty <br/>if (*head_ref == NULL) <br/>	return; <br/><br/>// Store head node <br/>struct Node* temp = *head_ref; <br/><br/>	// If head needs to be removed <br/>	if (position == 0) <br/>	{ <br/>		*head_ref = temp-&gt;next; // Change head <br/>		free(temp);			 // free old head <br/>		return; <br/>	} <br/><br/>	// Find previous node of the node to be deleted <br/>	for (int i=0; temp!=NULL &amp;&amp; i&lt;position-1; i++) <br/>		temp = temp-&gt;next; <br/><br/>	// If position is more than number of ndoes <br/>	if (temp == NULL || temp-&gt;next == NULL) <br/>		return; <br/><br/>	// Node temp-&gt;next is the node to be deleted <br/>	// Store pointer to the next of node to be deleted <br/>	struct Node *next = temp-&gt;next-&gt;next; <br/><br/>	// Unlink the node from linked list <br/>	free(temp-&gt;next); // Free memory <br/><br/>	temp-&gt;next = next; // Unlink the deleted node from list <br/>} <br/><br/>// This function prints contents of linked list starting from <br/>// the given node <br/>void printList(struct Node *node) <br/>{ <br/>	while (node != NULL) <br/>	{ <br/>		printf(&quot; %d &quot;, node-&gt;data); <br/>		node = node-&gt;next; <br/>	} <br/>} <br/><br/>/* Drier program to test above functions*/<br/>int main() <br/>{ <br/>	/* Start with the empty list */<br/>	struct Node* head = NULL; <br/><br/>	push(&amp;head, 6); <br/>	push(&amp;head, 7); <br/>	push(&amp;head, 3); <br/>	push(&amp;head, 2); <br/>	push(&amp;head, 9); <br/><br/>	puts(&quot;Created Linked List: &quot;); <br/>	printList(head); <br/>	deleteNode(&amp;head, 4); <br/>	puts(&quot;\nLinked List after Deletion at position 4: &quot;); <br/>	printList(head); <br/>	return 0; <br/>}</code></pre> </div>
<h2 id="output" class="color-purple">Output:</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-markdown code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-markdown code-embed-code">Created Linked List: <br/> 9  2  3  7  6 <br/>Linked List after Deletion at position 4: <br/> 9  2  3  7</code></pre> </div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/data-structure/how-to-delete-an-element-in-a-linked-list/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to detect a cycle in a linked list ?</title>
		<link>https://www.wikitechy.com/interview-questions/data-structure/how-to-detect-a-cycle-in-a-linked-list/</link>
					<comments>https://www.wikitechy.com/interview-questions/data-structure/how-to-detect-a-cycle-in-a-linked-list/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 16:48:05 +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[BMC Software interview questions and answers]]></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[circular linked list java]]></category>
		<category><![CDATA[Collabera Te interview questions and answers]]></category>
		<category><![CDATA[Comodo India Interview Questions and Answers]]></category>
		<category><![CDATA[cycle detection linked list]]></category>
		<category><![CDATA[cycle detection solution]]></category>
		<category><![CDATA[cycle detection solution c++]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[find cycle in linked list]]></category>
		<category><![CDATA[find length of loop in linked list]]></category>
		<category><![CDATA[find loop in linked list]]></category>
		<category><![CDATA[find start of loop in linked list]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[floyd's cycle detection algorithm]]></category>
		<category><![CDATA[floyd's cycle finding algorithm]]></category>
		<category><![CDATA[floyd's cycle-finding algorithm c++]]></category>
		<category><![CDATA[Genpact interview questions and answers]]></category>
		<category><![CDATA[given a linked list]]></category>
		<category><![CDATA[Globallogic India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[leetcode sort linked list]]></category>
		<category><![CDATA[link cycle]]></category>
		<category><![CDATA[linked list]]></category>
		<category><![CDATA[linked list cycle]]></category>
		<category><![CDATA[linked list in data structure]]></category>
		<category><![CDATA[linked lists detect a cycle]]></category>
		<category><![CDATA[list cycle]]></category>
		<category><![CDATA[Mphasis interview questions and answers]]></category>
		<category><![CDATA[n'th node from end of linked list]]></category>
		<category><![CDATA[nested loops java]]></category>
		<category><![CDATA[NetApp interview questions and answers]]></category>
		<category><![CDATA[Oracle Corporation interview questions and answers]]></category>
		<category><![CDATA[python linked list cycle]]></category>
		<category><![CDATA[remove loop in linked list]]></category>
		<category><![CDATA[return the node where the cycle begins. if there is no cycle]]></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[Tracxn Technologies Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[UnitedHealth Group interview questions and answers]]></category>
		<category><![CDATA[what is linked list in data structure]]></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=497</guid>

					<description><![CDATA[Answer : A linked list is said to contain a cycle ...]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="how-to-detect-a-cycle-in-a-linked-list" class="color-pink" style="text-align: justify;">How to detect a cycle in a linked list ?</h2>
<ul style="text-align: justify;">
<li>A <a href="https://www.wikitechy.com/technology/circular-linked-list-introduction-applications/" target="_blank" rel="noopener">linked list</a> is said to contain a cycle if any node is visited more than once.</li>
</ul>
</div>
</div>
<div class="ImageContent" style="text-align: justify;">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/interview-questions/data-structure/how-to-detect-a-cycle-in-a-linked-list.png" alt="How do you detect a cycle in a linked list" /></div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="method-1-using-hashing" class="color-green">Method 1 &#8211; Using Hashing</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Traverse the given list.</li>
<li>Insert each encountered node into a <a href="https://www.wikitechy.com/tutorials/java/java-hash-table" target="_blank" rel="noopener">hash table</a>.</li>
<li>If the current already present ,that means the cycle is present or not.</li>
</ul>
</div>
</div>
<div class="TextHeading">
<div class="hddn">
<h2 id="sample-code" class="color-blue" style="text-align: justify;">Sample code</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-java code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-java code-embed-code">#include &lt;iostream&gt;<br/>#include &lt;unordered_set&gt;<br/>using namespace std;<br/><br/>// Data Structure to store a linked list node<br/>struct Node<br/>{<br/>    int dt;<br/>    Node* next;<br/>};<br/><br/>// Helper function to create a new node with the given data and<br/>// pushes it onto the front of the list<br/>void push(Node*&amp; headRef, int dt)<br/>{<br/>    // create a new linked list node from heap<br/>    Node* newNode = new Node;<br/><br/>    newNode-&gt;dt = dt;<br/>    newNode-&gt;next = headRef;<br/>    headRef = newNode;<br/>}<br/><br/>// Function to detect Cycle in a linked list using Hashing<br/>bool detectcyc(Node *head)<br/>{<br/>    Node *current = head;<br/>    unordered_set&lt;Node*&gt; set;<br/><br/>    // traverse the list<br/>    while (current)<br/>    {<br/>        // return false if we already have seen this node before<br/>        if (set.find(current) != set.end())<br/>            return true;<br/><br/>        // insert current node into the set<br/>        set.insert(current);<br/><br/>        // move to the next node<br/>        current = current-&gt;next;<br/>    }<br/><br/>    // we reach here if list does not contain any cycle<br/>    return false;<br/>}<br/><br/>// Detect Cycle in a linked list<br/>int main()<br/>{<br/>    // input keys<br/>    int k[] = { 1, 2, 3, 4, 5 };<br/>    int n = sizeof(k) / sizeof(k[0]);<br/><br/>    Node* head = nullptr;<br/>    for (int i = n - 1; i &gt;= 0; i--)<br/>        push(head, k[i]);<br/><br/>    // insert cycle<br/>    head-&gt;next-&gt;next-&gt;next-&gt;next-&gt;next = head-&gt;next-&gt;next;<br/><br/>    if (detectcyc(head))<br/>        cout &lt;&lt; &quot;Cycle Found&quot;;<br/>    else<br/>        cout &lt;&lt; &quot;No Cycle Found&quot;;<br/><br/>    return 0;<br/>}</code></pre> </div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="output" class="color-blue">Output</h2>
</div>
</div>
<div class="Output" style="text-align: justify;">
<div class="hddn">
<figure class="highlight">
<pre><code class="hljs" data-lang=""><span class="nt">Cycle Found
</span></code></pre>
</figure>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="method-2-floyds-cycle-detection-algorithm" class="color-green">Method 2 &#8211; Floyd’s Cycle Detection Algorithm</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Use two pointers, which move through the sequence at different speed.</li>
<li>The fast <a href="https://www.wikitechy.com/tutorials/c++/c++-pointers-to-structure" target="_blank" rel="noopener">pointer</a> moves twice as quickly as the slow pointer.</li>
<li>Here the distance between the two pointers increased by 1 at each step.</li>
<li>If these <a href="https://www.wikitechy.com/tutorials/c++/pointer-to-array-in-c++" target="_blank" rel="noopener">pointers</a> meet at same node then there is a loop else <a href="https://www.wikitechy.com/technology/sorted-insert-circular-linked-list-2/" target="_blank" rel="noopener">linked list</a> doesn’t have loop.</li>
</ul>
</div>
</div>
<div class="TextHeading">
<div class="hddn">
<h2 id="sample-code-2" class="color-blue" style="text-align: justify;">Sample Code</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-java code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-java code-embed-code">#include &lt;iostream&gt;<br/>#include &lt;unordered_set&gt;<br/>using namespace std;<br/><br/>// Data Structure to store a linked list node<br/>struct Node<br/>{<br/>    int dt;<br/>    Node* next;<br/>};<br/><br/>// Helper function to create a new node with the given data and<br/>// pushes it onto the front of the list<br/>void push(Node*&amp; headRef, int dt)<br/>{<br/>    // create a new linked list node from heap<br/>    Node* nNode = new Node;<br/><br/>    nNode-&gt;dt = dt;<br/>    nNode-&gt;next = headRef;<br/>    headRef = nNode;<br/>}<br/><br/>// Function to detect Cycle in a linked list using<br/>// Floyd’s Cycle Detection Algorithm<br/>bool dcycle(Node *head)<br/>{<br/>    // take two pointers - slow and fast<br/>    Node *slow = head, *fast = head;<br/><br/>    while (fast &amp;&amp; fast-&gt;next)<br/>    {<br/>        // move slow by one pointer<br/>        slow = slow-&gt;next;<br/><br/>        // move fast by two pointers<br/>        fast = fast-&gt;next-&gt;next;<br/><br/>        // if they meet any any node, linked list contains a cycle<br/>        if (slow == fast)<br/>            return true;<br/>    }<br/><br/>    // we reach here if slow &amp; fast pointer do not meet<br/>    return false;<br/>}<br/><br/>// Detect Cycle in a linked list using Floyd’s Cycle Detection Algorithm<br/>int main()<br/>{<br/>    // input keys<br/>    int k[] = { 1, 2, 3, 4, 5 };<br/>    int n = sizeof(k) / sizeof(k[0]);<br/><br/>    Node* head = nullptr;<br/>    for (int i = n - 1; i &gt;= 0; i--)<br/>        push(head, k[i]);<br/><br/>    // insert cycle<br/>    head-&gt;next-&gt;next-&gt;next-&gt;next-&gt;next = head-&gt;next-&gt;next;<br/><br/>    if (dcycle(head))<br/>        cout &lt;&lt; &quot;Cycle Found&quot;;<br/>    else<br/>        cout &lt;&lt; &quot;No Cycle Found&quot;;<br/><br/>    return 0;<br/>}</code></pre> </div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="output-2" class="color-blue">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">Cycle Found</span></code></pre>
</figure>
</div>
</div>
</div>
</div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/data-structure/how-to-detect-a-cycle-in-a-linked-list/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What is Binary Tree in Data Structures ?</title>
		<link>https://www.wikitechy.com/interview-questions/data-structure/what-is-binary-tree-in-data-structures/</link>
					<comments>https://www.wikitechy.com/interview-questions/data-structure/what-is-binary-tree-in-data-structures/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 16:37:21 +0000</pubDate>
				<category><![CDATA[Data Structure]]></category>
		<category><![CDATA[a full binary tree with n leaves contains]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></category>
		<category><![CDATA[almost complete binary tree]]></category>
		<category><![CDATA[Altimetrik India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Applied Materials interview questions and answers]]></category>
		<category><![CDATA[array to bst]]></category>
		<category><![CDATA[b tree in data structure]]></category>
		<category><![CDATA[Bharti Airtel interview questions and answers]]></category>
		<category><![CDATA[binary search tree example]]></category>
		<category><![CDATA[binary search tree in data structure]]></category>
		<category><![CDATA[binary tree]]></category>
		<category><![CDATA[binary tree example]]></category>
		<category><![CDATA[binary tree in data structure program]]></category>
		<category><![CDATA[binary tree properties]]></category>
		<category><![CDATA[binary treetypes of binary tree]]></category>
		<category><![CDATA[BMC Software interview questions and answers]]></category>
		<category><![CDATA[bst deletion]]></category>
		<category><![CDATA[bst in data structure]]></category>
		<category><![CDATA[bst java]]></category>
		<category><![CDATA[bst traversal]]></category>
		<category><![CDATA[bst tree]]></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[Comodo India Interview Questions and Answers]]></category>
		<category><![CDATA[complete binary tree in data structure]]></category>
		<category><![CDATA[complete binary tree properties]]></category>
		<category><![CDATA[data tree]]></category>
		<category><![CDATA[database tree structure]]></category>
		<category><![CDATA[define bst]]></category>
		<category><![CDATA[define tree in data structure]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[difference between binary tree and complete binary tree]]></category>
		<category><![CDATA[extended binary tree]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[full binary tree]]></category>
		<category><![CDATA[full binary tree number of nodes]]></category>
		<category><![CDATA[Genpact interview questions and answers]]></category>
		<category><![CDATA[Globallogic India Pvt Ltd interview questions and answers]]></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[perfect binary tree]]></category>
		<category><![CDATA[properties of binary search tree]]></category>
		<category><![CDATA[properties of binary search tree in data structure]]></category>
		<category><![CDATA[properties of binary tree]]></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[strictly binary tree]]></category>
		<category><![CDATA[Tech Mahindra interview questions and answers]]></category>
		<category><![CDATA[Tracxn Technologies Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[tree algorithms]]></category>
		<category><![CDATA[tree data structure]]></category>
		<category><![CDATA[tree structure]]></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=495</guid>

					<description><![CDATA[Answer : Binary tree is a special type of data structure...]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="what-is-binary-tree-in-data-structures" class="color-pink">What is Binary Tree in Data Structures ?</h2>
</div>
</div>
<div class="Content">
<div class="hddn">
<ul>
<li><a href="https://www.wikitechy.com/technology/c-program-lowest-common-ancestor-binary-search-tree/" target="_blank" rel="noopener">Binary tree</a> is a special type of <a href="https://www.wikitechy.com/technology/applications-tree-data-structure/" target="_blank" rel="noopener">data structure</a>. In binary tree, every node can have a maximum of 2 children, which are known as Left child and Right Child.</li>
<li>It is a method of placing and locating the records in a database, especially when all the data is known to be in random access memory (RAM).</li>
<li>A <a href="https://www.wikitechy.com/technology/c-program-check-binary-tree-bst-not/" target="_blank" rel="noopener">binary tree</a> has the benefits of both an ordered array and a linked list as search is as quick as in a <a href="https://www.wikitechy.com/technology/algorithm-in-c-median-of-two-sorted-arrays/" target="_blank" rel="noopener">sorted array</a> and insertion or deletion operation are as fast as in linked list.</li>
</ul>
</div>
</div>
<div class="ImageContent">
<div class="hddn"><img decoding="async" class="img-responsive center-block" src="https://cdn.wikitechy.com/interview-questions/data-structure/what-is-binary-tree-in-data-structures.jpg" alt="What is Binary Tree in Data Structures" /></div>
</div>
<div class="TextHeading">
<div class="hddn">
<h2 id="representation-of-binary-tree-using-array" class="color-green">Representation of Binary Tree using Array</h2>
</div>
</div>
<ul>
<li><a href="https://www.wikitechy.com/interview-questions/data-structure/if-the-depth-of-a-tree-is-3-levels-then-what-is-the-size-of-the-tree/" target="_blank" rel="noopener">Binary tree</a> using array represents a node which is numbered sequentially level by level from left to right. Even empty nodes are numbered.</li>
</ul>
<div class="TextHeading">
<div class="hddn">
<h2 id="sample-code" class="color-blue">Sample Code</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-javascript code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-javascript code-embed-code">// JAVA implementation of tree using array <br/>// numbering starting from 0 to n-1. <br/>import java.util.*;<br/>import java.lang.*;<br/>import java.io.*;<br/><br/>class bTree {<br/>    public static void main(String[] args) {<br/>        btree_Array obj = new btree_Array();<br/>        obj.Root(&quot;P&quot;);<br/>        // obj.set_Left(&quot;Q&quot;, 0); <br/>        obj.set_Right(&quot;R&quot;, 0);<br/>        obj.set_Left(&quot;S&quot;, 1);<br/>        obj.set_Right(&quot;T&quot;, 1);<br/>        obj.set_Left(&quot;U&quot;, 2);<br/>        obj.print_Tree();<br/>    }<br/>}<br/><br/>class btree_Array {<br/>    static int root = 0;<br/>    static String[] s = new String[10];<br/><br/>    /*create root*/<br/>    public void Root(String key) {<br/>        s[0] = key;<br/>    }<br/><br/>    /*create left son of root*/<br/>    public void set_Left(String key, int root) {<br/>        int t = (root * 2) + 1;<br/><br/>        if (s[root] == null) {<br/>            System.out.printf(&quot;Can&#039;t set child at %d, no parent found\n&quot;, t);<br/>        } else {<br/>            s[t] = key;<br/>        }<br/>    }<br/><br/>    /*create right son of root*/<br/>    public void set_Right(String key, int root) {<br/>        int t = (root * 2) + 2;<br/><br/>        if (s[root] == null) {<br/>            System.out.printf(&quot;Can&#039;t set child at %d, no parent found\n&quot;, t);<br/>        } else {<br/>            s[t] = key;<br/>        }<br/>    }<br/><br/>    public void print_Tree() {<br/>        for (int i = 0; i &lt; 10; i++) {<br/>            if (s[i] != null)<br/>                System.out.print(s[i]);<br/>            else<br/>                System.out.print(&quot;-&quot;);<br/><br/>        }<br/>    }<br/>}</code></pre> </div>
<h2 id="output" class="color-purple">Output</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-javascript code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-javascript code-embed-code">Can&#039;t set child at 3, no parent found<br/>Can&#039;t set child at 4, no parent found<br/>P-R--U----</code></pre> </div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/data-structure/what-is-binary-tree-in-data-structures/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What is Linked List in Data Structure with example ?</title>
		<link>https://www.wikitechy.com/interview-questions/data-structure/what-is-linked-list-in-data-structure-with-example/</link>
					<comments>https://www.wikitechy.com/interview-questions/data-structure/what-is-linked-list-in-data-structure-with-example/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 15:28:48 +0000</pubDate>
				<category><![CDATA[Data Structure]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></category>
		<category><![CDATA[algorithm for creation of singly linked list in data structure]]></category>
		<category><![CDATA[Altimetrik India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Apostek Software Interview Questions and Answers]]></category>
		<category><![CDATA[application of linked list in data structure]]></category>
		<category><![CDATA[Applied Materials interview questions and answers]]></category>
		<category><![CDATA[Bharti Airtel interview questions and answers]]></category>
		<category><![CDATA[BMC Software interview questions and answers]]></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[circular linked list in data structure]]></category>
		<category><![CDATA[circular linked list in data structure program]]></category>
		<category><![CDATA[Collabera Te interview questions and answers]]></category>
		<category><![CDATA[data structure projects using linked list]]></category>
		<category><![CDATA[deletion in linked list in data structure]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[doubly linked list]]></category>
		<category><![CDATA[doubly linked list deletion]]></category>
		<category><![CDATA[doubly linked list in c]]></category>
		<category><![CDATA[doubly linked list in c++ source code]]></category>
		<category><![CDATA[doubly linked list in data structure]]></category>
		<category><![CDATA[doubly linked list insertion]]></category>
		<category><![CDATA[doubly linked list java]]></category>
		<category><![CDATA[doubly linked list program in data structure]]></category>
		<category><![CDATA[example of linked list in data structure]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[Genpact interview questions and answers]]></category>
		<category><![CDATA[Globallogic India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[insertion and deletion in linked list in data structure]]></category>
		<category><![CDATA[java linked list traversal]]></category>
		<category><![CDATA[linked list algorithm in data structure]]></category>
		<category><![CDATA[linked list c]]></category>
		<category><![CDATA[linked list data structure in c]]></category>
		<category><![CDATA[linked list data structure in java]]></category>
		<category><![CDATA[linked list in data structure]]></category>
		<category><![CDATA[linked list in data structure using c]]></category>
		<category><![CDATA[linked list insertion]]></category>
		<category><![CDATA[linked list program in data structure]]></category>
		<category><![CDATA[linked lists java]]></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[SAP Labs India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Sapient Consulting Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[singly linked list algorithm]]></category>
		<category><![CDATA[singly linked list algorithm in data structure]]></category>
		<category><![CDATA[singly linked list c++]]></category>
		<category><![CDATA[singly linked list in data structure]]></category>
		<category><![CDATA[singly linked list in data structure program]]></category>
		<category><![CDATA[singly linked list java]]></category>
		<category><![CDATA[singly linked list program in c]]></category>
		<category><![CDATA[singly linked list program in data structure]]></category>
		<category><![CDATA[Tech Mahindra interview questions and answers]]></category>
		<category><![CDATA[Tracxn Technologies Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[types of linked list]]></category>
		<category><![CDATA[types of linked list in data structure]]></category>
		<category><![CDATA[UnitedHealth Group interview questions and answers]]></category>
		<category><![CDATA[what is linked list in data structure]]></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=493</guid>

					<description><![CDATA[Answer : A linked list is a sequence of data structures, which are connected...]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="what-is-linked-list-in-data-structure-with-example" class="color-pink" style="text-align: justify;">What is Linked List in Data Structure with example ?</h2>
</div>
</div>
<div class="Content">
<div class="hddn">
<ul style="text-align: justify;">
<li>A linked list is a sequence of <a href="https://www.wikitechy.com/interview-questions/data-structure/what-is-data-structure/" target="_blank" rel="noopener">data structures</a>, which are connected together through links.</li>
<li><a href="https://www.wikitechy.com/tutorials/java/java-linked-list" target="_blank" rel="noopener">Linked List</a> is a sequence of links which contains objects. Each link contains a connection to another link. Linked list is the second most-used data structure after array.
<ul>
<li><b>Link − </b>Each link of a linked list can store a data called an element.</li>
<li><b>Next − </b>Each link of a linked list contains a link to the next link called Next.</li>
<li><b>LinkedList −</b> A Linked List contains the connection link to the first link called First.</li>
</ul>
</li>
</ul>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>A linked list consists of nodes where each node contains a data field and a reference(link) to the next node in the list.</li>
</ul>
</div>
</div>
<div class="ImageContent">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/interview-questions/data-structure/linked-list-in-data-structure.png" alt="Linked List in Data Structure" /></div>
<div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="types-of-linked-lists" class="color-purple">Types of Linked Lists</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Singly linked list</li>
<li>Doubly linked list</li>
<li>Circular linked list</li>
</ul>
</div>
</div>
<div class="subheading" style="text-align: justify;">
<h2 id="singly-linked-list">Singly linked list</h2>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>A <a href="https://www.wikitechy.com/technology/python-programming-select-random-node-singly-linked-list/">singly linked list</a> is Item navigation is forward only.</li>
</ul>
</div>
</div>
<div class="ImageContent" style="text-align: justify;">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/interview-questions/data-structure/singly-linked-list.png" alt="Singly Linked List" /></div>
</div>
<div class="subheading" style="text-align: justify;">
<h2 id="doubly-linked-list">Doubly linked list</h2>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>A doubly linked list is a list that has two references, one to the next node and another to previous node.</li>
</ul>
</div>
</div>
<div class="ImageContent">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/interview-questions/data-structure/doubly-linked-list.gif" alt="Doubly linked list" /></div>
<div>
<div class="subheading" style="text-align: justify;">
<h2 id="circular-linked-list">Circular linked list</h2>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Another important type of a linked list is called a <a href="https://www.wikitechy.com/technology/circular-linked-list-introduction-applications/" target="_blank" rel="noopener">circular linked list</a> where last node of the list points back to the first node (or the head) of the list.</li>
</ul>
</div>
</div>
<div class="ImageContent" style="text-align: justify;">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/interview-questions/data-structure/circular-linked-list.jpg" alt="Circular linked list" /></div>
</div>
<div class="subheading" style="text-align: justify;">
<h2 id="doubly-circular-linked-list">Doubly Circular linked list</h2>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Circular doubly linked list is a type of data structure in which a node contain pointers to its previous node as well as the next node.</li>
<li>Circular doubly linked list doesn&#8217;t contain NULL in any of the node.</li>
<li>The last node contains the address of the first node of the list. The first node also contain address of the last node in its previous pointer.</li>
</ul>
</div>
</div>
<div class="ImageContent">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/interview-questions/data-structure/doubly-circular-linked-list.jpg" alt="Doubly Circular linked list" /></div>
<div>
<h2 id="sample-code" class="color-purple" style="text-align: justify;">Sample Code:</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-javascript code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-javascript code-embed-code">#include&lt;stdio.h&gt;<br/>#include &lt;stdlib.h&gt;<br/>int main()<br/>{<br/>   struct node<br/>   {<br/>      int num;<br/>      struct node *ptr;<br/>   };<br/>   typedef struct node NODE;<br/>   NODE *head, *first, *temp=0;<br/>   int count = 0;<br/>   int choice = 1;<br/>   first = 0;<br/>   while(choice)<br/>   {<br/>      head =(NODE*) malloc(sizeof(NODE));<br/>      printf(&quot;Enter the data item: &quot;);<br/>      scanf(&quot;%d&quot;, &amp;head-&gt; num);<br/>      if(first != 0)<br/>      {<br/>         temp-&gt;ptr = head;temp = head;<br/>      }<br/>      else<br/>      {<br/>         first = temp = head;<br/>      }<br/>      fflush(stdin);<br/>      printf(&quot;Do you want to continue(Type 0 or 1)?\n\n&quot;);<br/>      scanf(&quot;%d&quot;, &amp;choice);<br/>   }<br/>   temp-&gt;ptr = 0;<br/>   temp = first; /* reset temp to the beginning*/<br/>   printf(&quot;\n Status of the linked list is\n&quot;);<br/>   while(temp!=0)<br/>   {<br/>      printf(&quot;%d=&gt;&quot;, temp-&gt;num);<br/>      count++;<br/>      temp = temp -&gt; ptr;<br/>   }<br/>   printf(&quot;NULL\n&quot;);<br/>   printf(&quot;No. of nodes in the list = %d\n&quot;, count);<br/>   return 0;<br/>}</code></pre> </div>
<h2 id="output" class="color-purple" style="text-align: justify;">Output:</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-markdown code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-markdown code-embed-code">Enter the data item: 10<br/>Do you want to continue &lt;Type 0 or 1&gt;?<br/>1<br/>Enter the data item: 20<br/>Do you want to continue&lt;Type 0 or 1&gt;?<br/>1<br/>Enter the data item: 30<br/>Do you want to continue&lt;Type 0 or 1&gt;?<br/>0<br/>Status of the Linked List is<br/>10=&gt;20=&gt;30=&gt;NULL<br/>No.of nodes in the list = 3</code></pre> </div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="advantages-of-linked-list" class="color-purple">Advantages of Linked List</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Linked list is dynamic in nature which allocates the memory when required.</li>
<li>In linked list, stack and queue can be easily executed.</li>
<li>It reduces the access time.</li>
<li>Insert and delete operation can be easily implemented in linked list.</li>
</ul>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="disadvantages-of-linked-list" class="color-purple">Disadvantages of Linked List</h2>
</div>
</div>
<div class="Content">
<div class="hddn">
<ul>
<li style="text-align: justify;">Reverse traversing is difficult in linked list.</li>
<li style="text-align: justify;">Linked list has to access each node sequentially; no element can be accessed randomly.</li>
<li style="text-align: justify;">In linked list, the memory is wasted as pointer requires extra memory for storage.</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/data-structure/what-is-linked-list-in-data-structure-with-example/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Difference between Stack and Heap ?</title>
		<link>https://www.wikitechy.com/interview-questions/data-structure/difference-between-stack-and-heap/</link>
					<comments>https://www.wikitechy.com/interview-questions/data-structure/difference-between-stack-and-heap/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 15:22:24 +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[Apostek Software 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[BMC Software interview questions and answers]]></category>
		<category><![CDATA[c# heap data structure]]></category>
		<category><![CDATA[c# stack allocation]]></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[define heap]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[difference between heap and stack in java]]></category>
		<category><![CDATA[difference between stack and heap]]></category>
		<category><![CDATA[difference between stack and heap allocation]]></category>
		<category><![CDATA[difference between stack and heap in c#]]></category>
		<category><![CDATA[difference between stack and heap in java]]></category>
		<category><![CDATA[difference between static stack and heap allocation in compiler design]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[Genpact interview questions and answers]]></category>
		<category><![CDATA[Globallogic India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[heap definition]]></category>
		<category><![CDATA[heap meaning]]></category>
		<category><![CDATA[heap size]]></category>
		<category><![CDATA[how much is a stack]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[java heap]]></category>
		<category><![CDATA[java stack]]></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[SAP Labs India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Sapient Consulting Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[stack and heap]]></category>
		<category><![CDATA[stack and heap in c# msdn]]></category>
		<category><![CDATA[stack and heap in ios]]></category>
		<category><![CDATA[stack class]]></category>
		<category><![CDATA[stack definition]]></category>
		<category><![CDATA[stack heap]]></category>
		<category><![CDATA[stack in data structure]]></category>
		<category><![CDATA[stack program]]></category>
		<category><![CDATA[stack size]]></category>
		<category><![CDATA[stack storage]]></category>
		<category><![CDATA[stack vs heap]]></category>
		<category><![CDATA[stack vs heap c++]]></category>
		<category><![CDATA[stack vs heap data structure]]></category>
		<category><![CDATA[string stored in heap or stack in c#]]></category>
		<category><![CDATA[Tech Mahindra interview questions and answers]]></category>
		<category><![CDATA[Tracxn Technologies Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[UnitedHealth Group interview questions and answers]]></category>
		<category><![CDATA[what does heap mean]]></category>
		<category><![CDATA[what is heap]]></category>
		<category><![CDATA[what is stack]]></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=491</guid>

					<description><![CDATA[Answer : Stack has very fast to access...]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="difference-between-stack-and-heap" class="color-pink">Difference between Stack and Heap ?</h2>
</div>
</div>
<div class="Content table-responsive">
<div class="hddn">
<table class="table-bordered table-striped table table-responsive">
<tbody>
<tr>
<th>Stack</th>
<th>Heap</th>
</tr>
<tr>
<td class="text-leftalign">Stack has very fast to access.</td>
<td class="text-leftalign">Heap has slower to access while compared to stack.</td>
</tr>
<tr>
<td class="text-leftalign">Limit on stack size depends<br />
on OS.</td>
<td class="text-leftalign">No limit on memory size.</td>
</tr>
<tr>
<td class="text-leftalign">Stack variables cannot be resized.</td>
<td class="text-leftalign">Heap variables can be resized using realloc() method.</td>
</tr>
<tr>
<td class="text-leftalign">In Stack,space is managed efficiently by CPU,<br />
memory will not become fragmented.</td>
<td class="text-leftalign">There is no guaranteed efficient use of space, memory may become fragented over time as blocks of memory are allocated, then freed.</td>
</tr>
<tr>
<td class="text-leftalign">Manage memory during allocating and freeing variables.</td>
<td class="text-leftalign">Don&#8217;t have to explicitly de-allocate variables.</td>
</tr>
<tr>
<td class="text-leftalign">Stack to accessed only local variables.</td>
<td class="text-leftalign">Heap variables can be accessed globally.</td>
</tr>
<tr>
<td class="text-leftalign">Stack memory is used only by<br />
one thread of execution.</td>
<td class="text-leftalign">Heap memory is used by all the parts of the application</td>
</tr>
<tr>
<td class="text-leftalign">The stack is always reserved<br />
in a LIFO order, the most recently reserved block<br />
is always the next block to be freed.</td>
<td class="text-leftalign">Element of the heap have no dependencies with each other and can always be accessed randomly at any time.</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="ImageContent">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/interview-questions/data-structure/difference-between-stack-and-heap.png" alt=" Difference Between Stack and Heap" /></div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/data-structure/difference-between-stack-and-heap/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What is Queue in Data Structure ?</title>
		<link>https://www.wikitechy.com/interview-questions/data-structure/what-is-queue-in-data-structure/</link>
					<comments>https://www.wikitechy.com/interview-questions/data-structure/what-is-queue-in-data-structure/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 15:12:27 +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[Apostek Software Interview Questions and Answers]]></category>
		<category><![CDATA[application of queue in data structure]]></category>
		<category><![CDATA[applications of circular queue]]></category>
		<category><![CDATA[applications of queue in data structure]]></category>
		<category><![CDATA[Applied Materials interview questions and answers]]></category>
		<category><![CDATA[Bharti Airtel interview questions and answers]]></category>
		<category><![CDATA[BMC Software interview questions and answers]]></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[circular queue in data structure]]></category>
		<category><![CDATA[circular queue in data structure program]]></category>
		<category><![CDATA[Collabera Te interview questions and answers]]></category>
		<category><![CDATA[data queue]]></category>
		<category><![CDATA[define queue]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[equeue in data structure using c]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[Genpact interview questions and answers]]></category>
		<category><![CDATA[Globallogic India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[in queue]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[insertion and deletion in circular queue in data structure]]></category>
		<category><![CDATA[insertion and deletion in queue in data structur]]></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[paramatrix interview questions and answers]]></category>
		<category><![CDATA[queue data structure in c]]></category>
		<category><![CDATA[queue data structure java]]></category>
		<category><![CDATA[queue example]]></category>
		<category><![CDATA[queue implementation]]></category>
		<category><![CDATA[queue implementation in c]]></category>
		<category><![CDATA[queue in a sentence]]></category>
		<category><![CDATA[queue in c]]></category>
		<category><![CDATA[queue in data structure]]></category>
		<category><![CDATA[queue in data structure using c++]]></category>
		<category><![CDATA[queue operations]]></category>
		<category><![CDATA[queued definition]]></category>
		<category><![CDATA[queuing analysis]]></category>
		<category><![CDATA[queuing process]]></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[Tracxn Technologies Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[types of queue in data structure]]></category>
		<category><![CDATA[UnitedHealth Group interview questions and answers]]></category>
		<category><![CDATA[what is queue]]></category>
		<category><![CDATA[what is queue in data structure]]></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=489</guid>

					<description><![CDATA[Answer : A queue is a container of objects (a linear collection) that are inserted...]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="what-is-queue-in-data-structure" class="color-pink" style="text-align: justify;">What is Queue in Data Structure ?</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li style="list-style-type: none;">
<ul>
<li>A queue is a container of objects (a linear collection) that are inserted and removed according to the first-in first-out (FIFO) principle.</li>
</ul>
</li>
</ul>
<div class="ImageContent">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/interview-questions/data-structure/first-in-first-out.gif" alt="Queue(FIFO)" /></div>
</div>
<ul>
<li>Here the first element is inserted from one end called REAR and deleted from the other end called as FRONT.</li>
<li>Front points to the beginning of the queue and Rear points to the end of the queue.</li>
</ul>
<div class="ImageContent">
<div class="hddn"><img decoding="async" class="img-responsive center-block" src="https://cdn.wikitechy.com/interview-questions/data-structure/what-is-enqueue-dequeue.gif" alt="Enqueue Dequeue" /></div>
</div>
<div class="text-center row">
<div class="col-sm-12">
<div id="bsa-zone_1590522538159-8_123456"></div>
</div>
</div>
<div class="TextHeading">
<div class="hddn">
<h2 id="operations-on-queue" class="color-green">Operations on Queue</h2>
</div>
</div>
<table class="table-bordered table-striped table table-responsive">
<tbody>
<tr>
<th>Operation</th>
<th>Description</th>
</tr>
<tr>
<td class="text-leftalign">enqueue()</td>
<td class="text-leftalign">This function defines the operation for adding an element into queue.</td>
</tr>
<tr>
<td class="text-leftalign">dequeue()</td>
<td class="text-leftalign">This function defines the operation for removing an element from queue.</td>
</tr>
<tr>
<td class="text-leftalign">init()</td>
<td class="text-leftalign">This function is used for initializing the queue.</td>
</tr>
<tr>
<td class="text-leftalign">Front</td>
<td class="text-leftalign">Front is used to get the front data item from a queue.</td>
</tr>
<tr>
<td class="text-leftalign">Rear</td>
<td class="text-leftalign">Rear is used to get the last item from a queue.</td>
</tr>
</tbody>
</table>
<div class="TextHeading">
<div class="hddn">
<h2 id="queue-implementation" class="color-green">Queue Implementation</h2>
</div>
</div>
<div class="ImageContent">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/interview-questions/data-structure/what-is-queue-in-data-structure.png" alt=" Queue in Data Structure" /></div>
</div>
<div class="Content">
<div class="hddn">
<ul>
<li>Array is the easiest way to implement a queue. Queue can be also implemented using Linked List or Stack.</li>
<li>Front and Rear of the queue point at the first index of the array. (Array index starts from 0).</li>
<li>While adding an element into the queue, the Rear keeps on moving ahead and always points to the position where the next element will be inserted. Front remains at the first index.</li>
</ul>
<h2 id="sample-code" class="color-blue">Sample Code</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-javascript code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-javascript code-embed-code">import java.io.*;<br/>class Queue <br/>{ <br/>    int front, rear, size; <br/>    int  capacity; <br/>    int array[]; <br/>       <br/>    public Queue(int capacity) { <br/>         this.capacity = capacity; <br/>         front = this.size = 0;  <br/>         rear = capacity - 1; <br/>         array = new int[this.capacity]; <br/>            <br/>    } <br/>       <br/>    // Queue is full when size becomes equal to  <br/>    // the capacity  <br/>    boolean isFull(Queue queue) <br/>    {  return (queue.size == queue.capacity); <br/>    } <br/>       <br/>    // Queue is empty when size is 0 <br/>    boolean isEmpty(Queue queue) <br/>    {  return (queue.size == 0); } <br/>       <br/>    // Method to add an item to the queue.  <br/>    // It changes rear and size <br/>    void enqueue( int items) <br/>    { <br/>        if (isFull(this)) <br/>            return; <br/>        this.rear = (this.rear + 1)%this.capacity; <br/>        this.array[this.rear] = items; <br/>        this.size = this.size + 1; <br/>        System.out.println(items+ &quot; enqueued to the queue&quot;); <br/>    } <br/>       <br/>    // Method to remove an item from queue.   <br/>    // It changes front and size <br/>    int dequeue() <br/>    { <br/>        if (isEmpty(this)) <br/>            return Integer.MIN_VALUE; <br/>           <br/>        int item = this.array[this.front]; <br/>        this.front = (this.front + 1)%this.capacity; <br/>        this.size = this.size - 1; <br/>        return item; <br/>    } <br/>       <br/>    // Method to get front of queue <br/>    int front() <br/>    { <br/>        if (isEmpty(this)) <br/>            return Integer.MIN_VALUE; <br/>           <br/>        return this.array[this.front]; <br/>    } <br/>        <br/>    // Method to get rear of queue <br/>    int rear() <br/>    { <br/>        if (isEmpty(this)) <br/>            return Integer.MIN_VALUE; <br/>           <br/>        return this.array[this.rear]; <br/>    } <br/>} <br/>   <br/>    <br/>// Driver class <br/>public class Test <br/>{ <br/>    public static void main(String[] args)  <br/>    { <br/>        Queue q1 = new Queue(1000); <br/>            <br/>        q1.enqueue(7); <br/>        q1.enqueue(8); <br/>        q1.enqueue(18); <br/>        q1.enqueue(25); <br/>        <br/>        System.out.println(q1.dequeue() +  <br/>                     &quot; dequeued from the queue\n&quot;); <br/>        <br/>        System.out.println(&quot;Front item is &quot; +  <br/>                               q1.front()); <br/>           <br/>        System.out.println(&quot;Rear item is &quot; +  <br/>                                q1.rear()); <br/>    } <br/>}</code></pre> </div>
<h2 id="output" class="color-blue">Output</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-markdown code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-markdown code-embed-code">7 enqueued to the queue<br/>8 enqueued to the queue<br/>18 enqueued to the queue<br/>12 enqueued to the queue<br/>7 dequeued from the queue<br/><br/>Front item is 8<br/>Rear item is 25</code></pre> </div>
</div>
</div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/data-structure/what-is-queue-in-data-structure/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What is Stack in Data Structure ?</title>
		<link>https://www.wikitechy.com/interview-questions/data-structure/what-is-stack-in-data-structure/</link>
					<comments>https://www.wikitechy.com/interview-questions/data-structure/what-is-stack-in-data-structure/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 15:04:54 +0000</pubDate>
				<category><![CDATA[Data Structure]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></category>
		<category><![CDATA[algorithm for push and pop operation in stack in c]]></category>
		<category><![CDATA[Altimetrik India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Apostek Software Interview Questions and Answers]]></category>
		<category><![CDATA[application of stack in data structure]]></category>
		<category><![CDATA[applications of stack in real life]]></category>
		<category><![CDATA[Applied Materials interview questions and answers]]></category>
		<category><![CDATA[array representation of stack]]></category>
		<category><![CDATA[Bharti Airtel interview questions and answers]]></category>
		<category><![CDATA[BMC Software interview questions and answers]]></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[data stack]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[Genpact interview questions and answers]]></category>
		<category><![CDATA[Globallogic India Pvt Ltd interview questions and answers]]></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[paramatrix interview questions and answers]]></category>
		<category><![CDATA[push and pop]]></category>
		<category><![CDATA[push and pop operation in stack in c program]]></category>
		<category><![CDATA[push and pop operation in stack in data structure]]></category>
		<category><![CDATA[push and pop operation in stack in data structure program]]></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[stack applications in data structure]]></category>
		<category><![CDATA[stack data structure in c]]></category>
		<category><![CDATA[stack data structure java]]></category>
		<category><![CDATA[stack definition]]></category>
		<category><![CDATA[stack implementation in java]]></category>
		<category><![CDATA[stack in c]]></category>
		<category><![CDATA[stack in data structure]]></category>
		<category><![CDATA[stack in data structure with example]]></category>
		<category><![CDATA[stack operations]]></category>
		<category><![CDATA[stack operations in capplication of stack]]></category>
		<category><![CDATA[stack pop]]></category>
		<category><![CDATA[stack program]]></category>
		<category><![CDATA[stack push]]></category>
		<category><![CDATA[stack push pop]]></category>
		<category><![CDATA[stacking containers]]></category>
		<category><![CDATA[Tech Mahindra interview questions and answers]]></category>
		<category><![CDATA[Tracxn Technologies Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[UnitedHealth Group interview questions and answers]]></category>
		<category><![CDATA[what is meant by stack]]></category>
		<category><![CDATA[what is stack data structure]]></category>
		<category><![CDATA[what is stack in c]]></category>
		<category><![CDATA[what is stack in data structure]]></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=487</guid>

					<description><![CDATA[Answer : A stack is a container of objects that are performed...]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="what-is-stack-in-data-structure" class="color-pink" style="text-align: justify;">What is Stack in Data Structure ?</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>A stack is a container of objects that are performed based on last-in first-out (LIFO) principle.</li>
<li>A stack is a limited access data structure-elements can be added and removed from the stack only at the top. A stack is a recursive data structure.</li>
<li>The structural definition of a Stack is either empty or it consists of a top and the rest.</li>
<li>There are two basic operations performed in a Stack they are:</li>
</ul>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li style="list-style-type: none;">
<ul>
<li>Push()</li>
<li>Pop()</li>
</ul>
</li>
</ul>
<div class="Content">
<div class="hddn">
<ul>
<li style="list-style-type: none;">
<ul>
<li>Push()-push function is used to add or insert new item into the stack.</li>
</ul>
</li>
</ul>
<div class="ImageContent">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/interview-questions/data-structure/push-operation.gif" alt="POP Operation" /></div>
</div>
<ul>
<li style="list-style-type: none;">
<ul>
<li>Pop()-pop function is used to delete or remove an item from the stack.</li>
</ul>
</li>
</ul>
<div class="ImageContent">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/interview-questions/data-structure/pop-operation.gif" alt=" Push Operation" /></div>
</div>
<ul>
<li>When a stack is completely full, it is said to be Overflow state and if stack is completely empty, it is said to be Underflow state.</li>
<li>Stack allows operations at one end only.</li>
</ul>
</div>
</div>
<div class="TextHeading">
<div class="hddn">
<h2 id="other-operations-used-in-stack" class="color-blue">Other operations used in Stack</h2>
</div>
</div>
<div class="Content">
<div class="hddn">
<ul>
<li>Peek()-The peek() function gets the top element of the stack, without deleting it.</li>
<li>isEmpty() -The isEmpty() function checks whether the stack is empty or not.</li>
<li>isFull()-The isFull() function is used to check whether the stack is full or not.</li>
</ul>
</div>
</div>
<div class="TextHeading">
<div class="hddn">
<h2 id="features-of-stacks" class="color-green">Features of stacks</h2>
</div>
</div>
<div class="Content">
<div class="hddn">
<ul>
<li>Dynamic data structures</li>
<li>Do not have a fixed size</li>
<li>Do not consume a fixed amount of memory</li>
<li>Size of stack changes with each push() and pop() operation. Each push() and pop() operation increases and decreases the size of the stack by 1, respectively.</li>
</ul>
</div>
</div>
<div class="TextHeading">
<div class="hddn">
<h2 id="implementation-of-stack" class="color-purple">Implementation of Stack</h2>
</div>
</div>
<div class="ImageContent">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/interview-questions/data-structure/stack-in-data-structure.png" alt=" Stack in Data Structure" /></div>
<div>
<h2 id="sample-code" class="color-blue">Sample Code</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-javascript code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-javascript code-embed-code">import java.io.*;<br/><br/><br/>/* Java program to implement basic stack <br/>operations */<br/>class Stack <br/>{ <br/>    static final int MAX = 1000; <br/>    int top; <br/>    int a[] = new int[MAX]; // Maximum size of Stack <br/>  <br/>    boolean isEmpty() <br/>    { <br/>        return (top &lt; 0); <br/>    } <br/>    Stack() <br/>    { <br/>        top = -1; <br/>    } <br/>  <br/>    boolean push(int b) <br/>    { <br/>        if (top &gt;= (MAX-1)) <br/>        { <br/>            System.out.println(&quot;Stack Overflow&quot;); <br/>            return false; <br/>        } <br/>        else<br/>        { <br/>            a[++top] = b; <br/>            System.out.println(b + &quot; pushed into the stack&quot;); <br/>            return true; <br/>        } <br/>    } <br/>  <br/>    int pop() <br/>    { <br/>        if (top &lt; 0) <br/>        { <br/>            System.out.println(&quot;Stack Underflow&quot;); <br/>            return 0; <br/>        } <br/>        else<br/>        { <br/>            int b = a[top--]; <br/>            return b; <br/>        } <br/>    } <br/>} <br/>  <br/>// Driver code <br/>class Main <br/>{ <br/>    public static void main(String args[]) <br/>    { <br/>        Stack s1 = new Stack(); <br/>        s1.push(80); <br/>        s1.push(75); <br/>        s1.push(90); <br/>        System.out.println(s1.pop() + &quot; Popped from the stack&quot;); <br/>    } <br/>}</code></pre> </div>
<h2 id="output" class="color-blue">Output</h2>
</div>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-javascript code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-javascript code-embed-code">80 pushed into the stack<br/>75 pushed into the stack<br/>90 pushed into the stack<br/>80 Popped from the stack</code></pre> </div>
</div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/data-structure/what-is-stack-in-data-structure/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Write a function to Delete a node from Doubly Linked List ?</title>
		<link>https://www.wikitechy.com/interview-questions/data-structure/write-a-function-to-delete-a-node-from-doubly-linked-list/</link>
					<comments>https://www.wikitechy.com/interview-questions/data-structure/write-a-function-to-delete-a-node-from-doubly-linked-list/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 14:56:24 +0000</pubDate>
				<category><![CDATA[Data Structure]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></category>
		<category><![CDATA[algorithm for insertion and deletion in doubly linked list]]></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[BMC Software interview questions and answers]]></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[delete a node from linked list in c]]></category>
		<category><![CDATA[delete all nodes in doubly linked list]]></category>
		<category><![CDATA[delete all nodes in doubly linked list c++]]></category>
		<category><![CDATA[delete at position in a doubly linked list]]></category>
		<category><![CDATA[delete last node in doubly linked list in c++]]></category>
		<category><![CDATA[delete last node in doubly linked list java]]></category>
		<category><![CDATA[delete node from doubly linked list c++]]></category>
		<category><![CDATA[delete node from doubly linked list java]]></category>
		<category><![CDATA[deletion in doubly linked list]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[doubly circular linked list in data structure]]></category>
		<category><![CDATA[doubly linked list]]></category>
		<category><![CDATA[doubly linked list c code]]></category>
		<category><![CDATA[doubly linked list deletion]]></category>
		<category><![CDATA[doubly linked list deletion program in cm]]></category>
		<category><![CDATA[doubly linked list example]]></category>
		<category><![CDATA[doubly linked list implementation]]></category>
		<category><![CDATA[doubly linked list implementation in c]]></category>
		<category><![CDATA[doubly linked list in c]]></category>
		<category><![CDATA[doubly linked list in data structure]]></category>
		<category><![CDATA[doubly linked list insertion and deletion]]></category>
		<category><![CDATA[doubly linked list java]]></category>
		<category><![CDATA[doubly linked list operations]]></category>
		<category><![CDATA[doubly linked list program in c]]></category>
		<category><![CDATA[doubly linked list program in data structure]]></category>
		<category><![CDATA[doubly linked list program in data structure using c]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[geekyants interview questions and answers]]></category>
		<category><![CDATA[Genpact interview questions and answers]]></category>
		<category><![CDATA[Globallogic India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[insertion and deletion in doubly linked list in c]]></category>
		<category><![CDATA[lete a node from doubly linked list]]></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[remove node from doubly linked list java]]></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[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[write a function to delete a node from doubly linked list]]></category>
		<category><![CDATA[write a function to delete a node from doubly linked list java]]></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=485</guid>

					<description><![CDATA[Answer : In a single linked list, every node has link to its next node in the sequence...]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="write-a-function-to-delete-a-node-from-doubly-linked-list" class="color-pink" style="text-align: justify;">Write a function to Delete a node from Doubly Linked List ?</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>In a <a href="https://www.wikitechy.com/technology/insertion-sort-singly-linked-list/" target="_blank" rel="noopener">single linked list</a>, every node has link to its next node in the sequence.</li>
<li>So, we can traverse from one node to another node only in one direction and we cannot traverse back. We can solve this kind of problem by using <a href="https://www.wikitechy.com/technology/quicksort-doubly-linked-list-3/" target="_blank" rel="noopener">double linked list</a>.</li>
<li>Double linked list is a sequence of elements in which every element has links to its previous element and next element in the sequence.</li>
<li>In double linked list, every node has link to its previous node and next node. So, we can <a href="https://www.wikitechy.com/technology/java-program-inorder-tree-traversal-without-recursion/" target="_blank" rel="noopener">traverse</a> forward by using next field and can traverse backward by using previous field.</li>
</ul>
</div>
</div>
<div class="ImageContent">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/interview-questions/data-structure/delete-a-node-from-doubly-linked-list.png" alt=" Delete a node Doubly Linked List" /></div>
<div>
<h2 id="algorithm" class="color-green" style="text-align: justify;">Algorithm</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-markdown code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-markdown code-embed-code">Algorithm to delete node from any position<br/>Input :<br/> head <br/> {<br/>   Pointer to the first node of the list<br/> }<br/>last <br/> {<br/>   Pointer to the last node of the list<br/> }<br/>N <br/> {<br/>  Position to be deleted from list<br/> }<br/>Begin :<br/>    current ← head;<br/>    For i ← 1 to N and current != NULL do<br/>        current ← current.next;<br/>    End for<br/>    If (N == 1) then<br/>        deleteFromBeginning()<br/>    End if<br/>    Else if (current == last) then <br/>        deleteFromEnd()<br/>    End if<br/>    Else if (current != NULL) then<br/>        current.prev.next ← current.next<br/>        If (current.next != NULL) then<br/>            current.next.prev ← current.prev;<br/>        End if<br/>        unalloc (current)<br/>        write (&#039;Node deleted successfully from &#039;, N, &#039; position&#039;)<br/>    End if<br/>    Else then<br/>        write (&#039;Invalid position&#039;)<br/>    End if<br/>End</code></pre> </div>
<h2 id="sample-code-in-c" class="color-blue" style="text-align: justify;">Sample Code in C++</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-markdown code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-markdown code-embed-code">#include &lt;bits/stdc++.h&gt; <br/>  <br/>using namespace std; <br/>  <br/>struct Node { <br/>    int data; <br/>    struct Node* next; <br/>    struct Node* prev; <br/>}; <br/>  <br/>/* Function to delete a node in a Doubly Linked List. <br/>   head_ref --&gt; pointer to head node pointer. <br/>   del  --&gt;  pointer to node to be deleted. */<br/>void deleteNode(struct Node** head_ref, struct Node* del) <br/>{ <br/>   <br/>    if (*head_ref == NULL || del == NULL) <br/>        return; <br/>  <br/>    /* If node to be deleted is head node */<br/>    if (*head_ref == del) <br/>        *head_ref = del-&gt;next; <br/>  <br/>    /* Change next only if node to be deleted is NOT  <br/>       the last node */<br/>    if (del-&gt;next != NULL) <br/>        del-&gt;next-&gt;prev = del-&gt;prev; <br/>  <br/>    /* Change prev only if node to be deleted is NOT  <br/>       the first node */<br/>    if (del-&gt;prev != NULL) <br/>        del-&gt;prev-&gt;next = del-&gt;next; <br/>  <br/>    /* Finally, free the memory occupied by del*/<br/>    free(del); <br/>} <br/>  <br/>/* Function to delete the node at the given position <br/>   in the doubly linked list */<br/>void deleteNodeAtGivenPos(struct Node** head_ref, int n) <br/>{ <br/>    /* if list in NULL or invalid position is given */<br/>    if (*head_ref == NULL || n &lt;= 0) <br/>        return; <br/>  <br/>    struct Node* current = *head_ref; <br/>    int i; <br/>  <br/>    /* traverse up to the node at position &#039;n&#039; from <br/>       the beginning */<br/>    for (int i = 1; current != NULL &amp;&amp; i &lt; n; i++) <br/>        current = current-&gt;next; <br/>  <br/>    /* if &#039;n&#039; is greater than the number of nodes <br/>       in the doubly linked list */<br/>    if (current == NULL) <br/>        return; <br/>  <br/>    /* delete the node pointed to by &#039;current&#039; */<br/>    deleteNode(head_ref, current); <br/>} <br/>  <br/>/* Function to insert a node at the beginning  <br/>   of the Doubly Linked List */<br/>void push(struct Node** head_ref, int new_data) <br/>{ <br/>    /* allocate node */<br/>    struct Node* new_node =  <br/>         (struct Node*)malloc(sizeof(struct Node)); <br/>  <br/>    /* put in the data  */<br/>    new_node-&gt;data = new_data; <br/>  <br/>    /* since we are adding at the beginning, <br/>    prev is always NULL */<br/>    new_node-&gt;prev = NULL; <br/>  <br/>    /* link the old list off the new node */<br/>    new_node-&gt;next = (*head_ref); <br/>  <br/>    /* change prev of head node to new node */<br/>    if ((*head_ref) != NULL) <br/>        (*head_ref)-&gt;prev = new_node; <br/>  <br/>    /* move the head to point to the new node */<br/>    (*head_ref) = new_node; <br/>} <br/>  <br/>/* Function to print nodes in a given doubly <br/>   linked list */<br/>void printList(struct Node* head) <br/>{ <br/>    while (head != NULL) { <br/>        cout &lt;&lt; head-&gt;data &lt;&lt; &quot; &quot;; <br/>        head = head-&gt;next; <br/>    } <br/>} <br/>  <br/>/* Driver program to test above functions*/<br/>int main() <br/>{ <br/>    /* Start with the empty list */<br/>    struct Node* head = NULL; <br/>  <br/>    /* Create the doubly linked list 10&lt;-&gt;8&lt;-&gt;4&lt;-&gt;2&lt;-&gt;5 */<br/>    push(&amp;head, 5); <br/>    push(&amp;head, 2); <br/>    push(&amp;head, 4); <br/>    push(&amp;head, 8); <br/>    push(&amp;head, 10); <br/>  <br/>    cout &lt;&lt; &quot;Doubly linked list before deletion:n&quot;; <br/>    printList(head); <br/>  <br/>    int n = 2; <br/>  <br/>    /* delete node at the given position &#039;n&#039; */<br/>    deleteNodeAtGivenPos(&amp;head, n); <br/>  <br/>    cout &lt;&lt; &quot;\nDoubly linked list after deletion:n&quot;; <br/>    printList(head); <br/>  <br/>    return 0; <br/>} </code></pre> </div>
<h2 id="output" class="color-purple" style="text-align: justify;">Output</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-markdown code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-markdown code-embed-code">Doubly linked list before deletion:<br/>10 8 4 2 5<br/>Doubly linked list after deletion:<br/>10 4 2 5</code></pre> </div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="time-complexity" class="color-green">Time Complexity</h2>
</div>
</div>
<div class="Content">
<div class="hddn">
<ul>
<li style="text-align: justify;">O(n), in worst case where n is the number of nodes in the doubly linked list.</li>
</ul>
</div>
</div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/data-structure/write-a-function-to-delete-a-node-from-doubly-linked-list/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>What is N Queen Problem ?</title>
		<link>https://www.wikitechy.com/interview-questions/data-structure/what-is-n-queen-problem/</link>
					<comments>https://www.wikitechy.com/interview-questions/data-structure/what-is-n-queen-problem/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 11:31:06 +0000</pubDate>
				<category><![CDATA[Data Structure]]></category>
		<category><![CDATA[4 queen problem]]></category>
		<category><![CDATA[4 queen problem using backtracking]]></category>
		<category><![CDATA[8 queen problem in python]]></category>
		<category><![CDATA[8 queen problem using backtracking]]></category>
		<category><![CDATA[8 queen problem using backtracking in python]]></category>
		<category><![CDATA[8 queen problem using genetic algorithm]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></category>
		<category><![CDATA[algorithm for n queen problem]]></category>
		<category><![CDATA[Altimetrik India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[applications of 8 queen problem]]></category>
		<category><![CDATA[Applied Materials interview questions and answers]]></category>
		<category><![CDATA[backtracking algorithm for 8 queen problem]]></category>
		<category><![CDATA[Bharti Airtel interview questions and answers]]></category>
		<category><![CDATA[BMC Software interview questions and answers]]></category>
		<category><![CDATA[c program for n queen problem]]></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[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[geekyants interview questions and answers]]></category>
		<category><![CDATA[Genpact interview questions and answers]]></category>
		<category><![CDATA[Globallogic India Pvt Ltd interview questions and answers]]></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[n queen problem algorithm]]></category>
		<category><![CDATA[n queen problem algorithm using backtracking]]></category>
		<category><![CDATA[n queen problem complexity]]></category>
		<category><![CDATA[n queen problem in c]]></category>
		<category><![CDATA[n queen problem in java]]></category>
		<category><![CDATA[n queen problem in java source code]]></category>
		<category><![CDATA[n queen problem using backtracking]]></category>
		<category><![CDATA[n queens problem c++]]></category>
		<category><![CDATA[n queens problem java]]></category>
		<category><![CDATA[n queens problem java recursive]]></category>
		<category><![CDATA[n queens problem java stack]]></category>
		<category><![CDATA[n queens problem using backtracking algorithm]]></category>
		<category><![CDATA[NetApp interview questions and answers]]></category>
		<category><![CDATA[Oracle Corporation 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[short note on 8 queen problem]]></category>
		<category><![CDATA[solution of 8 queen problem using backtracking]]></category>
		<category><![CDATA[Tech Mahindra interview questions and answers]]></category>
		<category><![CDATA[Tracxn Technologies Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[UnitedHealth Group interview questions and answers]]></category>
		<category><![CDATA[what is 8 queen problem]]></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=482</guid>

					<description><![CDATA[Answer : Let us discuss N Queen problem that can be solved using Backtracking...]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="n-queen-problem" class="color-pink" style="text-align: justify;">N Queen Problem</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn"></div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Let us discuss N Queen problem that can be solved using <a href="https://www.wikitechy.com/final-year-project/dotnet/server-hacking/backtracking-algorithm" target="_blank" rel="noopener">Backtracking</a>.</li>
<li>The N Queen is the problem of placing N chess queens on an N×N chessboard so that no two queens attack each other. For example, following the solution for 4 Queen problem.</li>
</ul>
</div>
</div>
<div class="ImageContent" style="text-align: justify;">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/interview-questions/data-structure/what-is-n-queen-problem.jpg" alt=" N Queen Problem" /></div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Binary <a href="https://www.wikitechy.com/tutorials/apache-pig/apache-pig-tutorial/matrix-multiplication-apache-pig" target="_blank" rel="noopener">matrix</a> which has 1&#8217;s for the blocks where queens are placed. For example, following is the output matrix for above 4 queen solution.</li>
</ul>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-markdown code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-markdown code-embed-code">{ 0,  1,  0,  0 }<br/>{ 0,  0,  0,  1 }<br/>{ 1,  0,  0,  0 }<br/>{ 0,  0,  1,  0 }</code></pre> </div>
<div class="TextHeading">
<div class="hddn">
<h2 id="backtracking-algorithm" class="color-green">Backtracking Algorithm</h2>
</div>
</div>
<div class="Content">
<div class="hddn"></div>
</div>
<div class="Content">
<div class="hddn">
<ul>
<li>The idea is to place queens one by one in different columns, starting from the leftmost column.</li>
<li>When we place a queen in a column, we can checkout to clashes with already placed queens.</li>
<li>In the current column, if we find a row for which there is no clash, we mark this row and column as part of the solution.</li>
<li>If we do not find such a row due to clashes then we backtrack and return false.</li>
</ul>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-markdown code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-markdown code-embed-code">1) Start from the leftmost column<br/>2) If all queens are placed<br/>    return true<br/>3) Try all rows in the current column.  Do following for every tried row.<br/>    a) If the queen can be placed safely in this row then mark this [row, <br/>        column] as part of the solution and recursively check if placing queen here leads to a solution.<br/>    b) If placing the queen in [row, column] leads to a solution then return <br/>        true.<br/>    c) If placing queen does not lead to a solution then umark this [row, <br/>        column] (Backtrack) and go to step (a) to try other rows.<br/>4) If all rows have been tried and nothing worked, return false to trigger <br/>    backtracking.</code></pre> </div>
<h2 id="sample-code-in-c" class="color-blue">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">/* C/C++ program to solve N Queen Problem using <br/>backtracking */<br/>#define N 4 <br/>#include&lt;stdio.h&gt; <br/>#include&lt;stdbool.h&gt; <br/><br/>/* A utility function to print solution */<br/>void printSolution(int board[N][N]) <br/>{ <br/>	for (int i = 0; i &lt; N; i++) <br/>	{ <br/>		for (int j = 0; j &lt; N; j++) <br/>			printf(&quot; %d &quot;, board[i][j]); <br/>		printf(&quot;\n&quot;); <br/>	} <br/>} <br/><br/>/* A utility function to check if a queen can be placed on board[row][col]. <br/>Note that this function is called when &quot;col&quot; queens are already placed in columns<br/> from 0 to col -1. So we need to check only left side for attacking queens */<br/>bool isSafe(int board[N][N], int row, int col) <br/>{ <br/>	int i, j; <br/><br/>	/* Check this row on left side */<br/>	for (i = 0; i &lt; col; i++) <br/>		if (board[row][i]) <br/>			return false; <br/><br/>	/* Check upper diagonal on left side */<br/>	for (i=row, j=col; i&gt;=0 &amp;&amp; j&gt;=0; i--, j--) <br/>		if (board[i][j]) <br/>			return false; <br/><br/>	/* Check lower diagonal on left side */<br/>	for (i=row, j=col; j&gt;=0 &amp;&amp; i&lt;N; i++, j--) <br/>		if (board[i][j]) <br/>			return false; <br/><br/>	return true; <br/>} <br/><br/>/* A recursive utility function to solve N <br/>Queen problem */<br/>bool solveNQUtil(int board[N][N], int col) <br/>{ <br/>	/* base case: If all queens are placed <br/>	then return true */<br/>	if (col &gt;= N) <br/>		return true; <br/><br/>	/* Consider this column and try placing <br/>	this queen in all rows one by one */<br/>	for (int i = 0; i &lt; N; i++) <br/>	{ <br/>		/* Check if the queen can be placed on <br/>		board[i][col] */<br/>		if ( isSafe(board, i, col) ) <br/>		{ <br/>			/* Place this queen in board[i][col] */<br/>			board[i][col] = 1; <br/><br/>			/* recur to place rest of the queens */<br/>			if ( solveNQUtil(board, col + 1) ) <br/>				return true; <br/><br/>			/* If placing queen in board[i][col] <br/>			doesn&#039;t lead to a solution, then <br/>			remove queen from board[i][col] */<br/>			board[i][col] = 0; // BACKTRACK <br/>		} <br/>	} <br/><br/>	/* If the queen cannot be placed in any row in <br/>		this colum col then return false */<br/>	return false; <br/>} <br/><br/>/* This function solves the N Queen problem using Backtracking. It mainly uses <br/>solveNQUtil() to solve the problem. It returns false if queens cannot be placed, <br/>otherwise, return true and prints placement of queens in the form of 1s.<br/><br/> Please note that there may be more than one solutions, this function prints one of the <br/>feasible solutions.*/<br/>bool solveNQ() <br/>{ <br/>	int board[N][N] = { {0, 0, 0, 0}, <br/>		{0, 0, 0, 0}, <br/>		{0, 0, 0, 0}, <br/>		{0, 0, 0, 0} <br/>	}; <br/><br/>	if ( solveNQUtil(board, 0) == false ) <br/>	{ <br/>	printf(&quot;Solution does not exist&quot;); <br/>	return false; <br/>	} <br/><br/>	printSolution(board); <br/>	return true; <br/>} <br/><br/>// driver program to test above function <br/>int main() <br/>{ <br/>	solveNQ(); <br/>	return 0; <br/>}</code></pre> </div>
<h2 id="output" class="color-blue">Output</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">0  0  1  0 <br/> 1  0  0  0 <br/> 0  0  0  1 <br/> 0  1  0  0 </code></pre> </div>
</div>
</div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/data-structure/what-is-n-queen-problem/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to find Second largest element in BST ?</title>
		<link>https://www.wikitechy.com/interview-questions/data-structure/how-to-find-second-largest-element-in-bst/</link>
					<comments>https://www.wikitechy.com/interview-questions/data-structure/how-to-find-second-largest-element-in-bst/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 11:24:08 +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[BMC Software interview questions and answers]]></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[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[find kth largest element in a binary search tree java]]></category>
		<category><![CDATA[find max value in binary search tree c++]]></category>
		<category><![CDATA[find maximum in binary search tree]]></category>
		<category><![CDATA[find min and max in binary search tree in c]]></category>
		<category><![CDATA[find the 2nd-largest node in a binary tree]]></category>
		<category><![CDATA[find the node with maximum value in a binary search tree]]></category>
		<category><![CDATA[find the second largest element in a binary search tree java]]></category>
		<category><![CDATA[find the second largest element in a binary search tree python]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[geekyants interview questions and answers]]></category>
		<category><![CDATA[Genpact interview questions and answers]]></category>
		<category><![CDATA[Globallogic India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[kth largest element in a stream bst]]></category>
		<category><![CDATA[kth largest element in bst]]></category>
		<category><![CDATA[kth smallest element in a bst leetcode]]></category>
		<category><![CDATA[kth smallest element in a bst python]]></category>
		<category><![CDATA[kth smallest element in a bst recursive]]></category>
		<category><![CDATA[largest node in bst]]></category>
		<category><![CDATA[largest number in bst which is less than or equal to n java]]></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[SAP Labs India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Sapient Consulting Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[second largest element in bst]]></category>
		<category><![CDATA[second largest element in bst java]]></category>
		<category><![CDATA[second largest element in bst leetcode]]></category>
		<category><![CDATA[second largest element in bst python]]></category>
		<category><![CDATA[second largest element in generic tree]]></category>
		<category><![CDATA[second largest element in generic tree java]]></category>
		<category><![CDATA[second largest element in n ary tree java]]></category>
		<category><![CDATA[second largest element in tree java]]></category>
		<category><![CDATA[second largest in tree]]></category>
		<category><![CDATA[second minimum node in a binary tree]]></category>
		<category><![CDATA[Tech Mahindra interview questions and answers]]></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=480</guid>

					<description><![CDATA[Answer : In an N-ary tree, the second largest value in the given tree to find and return the node...]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="how-to-find-second-largest-element-in-bst" class="color-pink" style="text-align: justify;">How to find Second largest element in BST ?</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>In an N-ary <a href="https://www.wikitechy.com/tutorials/r-programming/r-decision-tree" target="_blank" rel="noopener">tree</a>, the second largest value in the given tree to find and return the node. Return NULL if no node with required value is present.</li>
</ul>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>For example, in the given tree</li>
</ul>
</div>
</div>
<div class="ImageContent" style="text-align: justify;">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/interview-questions/data-structure/how-to-find-second-largest-element-in-a-bst.png" alt="Second largest element in a BST" /></div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<h3 id="second-largest-node-is-20">Second largest node is 20.</h3>
</div>
</div>
<div class="Content">
<div class="hddn">
<ul style="text-align: justify;">
<li>A simple solution is to traverse the <a href="https://www.wikitechy.com/tutorials/c++/passing-2d-array-to-function-c++" target="_blank" rel="noopener">array</a> twice. In the first traversal the maximum value node to be find.</li>
<li>In the second traversal find the greatest element node less than the element obtained in first traversal.</li>
<li>This solution O(n) is the <a href="https://www.wikitechy.com/interview-questions/programming/what-is-the-time-complexity-of-adding-three-matrices" target="_blank" rel="noopener">time complexity</a>.</li>
<li>To find the second largest element in a single traversal to be efficient solution.</li>
</ul>
<h2 id="algorithm" class="color-green" style="text-align: justify;">Algorithm</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-markdown code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-markdown code-embed-code">Initialize two nodes first and second to NULL as,<br/>first = second = NULL<br/><br/>Start traversing the tree,<br/>If the current node data say root-&gt;key is greater<br/>than first-&gt;key then update first and second as,<br/>second = first<br/>first = root<br/>If the current node data is in between first and<br/>second, then update second to store the value<br/>of current node as<br/>second = root<br/><br/>Return the node stored in second.</code></pre> </div>
<h2 id="sample-code-in-java" class="color-blue" style="text-align: justify;">Sample Code in Java</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-javascript code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-javascript code-embed-code">// Java code to find second largest element in BST <br/>  <br/>// A binary tree node <br/>class Node { <br/>  <br/>    int data; <br/>    Node left, right; <br/>  <br/>    Node(int d) <br/>    { <br/>        data = d; <br/>        left = right = null; <br/>    } <br/>} <br/>  <br/>class BinarySearchTree { <br/>  <br/>    // Root of BST <br/>    Node root; <br/>  <br/>    // Constructor <br/>    BinarySearchTree() <br/>    { <br/>        root = null; <br/>    } <br/>  <br/>    // function to insert new nodes <br/>    public void insert(int data) <br/>    { <br/>        this.root = this.insertRec(this.root, data); <br/>    } <br/>      <br/>    /* A utility function to insert a new node with given  <br/>    key in BST */<br/>    Node insertRec(Node node, int data) <br/>    { <br/>        /* If the tree is empty, return a new node */<br/>        if (node == null) { <br/>            this.root = new Node(data); <br/>            return this.root; <br/>        } <br/>  <br/>        /* Otherwise, recur down the tree */<br/>        if (data &lt; node.data) { <br/>            node.left = this.insertRec(node.left, data); <br/>        } else { <br/>            node.right = this.insertRec(node.right, data); <br/>        } <br/>        return node; <br/>    } <br/>  <br/>    // class that stores the value of count <br/>    public class count { <br/>        int c = 0; <br/>    } <br/>  <br/>    // Function to find 2nd largest element <br/>    void secondLargestUtil(Node node, count C) <br/>    {    <br/>        // Base cases, the second condition is important to <br/>        // avoid unnecessary recursive calls <br/>        if (node == null || C.c &gt;= 2) <br/>            return; <br/>              <br/>        // Follow reverse inorder traversal so that the <br/>        // largest element is visited first <br/>        this.secondLargestUtil(node.right, C);  <br/>          <br/>         // Increment count of visited nodes <br/>        C.c++; <br/>          <br/>        // If c becomes k now, then this is the 2nd largest <br/>        if (C.c == 2) { <br/>            System.out.print(&quot;2nd largest element is &quot;+ <br/>                                              node.data); <br/>            return; <br/>        } <br/>          <br/>         // Recur for left subtree <br/>        this.secondLargestUtil(node.left, C);  <br/>    } <br/>  <br/>    // Function to find 2nd largest element <br/>    void secondLargest(Node node) <br/>    {    <br/>        // object of class count <br/>        count C = new count();  <br/>        this.secondLargestUtil(this.root, C); <br/>    } <br/>  <br/>    // Driver function <br/>    public static void main(String[] args) <br/>    { <br/>        BinarySearchTree tree = new BinarySearchTree(); <br/>          <br/>        /* Let us create following BST <br/>              50 <br/>           /     \ <br/>          30      70 <br/>         /  \    /  \ <br/>       20   40  60   80 */<br/>         <br/>        tree.insert(50); <br/>        tree.insert(30); <br/>        tree.insert(20); <br/>        tree.insert(40); <br/>        tree.insert(70); <br/>        tree.insert(60); <br/>        tree.insert(80); <br/>  <br/>        tree.secondLargest(tree.root); <br/>    } <br/>} </code></pre> </div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="output" class="color-blue">Output</h2>
</div>
</div>
<div class="Output" style="text-align: justify;">
<div class="hddn">
<figure class="highlight">
<pre><code class="hljs" data-lang=""><span class="nt">2nd largest element is 70
</span></code></pre>
</figure>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="time-complexity" class="color-purple">Time Complexity</h2>
</div>
</div>
<div class="Content">
<div class="hddn">
<ul>
<li style="text-align: justify;">Time Complexity: The above solution is O(h) where h is height of <a href="https://www.wikitechy.com/technology/java-program-check-binary-tree-bst-not/" target="_blank" rel="noopener">BST</a>.</li>
</ul>
</div>
</div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/data-structure/how-to-find-second-largest-element-in-bst/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Write a program to reverse a string using stack data structure ?</title>
		<link>https://www.wikitechy.com/interview-questions/data-structure/write-a-program-to-reverse-a-string-using-stack-data-structure/</link>
					<comments>https://www.wikitechy.com/interview-questions/data-structure/write-a-program-to-reverse-a-string-using-stack-data-structure/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 11:18:34 +0000</pubDate>
				<category><![CDATA[Data Structure]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></category>
		<category><![CDATA[algorithm for palindrome using stack]]></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[BMC Software interview questions and answers]]></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[data structure to reverse string ( other than stack)]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[geekyants interview questions and answers]]></category>
		<category><![CDATA[Genpact interview questions and answers]]></category>
		<category><![CDATA[Globallogic India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[how to push a string into a stack in c]]></category>
		<category><![CDATA[how to reverse a stack in c++]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[java input string]]></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[rereverse a string using stack in cstack string java]]></category>
		<category><![CDATA[reverse a linked list using stack in c]]></category>
		<category><![CDATA[reverse a list using stack in c]]></category>
		<category><![CDATA[reverse a number using stack]]></category>
		<category><![CDATA[reverse a number using stack in c]]></category>
		<category><![CDATA[reverse a string in java]]></category>
		<category><![CDATA[reverse a string using stack c++]]></category>
		<category><![CDATA[reverse a string using stack in c#]]></category>
		<category><![CDATA[reverse a string using stack in java]]></category>
		<category><![CDATA[reverse a string using stack in python]]></category>
		<category><![CDATA[reverse string using stack data structure in c]]></category>
		<category><![CDATA[reverse string using stack in java]]></category>
		<category><![CDATA[reverse words in a string using stack]]></category>
		<category><![CDATA[reverse words in a string using stack 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[stack string java]]></category>
		<category><![CDATA[Tech Mahindra interview questions and answers]]></category>
		<category><![CDATA[Tracxn Technologies Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[UnitedHealth Group interview questions and answers]]></category>
		<category><![CDATA[use a stack to reverse the words of a sentence]]></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[write a program to reverse a string using stack data structu]]></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=478</guid>

					<description><![CDATA[Answer : Given a string, reverse it using stack...]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="write-a-program-to-reverse-a-string-using-stack-data-structure" class="color-pink" style="text-align: justify;">Write a program to reverse a string using stack data structure ?</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Given a string, reverse it using stack. For example <a href="https://www.wikitechy.com/" target="_blank" rel="noopener">“Wikitechy”</a> should be converted to “yhcetikiW”.</li>
<li>Following is simple algorithm to reverse a string using stack.</li>
</ul>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li style="list-style-type: none;">
<ul>
<li>Empty stack to be created.</li>
<li><a href="https://www.wikitechy.com/tutorials/javascript/creating-multiline-string-in-javascript" target="_blank" rel="noopener">String</a> to stack put one by one push all characters.</li>
<li>From the stack and put them back to string one by one pop all characters.</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="ImageContent">
<div class="hddn"><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/interview-questions/data-structure/reserve-a-string-using-stack.jpg" alt=" Reserve a String Using Stack" /></div>
<div>
<h2 id="sample-code-in-java" class="color-purple" style="text-align: justify;">Sample Code in Java</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-javascript code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-javascript code-embed-code">import java.util.*; <br/>  <br/>//stack <br/>class Stack <br/>{ <br/>    int size; <br/>    int top; <br/>    char[] a;  <br/>  <br/>    //function to check if stack is empty <br/>    boolean isEmpty() <br/>    { <br/>        return (top &lt; 0); <br/>    } <br/>      <br/>    Stack(int n) <br/>    { <br/>        top = -1; <br/>        size = n; <br/>        a = new char[size]; <br/>    } <br/>  <br/>    //function to push element in Stack <br/>    boolean push(char x) <br/>    { <br/>        if (top &gt;= size) <br/>        { <br/>        System.out.println(&quot;Stack Overflow&quot;); <br/>        return false; <br/>        } <br/>        else<br/>        { <br/>            a[++top] = x; <br/>            return true; <br/>        } <br/>    } <br/>  <br/>    //function to pop element from stack <br/>    char pop() <br/>    { <br/>        if (top &lt; 0) <br/>        { <br/>        System.out.println(&quot;Stack Underflow&quot;); <br/>        return 0; <br/>        } <br/>        else<br/>        { <br/>            char x = a[top--]; <br/>            return x; <br/>        } <br/>    } <br/>} <br/>  <br/>  <br/>// Driver code <br/>class Main <br/>{ <br/>    //function to reverse the string <br/>    public static void reverse(StringBuffer str) <br/>    { <br/>        // Create a stack of capacity  <br/>        // equal to length of string <br/>        int n = str.length(); <br/>        Stack obj = new Stack(n); <br/>          <br/>        // Push all characters of string  <br/>        // to stack <br/>        int i; <br/>        for (i = 0; i &lt; n; i++) <br/>        obj.push(str.charAt(i)); <br/>      <br/>        // Pop all characters of string  <br/>        // and put them back to str <br/>        for (i = 0; i &lt; n; i++) <br/>        {  <br/>            char ch = obj.pop(); <br/>            str.setCharAt(i,ch); <br/>        } <br/>    }  <br/>      <br/>    //driver function <br/>    public static void main(String args[]) <br/>    { <br/>        //create a new string <br/>        StringBuffer s= new StringBuffer(&quot;Wikitechy&quot;); <br/>          <br/>        //call reverse method <br/>        reverse(s); <br/>          <br/>        //print the reversed string <br/>        System.out.println(&quot;Reversed string is &quot; + s); <br/>    } <br/>} </code></pre> </div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="output" class="color-blue">Output</h2>
</div>
</div>
<div class="CodeContent" style="text-align: justify;">
<div class="hddn">
<figure class="highlight">
<pre><code id="code1" class="hljs typescript" data-lang=""><span class="nt">Reversed <span class="hljs-built_in">string</span> is yhcetikiW.
</span></code></pre>
</figure>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="time-complexity" class="color-blue">Time Complexity:</h2>
</div>
</div>
<div class="Content">
<div class="hddn">
<ul>
<li style="text-align: justify;">O(n) where n is number of characters in stack.</li>
</ul>
</div>
</div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/data-structure/write-a-program-to-reverse-a-string-using-stack-data-structure/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
