954,184 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Binary Search of an array of three strings

I have a homework assignment that requires that I sort an array of Accounts that contains strings for ID, PIN, and balance. I believe that I need to sort the array based on the ID. And then I have to verify the ID that the user inputs to the accounts that have been read in using ifStream. How do I use Binary Search to compare strings?

jfinch99
Newbie Poster
2 posts since Oct 2006
Reputation Points: 10
Solved Threads: 0
 

there are several examples and tutorials . I suggest you use a structure to hold the data for one account then put the structures in an array. That helps keep all the data together when sorting and searching. The actual algorithm you are looking for is almost the same as shown in the link I posted. Just change the comparison to use string compares instead of integer compares.

Ancient Dragon
Retired & Loving It
Team Colleague
30,047 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,342
 

Thanks

jfinch99
Newbie Poster
2 posts since Oct 2006
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You