1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Nastasia [14]
3 years ago
15

Write a function that removes duplicates from an array. For example, if remove_ duplicates is called with an array containing 1

4 9 16 9 7 4 9 11 then the array is changed to 1 4 9 16 7 11 Your function should have a reference parameter for the array size that is updated when removing the duplicates.
Computers and Technology
1 answer:
velikii [3]3 years ago
8 0

Answer:

Explanation:

The following code is written in Python. It takes in an array of numbers as a parameter and loops through it. It checks to see if each element is already inside the new_arr array and if not then it adds it. Finally, it prints out the new_arr, prints the new_arr size and returns new_arr to the user which contains all the numbers from the original array without the duplicates.

def removeDuplicates(arr):

   new_arr = []

   for element in arr:

       if element not in new_arr:

           new_arr.append(element)

   print(new_arr)

   print("New Array Size: " + str(len(new_arr)))

   return new_arr

test_arr = [1, 4, 9, 16, 9, 7, 4, 9, 11]

removeDuplicates(test_arr)

You might be interested in
What component of effective feedback is demonstrated by giving examples of what an employee is doing right instead of just prais
Aleksandr [31]
It's specific
<span>"Instead of giving general praise or criticism, tell the person exactly what they did right or how they can improve."</span>
4 0
3 years ago
Read 2 more answers
Security controls are measures taken to protect systems from attacks on the integrity, confidentiality, and availability of the
Delvig [45]

Answer:

The correct option is D: Administrative controls

Explanation:

Administrative controls are also known as work practice controls and involves changes in the procedure of work such as rules, schedules, policies, training etc, with the intention of cutting down to the barest minimum incidence, duration, and the graveness of exposure to situations or chemical that constitute a hazard. Drug screening test would be to ensure that the employee is fit to work and does not form a hazard and thus is an administrative control.

4 0
4 years ago
Can a percent be used in a filename?
alina1380 [7]
Hey There!

A percent can be used in a filename.
4 0
3 years ago
C++
vichka [17]

Answer:

#include <iostream>

#include <map>  

using namespace std;

int main()

{

   map<int, int> numbers;

   cout << "Enter numbers, 0 to finish" << endl;

   int number;

   while (true) {

       cin >> number;

       if (number == 0) break;

       numbers[number]++;

   }

   for (pair<int, int> element : numbers) {

       std::cout << element.first << ": occurs " << element.second << " times" << std::endl;

   }

}

Explanation:

One trick used here is not to keep track of the numbers themselves (since that is not a requirement), but start counting their occurrances right away. An STL map< > is a more suitable construct than a vector< >.

4 0
3 years ago
Blackbaud is a company that supplies services and software designed for nonprofit organizations. Which type of e-commerce websit
natka813 [3]

Explanation:

Blackbaud's software products are specially designed to support the unique needs of nonprofit and social good organizations.

Explore our software solutions that can help you advance your organization's mission.

3 0
3 years ago
Other questions:
  • Match the following.
    8·2 answers
  • Describe how antipoverty programs can discourage the poor from working. How might you reduce this disincentive? What are the dis
    11·1 answer
  • What is an objective of state-sponsored attackers?
    11·1 answer
  • This needs to be written in Java.
    11·1 answer
  • You work in the Accounting department and have been using a network drive to post Excel workbook files to your file server as yo
    15·1 answer
  • How are comments in a Java program treated by the compiler?
    14·2 answers
  • What is the main purpose of a web crawling program
    15·1 answer
  • Help fast fast anyone
    10·1 answer
  • When a computer is infected by a virus, _______.
    14·1 answer
  • Who designed the apple i computer in 1976?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!