Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Searching unsorted array with duplicate data items. Given array int B[10] = {10, 70, 20, 30, 25, 70 , 10, 25, 70, 50}; Design algorithm

  1. Searching unsorted array with duplicate data items.

Given array int B[10] = {10, 70, 20, 30, 25, 70 , 10, 25, 70, 50};

  1. Design algorithm int SearchUnsorted_First(int L[], int n, int k) that finds and returns the index of the first occurrence of k in L. If k is not found, -1 is returned. For example, the call SearchUnsorted_First(B, 10, 70); should return 1 (index of the first occurrence of 70 in the above array B).

The call: SearchUnsorted_First(B, 10, 15); should return -1.

  1. Design algorithm int SearchUnsorted_L(int L[], int n, int k) that finds and returns the index of the last occurrence of k in L. If k is not found, -1 is returned. For example, the call SearchUnsorted_L(B, 10, 70); should return 8 (index of the last occurrence of 70 in the above array B).

The call: SearchUnsorted_L(B, 10, 20); should return 2.

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

Online Systems For Physicians And Medical Professionals How To Use And Access Databases

Authors: Harley Bjelland

1st Edition

1878487442, 9781878487445

More Books

Students also viewed these Databases questions

Question

Determine miller indices of plane X z 2/3 90% a/3

Answered: 1 week ago