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
Vikentia [17]
3 years ago
6

Write an algorithm (pseudo-code) that takes an unsorted list of n integers and outputs a sorted list of all duplicate integers.

There must be no duplicates in the output list, also the output list should be a sorted list. The algorithm must run in O(n) time. Show your analysis of the running time. Note: Assume that inputs are integer values from 0 to 255. (Hint: use the concept that being used in the separate chaining)
Computers and Technology
1 answer:
nexus9112 [7]3 years ago
7 0

Answer:

brainliest if it did help you

Explanation:

Given array : A[0...n-1]Now, create a count array Cnt[0...n-1]then, initialize Cnt to zero

for(i=0...n-1)

Cnt[i]=0 ---------O(n) time

Linearly traverse the list and increment the count of respected number in count array.

for(i=0...n-1)

Cnt[A[i]]++; ---------O(n) time

Check in the count array if duplicates exist.

for(i=0...n-1){

if(C[i]>1)

output (i); -----------O(n) time

}

analysis of the above algorithm:

Algorithm takes = O(1 + n + n + n)

                           = O(n)          

//java code

public class SortIntegers {

  public static void sort(int[] arr) {

    int min = arr[0];

    int max = arr[0];

    for (int i = 0; i < arr.length; ++i) {

      if (arr[i] > max) {

        max = arr[i];

      }

      if (arr[i] < min) {

        min = arr[i];

      }

    }

    int counts[] = new int[max - min + 1];

    for (int i = 0; i < arr.length; ++i) {

      counts[arr[i] - min]++;

    }

    for (int i = 0; i < counts.length; ++i) {

      if (counts[i] > 1) {

        System.out.print((i + min) + " ");

      }

    }

    

    System.out.println();

  }

  public static void main(String[] args) {

    sort(new int[] { 5, 4, 10, 2, 4, 10, 5, 3, 1 });

  }

}

You might be interested in
Comparing tools made of stone, iron, and bronze: place them in the correct order from least to most durable.
densk [106]

Answer:

stone bronze and iron.

Explanation:

Your welcome! :)

8 0
3 years ago
An information system report is an example of...
STatiana [176]

Answer:

a. data processing

b. data collection

c. data input

d. data output

Explanation:

An information system is a system used to filter, process, collect, distribute and create data.

Information system can be a work system whereby humans and machine perform processess using informations gathered, process it to solve the needs of their customers in the form of goods and services.

8 0
4 years ago
Serena, an analyst at an environmental agency, wants to prepare a report using data from the Car Emissions database.
konstantin123 [22]

Answer:

The correct answer is:

Option 1: export the query results from the database to a spreadsheet, then export the graph to a document.

Explanation:

Spreadsheets are used to represent numerical data, perform calculations and display the results numerically or graphically.

When using a database, the query results can be exported to other software using the query web address.

So in order to include the graph in her report, Serena will export the result to spreadsheet and then export the graph to document.

Hence,

The correct answer is:

Option 1: export the query results from the database to a spreadsheet, then export the graph to a document.

5 0
3 years ago
Read 2 more answers
A simulation model includes: a. a description of the components of the system. b. a simulation clock. c. a definition of the sta
zloy xaker [14]

Answer: all of the above

Explanation:

8 0
3 years ago
At the monthly product meeting, one of the Product Owners proposes an idea to address an immediate shortcoming of the product sy
Mrrafil [7]

Answer:

Correct limitation for Attribute Name and value is option

b: Value and name combined must not exceed 400KB

Explanation:

For amazon dynamo db You can have unlimited attribute per item but one attribute cannot exceed 400 kb in size.400Kb is the limit of an item which can be stored in db.

If bigger data is required to store than data is stored some where and links/url to data are stored in the db.

For Item max size is 64KB

7 0
3 years ago
Other questions:
  • What possible reason would explain why you are unable to connect to the intranet site on your computer’s web server, using a bro
    13·1 answer
  • Describe the "Mister Splashy Pants" campaign. How did it start? What happened?
    7·2 answers
  • Why process scheduling is needed in a uni-processor system?
    12·1 answer
  • Adding all the three primary colors-red, green, and blue-at maximum intensity produces the color _____, while adding any two of
    9·1 answer
  • What is the platform-neutral programming language that can run on Windows, Macintosh, or UNIX?
    15·1 answer
  • Write a for loop to print all NUM_VALS elements of vector courseGrades, following each element with a space (including the last)
    11·1 answer
  • How many bytes are there in 256 Kbytes?
    6·1 answer
  • Which programming language was released first
    7·1 answer
  • A histogram titled Greeting card sales has date on the x-axis and cards (millions) on the y-axis. January is 1 card, February: 1
    12·2 answers
  • I’ll give brainliest if answers are correct
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!