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
podryga [215]
4 years ago
12

Q8.215 Points Write a non-recursive method to return a output list that remove duplicate elements in the input list. For example

, if the list is 10, 33, 28, 33, 50, 10, 20, 33, 15, 20, the output array should contain only 10, 33, 28, 50, 20, 15. Notice that the order is matter. In other words, the output array contains all elements from the list, except all duplicates elements are removed. You should not change the list. The return value is the output array. O(N^2).
Computers and Technology
1 answer:
melomori [17]4 years ago
8 0

Answer:

def remove_duplicates(duplicate_list):

   new_list = []

   for number in duplicate_list:

       if number not in new_list:

           new_list.append(number)

   return new_list

Explanation:

- Initialize a new list to hold the values that are not duplicates

- Loop through <em>duplicate_list</em>, check if the number is not in the <em>new_list</em>, put that number in the <em>new_list</em> using append method

- At the end of the loop, return the <em>new_list</em>

You might be interested in
Output a table that show the cube of the numbers 1-15<br> (C++)
Rainbow [258]

Answer:

The c++ program to display cube of numbers from 1 to 15 is given below.

#include <iostream>

using namespace std;

int main() {    

   // variables declared and initialized  

   int num = 15, k, cube;    

   cout << " Cubes of numbers from 1 to 15 are shown below " << endl;    

   for( k = 1; k <= num; k++ )

   {

       // cube is calculated for each value of k and displayed

       cube = k * k * k ;

       cout << " \t " << cube << endl;

   }

return 0;

}

 

OUTPUT

Cubes of numbers from 1 to 15 are shown below  

  1

  8

  27

  64

  125

  216

  343

  512

  729

  1000

  1331

  1728

  2197

  2744

  3375

Explanation:

The variables are declared and initialized for loop, cube and for condition in the loop – k, cube, num respectively.

Inside for loop which executes over k, beginning from 1 to 15, cube of each value of k is calculated and displayed. The loop executes 15 times. Hence, cube for numbers from 1 to 15 is displayed after it is calculated.

   for( k = 1; k <= num; k++ )

   {

      cube = k * k * k ;

       cout << " \t " << cube << endl;

   }

In the first execution of the loop, k is initialized to 1 and variable cube contains cube of 1. Hence, 1 is displayed on the screen.

In the second execution, k is incremented by 1 and holds the value 2. The variable cube contains cube of 2, which is calculated, and 8 gets displayed on the screen.

After each execution of the loop, value of k is incremented.

After 15 executions, value of k is incremented by 1 and k holds the value 16. This new value is greater than num. Hence, the loop terminates.

3 0
3 years ago
Which Operating System is used most often in households?
pshichka [43]

Answer:

Windows

Explanation:

Windows are one of the most popular household os.

3 0
3 years ago
Read 2 more answers
Database users who access data only through application programs are called
Alex777 [14]
A. casual users hope this helps
7 0
4 years ago
How many bit strings of length 12 contain the substring 111000?
ELEN [110]

Answer:

448 strings

Explanation:

Each bit string can be filled by two ways either 0 or 1. If the bit strings of length contain the substring '111000' we therefore need a substring of length 6.

The selection of bits starts from the 1st bit to 7th bit enclosing the substring 111000 and ensuring that the length 6 are all filled. So, there will be  7 ways to contain this substring.

The total ways to contain this substring = 7*2^6 =448

Therefore 448 strings of length 12 contain the substring '111000'.

7 0
3 years ago
What guidance identifies federal information security controls?
Vladimir79 [104]

Answer:

<u>FIPS</u> <u>Publication</u> <u>2</u><u>0</u><u>0</u>, the second of the mandatory security standards, specifies minimum security requirements for information and information systems supporting the executive agencies of the federal government and a risk-based process for selecting the security controls necessary to satisfy the minimum security..

Explanation:

Hope it helps you..

Your welcome in advance..

(ㆁωㆁ)

3 0
2 years ago
Other questions:
  • Automotive engine cylinder heads can be made of what?
    7·1 answer
  • What dose it need For a device to be considered a kind of computer
    14·2 answers
  • Write a program that asks the user to input four numbers (one at a time). After the four numbers have been supplied, it should t
    6·1 answer
  • As in algebra, you can use brackets to override the order of operations Excel follows to perform formula calculations. True or f
    13·1 answer
  • A compression scheme for long strings of bits called run-length encoding is described as follows: Rather than record each 0 and
    8·1 answer
  • Now now now now mowewweedeeee
    13·1 answer
  • What is the first priority when building or using vex robots
    10·2 answers
  • Match the crew members with the equipment or tasks they handle.
    12·1 answer
  • Hi there! I just started my beginner computer science class and I was wondering if anyone wants to help with an assignment i'm h
    15·1 answer
  • A data analyst adds descriptive headers to columns of data in a spreadsheet. How does this improve the spreadsheet?.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!