What to Do:
- Create a module called fillArray that has two input parameters: one for the array to be filled and the other for its size.
- Create a module called displayArray that has two input parameters: one for the array to be displayed and the other for its size.
- Create a sorting module of your choice and the binary search function:
- bubbleSort
- selectionSort
- insertionSort
- binarySearch
Hints:
- Do not try to create a sorting module or a search function yourself; study, understand, and use the pseudocode from the textbook only.
- It can be seen from the textbook that there is an input parameter for array size in all the sorting and binary search algorithms. However, you don't need such a parameter in Flowgorithm because you can use the size function to get the array size.
- Sorting algorithms are called modules, but the binary search algorithm is called a function. The rule is that if a block of pseudocode doesn't return a value, it is called a module; if a block of pseudocode returns a value, it is called a function.
Create main and in main do the following in sequence:
1. Create an integer array of size 50.
2. Fill the array with random numbers in the range of 0 through 1000.
3. Display every element in the array.
4. Sort the array using the sorting module of your choice.
5. Display every element in the array.
6. Create a random number in the range of 0 through 1000.
7. Use the binary search function to search the number.
8. Display your search results: the number is or is not in the array.
Hints:
- Create a constant and use it as the array size.
- Use the constant in array creation and display.
- Pay attention to the usage difference of the random function in pseudocode and in Flowgorithm.
- You cannot create a constant in Flowgorithm, but you can use the size function to get the array size.
- You can copy the flowcharts in this instruction.