0% found this document useful (0 votes)
2 views2 pages

Week 4 Array

Uploaded by

adityaroyy719
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Week 4 Array

Uploaded by

adityaroyy719
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

Write a program to find all occurrences of a key within a given array using a
sequential search algorithm.
Test Case:
Input:
array = {16, 31, 15, 27, 9, 15, 39, 15, 17, 12}; Key: 15
Output:
Element found at index 2
Element found at index 5
Element found at index 7

2. Given an unsorted array and a number n, find if there exists a pair of elements in
the array whose product is given number n.
Input: arr[] = {5, 20, 3, 2, 50, 80}, n = 150
Output: Pair Found: (3, 50)
3. Given an unsorted array of integers, sort the array into a wave-like array. An array
arr[] is in wave form if arr[0] >= arr[1] <= arr[2] >= arr[3] <= arr[4] >=…
Input: arr[] = {10, 90, 49, 2, 1, 5, 23}
Output: Pair Found: (10, 2, 90, 1, 49, 5, 23)

You might also like