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]
2 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]2 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
Greg is writing a report on becoming an advertising and promotions manager. Complete the report by correctly filling in the miss
zzz [600]

Since Greg wants to become an advertising and promotions manager, he needs to at least gain a (B) bachelor’s degree level of education, since generally, this educational background is expected from individuals who wishes to work in an entry-level position in the field of advertising.

One of the skills that he also needs to develop is (C) communication skills, because he would have to be able to communicate in both written and spoken to develop the advertisements according to the client’s desires.

8 0
3 years ago
Hello Brainly Students!
Usimov [2.4K]

Answer:

i need help on my wuestion and nobody responds

Explanation:

6 0
3 years ago
Read 2 more answers
In powerpoint a point is _____ of an inch in height.
USPshnik [31]
 a fraction

I think it is correct.

Hopefully it helps.
6 0
3 years ago
If Twitter were to exclusively use e-mail, collaborative computing, and other computer connections to connect geographically sep
sweet-ann [11.9K]

Answer:

Virtual is the correct answer for the above question.

Explanation:

A Virtual organization is a collection which is used to connect the geographical people, organizational units, employees, individuals and groups for some communication purpose. Virtual means that there is some existence like physically but it is not physically present. So the organization also connects the person and gives the real scenario with the help of some software for communication.

The question states that if twitter uses email and other computing connections to connect people globally then it comes in the Virtual department because it follows the concept of the virtual department. Hence Virtual is the correct answer.

5 0
3 years ago
Andrew has invested in a new CAD system to use in his workshop. What changes have occurred because he adopted the new system?
Bad White [126]

Answer:

B.   CAD produces designs that are of the highest quality.

C.   CAD provides systems for error-free manufacturing.

Explanation:

B.   CAD produces designs that are of the highest quality.

CAD does produce the highest quality of design, way better than what traditional paper plans can do.

C.   CAD provides systems for error-free manufacturing.

Many manufacturing systems can read CAD designs directly before the need of a human intervention in between, that eliminates possible errors.

Answers A and D are not true, because once passed the learning-curve, CAD greatly accelerates the production of designs.  And we know the learning-curve is behind them because the question says he has adopted the new system.

5 0
2 years ago
Read 2 more answers
Other questions:
  • If all of Earth's history were squeezed into one 12-hour period, how long ago did Precambrian time end? How long did the Cenozoi
    15·1 answer
  • Point mode allows you to select cells for use in a formula by using your finger or the pointer
    7·1 answer
  • The function keys are labeled from f1 to wat
    10·1 answer
  • Did this technological advancement take away or create jobs? Overall, what was the contribution of this technological advancemen
    12·1 answer
  • When you send an email how many computers does it go to
    12·1 answer
  • Information management should supply information in the form of meaningful images rather than raw data, which requires that we h
    13·1 answer
  • A ______ is a computer that controls access to the hardware, software, and other resources on a network. mainframe server workst
    10·1 answer
  • Which of the following is another type of brake system used in trucks
    5·1 answer
  • The road is closed a head
    9·1 answer
  • How does calculate() work?
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!