Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedimage text in transcribed

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

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

DB2 9 For Linux UNIX And Windows Advanced Database Administration Certification Certification Study Guide

Authors: Roger E. Sanders, Dwaine R Snow

1st Edition

1583470808, 978-1583470800

More Books

Students also viewed these Databases questions

Question

Can SS ever have a value less than zero? Explain your answer.

Answered: 1 week ago

Question

2. How were various roles filled?

Answered: 1 week ago