Algorithm to delete all occurence of duplicate elements from a list of array
what will be the algorithm for "to delete all occurence of duplicate elements from a list of array"?
Replies
-
Kaustubh Katdare
Welcome to CE, #-Link-Snipped-# . Have you made any attempts to write the algorithm? If yes, please share them with us. Do not worry about being right or wrong. I'm sure our fellow engineers will help you out with all your questions.Ishita H.Katiyarwhat will be the algorithm for "to delete all occurence of duplicate elements from a list of array"? -
Ramani Aswath#-Link-Snipped-#
-
rahul69
There can be multiple algorithms to achieve any particular task.Ishita H.Katiyarwhat will be the algorithm for "to delete all occurence of duplicate elements from a list of array"?
For example, a workable algorithm will be, to check each element to all the elements after it, and in case of any match, delete that element. ☕ -
Ramani Aswath
Agree. However, since there can be more than one match it may be better to delete the matching ones.rahul69in case of any match, delete that element. -
Jai KrishnaStart with a brute for algorithm e.g. sort the array and iterate through it once. If a number changes from one array index to the next keep it otherwise dont.
This can then be improved depending on runtime and space requirements, whether holes are allowed in the result or not etc. -
pratap singh, upendra
- Store the elements in the array say a[].
- Now create a dynamic linked list to store the output.
- Select elements from the array a[] one at a time
- Put this element in linked list only when it is not already present in the linked list .
- Iterate steps 3 and 4 through the array a[].
This method also reduces the space complexity of the program compared to storing the output in another array. - Store the elements in the array say a[].
-
simplycoder1)Sort the elements.
2)Delete the groups. -
pratap singh, upendra
Could you please elaborate?simplycoder1)Sort the elements.
2)Delete the groups. -
rahul69
I guess he says that, After sorting, duplicate elements will come together, thus those could be deleted in groups.proffyCould you please elaborate?
You are reading an archived discussion.
Related Posts
The Indian Government has obtained a formal membership of the Square Kilometer Array Organization (SKA). The SKA Organisation is an intergovernmental body that will build, manage and run the world's...
If you are experiencing extremely slow download speed for OSX El Capitan, I've a fix for you. My computer was showing ~2 days as approximate time to download the 6GB...
Hello friends.. My DELL VOSTRO 1015 laptop having white screen problem. I used all the solutions which are given on the google but no any change in my lappy's white...
friends im a 3rd undergraduate student persuing my B.E in aerospace manufacturing department so can anyone suggest me a project for my final year based on manufacturing field
so that...
Microsoft, just like Nokia isn’t very good at keeping secrets when it comes to its smartphone launches. In the past couple of months we have been hearing snippets and catching...