<?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>reverse a linked lis - Wikitechy</title>
	<atom:link href="https://www.wikitechy.com/interview-questions/tag/reverse-a-linked-lis/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.wikitechy.com/interview-questions/tag/reverse-a-linked-lis/</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=7.0</generator>

<image>
	<url>https://www.wikitechy.com/interview-questions/wp-content/uploads/2025/10/cropped-wikitechy-icon-32x32.png</url>
	<title>reverse a linked lis - Wikitechy</title>
	<link>https://www.wikitechy.com/interview-questions/tag/reverse-a-linked-lis/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<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 & 2: Allocate the Node & <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>
