BinarySearch & XPath which one is faster?

  • Thread starter Thread starter kids_pro
  • Start date Start date
K

kids_pro

Hi there,

When class construct it read content from XML file and store it in
ArrayList.
In my class I had implement Search method using BinarySearch behind.

I want to implement another Method XmlSearch() to search direct from XML
file.

<dictionary>
<lookup key="animal"/>
<lookup key="apple"/>
.... more records
</dictionary>

I had read MSDN and be able to implement both search method.

But the question is which method faster?

Any suggestion on these two method?

Cheers,
Kids
 
I'm not entirely sure how the xpath performs a search when you specify
criteria, but if you're working with an ordered list, it will almost be
certainly faster to use Binary Search.

That said, I'm guessing the XPath is linear since it doesn't require an
order?

Dan.
 
The key thing is XPath is *XML* aware. In other words it knows things like

<foo></foo> is the same as <foo/>

and

<x:foo xmlns:x="urn-foo">

<x:bar>blah</x:bar>

</x:foo>

is the same as

<hello:foo xmlns:hello="urn-foo">

<hello:bar>blah</hello:bar>

</hello:foo>

Unless your binary search can guarantee the same then the two aren't performing the same search.

Regards

Richard Blewett - DevelopMentor

http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<#t8EG8#[email protected]>


I'm not entirely sure how the xpath performs a search when you specify
criteria, but if you're working with an ordered list, it will almost be
certainly faster to use Binary Search.

That said, I'm guessing the XPath is linear since it doesn't require an
order?

Dan.


kids_pro said:
Hi there,

When class construct it read content from XML file and store it in
ArrayList.
In my class I had implement Search method using BinarySearch behind.

I want to implement another Method XmlSearch() to search direct from XML
file.

<dictionary>
<lookup key="animal"/>
<lookup key="apple"/>
... more records
</dictionary>

I had read MSDN and be able to implement both search method.

But the question is which method faster?

Any suggestion on these two method?

Cheers,
Kids



---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004



[microsoft.public.dotnet.languages.csharp]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top