<?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>doubly linked list geeksforgeeks - Wikitechy</title>
	<atom:link href="https://www.wikitechy.com/interview-questions/tag/doubly-linked-list-geeksforgeeks/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.wikitechy.com/interview-questions/tag/doubly-linked-list-geeksforgeeks/</link>
	<description>Interview Questions</description>
	<lastBuildDate>Mon, 13 Sep 2021 06:23:08 +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>doubly linked list geeksforgeeks - Wikitechy</title>
	<link>https://www.wikitechy.com/interview-questions/tag/doubly-linked-list-geeksforgeeks/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Delete all occurrences of a given key in a linked list ?</title>
		<link>https://www.wikitechy.com/interview-questions/data-structure/delete-all-occurrences-of-a-given-key-in-a-linked-list/</link>
					<comments>https://www.wikitechy.com/interview-questions/data-structure/delete-all-occurrences-of-a-given-key-in-a-linked-list/#respond</comments>
		
		<dc:creator><![CDATA[Editor]]></dc:creator>
		<pubDate>Tue, 13 Jul 2021 17:39:53 +0000</pubDate>
				<category><![CDATA[Data Structure]]></category>
		<category><![CDATA[Accenture interview questions and answers]]></category>
		<category><![CDATA[Altimetrik India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Applied Materials interview questions and answers]]></category>
		<category><![CDATA[Bharti Airtel interview questions and answers]]></category>
		<category><![CDATA[BMC Software interview questions and answers]]></category>
		<category><![CDATA[c program to delete first node in linked list]]></category>
		<category><![CDATA[Capgemini interview questions and answers]]></category>
		<category><![CDATA[CASTING NETWORKS INDIA PVT LIMITED interview questions and answers]]></category>
		<category><![CDATA[CGI Group Inc interview questions and answers]]></category>
		<category><![CDATA[Chetu interview questions and answers]]></category>
		<category><![CDATA[Ciena Corporation interview questions and answers]]></category>
		<category><![CDATA[Collabera Te interview questions and answers]]></category>
		<category><![CDATA[delete a specific node in linked list java]]></category>
		<category><![CDATA[delete all nodes in doubly linked list c++]]></category>
		<category><![CDATA[delete at position in a doubly linked list]]></category>
		<category><![CDATA[delete first node in linked list c++]]></category>
		<category><![CDATA[delete last node in doubly linked list in c++]]></category>
		<category><![CDATA[delete last node in linked list c++]]></category>
		<category><![CDATA[delete last node in linked list in c]]></category>
		<category><![CDATA[delete node at given position in a linked list in c++]]></category>
		<category><![CDATA[delete node from doubly linked list java]]></category>
		<category><![CDATA[Dell International Services India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[doubly linked list geeksforgeeks]]></category>
		<category><![CDATA[Flipkart interview questions and answers]]></category>
		<category><![CDATA[Genpact interview questions and answers]]></category>
		<category><![CDATA[Globallogic India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[IBM interview questions and answers]]></category>
		<category><![CDATA[Indecomm Global Services interview questions and answers]]></category>
		<category><![CDATA[Mphasis interview questions and answers]]></category>
		<category><![CDATA[NetApp interview questions and answers]]></category>
		<category><![CDATA[Oracle Corporation interview questions and answers]]></category>
		<category><![CDATA[remove element from doubly linked list c++]]></category>
		<category><![CDATA[samsung interview questions and answers]]></category>
		<category><![CDATA[SAP Labs India Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Sapient Consulting Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Tech Mahindra interview questions and answers]]></category>
		<category><![CDATA[Tracxn Technologies Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[UnitedHealth Group interview questions and answers]]></category>
		<category><![CDATA[Wipro Infotech interview questions and answers]]></category>
		<category><![CDATA[WM Global Technology Services India Pvt.Ltd Limited (WMGTS) interview questions and answers]]></category>
		<category><![CDATA[write a program to delete a node from linked list in c++]]></category>
		<category><![CDATA[write ac program to delete a particular element in the doubly linked list]]></category>
		<category><![CDATA[write an algorithm to delete duplicate elements in a singly linked list]]></category>
		<category><![CDATA[Xoriant Solutions Pvt Ltd interview questions and answers]]></category>
		<category><![CDATA[Yodlee Infotech Pvt Ltd interview questions and answers]]></category>
		<guid isPermaLink="false">https://www.wikitechy.com/interview-questions/?p=509</guid>

					<description><![CDATA[Answer : Given a singly linked list, delete all occurrences...]]></description>
										<content:encoded><![CDATA[<div class="TextHeading">
<div class="hddn">
<h2 id="delete-all-occurrences-of-a-given-key-in-a-linked-list" class="color-pink">Delete all occurrences of a given key in a linked list ?</h2>
</div>
</div>
<div class="CodeContent">
<div class="hddn">
<ul>
<li>Given a singly linked list, delete all occurrences of a given key in it. For example,</li>
</ul>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-markdown code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-markdown code-embed-code">Input:  2 -&gt; 1 -&gt; 8 -&gt; 2 -&gt;  3 -&gt;  2 -&gt; 7<br/>       Key to delete = 2<br/>Output:  1 -&gt; 8 -&gt; 3 -&gt; 7 </code></pre> </div>
<h2 id="sample-code-in-c" class="color-purple">Sample Code in C</h2>
<div class="code-embed-wrapper"> <div class="code-embed-infos"> </div> <pre class="language-c code-embed-pre line-numbers"  data-start="1" data-line-offset="0"><code class="language-c code-embed-code">#include &lt;stdio.h&gt; <br/>#include &lt;stdlib.h&gt; <br/>// A linked list node <br/>struct Node <br/>{ <br/>    int data; <br/>    struct Node *next; <br/>}; <br/>/* Given a reference (pointer to pointer) to the head of a list <br/>   and an int, inserts a new node on the front of the list. */<br/>void push(struct Node** head_ref, int new_data) <br/>{ <br/>    struct Node* new_node = (struct Node*) malloc(sizeof(struct Node)); <br/>    new_node-&gt;data  = new_data; <br/>    new_node-&gt;next = (*head_ref); <br/>    (*head_ref)    = new_node; <br/>} <br/>/* Given a reference (pointer to pointer) to the head of a list and <br/>   a key, deletes all occurrence of the given key in linked list */<br/>void deleteKey(struct Node **head_ref, int key) <br/>{ <br/>    // Store head node <br/>    struct Node* temp = *head_ref, *prev; <br/>    // If head node itself holds the key or multiple occurrences of key <br/>    while (temp != NULL &amp;&amp; temp-&gt;data == key) <br/>    { <br/>        *head_ref = temp-&gt;next;   // Changed head <br/>        free(temp);               // free old head <br/>        temp = *head_ref;         // Change Temp <br/>    } <br/>    // Delete occurrences other than head <br/>    while (temp != NULL) <br/>    { <br/>        // Search for the key to be deleted, keep track of the <br/>        // previous node as we need to change &#039;prev-&gt;next&#039; <br/>        while (temp != NULL &amp;&amp; temp-&gt;data != key) <br/>        { <br/>            prev = temp; <br/>            temp = temp-&gt;next; <br/>        } <br/>        // If key was not present in linked list <br/>        if (temp == NULL) return; <br/>        // Unlink the node from linked list <br/>        prev-&gt;next = temp-&gt;next; <br/>        free(temp);  // Free memory <br/>        //Update Temp for next iteration of outer loop <br/>        temp = prev-&gt;next; <br/>    } <br/>} <br/>// This function prints contents of linked list starting from <br/>// the given node <br/>void printList(struct Node *node) <br/>{ <br/>    while (node != NULL) <br/>    { <br/>        printf(&quot; %d &quot;, node-&gt;data); <br/>        node = node-&gt;next; <br/>    } <br/>} <br/>   /* Drier program to test above functions*/<br/>int main() <br/>{ <br/>    /* Start with the empty list */<br/>    struct Node* head = NULL; <br/>    push(&amp;head, 7); <br/>    push(&amp;head, 2); <br/>    push(&amp;head, 3); <br/>    push(&amp;head, 2); <br/>    push(&amp;head, 8); <br/>    push(&amp;head, 1); <br/>    push(&amp;head, 2); <br/>    push(&amp;head, 2); <br/>    int key = 2; // key to delete <br/>    puts(&quot;Created Linked List: &quot;); <br/>    printList(head); <br/>    deleteKey(&amp;head, key); <br/>    puts(&quot;\nLinked List after Deletion: &quot;); <br/>    printList(head); <br/>    return 0; <br/>}</code></pre> </div>
<div class="TextHeading">
<div class="hddn">
<h2 id="output" class="color-purple">Output</h2>
</div>
</div>
<div class="Output">
<div class="hddn">
<figure class="highlight">
<pre><code class="hljs" data-lang=""><span class="nt">Created Linked List:
 2  2  1  8  2  3  2  7
Linked List after Deletion:
 1  8  3  7 </span></code></pre>
</figure>
</div>
</div>
</div>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.wikitechy.com/interview-questions/data-structure/delete-all-occurrences-of-a-given-key-in-a-linked-list/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
