473,387 Members | 3,787 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

BinarySearch & XPath which one is faster?

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
Nov 16 '05 #1
2 1601

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" <ki******@yahoo.com> wrote in message
news:eZ**************@TK2MSFTNGP15.phx.gbl...
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

Nov 16 '05 #2
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/<#t**************@tk2msftngp13.phx.gbl>
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" <ki******@yahoo.com> wrote in message
news:eZ**************@TK2MSFTNGP15.phx.gbl...
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]
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for...
18
by: Maxim Kazitov | last post by:
Hi, I create application which transform huge XML files (~ 150 Mb) to CVS files. And I am facing strange problem. First 1000 rows parsed in 1 sec after 20000 rows speed down to 100 rows per sec,...
6
by: Chua Wen Ching | last post by:
Hi there, I had this xml file with me (not yet consider implementing xml namespaces yet). <?xml version='1.0'?> <Object> <Windows> <EID>1</EID> <EDesc>Error 1</EDesc> </Windows>
8
by: Sueffel | last post by:
Okay, I can certinatly use a For..Next loop to find the specified info I need, but I'm thinking the BinarySearch will be faster, if I can get it working LOL Anyhew, got an array, may have 5 or...
11
by: solandre | last post by:
my motivation is as follows: i have to binarysearch several million times an long that is several million items big. this costs time, although i use Array.Binarysearch<long>. so i try to keep...
43
by: tshad | last post by:
Which is better to use with an ArrayList: BinarySearch or Contains? The list is only going to have strings in it and it will be sorted. Thanks, Tom
8
stealwings
by: stealwings | last post by:
I have this code that does a linear search within two files, but it is too slow...... for(unsigned i=0;i<Standard.size();i++) { for(unsigned j=0;j<MyWords.size();j++) //each MyWords...
8
by: Guy | last post by:
Is there a better way to search identical elements in a sorted array list than the following: iIndex = Array.BinarySearch( m_Array, 0, m_Array.Count, aSearchedObject ); aFoundObject= m_Array;...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.