Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Searching sequentially a sorted array without duplicate items . Design algorithm int SearchSorted_Asc(int L[], int n, int k) that finds and returns the index of

  1. Searching sequentially a sorted array without duplicate items.

    1. Design algorithm int SearchSorted_Asc(int L[], int n, int k) that finds and returns the index of k in L sorted in ascending order. If k is not found, -1 is returned. For example, given array int C[10] = {20, 30, 40, 50, 60, 70 , 80, 90, 100, 110}; sorted in ascending order. The call SearchSorted_ Asc (C, 10, 70); should return 5 (index of 70 in the above array C).

The call: SearchSorted_ Asc (C, 10, 35); should return -1(not found).

  1. Design algorithm int SearchSorted_Des(int L[], int n, int k) that finds and returns the index of k in L sorted in descending order. If k is not found, -1 is returned. For example, given array int D[12] = {120, 110, 100, 90, 80, 70 , 60, 50, 40, 30, 20, 10}; sorted in descending order. The call SearchSorted_ Dec(D, 10, 90); should return 3 (index of 90 in the above array D).

The call: SearchSorted_ Dec(D, 10, 115); should return -1(not found).

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

The Database Management Systems

Authors: Patricia Ward, George A Dafoulas

1st Edition

ISBN: 1844804526, 978-1844804528

More Books

Students also viewed these Databases questions

Question

How much of this is in your direct control?

Answered: 1 week ago

Question

3. Define the roles individuals play in a group

Answered: 1 week ago