S
S
Saa0052020-10-16 15:20:37
C++ / C#
Saa005, 2020-10-16 15:20:37

C++. Write a function that returns the number of elements of one array in another. How to write with binary search?

Good afternoon!
We need to write a binary search function that should return the number of elements of one array in another. The first array must be sorted.
For example: Array 1: 1, 6, 8, 9, 33, 67
Array 2: 67, 1, 0
Answer: 2 elements
Please help! I've been scratching my head all day, but I think it's somehow wrong.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ananiev, 2020-10-16
@SaNNy32

Each element of the second array is taken and searched by binary search in the first one. If an element is found, the counter of the number of elements in the second array in the first one is increased by one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question