Language is C++  Lab10B: 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 lecture 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 I included some sample outputs; the user input is in bold (just examples)

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Language is C++ 

Lab10B: 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 lecture 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

I included some sample outputs; the user input is in bold (just examples) 

**Sample Output #2**

**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:** -5

The sorted set is: -99 -14 1 2 11 12 15 27 42 67 89

Low is 0  
High is 11  
Mid is 5  
Searching  

Low is 0  
High is 4  
Mid is 2  
Searching  

Low is 0  
High is 1  
Mid is 0  
Searching  

Low is 1  
High is 1  
Mid is 1  
Searching  

The target is not in the set.

---

**Explanation:**

This output is a demonstration of a binary search algorithm. Here are the steps visually displayed:

1. **Input:** The user inputs 11 integers.
2. **Sorted Set:** The list of integers is sorted in ascending order.
3. **Binary Search Process:** 
   - Begins with initial boundaries (`Low` and `High`).
   - The midpoint (`Mid`) is calculated.
   - The search narrows down based on comparisons until the target is found or determined to be absent.
4. **Result:** The searched target number, -5, is confirmed to not be in the sorted list.
Transcribed Image Text:**Sample Output #2** **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:** -5 The sorted set is: -99 -14 1 2 11 12 15 27 42 67 89 Low is 0 High is 11 Mid is 5 Searching Low is 0 High is 4 Mid is 2 Searching Low is 0 High is 1 Mid is 0 Searching Low is 1 High is 1 Mid is 1 Searching The target is not in the set. --- **Explanation:** This output is a demonstration of a binary search algorithm. Here are the steps visually displayed: 1. **Input:** The user inputs 11 integers. 2. **Sorted Set:** The list of integers is sorted in ascending order. 3. **Binary Search Process:** - Begins with initial boundaries (`Low` and `High`). - The midpoint (`Mid`) is calculated. - The search narrows down based on comparisons until the target is found or determined to be absent. 4. **Result:** The searched target number, -5, is confirmed to not be in the sorted list.
## 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

### Binary Search Steps:

1. **Initial Values:**
   - Low is 0
   - High is 11
   - Mid is calculated as (0 + 11) / 2, which is 5

   **Searching...**

2. **Update Values:**
   - Low is updated to 6 (as the target is greater than the mid value)
   - High remains 11
   - Mid is recalculated as (6 + 11) / 2, which is 8

   **Searching...**

3. **Result:**
   - The target is found in the set.

This output illustrates the use of the binary search algorithm to locate the target number within a sorted list.
Transcribed Image Text:## 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 ### Binary Search Steps: 1. **Initial Values:** - Low is 0 - High is 11 - Mid is calculated as (0 + 11) / 2, which is 5 **Searching...** 2. **Update Values:** - Low is updated to 6 (as the target is greater than the mid value) - High remains 11 - Mid is recalculated as (6 + 11) / 2, which is 8 **Searching...** 3. **Result:** - The target is found in the set. This output illustrates the use of the binary search algorithm to locate the target number within a sorted list.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY