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
marissa [1.9K]
3 years ago
7

You are given an array of integers, each with an unknown number of digits. You are also told the total number of digits of all t

he integers in the array is n. Provide an algorithm that will sort the array in O(n) time no matter how the digits are distributed among the elements in the array. (e.g. there might be one element with n digits, or n/2 elements with 2 digits, or the elements might be of all different lengths, etc. Be sure to justify in detail the run time of your algorithm.
Computers and Technology
1 answer:
Vlad [161]3 years ago
8 0

Answer:

Explanation:

Since all of the items in the array would be integers sorting them would not be a problem regardless of the difference in integers. O(n) time would be impossible unless the array is already sorted, otherwise, the best runtime we can hope for would be such a method like the one below with a runtime of O(n^2)

static void sortingMethod(int arr[], int n)  

   {  

       int x, y, temp;  

       boolean swapped;  

       for (x = 0; x < n - 1; x++)  

       {  

           swapped = false;  

           for (y = 0; y < n - x - 1; y++)  

           {  

               if (arr[y] > arr[y + 1])  

               {  

                   temp = arr[y];  

                   arr[y] = arr[y + 1];  

                   arr[y + 1] = temp;  

                   swapped = true;  

               }  

           }  

           if (swapped == false)  

               break;  

       }  

   }

You might be interested in
1. What is the difference between a group and a topic?
kap26 [50]
<h3>What is the difference between group and a topic ?</h3>

<h3>Group</h3>
  • You can publish a comment or question to the main community feed or to a group of which you are a member. Members with a common interest can form group within the wider community to form a small community around that topic and group posts will only appear in the feeds of other group members, not in the general community feed.
<h3>Topic</h3>
  • Topic work similarly to hashtags. Use the "+" symbol to the left of the Post/Ask button to add a topic (tag) to your post or question so that it can be classified along with other related posts and topics are a way to group posts and queries with similar content, but they don’t bring everyone with the same interest together in one place and this is where the groups come in!
7 0
2 years ago
Select the correct answer. Matt works for an advertising agency. He is often involved in the designing and development processes
Rus_ich [418]

Answer:

MAY BE A

Explanation:

I THINK A IS THE CORRECT ANSWER

8 0
3 years ago
Read 2 more answers
What kind of software would you recommend a company use if its employees are receiving e-mails that are potentially hazardous ?
scZoUnD [109]

Answer:

Microsoft project

Explanation:

I'm smart

6 0
3 years ago
Drag the tiles to the correct boxes to complete the pairs.
Monica [59]

Answer:

refers to how much black or white color contains: value,defines a range from dark (0%)to fully illuminated (100%):lightness, Express the brightness or dullness of a color:intensity ,stands for a pure color:hue

HOPE THIS HELPS

8 0
3 years ago
What is the first thing you need to do to edit a graph?
Kay [80]
Know the numbers and info
3 0
2 years ago
Read 2 more answers
Other questions:
  • To resize columns in a subform, press and hold or right-click the subform in the navigation pane, and tap or click ____ on the s
    12·1 answer
  • T F A stub is a dummy function that is called instead of the actual function it<br><br> represents.
    7·1 answer
  • Assign a variable solveEquation with a function expression that has three parameters (x, y, and z) and returns the result of eva
    6·1 answer
  • The command button to protect a document is part of the​.
    10·1 answer
  • WRITE A JAVA PROGRAM TO PRINT THE PATTERN<br> 13579<br> 2468<br> 357<br> 46<br> 5
    12·1 answer
  • Chuck plans to go on a hiking trip. Before the hiking trip, Chuck's bank account has $129.50. He then spends $129.50 on hiking g
    6·1 answer
  • For this scenario related to turtle drawing, indicate whether it is better to write a loop or a function (or a set of functions)
    13·1 answer
  • Fill in the missing step in the following deadlock situation. Two users from the local board of education are each running a pro
    11·1 answer
  • Which of the following statements best reflects the pros and cons of overtime potential for a line installer or repairer?
    15·1 answer
  • Patricia Works in a coffee shop and manages the inventory of items.for each item she needs to recover the quantity in stock and
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!