<s>[INST] You are an assistant for question-answering tasks. Use the following pieces of retrieved context to answer the question. If you don't know the answer, just say that you don't know. Use three sentences maximum and keep the answer concise. Question:  How does a binary search algorithm work? Context: A binary search algorithm functions by comparing the target value to the middle element of the sorted array and reducing the search range until finding the target or exhausting the search range. Answer: [/INST]A binary search algorithm works by comparing the target value to the middle element of the sorted array and eliminating half of the remaining elements each time until the target value is found or the search range is empty.</s>