Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem Description: Given an unsorted array A[] and a key k. First you need to write a function named InsertionSort to sort the array in
Problem Description: Given an unsorted array A[] and a key "k. First you need to write a function named InsertionSort to sort the array in descending order and then complete the function BinSearch to determine the position of the key if the key is present in the array. If the key is not present then you have to return -1. Input: The first line contains an integer 'N' denoting the size of the array. Second line consists of 'N' space separated integers denoting the elements of the array A[]. The third line contains a key 'k'. Output: Print the sorted array in first line, then show position of the key in second line if its present in the array else print -1 if the key is not present in the array Example: Input 1: 5 41352 2 Input 2: 6 11 66 22 44 33 55 99 Output 1: 5 4 3 2 1 2 Output 2: 66 55 44 33 22 11 -1 Hint: according to binary search, 2 found at 2nd time checking
Step 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