C# PLEASE Lab9B: Binary Bubbles. Binary search is a very fastsearching algorithm, however it requires a set
Fantastic news! We've Found the answer you've been seeking!
Question:
C# PLEASE Lab9B: Binary Bubbles. Binary search is a very fastsearching algorithm, however it requires a set of numbers to besorted first.
Transcribed Image Text:
Lab9B: Binary Bubbles. Binary search is a very fast searching algorithm, however it requires a set of numbers to be sorted first. For this lab, create an array full of 11 integers which the user will generate. Like in the previous lab, assume that the values will be between -100 and +100. Then, using the sorting algorithm called BubbleSort, put the array in the correct order (from lowest to highest number). After this, please print the array to the screen. Finally, search the array for the target value using Binary Search. The BinarySearch code will implement the algorithm described in the lab slides. During this, you should print out a few key values which help Binary Search function. For example, this algorithm focuses on a low, mid, and high which correspond to the indices in the array the algorithm is currently considering and searching. Printing these values during the search process will help with debugging and fixing any issues. • BubbleSort sorts the array to prepare for the next step • BinarySearch searches the now sorted array to determine if the target value is in the array or not Remember, the file name should be Lab9B. The user input is indicated in bold. Sample output #1 Please enter 11 numbers: Integer 1: 15 Integer 2: 12 Integer 3: 89 Integer 4: -14 Integer 5: 11 Integer 6: -99 Integer 7: 1 Integer 8: 42 Integer 9: 27 Integer 10: 2 Integer 11: 67 What is the target number: 42 The sorted set is: -99 -14 1 2 11 12 15 27 42 67 89 Low is 0 High is 10 Mid is 5 Searching Low is 6 High is 10 Mid is 8 Searching The target is in the set. Lab9B: Binary Bubbles. Binary search is a very fast searching algorithm, however it requires a set of numbers to be sorted first. For this lab, create an array full of 11 integers which the user will generate. Like in the previous lab, assume that the values will be between -100 and +100. Then, using the sorting algorithm called BubbleSort, put the array in the correct order (from lowest to highest number). After this, please print the array to the screen. Finally, search the array for the target value using Binary Search. The BinarySearch code will implement the algorithm described in the lab slides. During this, you should print out a few key values which help Binary Search function. For example, this algorithm focuses on a low, mid, and high which correspond to the indices in the array the algorithm is currently considering and searching. Printing these values during the search process will help with debugging and fixing any issues. • BubbleSort sorts the array to prepare for the next step • BinarySearch searches the now sorted array to determine if the target value is in the array or not Remember, the file name should be Lab9B. The user input is indicated in bold. Sample output #1 Please enter 11 numbers: Integer 1: 15 Integer 2: 12 Integer 3: 89 Integer 4: -14 Integer 5: 11 Integer 6: -99 Integer 7: 1 Integer 8: 42 Integer 9: 27 Integer 10: 2 Integer 11: 67 What is the target number: 42 The sorted set is: -99 -14 1 2 11 12 15 27 42 67 89 Low is 0 High is 10 Mid is 5 Searching Low is 6 High is 10 Mid is 8 Searching The target is in the set.
Expert Answer:
Answer rating: 100% (QA)
C program that searches for an integer in an array using binary search using System class Lab9B static void Main create an array of size 11 int number... View the full answer
Related Book For
Introduction to Algorithms
ISBN: 978-0262033848
3rd edition
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
Posted Date:
Students also viewed these electrical engineering questions
-
Binary Search is performed on a sorted set of elements, it compares the number to be found with the middle element, if it is not the same, then it checks which (left or right) subarray will contain...
-
Binary search of a sorted array takes logarithmic search time, but the time to insert a new element is linear in the size of the array. We can improve the time for insertion by keeping several sorted...
-
A fragment of the source code for a Binary Search Tree (BST) in JavaScript is given down below: class Node { constructor(val){ this.val = val this.left = null this.right = null } } class BST {...
-
Dakota Company purchased several assets from a competitor, paying a lump-sum of $1,000,000 (one million dollars). The assets included: i. Land - valued at $420,000 ii. Building - valued at $400,000...
-
St. Paul Milling buys oats at $.80 per pound and produces SPM Oat Flour, SPM Oat Flakes, and SPM Oat Bran. The process of separating the oats into oat flour and oat bran costs $.40 per pound. The oat...
-
Consider a window the shape of which is a rectangle of height h surmounted a triangle having a height T that is 1 times the width w of the rectangle (as shown in the figure below). If the...
-
A large company has the opportunity to select one of seven projects-A, B, C, D, E, F, G-or choose the null (donothing) alternative. Each project requires a single initial investment as shown in the...
-
Grave City is considering the relocation of several police substations to obtain better enforcement in high-crime areas. The locations under consideration together with the areas that can be covered...
-
below is the code for quick sort. Modify this code so it runs in O(nlogn) time on sorted input. int partition(std::vector arr, int p, int r) int pivot int i=p for (int arr[r]; 1; p;j
-
Your investment bank has an investment of $100 million in the stock of the Swiss Roll Corporation and a short position in the stock of the Frankfurter Sausage Company. Here is the recent price...
-
Despite being a fairly old technology, menu-driven interfaces are very common in user interface design. Menu-driven interfaces consist of a series of screens that are navigated by choosing options...
-
A company has a beta of 0.1, the T-bill rate is 6.68%, and the expected return on the market is 14.26%. What is its required rate of return? Do not round your intermediate calculations. Express as a...
-
a. Most currencies, such as fiat currencies (e.g. the U.S. Dollar), have a theoretically unlimited supply, while Bitcoin has a maximum fixed supply of only 18.7 million Bitcoin in total. Given the...
-
a.) What caused the recent increases in P&G products? b.) P&G announced 6% increase in sales revenue in the most recent quarter. Explain what we know is true of price elasticity given this increase...
-
1. Until roughly 2006, default rates on mortgages were fairly low due to ever increasing home prices. According to the videos, how did rising home prices make a cycle which then caused home prices to...
-
Given the coordinate matrix of x relative to a (nonstandard) basis B for R, find the coordinate matrix of x relative to the standard basis. B = {(1, 0, 0), (1, 1, 0), (0, 1, 1)}, []B =[4 0 2]T -01 E...
-
Ironwood sells a single product for $10. The purchase cost is $4 per unit and Ironwood pays a 20% sales commission. Fixed costs are $45,000 per month including $12,000 depreciation, and the company...
-
When is the indirect pattern appropriate, and what are the benefits of using it?
-
Find all solutions to the equations x 4 (mod 5) and x 5 (mod 11).
-
Consider the following multithreaded pseudocode for transposing an n à n matrix A in place: Analyze the work, span, and parallelism of this algorithm. P-TRANSPOSE(A) 1 n = A.rows 2 parallel...
-
Prove that the maximum element in a symmetric positive-definite matrix lies on the diagonal.
-
Personalized medicine may be used a. to characterize types of tumors. b. to predict the outcome of certain types of cancers. c. to determine the proper dosage of drugs. d. in all of the above.
-
Tumor-suppressor genes promote cancer when a. they are overexpressed. b. they are expressed in the wrong cell type. c. their function is inactivated. d. they are expressed at the wrong stage of...
-
A mutant gene that promotes cancer when it is overexpressed is called a. a tumor-suppressor gene. b. an oncogene. c. both a and b. d. neither a nor b.
Study smarter with the SolutionInn App