C/C programming
Expert: Zlatko - 6/12/2010
QuestionPlease help me in writing a C Code for Deletion of Duplicates from a Sorted array.
thanks
AnswerHello Kuldeep
The easiest way to do this is to first print the unique elements to the screen. Once that is working you can put the unique elements into a new unique array instead of printing them to the screen.
You need to go through each element of the sorted array and compare each element with the previous element. Of course when you are examining the first element there will be no previous element so that is a special case. You need to print out the current element if it is the first element or if it is not the same as the previous element.
Show me an attempt at that and I will help you more if you need it.
Best regards
Zlatko