<?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>geekyants interview questions and answers - Wikitechy</title>
	<atom:link href="https://www.wikitechy.com/interview-questions/tag/geekyants-interview-questions-and-answers/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.wikitechy.com/interview-questions/tag/geekyants-interview-questions-and-answers/</link>
	<description>Interview Questions</description>
	<lastBuildDate>Mon, 13 Sep 2021 10:24:56 +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>geekyants interview questions and answers - Wikitechy</title>
	<link>https://www.wikitechy.com/interview-questions/tag/geekyants-interview-questions-and-answers/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>DFD for E-Commerce Website</title>
		<link>https://www.wikitechy.com/interview-questions/software-engineering/dfd-for-e-commerce-website/</link>
					<comments>https://www.wikitechy.com/interview-questions/software-engineering/dfd-for-e-commerce-website/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Thu, 22 Jul 2021 04:12:25 +0000</pubDate>
				<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[0 level dfd for online shopping project]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></category>
		<category><![CDATA[Applied Materials interview questions and answers]]></category>
		<category><![CDATA[Atos 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 Technologies interview questions and answers]]></category>
		<category><![CDATA[context level data flow diagram]]></category>
		<category><![CDATA[data flow diagram]]></category>
		<category><![CDATA[data flow diagram examples]]></category>
		<category><![CDATA[data flow diagram for online ordering system]]></category>
		<category><![CDATA[data flow diagram for online shopping system]]></category>
		<category><![CDATA[data flow diagram for website projects]]></category>
		<category><![CDATA[data flow diagram of website]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[dfd diagram for e-commerce website]]></category>
		<category><![CDATA[dfd for online gift shopping]]></category>
		<category><![CDATA[dfd for online supermarket]]></category>
		<category><![CDATA[dfd for websitee-commerce context diagram]]></category>
		<category><![CDATA[dfd level 0]]></category>
		<category><![CDATA[dfd level 1 for e commerce website]]></category>
		<category><![CDATA[dfd of e commerce site]]></category>
		<category><![CDATA[draw dfd for online shopping mall]]></category>
		<category><![CDATA[first level dfd for online shopping systemer diagram for online shopping]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[flow diagram of e commerce website]]></category>
		<category><![CDATA[geekyants interview questions and answers]]></category>
		<category><![CDATA[how to draw data flow diagram with example]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[Infosys Technologiesinterview questions and answers]]></category>
		<category><![CDATA[level 2 dfd for online shopping system]]></category>
		<category><![CDATA[level-1 dfd for online shopping system]]></category>
		<category><![CDATA[Mavenir interview questions and answers]]></category>
		<category><![CDATA[Mphasis interview questions and answers]]></category>
		<category><![CDATA[NetApp interview questions and answers]]></category>
		<category><![CDATA[olx data flow diagram]]></category>
		<category><![CDATA[online shopping dfd level 2]]></category>
		<category><![CDATA[online shopping e-r diagram and dfd]]></category>
		<category><![CDATA[Oracle Corporation interview questions and answers]]></category>
		<category><![CDATA[Reliance Industries Ltd interview questions and answers]]></category>
		<category><![CDATA[Ruboid Technovision Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[SAP Labs India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Tech Mahindra interview questions and answers]]></category>
		<category><![CDATA[Trigent Software interview questions and answers]]></category>
		<category><![CDATA[UnitedHealth Group 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[Xoriant Solutions Pvt Ltd interview questions and answers]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=1180</guid>

					<description><![CDATA[Answer : The System is recognized as a complete system “Fruit Bazaar System...]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="dfd-for-e-commerce-website" class="color-pink" style="text-align: justify;">DFD for E-Commerce Website</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>The System is recognized as a complete system “Fruit Bazaar System. The main actors for this system as Admin, Users, ShippingAgent.</li>
</ul>
</div>
</div>
<div class="ImageContent" style="text-align: justify;">
<div class="hddn"><img decoding="async" class="img-responsive center-block" src="https://cdn.wikitechy.com/interview-questions/software-engineering/dfd-for-e-commerce-website.png" alt=" DFD for E-Commerce Website" /></div>
</div>
<p style="text-align: justify;" align="center">DFD for E-Commerce Website</p>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="dfd-level-1" class="color-blue">DFD Level 1</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>User can Log-in, add, remove items to cart, register, pay.</li>
<li>Admin can have privileged login, they can change, modify catalog, to maintain the user data. In cart adding items then they can make an order. Un order database orders are stored.</li>
<li>The orders are processed and items from the <a href="https://www.wikitechy.com/tutorials/sqoop/sqoop-import-data-directly-into-hive-warehouse" target="_blank" rel="noopener">warehouse</a> are delivered to customer by shipping agent.</li>
</ul>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="dfd-level-2" class="color-blue">DFD Level 2</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>CartCustomer/User can browse the catalog and can add items to their cart for ordering. Moreover, Customer can remove items from their cart and after adding items to their cart they can checkout and move to Ordering.</li>
<li>For Order a customer should to be log-in.</li>
<li>Registration Maintenance</li>
<li>Admin can maintain the Catalog. The Catalog contains all items they are in stock with their rates.</li>
<li>Dynamic rates according to market value can also change the catalog information by Admin. He can add and remove the items from catalog and stocks.</li>
</ul>
</div>
</div>
<div class="Content">
<div class="hddn">
<ul>
<li style="text-align: justify;">User can manage their profile. Profile handling includes changing their account information like email, shipping address, passwords.</li>
<li style="text-align: justify;">If the user has created an invalid account then Admin can be removing the account or can intimate User about any fault in their profile.</li>
<li style="text-align: justify;">Physical Transaction At the time of delivery A shipping Agent which will take the items from warehouse along with the bill and deliver the item to customer.</li>
<li style="text-align: justify;">Customer will pay the respective bill and the bill id will be stored in transaction database.</li>
<li style="text-align: justify;">Cash transaction should be keeping record like in transaction database which will store bill amount and bill id.</li>
<li style="text-align: justify;">LOGINUser enter their login-id along with password. If the entered data is valid combination then homepage will be displayed.</li>
<li style="text-align: justify;">Otherwise a message intimating user about them invalidate login details.</li>
<li style="text-align: justify;">After placing Order Customer will be intimated by an order confirmation mail and sending a SMS containing order details and delivery time.</li>
</ul>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/software-engineering/dfd-for-e-commerce-website/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Difference Between Get and Post Method in PHP ?</title>
		<link>https://www.wikitechy.com/interview-questions/php/difference-between-get-and-post-method-in-php/</link>
					<comments>https://www.wikitechy.com/interview-questions/php/difference-between-get-and-post-method-in-php/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Wed, 21 Jul 2021 13:30:53 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[3i Infotech Limited interview questions and answers]]></category>
		<category><![CDATA[Accel Frontline Ltd interview questions and answers]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></category>
		<category><![CDATA[Applied Materials interview questions and answers]]></category>
		<category><![CDATA[Brillio Technologies Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Cactus Communications 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[CSG International interview questions and answers]]></category>
		<category><![CDATA[Cybage interview questions and answers]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[dget and post]]></category>
		<category><![CDATA[diff between get and post]]></category>
		<category><![CDATA[difference between get and post]]></category>
		<category><![CDATA[difference between get and post in html]]></category>
		<category><![CDATA[difference between get and post in java]]></category>
		<category><![CDATA[difference between get and post in php]]></category>
		<category><![CDATA[difference between get and post method]]></category>
		<category><![CDATA[difference between get and post method in htm]]></category>
		<category><![CDATA[difference between get and post method in java]]></category>
		<category><![CDATA[difference between get and post method in php]]></category>
		<category><![CDATA[difference between get and post method in php with example]]></category>
		<category><![CDATA[difference between get and post request]]></category>
		<category><![CDATA[difference between http get and post]]></category>
		<category><![CDATA[difference get and post]]></category>
		<category><![CDATA[example of get and post method]]></category>
		<category><![CDATA[example of get and post method in php]]></category>
		<category><![CDATA[geekyants interview questions and answers]]></category>
		<category><![CDATA[get and post difference]]></category>
		<category><![CDATA[get and post examples]]></category>
		<category><![CDATA[get and post in php]]></category>
		<category><![CDATA[get and post metho]]></category>
		<category><![CDATA[get and post method in c#]]></category>
		<category><![CDATA[get and post method in html]]></category>
		<category><![CDATA[get and post method in html examples]]></category>
		<category><![CDATA[get and post method in java]]></category>
		<category><![CDATA[get and post method in php]]></category>
		<category><![CDATA[get and post request]]></category>
		<category><![CDATA[Harbinger Systems interview questions and answers]]></category>
		<category><![CDATA[html get and post]]></category>
		<category><![CDATA[html get and post example]]></category>
		<category><![CDATA[http get and post]]></category>
		<category><![CDATA[http get and post method]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[Info Edge interview questions and answers]]></category>
		<category><![CDATA[Infogain interview questions and answers]]></category>
		<category><![CDATA[javascript get and post]]></category>
		<category><![CDATA[Maintec Technologies Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Mphasis interview questions and answers]]></category>
		<category><![CDATA[Net Solutions interview questions and answers]]></category>
		<category><![CDATA[Oracle Corporation interview questions and answers]]></category>
		<category><![CDATA[Prokarma Softech Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Raqmiyat Information Technologies Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Sopra Steria interview questions and answers]]></category>
		<category><![CDATA[Tech Mahindra 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[what is get and post]]></category>
		<category><![CDATA[what is get and post method]]></category>
		<category><![CDATA[what is the difference between get and post]]></category>
		<category><![CDATA[what is the difference between get and post method]]></category>
		<category><![CDATA[when to use get and post]]></category>
		<category><![CDATA[Wipro interview questions and answers]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=1148</guid>

					<description><![CDATA[Answer : GET requests can be cached...]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="difference-between-get-and-post-method-in-php" class="color-pink">Difference Between Get and Post Method in PHP ?</h2>
</div>
</div>
<div class="table-responsive">
<div class="hddn">
<table class="table-bordered table-striped table table-responsive">
<tbody>
<tr>
<th><a href="https://www.wikitechy.com/php/php-get" target="_blank" rel="noopener">$_GET Method</a></th>
<th><a href="https://www.wikitechy.com/php/php-post" target="_blank" rel="noopener">$_POST Method</a></th>
</tr>
<tr>
<td class="text-leftalign">GET requests can be cached.</td>
<td class="text-leftalign">POST requests are never cached.</td>
</tr>
<tr>
<td class="text-leftalign">GET requests remain in the browser history.</td>
<td class="text-leftalign">POST requests do not remain in the browser history.</td>
</tr>
<tr>
<td class="text-leftalign">Easier to hack for script kiddies.</td>
<td class="text-leftalign">More difficult to hack.</td>
</tr>
<tr>
<td class="text-leftalign">Restrictions on form data type. Only ASCII characters<br />
allowed.</td>
<td class="text-leftalign">No restrictions. Binary data is also allowed.</td>
</tr>
<tr>
<td class="text-leftalign">GET requests can be bookmarked.</td>
<td class="text-leftalign">POST requests cannot be bookmarked.</td>
</tr>
<tr>
<td class="text-leftalign">GET is less secure compared to POST because data sent<br />
is part of the URL. So it&#8217;s saved in browser history<br />
and server logs in plaintext.</td>
<td class="text-leftalign">POST is a little safer than GET because the parameters are not stored in browser history or in web server logs.</td>
</tr>
<tr>
<td class="text-leftalign">GET requests have length limitations.</td>
<td class="text-leftalign">POST requests have no limitations on data length .</td>
</tr>
<tr>
<td class="text-leftalign">GET method should not be used when<br />
sending passwords or other sensitive data.<br />
GET requests is only used to request data (not modify).</td>
<td class="text-leftalign">POST method used when sending passwords or other sensitive data.</td>
</tr>
<tr>
<td class="text-leftalign">
<div class="TextHeading">
<div class="hddn">
<h2 id="sample-code" class="color-purple">Sample Code</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-markup code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-markup code-embed-code">&lt;!DOCTYPE html&gt; <br/>&lt;html lang=&quot;en&quot;&gt; <br/>&lt;head&gt;<br/> &lt;title&gt;Example of PHP GET method&lt;/title&gt; <br/>&lt;/head&gt; <br/>&lt;body&gt; <br/>&lt;?php<br/> if(isset($_GET[&quot;name&quot;])){<br/> echo &quot;&lt;p&gt;Hi, &quot; . $_GET[&quot;name&quot;] . &quot;&lt;/p&gt;&quot;; <br/>} ?&gt;<br/> &lt;form method=&quot;get&quot; action=&quot;&lt;?<br/>php echo $_SERVER[&quot;PHP_SELF&quot;];?&gt;&quot;&gt;<br/> &lt;label for=&quot;inputName&quot;&gt;Name:&lt;/label&gt; <br/>&lt;input type=&quot;text&quot; name=&quot;name&quot; id=&quot;inputName&quot;&gt;<br/> &lt;input type=&quot;submit&quot; value=&quot;Submit&quot;&gt; <br/>&lt;/form&gt; <br/>&lt;/body&gt;</code></pre> </div>
</div>
</div>
<div class="CodeContent">
<div class="hddn"></div>
</div>
</td>
<td class="text-leftalign">
<div class="TextHeading">
<div class="hddn">
<h2 id="sample-code-2" class="color-purple">Sample Code</h2>
</div>
</div>
<div class="CodeContent">
<div class="hddn">
<figure class="highlight"><div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-markup code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-markup code-embed-code">&lt;!DOCTYPE html&gt; <br/>&lt;html lang=&quot;en&quot;&gt;<br/> &lt;head&gt; <br/>&lt;title&gt;Example of PHP POST method&lt;/title&gt;<br/> &lt;/head&gt; &lt;body&gt; <br/>&lt;?php <br/>if(isset($_POST[&quot;name&quot;])){ <br/>echo &quot;&lt;p&gt;Hi, &quot; . $_POST[&quot;name&quot;] . &quot;&lt;/p&gt;&quot;; } <br/>?&gt; <br/>&lt;form method=&quot;post&quot; action=&quot;<br/>&lt;?php echo $_SERVER[&quot;PHP_SELF&quot;];?<br/>&gt;&quot;&gt; <br/>&lt;label for=&quot;inputName&quot;&gt;Name:&lt;/label&gt; <br/>&lt;input type=&quot;text&quot; name=&quot;name&quot; id=&quot;inputName&quot;&gt;<br/> &lt;input type=&quot;submit&quot; value=&quot;Submit&quot;&gt;<br/> &lt;/form&gt;<br/> &lt;/body&gt;</code></pre> </div></figure>
</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/php/difference-between-get-and-post-method-in-php/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to check if two rectangles intersect or not ?</title>
		<link>https://www.wikitechy.com/interview-questions/java/how-to-check-if-two-rectangles-intersect-or-not/</link>
					<comments>https://www.wikitechy.com/interview-questions/java/how-to-check-if-two-rectangles-intersect-or-not/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 23:34:06 +0000</pubDate>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></category>
		<category><![CDATA[Applied Materials interview questions and answers]]></category>
		<category><![CDATA[area of intersection of two rectangles]]></category>
		<category><![CDATA[area of intersection of two rectangles python]]></category>
		<category><![CDATA[area of overlapping rectangles algorithm]]></category>
		<category><![CDATA[area of overlapping rectangles java]]></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[check if two rotated rectangles intersect]]></category>
		<category><![CDATA[Chetu interview questions and answers]]></category>
		<category><![CDATA[Ciena Corporation 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[determine if two rectangles overlap python]]></category>
		<category><![CDATA[find the intersection of two rectangles c]]></category>
		<category><![CDATA[FIS Global Business Solutions 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[how to find intersection of two rectangles in c]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[Infosys Technologies interview questions and answers]]></category>
		<category><![CDATA[intersection of rectangles in c]]></category>
		<category><![CDATA[intersection of two rectangles in c]]></category>
		<category><![CDATA[L&T Infotech 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[overlapping rectangles]]></category>
		<category><![CDATA[PeopleStrong interview questions and answers]]></category>
		<category><![CDATA[Persistent Systems interview questions and answers]]></category>
		<category><![CDATA[RBS India De interview questions and answers]]></category>
		<category><![CDATA[rectangle intersection algorithm]]></category>
		<category><![CDATA[rectangle overlap area c++]]></category>
		<category><![CDATA[rectangle overlap leetcode]]></category>
		<category><![CDATA[rectangle overlap lintcode]]></category>
		<category><![CDATA[Reliance Industries Ltd interview questions and answers]]></category>
		<category><![CDATA[SAP Labs India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Tech Mahindra interview questions and answers]]></category>
		<category><![CDATA[to check if two rectangles are intersecting or not]]></category>
		<category><![CDATA[UnitedHealth Group 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[Wipro Infotech interview questions and answers]]></category>
		<category><![CDATA[write a c program to find the intersection of the two given rectangles.]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=647</guid>

					<description><![CDATA[Answer : The following standard Java coding practices to solve...]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="how-to-check-if-two-rectangles-intersect-or-not" class="color-pink" style="text-align: justify;">How to check if two rectangles intersect or not ?</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li style="list-style-type: none;">
<ul>
<li>The following standard Java coding practices to solve this problem.</li>
<li>We have an encapsulated two co-ordinates in a Point class and have Rectangle has two Point <a href="https://www.wikitechy.com/tutorials/ruby-on-rails/avoid-instance-variables-use-getters-and-setters" target="_blank" rel="noopener">instance variable</a> and an instance method like <a href="https://www.wikitechy.com/tutorials/java/java-strings-equals" target="_blank" rel="noopener">equals()</a> to check if another rectangle is overlapping or not.</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/java/how-to-check-if-two-rectangles-intersect-or-not.jpg" alt=" To Check Rectangle Intersects or Not" /></div>
</div>
<ul>
<li>A rectangle can be represented by two coordinates, top left, and bottom right. As part of the problem you will be given four coordinates L1, R1 and L2, R2, top left and bottom right coordinate of two rectangles and you need to write a function isOverlapping() which should return true if rectangles are overlapping or false if they are not.</li>
</ul>
</div>
</div>
<div class="text-center row" style="text-align: justify;"></div>
<div class="TextHeading">
<div class="hddn">
<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-java code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-java code-embed-code">public class Main {<br/><br/>  public static void main(String[] args) {<br/>  Point l1 = new Point(0, 10);<br/>  Point r1 = new Point(10, 0);<br/>  Point l2 = new Point(5, 5);<br/>  Point r2 = new Point(15, 0);<br/><br/>  Rectangle first = new Rectangle(l1, r1);<br/>  Rectangle second = new Rectangle(l2, r2);<br/><br/>  if (first.isOverLapping(second)) {<br/>  System.out<br/>  .println(&quot;Yes, two rectangles are intersecting with each other&quot;);<br/>  } else {<br/>  System.out<br/>  .println(&quot;No, two rectangles are not overlapping with each other&quot;);<br/>  }<br/>  }<br/><br/>}<br/><br/>class Point {<br/>  int x;<br/>  int y;<br/><br/>  public Point(int x, int y) {<br/>  super();<br/>  this.x = x;<br/>  this.y = y;<br/>  }<br/>}<br/><br/>class Rectangle {<br/><br/>  private final Point topLeft;<br/>  private final Point bottomRight;<br/><br/>  public Rectangle(Point topLeft, Point bottomRight) {<br/>  this.topLeft = topLeft;<br/>  this.bottomRight = bottomRight;<br/>  }<br/><br/>  public boolean isOverLapping(Rectangle other) {<br/>  if (this.topLeft.x &gt; other.bottomRight.x // R1 is right to R2<br/>  || this.bottomRight.x &lt; other.topLeft.x // R1 is left to R2<br/>  || this.topLeft.y &lt; other.bottomRight.y // R1 is above R2<br/>  || this.bottomRight.y &gt; other.topLeft.y) { // R1 is below R1<br/>  return false;<br/>  }<br/>  return true;<br/>  }<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">
<div class="hddn">
<figure class="highlight" style="text-align: justify;">
<pre><code class="hljs javascript" data-lang=""><span class="nt">Yes, two rectangles are intersecting <span class="hljs-keyword">with</span> each other</span></code></pre>
</figure>
</div>
</div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/java/how-to-check-if-two-rectangles-intersect-or-not/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>
		<item>
		<title>How to remove duplicates from a sorted linked list ?</title>
		<link>https://www.wikitechy.com/interview-questions/data-structure/how-to-remove-duplicates-from-a-sorted-linked-list/</link>
					<comments>https://www.wikitechy.com/interview-questions/data-structure/how-to-remove-duplicates-from-a-sorted-linked-list/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 11:14:06 +0000</pubDate>
				<category><![CDATA[Data Structure]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></category>
		<category><![CDATA[algorithm to remove duplicate elements from 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[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[find duplicates in linked list java]]></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[linked list algorithm]]></category>
		<category><![CDATA[linked list implementation in java]]></category>
		<category><![CDATA[linked list insertion]]></category>
		<category><![CDATA[linked list interview questions]]></category>
		<category><![CDATA[linked list program in java]]></category>
		<category><![CDATA[merge sort 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 duplicates from linked list java]]></category>
		<category><![CDATA[remove duplicates from sorted linked list java]]></category>
		<category><![CDATA[remove duplicates from unsorted linked list]]></category>
		<category><![CDATA[reverse a linked lis]]></category>
		<category><![CDATA[reverse 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[Searches related to remove duplicates from unsorted linked list]]></category>
		<category><![CDATA[singly linked list]]></category>
		<category><![CDATA[sort linked list java]]></category>
		<category><![CDATA[sort linked listmerge two sorted linked lists]]></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=476</guid>

					<description><![CDATA[Answer : To write a removeDuplicates() function which takes a list sorted...]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="how-to-remove-duplicates-from-a-sorted-linked-list" class="color-pink" style="text-align: justify;">How to remove duplicates from a sorted linked list ?</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>To write a removeDuplicates() function which takes a <a href="https://www.wikitechy.com/interview-questions/latex/what-are-the-list-of-latex/" target="_blank" rel="noopener">list</a> sorted from the list any duplicate nodes to be deleted. The list should be traversed only once.</li>
</ul>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="algorithm" class="color-green">Algorithm</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Traverse the head (or start) node from the list. Compare each node with its next node while <a href="https://www.wikitechy.com/technology/python-algorithm-circular-linked-list-traversal/" target="_blank" rel="noopener">traversing</a>.</li>
<li>If same as the current node and data of next node to be delete that node. Before we delete a node, we need to store next pointer of the node.</li>
</ul>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="implementation" class="color-green">Implementation</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li><a href="https://www.wikitechy.com/tutorials/sql/functions-in-sql" target="_blank" rel="noopener">Functions</a> other than removeDuplicates() are just to create a linked.</li>
<li><a href="https://www.wikitechy.com/tutorials/java/java-linked-list" target="_blank" rel="noopener">Linked list</a> to be tested and removeDuplicates() from 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/how-to-remove-duplicates-from-a-sorted-linked-list.png" alt=" Remove Duplicate From a Sorting Linked List" /></div>
<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">class LinkedListExample <br/>{ <br/>	Node head; // head of list <br/><br/>	/* Linked list Node*/<br/>	class Node <br/>	{ <br/>		int data; <br/>		Node next; <br/>		Node(int d) {data = d; next = null; } <br/>	} <br/><br/>	void removeDuplicates() <br/>	{ <br/>		/*Another reference to head*/<br/>		Node current = head; <br/><br/>		/* Pointer to store the next pointer of a node to be deleted*/<br/>		Node next_next; <br/><br/>		/* do nothing if the list is empty */<br/>		if (head == null)	 <br/>			return; <br/><br/>		/* Traverse list till the last node */<br/>		while (current.next != null) { <br/><br/>			/*Compare current node with the next node */<br/>			if (current.data == current.next.data) { <br/>				next_next = current.next.next; <br/>				current.next = null; <br/>				current.next = next_next; <br/>			} <br/>			else // advance if no deletion <br/>			current = current.next; <br/>		} <br/>	} <br/>					<br/>	/* Utility functions */<br/><br/>	/* Inserts a new Node at front of the list. */<br/>	public void push(int new_data) <br/>	{ <br/>		/* 1 &amp; 2: Allocate the Node &amp; <br/>				Put in the data*/<br/>		Node new_node = new Node(new_data); <br/><br/>		/* 3. Make next of new Node as head */<br/>		new_node.next = head; <br/><br/>		/* 4. Move the head to point to new Node */<br/>		head = new_node; <br/>	} <br/><br/>	/* Function to print linked list */<br/>	void printList() <br/>	{ <br/>		Node temp = head; <br/>		while (temp != null) <br/>		{ <br/>			System.out.print(temp.data+&quot; &quot;); <br/>			temp = temp.next; <br/>		} <br/>		System.out.println(); <br/>	} <br/><br/>	/* Drier program to test above functions */<br/>	public static void main(String args[]) <br/>	{ <br/>		LinkedListExample wikitechylist = new LinkedListExample(); <br/>		wikitechylist.push(63); <br/>		wikitechylist.push(50); <br/>		wikitechylist.push(50); <br/>		wikitechylist.push(42); <br/>		wikitechylist.push(27); <br/>		wikitechylist.push(27); <br/>		<br/>		System.out.println(&quot;LinkedList before removal of duplicates&quot;); <br/>		wikitechylist.printList(); <br/>		<br/>		wikitechylist.removeDuplicates(); <br/>		<br/>		System.out.println(&quot;LinkedList after removal of elements&quot;); <br/>		wikitechylist.printList(); <br/>	} <br/>} </code></pre> </div>
<div class="Output" style="text-align: justify;">
<div class="hddn">
<figure class="highlight"><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">LinkedList before removal of duplicates<br/>27 27 42 50 50 63 <br/>LinkedList after removal of elements<br/>27 42 50 63</code></pre> </div></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 nodes in the given linked list.</li>
</ul>
</div>
</div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/data-structure/how-to-remove-duplicates-from-a-sorted-linked-list/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
