Академический Документы
Профессиональный Документы
Культура Документы
==========================================
The existing project is going to use more algorithms from the
Standard Template Library, and also to access search, and
sort for both, standard C-type arrays and C++ arrays.
1. Inside the two files, use algorithm find(), with the return
type auto ptr, to search for the first-element in the array
that has a specified value.
Use if-else to display the index.
Select first a known value from the array, and next one not
part of the array.
2. Inside the two files, use algorithm count() to count how many
elements in the array have a specified value.
Change first the value at index 0 to become identical to the
value at index 1.
count() should return value 2.
3. Inside the two files, use algorithm count_if() to return the
number of elements with values greater than 50 (in
UsingCTypeAlgorithms()) and greater than 60 (in
UsingCppTypeAlgorithms()).
Insert the corresponding predicate-function-definitions at the
top of the two cpp functions.
4. Inside the two files, use algorithm is_sorted().
5. Inside the two files, use algorithm sort() to sort the array
in ascending order.
And display the array.
Follow with a call to is_sorted().
6. Inside the two files, use again the algorithm sort(), with
the third argument, greater<size_t>(), to reverse the current
sorted order to a descending order.
And display the array.
It requires #include <functional>
7. Inside the two files, use algorithm reverse(), to reverse the
current order, back to ascending.
And display the array.
8. Inside the two files, use algorithm binary_search().
The prerequisite is met: the array is sorted.
Select first a known value from the array, and next, one not
part of the array.
Implement code for function BinarySearch()
-----------------------------------------9. As a review, declare and implement, as part of the class
ProcessArray, the private function BinarySearch() (see
lecture-handout code example):
- implement it only for the C-type array;
- inside function UsingCTypeAlgorithms(), declare a particular
key value;
- call BinarySearch() and display the index;
- select first a known value from the array, and next, one not
part of the array.
10. Inside the two files, use algorithm random_shuffle().
And redisplay the arrays.
Implement code for function LinearSearchCArray()
------------------------------------------------11. Declare, as part of the class ProcessArray, the private
function LinearSearchCArray() (see lecture-handout example);
********************************************
SEND TO INSTRUCTOR
- THE SOURCE/HEADER FILES
- THE FILE WITH CAPTURED OUTPUT-SCREEN
********************************************