Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you help me to debug this c++ file? The correct answer is shown in Expected, and my answer is shown in received For the

Can you help me to debug this c++ file? The correct answer is shown in "Expected", and my answer is shown in "received"

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

For the test case 16, and 26, the number is {5 4 3 2 1 6 7 8 9 10}, so the inversion counter should be 2 (5 exchange with 1, and 4 exchange with 2), not 6, but I receive 11.

#include #include #include #include #include #include #include using namespace std; // Function prototype static long mergesort (int array[], int scratch[], int low, int high); Counts the number of inversions in an array in theta(n 2) time. long count_inversions_slow(int array[], int length) // TODO int j, i, key; long int ans-0; // Use insertion sort for slow run for 2sj && array[i] > key){ array[i1]-array[i]; anstt array[i 1]key; return(ans); #include #include #include #include #include #include #include using namespace std; // Function prototype static long mergesort (int array[], int scratch[], int low, int high); Counts the number of inversions in an array in theta(n 2) time. long count_inversions_slow(int array[], int length) // TODO int j, i, key; long int ans-0; // Use insertion sort for slow run for 2sj && array[i] > key){ array[i1]-array[i]; anstt array[i 1]key; return(ans)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

More Books

Students also viewed these Databases questions

Question

Which of these represents the allowed values for a list index?

Answered: 1 week ago

Question

A 300N F 30% d 2 m Answered: 1 week ago

Answered: 1 week ago