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
What does it mean by does the author create an emotional connection toward the readers?
andreyandreev [35.5K]

Answer:

the author makes an emotional connection between you and the character

Explanation:

short version:you feel the characters emotion

6 0
3 years ago
What Intel socket recommends the use of a liquid cooling system?
Komok [63]
The socket which Intel recommends that one should use with a liquid cooling system is LGA 2011. LGA 2011, also known as socket R is a CPU socket manufactured by Intel. It was released into the market in November 2011 and it replaced LGA 1366 and LGA 1567 in the performance and high end desk tops and server platforms. Socket R has 2011 pins that touch contact points on the underside of the processor.
7 0
3 years ago
Write a program that receives a series of numbers from the user and allows the user to press the enter key to indicate that he o
Dmitriy789 [7]

Answer:

The solution code is written in Python 3

  1. count = 0
  2. sum = 0
  3. num = input("Enter a number: ")
  4. while(num != ''):
  5.    sum += float(num)
  6.    count += 1
  7.    num = input("Enter a number: ")
  8. print("Sum : " + str(sum))
  9. print("Average: " + str(sum / count))

Explanation:

Firstly, we declare two variables count and sum to hold the number of input number and the total of the input number, respectively (Line 1-2)

Next, we prompt user to input the first number (Line 4). While the num is not ' ' (This means it is not "Enter" key), accumulate the num to sum variable and increment count by one (Line 6-8) and then prompt the user to input the next number (Line 9).

At the end, display the sum and average using print function (Line 11 -12).

5 0
3 years ago
In brainly.com which is best answerer​
mote1985 [20]

Explanation:

I don't know, because I had only spent one month in brainly. but I think it is Mister 360. s/he is a great answerer and always stay at top in leaderboard.

5 0
3 years ago
1st page<br><br> Please answer <br><br> Part C
Bas_tet [7]

Answer:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

       Dim a As Byte

       For a = 1 To 5

           MessageBox.Show(a)

       Next a

   End Sub

   Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

       Close()

   End Sub

Button2 is exit button, and button1 is display button.

Explanation:

Please check the answer section.

4 0
3 years ago
Other questions:
  • Ming is building an inexpensive computer to use for her online classes, and needs to purchase Windows. What is the most cost-eff
    8·1 answer
  • Plagiarism occurs when writers
    14·2 answers
  • What is a expansion card for computer?
    5·1 answer
  • A graph of an organization'snet income over the past 10 years is an example of an analogmodel.
    7·1 answer
  • I keep getting this error: postfix.cpp: In function ‘double RPN_evaluation(std::string)’: postfix.cpp:42:26: error: cannot conve
    7·1 answer
  • Is the internet a private place?
    15·2 answers
  • A motorist is using the AHP to choose a new car from three possible models Arrow, a Bestmobile and a Commuter. The choice will a
    15·2 answers
  • What is the age group for the silent genration
    10·1 answer
  • Which of the following is not a benefit of shaping data with the Power Query Editor?
    13·1 answer
  • Which phrase suggests feedback?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!