subject

// Binary String Search and Selection Sort #include
#include
using namespace std;
// Function prototypes
void selectionSort(string[], int);
void displayArray(string[], int);
int binarySearch(string[], int, string);
int main()
{
const int NUM_NAMES = 20;
string search;
string names[NUM_NAMES] = { "Collins, Bill", "Smith, Bart", "Allen, Jim",
"Griffin, Jim", "Stamey, Marty", "Rose, Geri",
"Taylor, Terri", "Johnson, Jill",
"Allison, Jeff", "Looney, Joe", "Wolfe, Bill",
"James, Jean", "Weaver, Jim", "Pore, Bob",
"Rutherford, Greg", "Javens, Renee",
"Harrison, Rose", "Setzer, Cathy",
"Pike, Gordon", "Holland, Beth" };
// Sort the array.
selectionSort(names, NUM_NAMES);
// Display the sorted array.
cout << "Here are the names sorted:\n";
cout << "\n";
displayArray(names, NUM_NAMES);
// Get a name to search for.
cout << "Enter a name to search for: ";
getline(cin, search);
// Search for the name.
int results = binarySearch(names, NUM_NAMES, search);
// If results contains -1 the string was not found.
if (results == -1)
cout << "That names does not exist in the array.\n";
else
{
// Otherwise results contains the subscript of
// the specified name in the array.
cout << "That name is found at element " << results;
cout << " in the array.\n";
}

return 0;
}
//
// The selectionSort function performs an ascending order *
// selection sort on an array of strings. The size *
// parameter is the number of elements in the array. *
//
void selectionSort(string values[], int size)
{
int startScan;
int minIndex;
string minValue;
for (startScan = 0; startScan < (size - 1); startScan++)
{
minIndex = startScan;
minValue = values[minIndex];
// key fill in the index bounds
for (int index = key; index < key; index++)
{
// key what operator?
if (values[index] key minValue)
{
minValue = values[index];
minIndex = index;
}
}

values[minIndex] = values[startScan];
values[startScan] = minValue;
}
}
//
// The displayArray function displays the contents of *
// the array. *
//
void displayArray(string values[], int size)
{
for (int i = 0; i < size; i++)
cout << values[i] << endl;
}
//
// The binarySearch function performs a binary search on *
// an array of strings. array, which has a maximum of *
// size elements, is searched for the string stored in *
// value. If the string is found, its array subscript is *
// returned. Otherwise, -1 is returned indicating the *
// string was not in the array. *
//
int binarySearch(string values[], int size, string value)
{
bool found = false; // Flag, initialized to false.
int first = 0; // To hold the first array element
int middle; // To hold the mid point of search
int last = size - 1; // To hold the last array element
int position = -1; // To hold the position of search value
while (!found && first <= last)
{
// Calculate the mid point.
// key
middle = key
// Determine if the value is found at the mid point.
if (values[middle] == value)
{
position = middle;
found = true;
}
// Determine if the value is in the lower half.
// key add the comparison operator here
else if (values[middle] key value)
// key
last = key
// Determine if the value is in the upper half.
else
// key
first = key
}
return position;
}
complete the marked key

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:40
Pthreads programming: create and terminate a thread write a c++ program that creates a thread. the main will display a message “hello world from the main”. the main will create a thread that will display a message “hello world from the thread” and then terminates with a call to pthread_exit()
Answers: 3
question
Computers and Technology, 22.06.2019 20:00
Need asap assignment directions: think of an organization (business, religious institution, volunteer organization, sports team) with which you have been involved. imagine outfitting it with an it infrastructure. prepare a plan for what you would do to support outfitting it. draw a map of a network connecting all the individuals, give them pcs and printers, and lay out the design as best you can. the purpose is to begin working with these concepts, not to build a perfect network.
Answers: 2
question
Computers and Technology, 23.06.2019 04:31
Cloud computing service providers manage different computing resources based on the services they offer. which resources do iaas and paas providers not manage? iaas providers do not manage the for the client, whereas paas providers usually do not manage the for their clients. iaas- storage server operating system network paas- applications interafce storage vertualiation
Answers: 2
question
Computers and Technology, 23.06.2019 09:30
:you areto design the controller for alight that functions both as an ordinary light and also as a motion activated light and alarm. a.if the manual switch s is on, then the light l is on. b.besides the manual switch, there is a motion detector, m1, which activatesthis light.c.if motion is detected but the light is on anyway because s is on, only then a secondoutput a, an alarm, is turned on. d.the disable switch, d, disables the motion activated light and alarmbut leaves manual control operation of the light using switch s.(i)read the problem statement and clearly identify the inputs and outputs for the circuit you are designing. (ii)create the truth table for this system; include the light, alarm, switch, disable, and the motion sensor.(iii)draw a schematic of this system.
Answers: 1
You know the right answer?
// Binary String Search and Selection Sort #include
#include
using namespace std;
Questions
Questions on the website: 13722367