Please Please Please Read the instructions and do everything listed there. if you no going to read the instructions and I received bad Credit I will do Bad Rating.
Lab #11:
Write a program that will do the following:
Output:
• Display the entire array.
• Display the extra random number.
• Depending upon the result of your search, display one of the following:
– How many times the random number occurs.
– That the random number did not occur at all.
Also include:
NOTE 1: Other than the prompt to repeat the task, there is no input from the User in this program.
NOTE 2: This program will have 3 functions:
======================= Please Read ======================
Searching Through Arrays
Now that we can store large amounts of data we are ready to learn was to process the data. One way is to search through the data we have stored.
To search for instances of a value in an Array, you use a looping structure – which begins with the starting position of the Array and loops through each consecutive cell. There are two types of searches.
If you are searching for a value where only one instance will occur in the array (no duplicates) then you search until the value is found or until you reach the end of the array. If more than one instance can occur in the array then you must search until you reach the end of the array. If you are not sure whether there will be only one instance of a value or not then you assume it could occur more than once and use the second method.
Searching for a single instance of a value in an Array
When searching for one instance, you use a sentinel driven While or Do Loop. When setting up the condition for the looping structure, you must stop when one of two things occur:
You must stop when the value is found
OR
You must stop when you reach the end of the Array
The pseudo-code would look like this:
initialize index to the beginning index value of your Array
initialize a flag (Boolean variable) to false to represent element not found
WHILE the flag is equal to false AND index is less than size of Array
IF the element at Array (index) is equal to the element you are searching for THEN
flag is assigned true (element found)
ELSE
increment index
END IF
END WHILE
Remember:
NOTE 1: This is only one way to search for a element contained within an Array. There are many other ways.
NOTE 2: This assumes there is only one instance of an element in the Array.
Searching for duplicate instances of a value in an Array
If you need to search for a value that can occur more than once in an array then you need to cycle through the ENTIRE Array (instead of stopping when the first instance is found) and count (using a different counter than the Loop index) how many times the element occurred. Within each cycle, a comparison is made between the value you are searching for and the contents of the cell. Each time there is a match you count it by incrementing a counter.
Initialize the counter to 0 (to start counting)
FOR (index is equal to beginning index value of Array, index is less than size of Array, increment index by 1)
IF the element at Array (index) is equal to the element you are searching for THEN
increment the counter (element found)
END IF
END FOR
In this algorithm, when the looping structure ends the counter will either be zero or it will contain the number of instances the value occurred within the array. If the counter is zero then there were no instances of the value in the array.
Your Responsibilities in Module 11
Module Overview:
This Module continues with the topic of arrays. The focus is on how to process data stored within an array. Searching for and sorting data within an array is discussed.
Module Learning Objectives:
Readings:
1. Read all Mini-Lectures Module 11
2. Text:
Choose an academic level, add pages, and the paper type you want.
To reduce the cost of our essay writing services, select the lengthier deadline.
We can't believe we just said that to you.
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more
Recent Comments