Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

Binary Search Java

**Lab10B: Binary Bubbles**

Binary search is a very fast searching algorithm, but it requires a sorted list. For this lab, you'll create an array of 11 integers. Assume values range between -100 and +100. First, use the BubbleSort algorithm to sort the numbers in ascending order. Then, search for a target value using the Binary Search algorithm.

The **BinarySearch code** follows the algorithm described in lectures. During the search, print index values which help track the search's progress. This includes:
- **Low**, **Mid**, and **High** indices, which correspond to sections of the array currently being searched.

Printing these values aids debugging and fixing issues.

- **BubbleSort** prepares the array for search.
- **BinarySearch** determines if the target is present.

**Note:** Save your program file as `Lab10B`.

**Sample Output #1:**

- 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

- Target number: **42**

- Sorted set: -99, -14, 1, 2, 11, 12, 15, 27, 42, 67, 89

  - **Low** is 0
  - **High** is 11
  - **Mid** is 5
  
- Searching:

  - **Low** is 5
  - **High** is 11
  - **Mid** is 8

- Target found in the set.
expand button
Transcribed Image Text:**Lab10B: Binary Bubbles** Binary search is a very fast searching algorithm, but it requires a sorted list. For this lab, you'll create an array of 11 integers. Assume values range between -100 and +100. First, use the BubbleSort algorithm to sort the numbers in ascending order. Then, search for a target value using the Binary Search algorithm. The **BinarySearch code** follows the algorithm described in lectures. During the search, print index values which help track the search's progress. This includes: - **Low**, **Mid**, and **High** indices, which correspond to sections of the array currently being searched. Printing these values aids debugging and fixing issues. - **BubbleSort** prepares the array for search. - **BinarySearch** determines if the target is present. **Note:** Save your program file as `Lab10B`. **Sample Output #1:** - 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 - Target number: **42** - Sorted set: -99, -14, 1, 2, 11, 12, 15, 27, 42, 67, 89 - **Low** is 0 - **High** is 11 - **Mid** is 5 - Searching: - **Low** is 5 - **High** is 11 - **Mid** is 8 - Target found in the set.
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education