Codeforces celebrates 10 years! We are pleased to announce the crowdfunding-campaign. Congratulate us by the link https://codeforces.com/10years. ×

Efficient searching algo

Revision en1, by guacamolesyrup, 2019-02-20 17:55:17

Recently I have encountered a problem regarding searching.Any help would be appreciated.It says let, A be a sorted array(1-based index) of size n where n is even.A new array B is generated by swapping some elements in odd-numbered positions in the first half of A with some elements in odd-numbered positions in the second half of A.Note that elements in the even numbered positions are the same in both A and B, whereas each element in an odd-numbered position in A takes part in at most one swap.Write an algorithm that takes A and an integer x as inputs and finds whether x is present in B or not.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English guacamolesyrup 2019-02-20 17:55:17 664 Initial revision (published)