MATCH OUTPUT WITH QUESTION OUTPUT --------------------------------------- Write a C++ Program for searching an element on a given list of integers using the Binary Search method. Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement. Initialize the array size in the constructor of the Search class.   Function Description int search(int n, int k) The function defines the logic for searching an element from the given array. If the element is found return '1'. Otherwise, return '0'. Input Format: The first line is an integer 'n' which corresponds to the number of elements in the array. The next 'n' lines correspond to the elements of the array. The last line is an integer 'k' which corresponds to the key element to be searched. Output Format: Print "Element Found" if the element is present in the array otherwise print "Element not Found". [All text in bold corresponds to the input and the rest corresponds to output] Sample Input and Output 1: 5 1 2 3 4 5 3 Element found Sample Input and Output 2: 4 3 5 7 9 11 Element Not Found   -----STRICTLY USE BELOW TEMPLATE IN YOUR SOLUTION--------- MAIN.CPP #include #include #include #include #include"Search.cpp" using namespace std; int main() { //Fill your code here }   SEARCH.CPP #include using namespace std; class Search { public: int *arr; Search(int a[], int n){ //Fill your code here } int search(int n,int k) { //Fill your code here } };

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

MATCH OUTPUT WITH QUESTION OUTPUT

---------------------------------------

Write a C++ Program for searching an element on a given list of integers using the Binary Search method.

Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement.

Initialize the array size in the constructor of the Search class.
 

Function Description
int search(int n, int k) The function defines the logic for searching an element from the given array.
If the element is found return '1'. Otherwise, return '0'.


Input Format:
The first line is an integer 'n' which corresponds to the number of elements in the array.
The next 'n' lines correspond to the elements of the array.
The last line is an integer 'k' which corresponds to the key element to be searched.

Output Format:
Print "Element Found" if the element is present in the array otherwise print "Element not Found".

[All text in bold corresponds to the input and the rest corresponds to output]

Sample Input and Output 1:

5
1
2
3
4
5
3

Element found

Sample Input and Output 2:

4
3
5
7
9
11

Element Not Found

 

-----STRICTLY USE BELOW TEMPLATE IN YOUR SOLUTION---------

MAIN.CPP

#include<cstring>
#include<iostream>
#include<queue>
#include<string>
#include"Search.cpp"
using namespace std;
int main()
{
//Fill your code here
}

 

SEARCH.CPP

#include <bits/stdc++.h>
using namespace std;

class Search {
public:
int *arr;

Search(int a[], int n){
//Fill your code here
}

int search(int n,int k)
{
//Fill your code here
}
};

Expert Solution
steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education