In the previous walkthrough you saw binary search implemented in the search function. Rewrite the function, renamed psearch, so that it uses two pointers, instead of indexes, as its arguments. The...


C++


In the previous walkthrough you saw binary search implemented in the search function. Rewrite the<br>function, renamed psearch, so that it uses two pointers, instead of indexes, as its arguments. The<br>function returns a pointer to the element or nullptr.<br>arrays.cpp<br>1<br>using iptr = const int*;<br>2<br>iptr psearch(iptr low, iptr high, int value)<br>{<br>4<br>if (low <= high)<br>{<br>auto mid =.. .;<br>if (*mid ==<br>{<br>return mid;<br>}<br>else if (*mid < value )<br>{<br>return psearch(.<br>7<br>value)<br>9<br>10<br>11<br>12<br>13<br>14<br>value);<br>}<br>else<br>{<br>return psearch(. . ., . .<br>15<br>16<br>17<br>18<br>value);<br>}<br>}<br>else<br>{<br>return nullptr;<br>}<br>}<br>19<br>20<br>21<br>22<br>23<br>24<br>25<br>CodeCheck<br>Reset<br>

Extracted text: In the previous walkthrough you saw binary search implemented in the search function. Rewrite the function, renamed psearch, so that it uses two pointers, instead of indexes, as its arguments. The function returns a pointer to the element or nullptr. arrays.cpp 1 using iptr = const int*; 2 iptr psearch(iptr low, iptr high, int value) { 4 if (low <= high)="" {="" auto="" mid=".." .;="" if="" (*mid="=" {="" return="" mid;="" }="" else="" if="" (*mid="">< value="" )="" {="" return="" psearch(.="" 7="" value)="" 9="" 10="" 11="" 12="" 13="" 14="" value);="" }="" else="" {="" return="" psearch(.="" .="" .,="" .="" .="" 15="" 16="" 17="" 18="" value);="" }="" }="" else="" {="" return="" nullptr;="" }="" }="" 19="" 20="" 21="" 22="" 23="" 24="" 25="" codecheck="">

Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here