<?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>compro technologies interview questions and answers - Wikitechy</title>
	<atom:link href="https://www.wikitechy.com/interview-questions/tag/compro-technologies-interview-questions-and-answers/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.wikitechy.com/interview-questions/tag/compro-technologies-interview-questions-and-answers/</link>
	<description>Interview Questions</description>
	<lastBuildDate>Mon, 02 May 2022 06:17:05 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>

<image>
	<url>https://www.wikitechy.com/interview-questions/wp-content/uploads/2025/10/cropped-wikitechy-icon-32x32.png</url>
	<title>compro technologies interview questions and answers - Wikitechy</title>
	<link>https://www.wikitechy.com/interview-questions/tag/compro-technologies-interview-questions-and-answers/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Java Program to reverse a Linked List ?</title>
		<link>https://www.wikitechy.com/interview-questions/java/java-program-to-reverse-a-linked-list/</link>
					<comments>https://www.wikitechy.com/interview-questions/java/java-program-to-reverse-a-linked-list/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Wed, 14 Jul 2021 00:03:25 +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[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[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 Technologies interview questions and answers]]></category>
		<category><![CDATA[compro technologies interview questions and answers]]></category>
		<category><![CDATA[create linked list java]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[doubly linked list java]]></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[how to implement 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[Infosys Technologies interview questions and answers]]></category>
		<category><![CDATA[javascript linked list]]></category>
		<category><![CDATA[L&T Infotech interview questions and answers]]></category>
		<category><![CDATA[linked list class in java]]></category>
		<category><![CDATA[linked list data structure in java]]></category>
		<category><![CDATA[linked list implementation in java]]></category>
		<category><![CDATA[linked list implementation in java source code]]></category>
		<category><![CDATA[linked list java code]]></category>
		<category><![CDATA[linked list java tutorial]]></category>
		<category><![CDATA[linked list program in 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[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[Reliance Industries Ltd interview questions and answers]]></category>
		<category><![CDATA[reverse linked list java]]></category>
		<category><![CDATA[SAP Labs India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[singly linked list java]]></category>
		<category><![CDATA[sort linked list java]]></category>
		<category><![CDATA[Tech Mahindra 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[Wipro Infotech interview questions and answers]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=666</guid>

					<description><![CDATA[Answer : A Linked list contains two things data and the address of the node each node....]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="java-program-to-reverse-a-linked-list" class="color-pink" style="text-align: justify;">Java Program to reverse a Linked List ?</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>A <a href="https://www.wikitechy.com/technology/quicksort-doubly-linked-list-2/" target="_blank" rel="noopener">Linked list</a> contains two things data and the address of the node each node is linked to the next node.</li>
<li>There can be two solution to reverse a linked list in java.
<ul>
<li><a href="https://www.wikitechy.com/technology/iterative-quick-sort/" target="_blank" rel="noopener">Iterative</a></li>
<li><a href="https://www.wikitechy.com/technology/c-algorithm-write-recursive-function-print-reverse-linked-list/" target="_blank" rel="noopener">Recursive</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="iterative" class="color-purple">Iterative</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Here we have three nodes i.e previousNode, currentNode and nextNode</li>
<li>When currentNode is starting node, then previousNode will be null</li>
<li>Assign currentNode.next to previousNode to reverse the link.</li>
<li>In each iteration move currentNode and previousNode by 1 node.</li>
</ul>
</div>
</div>
<div class="text-center row" style="text-align: justify;">
<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/java/iterative-method-linked-list.gif" alt=" data- linked-list" /></div>
<div>
<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 static Node reverseLinkedList(Node currentNode)<br/>	{<br/>		// For first node, previousNode will be null<br/>		Node previousNode=null;<br/>		Node nextNode;<br/>		while(currentNode!=null)<br/>		{<br/>			nextNode=currentNode.next;<br/>			// reversing the link<br/>			currentNode.next=previousNode;<br/>			// moving currentNode and previousNode by 1 node<br/>			previousNode=currentNode;<br/>			currentNode=nextNode;<br/>		}<br/>		return previousNode;<br/>	}</code></pre> </div>
<h2 id="sample-code-in-java" class="color-pink" 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 LinkedList{<br/> <br/>	private Node head;<br/> <br/>	private static class Node {<br/>		private int value;<br/>		private Node next;<br/> <br/>		Node(int value) {<br/>			this.value = value;<br/> <br/>		}<br/>	}<br/> <br/>	public void addToTheLast(Node node) {<br/> <br/>		if (head == null) {<br/>			head = node;<br/>		} else {<br/>			Node temp = head;<br/>			while (temp.next != null)<br/>				temp = temp.next;<br/> <br/>			temp.next = node;<br/>		}<br/>	}<br/> <br/> <br/>	public void printList(Node head) {<br/>		Node temp = head;<br/>		while (temp != null) {<br/>			System.out.format(&quot;%d &quot;, temp.value);<br/>			temp = temp.next;<br/>		}<br/>		System.out.println();<br/>	}<br/> <br/>	// Reverse linkedlist using this function <br/>	public static Node reverseLinkedList(Node currentNode)<br/>	{<br/>		// For first node, previousNode will be null<br/>		Node previousNode=null;<br/>		Node nextNode;<br/>		while(currentNode!=null)<br/>		{<br/>			nextNode=currentNode.next;<br/>			// reversing the link<br/>			currentNode.next=previousNode;<br/>			// moving currentNode and previousNode by 1 node<br/>			previousNode=currentNode;<br/>			currentNode=nextNode;<br/>		}<br/>		return previousNode;<br/>	}<br/> <br/>	public static void main(String[] args) {<br/>		LinkedList list = new LinkedList();<br/>		// Creating a linked list<br/>		Node head=new Node(5);<br/>		list.addToTheLast(head);<br/>		list.addToTheLast(new Node(6));<br/>		list.addToTheLast(new Node(7));<br/>		list.addToTheLast(new Node(1));<br/>		list.addToTheLast(new Node(2));<br/> <br/>		list.printList(head);<br/>		//Reversing LinkedList<br/>		Node reverseHead=reverseLinkedList(head);<br/>		System.out.println(&quot;After reversing&quot;);<br/>		list.printList(reverseHead);<br/> <br/>	}<br/> <br/>}</code></pre> </div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="output" class="color-pink">Output :</h2>
</div>
</div>
<div class="Output">
<div class="hddn">
<figure class="highlight">
<pre><code class="hljs" data-lang=""><span class="nt">5 6 7 1 2 
After reversing
2 1 7 6 5</span></code></pre>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="recursive-method" class="color-purple">Recursive Method:</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Divide the list in two parts – first node and rest of the linked list.</li>
<li>Call reverse for the rest of the linked list.</li>
<li>Link rest to first.</li>
<li>Fix head 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/java/reverse-linked-list-in-java.jpg" alt=" data- linked-list" /></div>
</div>
</figure>
</div>
</div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/java/java-program-to-reverse-a-linked-list/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Why do we need garbage collection ?</title>
		<link>https://www.wikitechy.com/interview-questions/java/why-do-we-need-garbage-collection/</link>
					<comments>https://www.wikitechy.com/interview-questions/java/why-do-we-need-garbage-collection/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Wed, 14 Jul 2021 00:03:15 +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[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[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[compro technologies interview questions and answers]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></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[g1 garbage collector]]></category>
		<category><![CDATA[garbage collection algorithms for equal sized blocks]]></category>
		<category><![CDATA[garbage collection algorithms in java]]></category>
		<category><![CDATA[garbage collection algorithms in java 8]]></category>
		<category><![CDATA[garbage collection algorithms mark and sweep]]></category>
		<category><![CDATA[garbage collection in java]]></category>
		<category><![CDATA[garbage collection in java 8]]></category>
		<category><![CDATA[garbage collection in java 8 example]]></category>
		<category><![CDATA[garbage collection in java interview questions]]></category>
		<category><![CDATA[garbage collectors in jdk 6 includes]]></category>
		<category><![CDATA[how garbage collection works in java]]></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[java 7 garbage collection]]></category>
		<category><![CDATA[java garbage collection tuning]]></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[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[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[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[what is the purpose of garbage collection in java and when is it used]]></category>
		<category><![CDATA[Wipro Infotech interview questions and answers]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=665</guid>

					<description><![CDATA[Answer : Java garbage collection is the method by which Java programs ....]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="why-do-we-need-garbage-collection" class="color-pink" style="text-align: justify;">Why do we need garbage collection ?</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Java garbage collection is the method by which Java programs achieve automatic <a href="https://www.wikitechy.com/tutorials/c++/c++-memory-management" target="_blank" rel="noopener">memory management</a>.</li>
<li>Java programs compile to bytecode which will be run on a Java Virtual Machine.</li>
<li>Once java programs run on the JVM, objects are created on the <a href="https://www.wikitechy.com/technology/time-complexity-building-heap-2/" target="_blank" rel="noopener">heap</a>, which is a portion of memory dedicated to the program. Finally, some objects cannot be required.</li>
<li>The garbage collector finds these unused objects and deletes them to free up memory.</li>
</ul>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="how-java-garbage-collection-works" class="color-blue">How Java Garbage Collection Works</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Java garbage collection is an automatic process.</li>
<li>The programmer does not need to explicitly mark objects to be deleted. The garbage collection implementation lives in the JVM. Every JVM will implement garbage collection however it satisfies the only requirement is that it meets the JVM specification.</li>
<li>Although there are many JVMs, Oracle’s HotSpot is the most common. It offers a robust and complete set of garbage collection options.</li>
<li>While HotSpot has multiple garbage collectors that are optimized for various use cases, all its garbage collectors follow the same basic process.
<ul>
<li>In the first step, unreferenced objects are identified and marked as ready for garbage collection.</li>
<li>In the second step, marked objects are deleted.</li>
<li>Optionally, memory can be compacted after the garbage collector deletes objects, so remaining objects are in a contiguous block at the start of the heap. The compaction process makes it easier to allocate memory to new objects sequentially after the block of memory allocated to existing objects.</li>
</ul>
</li>
<li>All of HotSpot’s garbage collectors implement a generational garbage collection strategy that categorizes objects by age. The rationale behind generational garbage collection is that most objects are short-lived and will be ready for garbage collection soon after creation.</li>
</ul>
</div>
</div>
<div class="text-center row" style="text-align: justify;"></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/java/garbage-collection-in-java.png" alt=" garbage" /></div>
</div>
<div class="subheading" style="text-align: justify;">
<h2 id="the-heap-is-divided-into-three-sections">The heap is divided into three sections:</h2>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="young-generation" class="color-pink">Young Generation</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>Newly created objects start in the Young Generation. The Young Generation is further subdivided into an Eden space, where all new objects start, and two Survivor spaces, where objects are moved from Eden after surviving one garbage collection cycle.</li>
<li>When objects are garbage collected from the Young Generation, it is a minor garbage collection event.</li>
</ul>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="old-generation" class="color-pink">Old Generation:</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li><a href="https://www.wikitechy.com/tutorials/c++/c++-object" target="_blank" rel="noopener">Objects</a> that are long-lived are ultimately moved from the Young Generation to the Old Generation. When objects are garbage collected from the Old Generation, it is a major garbage collection event.</li>
</ul>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="permanent-generation" class="color-pink">Permanent Generation:</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li><a href="https://www.wikitechy.com/interview-questions/pentaho/what-is-the-importance-of-metadata-in-pentaho/" target="_blank" rel="noopener">Metadata</a> classes and methods are stored in the Permanent Generation. Classes that are no longer in use may be garbage collected from the Permanent Generation.</li>
</ul>
<p><img fetchpriority="high" decoding="async" class="alignnone size-full wp-image-4219 aligncenter" src="https://www.wikitechy.com/interview-questions/wp-content/uploads/2021/07/how-garbage-collector-works.png" alt="" width="1490" height="808" srcset="https://www.wikitechy.com/interview-questions/wp-content/uploads/2021/07/how-garbage-collector-works.png 1490w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2021/07/how-garbage-collector-works-300x163.png 300w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2021/07/how-garbage-collector-works-1024x555.png 1024w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2021/07/how-garbage-collector-works-768x416.png 768w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2021/07/how-garbage-collector-works-390x211.png 390w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2021/07/how-garbage-collector-works-820x445.png 820w, https://www.wikitechy.com/interview-questions/wp-content/uploads/2021/07/how-garbage-collector-works-1180x640.png 1180w" sizes="(max-width: 1490px) 100vw, 1490px" /></p>
</div>
</div>
<div class="TextHeading" style="text-align: justify;">
<div class="hddn">
<h2 id="needs-of-java-garbage-collection" class="color-green">Needs of Java Garbage Collection</h2>
</div>
</div>
<div class="Content">
<div class="hddn">
<ul>
<li style="text-align: justify;">The benefit of Java garbage collection is that it automatically handles the deletion of unused objects or objects that are out of reach to free up memory resources.</li>
<li style="text-align: justify;">Programmers working in languages without garbage collection (like <a href="https://www.wikitechy.com/tutorials/c-programming/" target="_blank" rel="noopener">C</a> and <a href="https://www.wikitechy.com/tutorials/c++/">C++</a>) must implement manual memory management in their code.</li>
<li style="text-align: justify;">Some programmers maintain in favor of manual memory management over garbage collection, primarily for reasons of control and performance.</li>
<li style="text-align: justify;">While the discussion over memory management approaches continues to rage on, garbage collection is now a standard component of many popular programming languages.</li>
<li style="text-align: justify;">For situations in which the garbage collector is negatively impacting performance, Java offers several options for tuning the garbage collector to improve its efficiency.</li>
</ul>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/java/why-do-we-need-garbage-collection/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Find number of occurrence of each of the unique characters in a string ?</title>
		<link>https://www.wikitechy.com/interview-questions/java/find-number-of-occurrence-of-each-of-the-unique-characters-in-a-string/</link>
					<comments>https://www.wikitechy.com/interview-questions/java/find-number-of-occurrence-of-each-of-the-unique-characters-in-a-string/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Wed, 14 Jul 2021 00:03:09 +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[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[charat java]]></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[compro technologies interview questions and answers]]></category>
		<category><![CDATA[count occurrences of character in string java using hashmap]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></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[how to count characters in string array in java]]></category>
		<category><![CDATA[how to count occurrence of a given character in a string 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[java counter]]></category>
		<category><![CDATA[java replace]]></category>
		<category><![CDATA[java string]]></category>
		<category><![CDATA[java string compare]]></category>
		<category><![CDATA[java string contains]]></category>
		<category><![CDATA[java string length]]></category>
		<category><![CDATA[java string replace]]></category>
		<category><![CDATA[java trim]]></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[occurrence of each character in string java]]></category>
		<category><![CDATA[Oracle Corporation interview questions and answers]]></category>
		<category><![CDATA[PeopleStrong interview questions and answers]]></category>
		<category><![CDATA[Persistent Systems interview questions and answers]]></category>
		<category><![CDATA[program to find occurrence of a character in a string in java]]></category>
		<category><![CDATA[RBS India De interview questions and answers]]></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[string class in java]]></category>
		<category><![CDATA[string class methods in java]]></category>
		<category><![CDATA[string count]]></category>
		<category><![CDATA[substring java]]></category>
		<category><![CDATA[Tech Mahindra 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[Wipro Infotech interview questions and answers]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=664</guid>

					<description><![CDATA[Answer : In this program an approach using Hashmap....]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="find-number-of-occurrence-of-each-of-the-unique-characters-in-a-string" class="color-pink" style="text-align: justify;">Find number of occurrence of each of the unique characters in a string ?</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li>In this program an approach using <a href="https://www.wikitechy.com/tutorials/java/java-linked-hashmap" target="_blank" rel="noopener">Hashmap</a> in Java.
<ul>
<li>Declare a Hashmap in Java of {char, int}.</li>
<li>Traverse in the string, check if the Hashmap already contains the traversed character or not.</li>
<li>If it is present, then increase its count using <a href="https://www.wikitechy.com/tutorials/python/get-method-for-dictionaries-in-python" target="_blank" rel="noopener">get()</a> and put() function in Hashmap.</li>
<li>Once the traversal is completed, traverse in the Hashmap and print the character and its frequency.</li>
</ul>
</li>
</ul>
</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-java code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-java code-embed-code">Input: str = &quot;Wikitechy&quot;<br/>Output: <br/>        W 1<br/>        i 2<br/>        k 1<br/>        t 1<br/>        e 1<br/>        c 1<br/>        h 1<br/>        y 1</code></pre> </div>
<h2 id="sample-code-in-java" class="color-blue">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">// Java prorgam to count frequencies of <br/>// characters in string using Hashmap <br/>import java.io.*; <br/>import java.util.*; <br/>class OccurenceOfCharInString { <br/>	static void characterCount(String inputString) <br/>	{ <br/>		// Creating a HashMap containing char <br/>		// as a key and occurrences as a value <br/>		HashMap<Character, Integer> charCountMap = new HashMap<Character, Integer>(); <br/><br/>		// Converting given string to char array <br/><br/>		char[] strArray = inputString.toCharArray(); <br/><br/>		// checking each char of strArray <br/>		for (char c : strArray) { <br/>			if (charCountMap.containsKey(c)) { <br/><br/>				// If char is present in charCountMap, <br/>				// incrementing it&#039;s count by 1 <br/>				charCountMap.put(c, charCountMap.get(c) + 1); <br/>			} <br/>			else { <br/><br/>				// If char is not present in charCountMap, <br/>				// putting this char to charCountMap with 1 as it&#039;s value <br/>				charCountMap.put(c, 1); <br/>			} <br/>		} <br/><br/>		// Printing the charCountMap <br/>		for (Map.Entry entry : charCountMap.entrySet()) { <br/>			System.out.println(entry.getKey() + &quot; &quot; + entry.getValue()); <br/>		} <br/>	} <br/><br/>	// Driver Code <br/>	public static void main(String[] args) <br/>	{ <br/>		String str = &quot;Wikitechy&quot;; <br/>		characterCount(str); <br/>	} <br/>} </code></pre> </div>
<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">Output<br/>c 1<br/>t 1<br/>e 1<br/>W 1<br/>h 1<br/>i 2<br/>y 1<br/>k 1</code></pre> </div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/java/find-number-of-occurrence-of-each-of-the-unique-characters-in-a-string/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->25->4->30<br/>   lsit2:  8->4->2->20<br/>Output:<br/>   Intersection List: 4->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<stdio.h> <br/>#include<stdlib.h> <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 > 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 < d; i++) <br/>  { <br/>    if(current1 == NULL) <br/>    {  return -1; } <br/>    current1 = current1->next; <br/>  } <br/>  <br/>  while(current1 !=  NULL && current2 != NULL) <br/>  { <br/>    if(current1 == current2) <br/>      return current1->data; <br/>    current1= current1->next; <br/>    current2= current2->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->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->6->9->15->30 <br/>    2nd 10->15->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->data  = 10; <br/>  <br/>  struct Node* head2 = <br/>            (struct Node*) malloc(sizeof(struct Node)); <br/>  head2->data  = 3; <br/>  <br/>  newNode = (struct Node*) malloc (sizeof(struct Node)); <br/>  newNode->data = 6; <br/>  head2->next = newNode; <br/>  <br/>  newNode = (struct Node*) malloc (sizeof(struct Node)); <br/>  newNode->data = 9; <br/>  head2->next->next = newNode; <br/>  <br/>  newNode = (struct Node*) malloc (sizeof(struct Node)); <br/>  newNode->data = 15; <br/>  head1->next = newNode; <br/>  head2->next->next->next  = newNode; <br/>  <br/>  newNode = (struct Node*) malloc (sizeof(struct Node)); <br/>  newNode->data = 30; <br/>  head1->next->next= newNode; <br/>  <br/>  head1->next->next->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 – 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->2->3->7->6<br/>Output: Linked List =  9->3->7->6<br/><br/>Input: position = 0, Linked List = 9->2->3->7->6<br/>Output: Linked List = 2->3->7->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 <stdio.h> <br/>#include <stdlib.h> <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->data = new_data; <br/>	new_node->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->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 && i<position-1; i++) <br/>		temp = temp->next; <br/><br/>	// If position is more than number of ndoes <br/>	if (temp == NULL || temp->next == NULL) <br/>		return; <br/><br/>	// Node temp->next is the node to be deleted <br/>	// Store pointer to the next of node to be deleted <br/>	struct Node *next = temp->next->next; <br/><br/>	// Unlink the node from linked list <br/>	free(temp->next); // Free memory <br/><br/>	temp->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->data); <br/>		node = node->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(&head, 6); <br/>	push(&head, 7); <br/>	push(&head, 3); <br/>	push(&head, 2); <br/>	push(&head, 9); <br/><br/>	puts(&quot;Created Linked List: &quot;); <br/>	printList(head); <br/>	deleteNode(&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>What is the best way to sort an array of 0s and 1s ?</title>
		<link>https://www.wikitechy.com/interview-questions/cpp/what-is-the-best-way-to-sort-an-array-of-0s-and-1s/</link>
					<comments>https://www.wikitechy.com/interview-questions/cpp/what-is-the-best-way-to-sort-an-array-of-0s-and-1s/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Mon, 12 Jul 2021 23:13:59 +0000</pubDate>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></category>
		<category><![CDATA[all sorting programs in c++]]></category>
		<category><![CDATA[Applied Materials interview questions and answers]]></category>
		<category><![CDATA[array sort]]></category>
		<category><![CDATA[array sort c++]]></category>
		<category><![CDATA[array sorting in c]]></category>
		<category><![CDATA[arraylist sort]]></category>
		<category><![CDATA[ascending order program in c++ using for loop]]></category>
		<category><![CDATA[Atos interview questions and answers]]></category>
		<category><![CDATA[BMC Software interview questions and answers]]></category>
		<category><![CDATA[Bosch India Software interview questions and answers]]></category>
		<category><![CDATA[bubble sort c++]]></category>
		<category><![CDATA[c++ container sort]]></category>
		<category><![CDATA[c++ program to sort an array in ascending order using functionsort array c++ ascending function]]></category>
		<category><![CDATA[c++ program to sort an array in descending order]]></category>
		<category><![CDATA[c++ set sort]]></category>
		<category><![CDATA[c++ sort array]]></category>
		<category><![CDATA[c++ sort array alphabetically]]></category>
		<category><![CDATA[c++ sort custom comparator]]></category>
		<category><![CDATA[c++ sort vector of doubles]]></category>
		<category><![CDATA[c++ sort vector of strings]]></category>
		<category><![CDATA[c++ sort vector of strings alphabetically]]></category>
		<category><![CDATA[CASTING NETWORKS INDIA PVT LIMITED interview questions and answers]]></category>
		<category><![CDATA[Chetu interview questions and answers]]></category>
		<category><![CDATA[Ciena Corporation 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[eInfochips interview questions and answers]]></category>
		<category><![CDATA[Electronics Arts Inc interview questions and answers]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[Harman International interview questions and answers]]></category>
		<category><![CDATA[how to sort an array]]></category>
		<category><![CDATA[how to sort an array in c++]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[Larsen & Toubro interview questions and answers]]></category>
		<category><![CDATA[Mathworks India Private Limited interview questions and answers]]></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[Oracle Corporation interview questions and answers]]></category>
		<category><![CDATA[PeopleStrong interview questions and answers]]></category>
		<category><![CDATA[Philips Software Centre Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[q sort function in c++]]></category>
		<category><![CDATA[sort array c++ ascending]]></category>
		<category><![CDATA[sort deque c++]]></category>
		<category><![CDATA[sort float vector c++]]></category>
		<category><![CDATA[sort function in c]]></category>
		<category><![CDATA[sort part of array c++]]></category>
		<category><![CDATA[sort part of vector c++]]></category>
		<category><![CDATA[sort string array in java]]></category>
		<category><![CDATA[sort vector in descending order c++]]></category>
		<category><![CDATA[sorting an array in c++ program]]></category>
		<category><![CDATA[SRM Technologies interview questions and answers]]></category>
		<category><![CDATA[Symphony Teleca interview questions and answers]]></category>
		<category><![CDATA[Tech Mahindra interview questions and answers]]></category>
		<category><![CDATA[Tecnotree interview questions and answers]]></category>
		<category><![CDATA[Wipro Infotech interview questions and answers]]></category>
		<category><![CDATA[Wipro interview questions and answers]]></category>
		<category><![CDATA[Yash Technologies interview questions and answers]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=398</guid>

					<description><![CDATA[Answer : Sort an array elements means arrange...]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="what-is-the-best-way-to-sort-an-array-of-0s-and-1s" class="color-pink" style="text-align: justify;">What is the best way to sort an array of 0s and 1s ?</h2>
</div>
</div>
<div class="Content" style="text-align: justify;">
<div class="hddn">
<ul>
<li><a href="https://www.wikitechy.com/tutorials/java/how-to-sort-string-array-in-java" target="_blank" rel="noopener">Sort an array</a> elements means arrange elements of array in <a href="https://www.wikitechy.com/angularjs/angularjs-orderby-filter" target="_blank" rel="noopener">ascending order and descending order</a>.</li>
</ul>
</div>
</div>
<p style="text-align: justify;">Given an array A[] consisting 0s, 1s and 2s, write a function that sorts A[]. The functions should put all 0s first, then all 1s and all 2s in last.</p>
<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-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">Input :  {0, 1, 2, 0, 1, 2}<br/>Output : {0, 0, 1, 1, 2, 2}<br/>Input :  {0, 1, 1, 0, 1, 2, 1, 2, 0, 0, 0, 1}<br/>Output : {0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2}</code></pre> </div>
</div>
</div>
<div class="Output" style="text-align: justify;">
<div class="hddn">
<figure class="highlight">
<pre><code class="hljs" data-lang=""></code><img decoding="async" class="img-responsive center-block aligncenter" src="https://cdn.wikitechy.com/interview-questions/cpp/sort-an-array-of-0s-and-1s.gif" alt=" Sort" /></pre>
</figure>
</div>
</div>
<div class="CodeContent" style="text-align: justify;">
<div class="hddn">
<figure class="highlight">
<div class="TextHeading">
<div class="hddn">
<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-cpp code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-cpp code-embed-code">#include <bits/stdc++.h><br/>using namespace std; <br/>  <br/>// Function to segregate 0s and 1s <br/>void segregate0and1(intarr[], int n) <br/>{ <br/>    int count = 0; // Counts the no of zeros in arr<br/>  	<br/>    for (inti = 0; i< n; i++) { <br/>        if (arr[i] == 0) <br/>            count++; <br/>    } <br/>  <br/>    // Loop fills the arr with 0 until count <br/>    for (inti = 0; i< count; i++) <br/>        arr[i] = 0; <br/>  <br/>    // Loop fills remaining arr space with 1 <br/>    for (inti = count; i< n; i++) <br/>        arr[i] = 1; <br/>} <br/>  <br/>// Function to print segregated array <br/>void print(intarr[], int n) <br/>{ <br/>    cout<< &quot;Array after segregation is &quot;; <br/>  <br/>    for (inti = 0; i< n; i++) <br/>        cout<<arr[i] << &quot; &quot;; <br/>} <br/>  <br/>// Driver function <br/>int main() <br/>{ <br/>    intarr[] = { 0, 1, 0, 1, 1, 1 }; <br/>    int n = sizeof(arr) / sizeof(arr[0]); <br/>      <br/>    segregate0and1(arr, n); <br/>    print(arr, n); <br/>      <br/>    return 0; <br/>} </code></pre> </div>
<div class="TextHeading">
<div class="hddn">
<h2 id="output" class="color-purple">Output</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">Array after segregation is 0 0 1 1 1 1</code></pre> </div>
</div>
</div>
</div>
</div>
</figure>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/cpp/what-is-the-best-way-to-sort-an-array-of-0s-and-1s/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
