![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Battle Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 747
Rep Power: 3
![]() |
iteration > recursion usually...
I don't see how a binary tree is better than a linear comparison for checking if two strings are equal. I understand if you're searching through sorted data, but binary tree or linear comparison, you still have to compare the whole of each string ![]() |
|
|
|
|
|
#12 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
First, if you're taking about a C-string, checking the length would be a big waste. You could do the comparison and be done by the time you counted the characters. Unless you have some very specialized knowledge about some very specially-arranged strings, binary hopping-about is only going to slow you down with the attendant overhead while providing no benefits. Your method might make a great learning exercise, but don't try to sell it to a knowledgeable boss. If your teacher mentioned binary is better in THIS context, uh-oh.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|