![scottkayce](/avatars/43596.jpg)
scottkayce
04.08.2019 •
Computers and Technology
What is required to control access to the file system using file and folder permissions on a windows based computer?
Solved
Show answers
More tips
- H Health and Medicine How to Calculate Pregnancy Due Date?...
- C Computers and Internet Step-by-Step Guide on How to Download Music to Your iPhone...
- A Animals and plants Unraveling the Mystery of Loch Ness: What Does the Loch Ness Monster Look Like?...
- L Leisure and Entertainment Should You Buy a Ceramic Knife?...
- C Computers and Internet How to easily and quickly disable Firebug in Gmail and Google Docs...
- G Goods and services How to sew a ribbon: Tips for beginners...
- F Food and Cooking How to Make Mayonnaise at Home? Secrets of Homemade Mayonnaise...
- C Computers and Internet Which Phone is Best for Internet Surfing?...
- F Food and Cooking Everything You Need to Know About Pasta...
- C Computers and Internet How to Choose a Monitor?...
Answers on questions: Computers and Technology
- B Business They really don’t purchase much, but they like the recreation the outing provides. which type of shopping activity is this? group of answer choices acquisitional...
- C Chemistry What is the correct lewis structure for co2? a) a b) b c) c d) d...
- S Social Studies Whats the bone located in the middle of the rib cage?...
- M Mathematics How do i solve this equation for x?...
- M Mathematics Find the length of AB please help me on this its for a revision for a test...
Ответ:
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;
}
}