6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Sep 27, 2024 11:16 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: HELP ME PROGRAMMING 6502
PostPosted: Sat May 22, 2004 9:05 pm 
Offline

Joined: Sat May 22, 2004 7:58 pm
Posts: 2
Hello everybody. Can you help me with a problem that I have?

That is the problem:
We have a filed table. It is filed with the bubble sort algorithm. I want to make a codec to do binary search in this table. I would have a number for search and the program would seach for the number into the table.

What do you think? Can you help me? Thank you from now. I am from Greece and I study to a department of iformatics & comunication.

Waiting hearing from you.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue May 25, 2004 3:01 pm 
Offline

Joined: Thu Jan 16, 2003 12:55 pm
Posts: 64
Location: Indianapolis
Figure anything out yet?

You could just use brute force and go through the whole table using the CMP instruction on each entry. That's the easy and cheap way.

Since you say the table is sorted though, I'd advise doing some greater than/less than comparisons to speed it up. Narrow down the possibilities. If you don't know how, check out the relationship between the CMP instruction and the carry flag, it's really useful. If your value is less than the next entry, and greater than the previous entry, then you know it's not in the table.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue May 25, 2004 3:58 pm 
Offline

Joined: Wed Dec 18, 2002 3:20 am
Posts: 113
I'd also recommend a divide and conquer (sp?) aproach - if you want to check if it's even in the table, check say first and last to see if lesser or greater then anything in the table, then if it is likely to be in the table, then start in the center, compare and go higher or lower depending on the value you are looking for.

Obviously like what memblers said, if you run into a value that is lower then your target value, then the next value is larger, it just isn't in the table and you can quit the search and return an entry not found.

_________________
-Tony
KG4WFX


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: