CEG's Linux User Group

  • Increase font size
  • Default font size
  • Decrease font size
Home Labs DeleteDuplicate elements in List

DeleteDuplicate elements in List

E-mail Print
User Rating: / 8
PoorBest 
Article Index
DeleteDuplicate elements in List
Source code
Documentation
Test cases
Compatibility & Reference
All Pages

DELETE DUPLICATE ELEMENTS IN A LIST

Introduction :

Linked lists are used to organize data in specific desired logical order, independent of the memory address each node is assigned to. Linked list data storage works best with data arrays in which one doesn’t know how large the array will need to be or when there is a certainty of more data being added or subtracted at later times.

The aim of this program is to delete the duplicate elements (i.e. the repeating elements) in the list. This can be done by overwriting the node with duplicate element with its next node. Consider the following list with 4 nodes.

delduplicate1


In this example, the third node is a duplicate to that of the first which is found out using 2 temporary pointers to the list. When a duplicate element is identified, it is overwritten by its next node. Here, the third node is overwritten by fourth node. So, the list becomes

delduplicate2

Thus, the duplicate elements are overwritten.

Last Updated on Tuesday, 09 June 2009 12:59  
Please register or login to add your comments to this article.