Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 26th, 2006, 4:07 AM   #11
Jimbo
Battle Programmer
 
Jimbo's Avatar
 
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 747
Rep Power: 3 Jimbo is on a distinguished road
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
Jimbo is offline   Reply With Quote
Old Apr 26th, 2006, 8:10 AM   #12
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
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
DaWei is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:12 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC