Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

Design and implement an algorithm that

Design and implement an algorithm that, when given a collection of integers in an unsorted array, determines the

third smallest number (or third minimum). For example, if the array consists of the values 21, 3, 25, 1, 12, and 6 the algorithm should report the value 6, because it is the third smallest number in the array. Do not sort the array.

To implement your algorithm, write a function thirdSmallest that receives an array as a parameter and returns the third-smallest number. To test your function, write a program that populates an array with random numbers and then calls your function. ATTACHMENT PREVIEW Download attachment/*********************************Week 4 lesson:**finding the smallest number **********************************/#include <iostream>using namespace std;/** Returns the smallest element in the range [0, n-1] of array a*/int minimum(int a[], int n){int min = a[0];for (int i = 1; i < n; i++)if (min > a[i]) min = a[i];return min;}int main(){int a[10];for (int i = 0; i < 10; i++){a[i] = rand()%100;cout << a[i] << ” “;}cout << endl << “Min =” << minimum(a, 10) << endl;return 0;}

Background image of page 1
 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"