Solution Found!
Write a function that removes duplicates from an array. For example, if
Chapter 6, Problem P6.12(choose chapter or problem)
Write a function that removes duplicates from an array. For example, if remove_duplicates is called with an array containing1 4 9 16 9 7 4 9 11then the array is changed to1 4 9 16 7 11Your function should have a reference parameter for the array size that is updatedwhen removing the duplicates.
Questions & Answers
QUESTION:
Write a function that removes duplicates from an array. For example, if remove_duplicates is called with an array containing1 4 9 16 9 7 4 9 11then the array is changed to1 4 9 16 7 11Your function should have a reference parameter for the array size that is updatedwhen removing the duplicates.
ANSWER:Step 1 of 2
The function remove_duplicates() takes two arguments. One is an integer array and the other is the size of an array which is reference parameter. The pseudocode to remove the duplicates from an array is given below:
1. For every element in an array
2. Check if its duplicate is present. If so,
3. Move the duplicate element to the last of the array and update the size