Question
Hi , there hope ur doing well below i have mention 19 and 25 with short simple option , wanna see if u think of
Question 25)))))
Download the file named "file1.txt" in the folder "Files Needed For Coursework Exam 2Folder". Then run the following piece of code, which reads in data from the file, sorts it and searches for a particular number using the binary search algorithm:
#include
#include
using namespace std;
int binarySearch(int arr[], int value, int left, int right)
{
int count = 0;
while (left {
count++;
int middle = (left + right) / 2;
if (arr[middle] == value)
{
cout return middle;
}
else if (arr[middle] > value)
right = middle - 1;
else
left = middle + 1;
}
cout return -1;
}
void selectionSort(int arr[], int n) {
int i, j, minIndex, tmp;
for (i = 0; i minIndex = i;
for(j = i + 1; j if(arr[j] minIndex = j;
}
if (minIndex != i) {
tmp = arr[i];
arr[i] = arr[minIndex];
arr[minIndex] = tmp;
}
}
}
int main()
{
ifstream input("file1.txt");
const int size = 100;
int list[size];
for (int i = 0; i input >> list[i];
selectionSort(list, size);
int number = 16;
cout int pos1 = binarySearch(list, number, 0, size-1);
cout return 0;
}
Question 19))))
The Employee base class, the derived classes Sales and Technician (their definitions and implementations) and the test program testEmployee.cpp can be found in "Files Needed For Coursework Exam 2Folder". Download the files and inspect them.
Which of the following are features of the classes and their use in this example?
pointer-returning function(s)
polymorphism
dynamic objects
file input/output
inheritance
dynamic binding
string streams
dynamic array
generic function(s)
static member(s)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started