You are here:

C++/file struction

Advertisement


Question
how can i do binary search for sorted records in afile

Answer
Dear Malik:

According to this article: http://www.daniweb.com/forums/thread57575.html
You must read all the contents of the file to an array then do a qsort or a sort on the array.  If you have to do a binary sort then you must write that sort routine yourself.  Once the array is sorted you can write the elements back to the file.

Here is an article on binary sort: http://en.wikipedia.org/wiki/Binary_search

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Titus B. Ledbetter, Jr.

Expertise

C , MFC, Object Oriented, Artificial Intelligence

Experience

I have over ten years experience in the field of Computer Science, five years experience developing C/C++. I recently wrote a chess program using Object Oriented, C++, MFC.

Education/Credentials
Master's Degree Computer Science from Johns Hopkins

©2016 About.com. All rights reserved.