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
astraxan [27]
3 years ago
10

Assume you have a sorting algorithm that you can use as a black box. Use the sorting algorithm to sort the input list. Now write

an algorithm to count the number of duplicates again. Analyze the time complexity of your algorithm in the worst-case (ignore the time complexity of sorting). Could you improve the worst-case time complexity of your algorithm compared to the previous question
Computers and Technology
1 answer:
Ber [7]3 years ago
7 0

Answer:

Algorithm explained below

Explanation:

Algorithm to check duplicate when list of element is sorted:

CheckDuplicate( Sorted list )

    initialize count = 0

    Repeat untill we reach on end of list :

            if next is not end of list and current element is equal to next element

                    count = count+1

                    increase the pointer to next untill a different element is found

end CheckDuplicate

Worst Case Time Complexity will be O(n). Because there is only one iteration over the list will be performed.

Yes We have improved the worst case time complexity compared to previous question.

Actually after applying sorting all the similar element to will be next to each other.Then we will start iterating one by one from one side and check which is similar to next.If a different element will be find then we will check whether it's next is similar to it or not.

eg. 1 1 1 2 2 2 4 4 4 we can check duplicate in one iteration.

You might be interested in
"if" statements are part of creating computer programs, what are these instructions called and how would you use them?
podryga [215]

Answer:

if means that like (if this happen it will come or not come answer)

Explanation:

sorry I don't know how to tell but plz reply if you understand or not.

7 0
2 years ago
Read 2 more answers
Question # 4
natka813 [3]

Answer:

class

Explanation:

edg2020

4 0
3 years ago
a. Describe how the student can use the jar of rice to model particle motion of a substance in each state of matter: solid, liqu
Black_prince [1.1K]

Answer:

because the jar is ........

4 0
2 years ago
Keith has to carry out a photo shoot to capture images of the ocean during the monsoons. What is a recommended practice when sho
Semmy [17]

Answer:

Answer is A: place absorbent chemical packets in the camera cover

Explanation:

Keith is required to carry adequate gear while going for a shoot. And in this case, he should carry anything that will protect his camera from the ocean and rainwater. By anything, I mean anything that Keith will use to stay dry. Using an air conditioner would be the worst idea. An air conditioner might blow the air towards your camera. Placing the camera in its case will ensure that it is dry and Keith will keep on shooting. Placing absorbent chemical packets in the camera cover will ensure that any water droplets that might fall on the cover of the camera will be absorbed. The point here is to keep dry.

6 0
3 years ago
When the tv was created (year)
nikitadnepr [17]

Answer:

1927

Explanation:

6 0
3 years ago
Read 2 more answers
Other questions:
  • What is the main storage location of a computer
    13·1 answer
  • In symmetric encryption the same key is used to encrypt and decrypt a message. in asymmetric encryption different keys are used
    6·2 answers
  • The four key stages with regards to data visualization workflow. Select one key stage and explain it briefly about that stage.St
    10·1 answer
  • Which of the following attacks seeks to introduce erroneous or malicious entries into a server's hostname-to-IP address cache or
    5·1 answer
  • Heather has segmented all of the individuals in her database into four categories according to how many game tickets they purcha
    12·2 answers
  • What is a word processor in ms word​
    9·2 answers
  • Intelligence is to creativity as _____ is to _____. Group of answer choices spatial intelligence; musical intelligence correct t
    15·1 answer
  • Which option correctly identifies if the researcher’s approach was the best choice in the following scenario and explains why?
    10·2 answers
  • Given positive integer n, write a for loop that outputs the even numbers from n down to 0. If n is odd, start with the next lowe
    8·1 answer
  • I WILL GIVE BRAINLIST THING TO WHOEVER GIVES ME THE CORRECT ANSWER
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!