answer.
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
Maurinko [17]
2 years ago
4

You have an array of elements of type double. It must be sorted, but recently, because of a system glitch, the sorting-in-place

mechanism might allow ONE outlier, i.e., your (supposed to be) sorted array might contain one element in a wrong place. The elements in the array are not necessarily distinct. Write a function that takes the pointer to an array and the array’s size (number of elements in the array) as arguments, finds the place the index of the outlier, fixes the array in place (that is puts the outlier to a place it is supposed to be), and returns the old index where the outlier was found. In case there was no outlier, the function should return -1. This is the function’s signature: long long int fix_sorted_array(double* arr, unsigned long n);
Computers and Technology
1 answer:
tangare [24]2 years ago
8 0

Answer:

#include <stdio.h>

int fix_sorted_array(double * arr,unsigned long n){

int i;

int index=-1;

int item;

for(i=1;i<n;i++){

if(arr[i]<arr[i-1]){

index = i;

item = arr[i];

break;

}

}

for(i=index;i>0;i--){

if(arr[i-1]>item){

arr[i] = arr[i-1];

}else{

arr[i] = item;

break;

}

}

return index;

}

void print(double *arr,long s){

int i;

for(i=0;i<s;i++){

printf("%.2f ",arr[i]);

}

printf("\n");

}

int main(void){

double array[7] = {-23.75,20,25.10,-15,37.10,200.12,1000};

printf("array before : ");

print(array,7);

int index = fix_sorted_array(array,7);

printf("\nReturn index : %d\n",index);

printf("array after : ");

print(array,7);

return 0;

}

Explanation:

#include <stdio.h>

int fix_sorted_array(double * arr,unsigned long n){

int i;

int index=-1;

int item;

for(i=1;i<n;i++){

if(arr[i]<arr[i-1]){

index = i;

item = arr[i];

break;

}

}

for(i=index;i>0;i--){

if(arr[i-1]>item){

arr[i] = arr[i-1];

}else{

arr[i] = item;

break;

}

}

return index;

}

void print(double *arr,long s){

int i;

for(i=0;i<s;i++){

printf("%.2f ",arr[i]);

}

printf("\n");

}

int main(void){

double array[7] = {-23.75,20,25.10,-15,37.10,200.12,1000};

printf("array before : ");

print(array,7);

int index = fix_sorted_array(array,7);

printf("\nReturn index : %d\n",index);

printf("array after : ");

print(array,7);

return 0;

}

You might be interested in
You are the administrator for the contoso.com website. recently, the server hosting the website had a failure that caused it to
Alisiya [41]
Protecting the Power supply
Adding disk Arrays
Install an NLB Cluster
4 0
2 years ago
The flagging of an uncommon last name as a spelling error can be stopped by opening the shortcut menu on the first occurrence of
Mice21 [21]

Solution:

The flagging of an uncommon last name as a spelling error can be stopped by opening the shortcut menu on the first occurrence of the name and selecting of ignoring all.

Thus the required right answer is B.

8 0
2 years ago
Write an if-else statement with multiple branches. If givenYear is 2101 or greater, print "Distant future" (without quotes). Els
kherson [118]

Answer:

// here is code in c.

#include <stdio.h>

// main function

int main()

{

// variable to store year

int year;

printf("enter year:");

// read the year

scanf("%d",&year);

// if year>=2101

if(year>=2101)

{

printf("Distant future");

}

//if year in 2001-2100

else if(year>=2001&&year<=2100)

{

   printf("21st century");

}

//if year in 19011-2000

else if(year>=1901&&year<=2000)

{

  printf("20th century");

}

// if year<=1900

else if(year<=1900)

{

  printf("Long ago");  

}

return 0;

}

Explanation:

Read the year from user.After this, check if year is greater or equal to 2101 then print "Distant future".If year is in between 2001-2100 then print "21st century".If year is in between 1901-2000 then print "20th century".Else if year is less or equal to 1900 then print "Long ago".

Output:

enter year:2018                                                                                                            

21st century

7 0
2 years ago
Read 2 more answers
The process of checking data for validity and integrity before placing it in a data warehouse is called Group of answer choices
guajiro [1.7K]

Answer:

data cleaning

Explanation:

Data cleaning exemplifies the process which includes identifying the incorrect, or inaccurate data from the records. It further proceeds its function in correcting and replacing the correct data in the records or database. By adding information, by deleting incorrect information and modifying the incorrect information are some of the ways by which data cleaning is done.

7 0
2 years ago
Asia pacific and Japanese sales team from cloud kicks have requested separate report folders for each region.The VP of sales nee
MaRussiya [10]

Answer:

B) Create all new regional folders and move the reports to the respective region folder with viewer access.

Explanation:

Below are the options

A) Create grouped folders, keeping the top region folder sharing settings and limiting the sharing settings for the grouped folders for each region.

B) Create all new regional folders and move the reports to the respective region folder with viewer access.

C) Create all new regional folders and move the reports to the respective region folder with subscribe access.

D) Create subfolders, keeping the top region folder sharing settings and limiting the sharing settings for the subfolders for each region

In order to required reports at one place and also wants to retain the visibility for each folder the consultant should suggest that all new regional folders should be created and afterwards it would be moved to their relevant region folders by involving the viewer access feature so that the VP should access it anytime

Hence, the correct option is B.

3 0
2 years ago
Other questions:
  • In an ethernet network, the signal that is sent to indicate a signal collision is called a ________ signal.
    7·1 answer
  • Computer hardware had been designed to run a single operating system and a single app, leaving computers vastly underutilized. o
    15·1 answer
  • Match the following technologies with their applications.
    9·1 answer
  • In your own words, what is pair-programming? What is the role of the driver? What is the role of the navigator? What are some be
    15·1 answer
  • What is ODBC? How is it related to SQL/CLI? 10.2. What is JDBC? Is it an example of embedded SQL or of using function calls? 10.
    8·1 answer
  • 1. PLCs were originally designed as replacements for: a) microcomputers. c) analog controllers. b) relay control panels. d) digi
    6·1 answer
  • Assume a program requires the execution of 50 x 106 FP instructions, 110 x 106 INT instructions, 80 x 106 L/S instructions, and
    9·1 answer
  • E xercise 17.2.4: The following is a sequence of undo-log records written by two transactions T and U: &lt; START T&gt;; ; &lt;
    15·1 answer
  • An Internet user has a need to send private data to another user. Which of the following provides the most security when transmi
    14·2 answers
  • Consider the following sequence of instructions:
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!