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
Match the parts of the software applications with what they do.
Lady_Fox [76]

1-h

2-f

3-e

4-g

5-d

6-c

7-b

8-a

4 0
3 years ago
Suppose that sales is a two-dimensional array of 10 rows and 7 columns wherein each component is of the type int , and sum and j
Deffense [45]

According to the given question, sales is a two-dimensional array and contains 10 rows and 7 columns wherein each component is of type integer and the variables sum and j are also of integer type.

<u>Explanation:</u>

In order to find the sum of the elements of the fifth row of sales, the correct piece of code should be:

sum=0;

for(j=0;j<7;j++)

sum=sum+sales[4][j];  

The indexing in an array always starts from zero, therefore, to calculate the sum of the fifth row, the user has to write 4 in the index to point to the fifth row.

3 0
3 years ago
A computer ia a personal computer you can carry from place to place​
tester [92]

Answer:

laptop is portable and wireless

5 0
3 years ago
Read 2 more answers
A huge variety of networking hardware and software appeared. One challenge was to enable these different networks to communicate
madam [21]

Answer:

Internet Protocol (IP)

Explanation:

The Internet Protocol (IP) is a protocol, or set of rules, for routing and addressing packets of data so that they can travel across networks and arrive at the correct destination.The Internet Protocol is the principal communications protocol in the Internet protocol suite for relaying datagrams across network boundaries. Its routing function enables internetworking, and essentially establishes the Internet.

6 0
3 years ago
Conflict on cross-cultural teams
mars1129 [50]

Answer:

A : is inevitable and should just be ignored until it blows over

Explanation:

Hopefully this helps!

3 0
3 years ago
Read 2 more answers
Other questions:
  • A method in a class that modifies information about an object is called a/an ____ method.
    14·1 answer
  • Di bawah ini tampilan submenu pada tab menu insert pada microsoft word 2010,yaitu...
    6·1 answer
  • Create a class called Clock to represent a Clock. It should have three private instance variables: An int for the hours, an int
    15·1 answer
  • What is the keyboard shortcut Ctrl+Z used for?
    14·2 answers
  • Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, ending whe
    5·2 answers
  • Lisa is modifying a spreadsheet. Which view will allow Lisa to see how her changes will look when she prints the spreadsheet?
    13·2 answers
  • You are hired to train a group of new users to become technicians. One of your lessons is on how to construct Cat5 and Cat6 Ethe
    10·1 answer
  • To print a budget:________.
    9·1 answer
  • What is cyber security ???​
    8·1 answer
  • A printer is considered to be in the category of
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!