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
Assume we are testing a variable is_sunny in a while loop. is_sunny = “n”.
zubka84 [21]

Answer:

while(is_sunny=="n")

Explanation:

The loop keeps repeating itself until a certain condition is met.

Here while loop keeps executing until value of is_sunny is not equal to 'n'

When the value of is_sunny is not equal to n then the loop stops.

So lets explain this logic with a chunk of code:

#include <iostream> //to use input output functions

using namespace std; //to identify objects like cin cout

int main() {  //start of main function

  string is_sunny = "n"; //value of is_sunny is set to n

  cout<<"Enter value of is_sunny: "; // prompts user to enter value of is_sunny

  cin>>is_sunny; // reads value of is_sunny from user

  while(is_sunny=="n") // keeps iterating until value of is_sunny is not equal to n

  {   cout<<"keep executing until is_sunny is not equal to n"<<endl;//display this message with each iteration

      cout<<"Enter value of is_sunny: "; //keeps prompting to enter is_sunny

      cin>>is_sunny;   } } //keeps reading value of is_sunny from user

Now if the user keeps entering "n" as value of is_sunny then the loop keeps repeating. When the user enters any string other than n then the loop breaks. The output of the program is attached.

6 0
3 years ago
__________ is a collection of formatting options—such as a frame, a rounded shape, and a shadow—that changes a picture’s overall
LenaWriter [7]

Answer:

Picture Style

Explanation:

According to my research on the Microsoft Word Software, I can say that based on the information provided within the question the term being mentioned in the question is called a Picture Style. This is a feature in Microsoft Word that allows you to apply a style or effect to a picture in order to enhance the way it looks or presents, such as a frame, shadow, or shape.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

6 0
3 years ago
What is the purpose of the operating systems management function
PIT_PIT [208]
The purpose of the operating systems is to provide an interface between the user and hardware. It's mange all resources, for example; memory, processors, and disk space. It's also mange how to file and store data in a computer system.
3 0
4 years ago
What is the output of this program?
Leto [7]

Answer:

70 is the answer negative one begins from 83 and count down to 89, Therefore, 70 is is -4 and is chosen as the best answer

7 0
3 years ago
What is up with the bots? They are so annoying.
Yuki888 [10]

Answer:

very very very annoying

6 0
3 years ago
Read 2 more answers
Other questions:
  • The information security organization performs a significant role in the implementation of solutions that mitigate risk and cont
    6·1 answer
  • What conversion factor should be used to convert from meters to Gigameters?
    9·1 answer
  • Using the SUM function allows a series of numbers to be 1. Multiplied 2. Subtracted 3 Added 4. Divided
    11·1 answer
  • What can you learn at Udemy.com?
    11·1 answer
  • Using Word, Maureen is writing an outline of a presentation she plans to give to her company. She will be showing a video during
    12·2 answers
  • When Nathanil Inc, a network service provider, introduced 4G data plans, it observed that most of its customers completely stopp
    9·1 answer
  • In a CPMT, a(n) ____ should be a high-level manager with influence and resources that can be used to support the project team, p
    10·1 answer
  • What type of things can be marketed
    11·1 answer
  • Evaluate the expression. Be sure to list a value of appropriate type (e.g., 7.0 rather than 7 for a double, Strings in quotes).
    7·1 answer
  • Which one of these lifestyle factors has led to the buildup of litter in our
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!