Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using C Q3) Write a C function using recursion to check if a given array of integer values of size n is a partially sorted

Using C

image text in transcribed

Q3) Write a C function using recursion to check if a given array of integer values of size n is a partially sorted array of degree m or not. The function IsPartiallySoreted will return 1 if the given array is an imperfect sorted array of degree less than or equal m and return 0 if the imperfect degree is greater than m. [40 points] Given an array of n elements, where each element is at most m positions away from its target position if the array was sorted correctly, we call this array an imperfect sorted array of degree m NOTE: you may assume that all the values in the array are unique (no duplicates). Examples, Is the following array is an imperfect sorted array of degree 2 ? in other words, m = 2 1 0 1 2 3 4 5 6 7 8 3 | 7 8 10 9 12 14 11 17 20 YES: We can see that for a sorted array the values 9, 10, 12, 14, and 11 are not in their correct positions, however, to put any of them in its correct position we only need to move it at most 2 positions, for example, 11 will move from Array[7] to Array[5] and 10 will move from Array[3] to Array[4] Examples, The following array Is NOT an imperfect sorted array of degree 3, in other words, m = 3 0 10 1 11 2 51 3 21 4 9 5 7 6 5 7 1 8 12 | | | 15 NO: We can see that for value 1 to be in the correct position it has to move from Array[7] to Array[0], therefore m > 3

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_2

Step: 3

blur-text-image_3

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

Advances In Databases And Information Systems 22nd European Conference Adbis 2018 Budapest Hungary September 2 5 2018 Proceedings Lncs 11019

Authors: Andras Benczur ,Bernhard Thalheim ,Tomas Horvath

1st Edition

3319983970, 978-3319983974

More Books

Students also viewed these Databases questions