Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Just Q3 and Q4 Q1] Write a C function to implement the binary search algorithm over an array of integer numbers and size n. The
Just Q3 and Q4
Q1] Write a C function to implement the binary search algorithm over an array of integer numbers and size n. The function should return the index of the search key if the search key exists and return - 1 if the search key doesn't exist. [10 Points] Q2] Write a C function to implement the selection sort algorithm, to sort an array of float values and size n. The function should sort the array in ascending order [10 Points). 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 of 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 degreem 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 0 1 2 3 4 5 6 7 3 7 8 109 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 10 11 51 2191 5 1 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 (4) Write a complete C program to test your implementation of the C functions in Q1, Q2, and Q3. In addition, write/use c functions EnterArrayData(int size, int data[]) and PrintArrayData(int size, int data[]), to allow the user to enter the data for the array and display the array data when needed (40 Points] Rules and Conditions The IsPartiallySoreted() MUST have the header int IsPartiallySoreted(int size, int data[], int m, ... ), you CAN NOT change the return type, however, you may add some additional arguments or change them if needed. If you change the return type you lose points (-10 points) You are NOT allowed to use any iterative programming keywords to implement IslmpSortArray. You CAN NOT use for, while or do-while. If you use any of these C/C++ statements you lose point [-10 points] You are NOT allowed to use any Global or Static variables. If you used any Global or any Static variables you lose [-10 points] You may create some additional functions or use some of the existing functions from Q1-Q4 if neededStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started