// Ask the user to enter an array // sort the array using Selection sort and Bubble sort // Ask the user to enter the target value (for example they enter 7) // search for the target value //using Linear search and Binary search A sample design (You can have your own design): * Ask the user to enter the size of the array * In a "for" loop ask the user to enter the elements * Show the values of the elements of the array => Write showValues function to show the values of the elements in the array * Ask the user what type of sort algorithms they want to be used: 1 Selection Sort 2.Bubble Sort * Show the values of the elements of the array => Use the showValues function to show the values of the elements in the array * Ake the user to enter the target value they want to search in the array * Ask the user what type of search algorithms they want to be used: 1 Linear Search 2. Binary Search * Show the index of the target in the array
Added by Phillip C.
Close
Step 1
The problem statement provides a high-level overview and then a more detailed sample design. I will break down the implementation into functions for clarity and modularity. First, I'll define the main function structure and then implement each required Show more…
Show all steps
Your feedback will help us improve your experience
Vandit Tyagi and 95 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
'Write a functional program that sorts 10 input integers (signed) using either bubble sort or selection sort algorithm: The output window must show both unsorted array of integers and sorted array of integers'
Vandit T.
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.
Akash M.
Consider an array of integers. Write pseudocode for either the selection sort, insertion sort, or bubble sort algorithm. Include loop invariants in your pseudocode. All code written in C++ and commented to understand each line/section. No GUI is needed, just a CLI application that can be run from an IDE.
Aarya B.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD