Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Which of the following data structures is on average the
fastest for retrieving data:




1) Binary Tree


2) Hash Table


3) Stack

Answer Posted / jbo5112

It depends on what you're looking for. If you want to find
what you just inserted, then a stack would be best. If you
have some sort of key that you're using to search through
the data, then it depends.

A hash table will generally be better, like Shruti said, but
if your container has few values and your key is large, then
doing a binary search might be faster than computing a hash
value for your key. That, of course, requires your Binary
Tree to be sorted and at least somewhat optimized (not all
branching the same direction). If your data is mostly
ordered, it's also possible to optimize your binary tree
search based on your previous search, but that will slow
down random data. I personally use hash tables or...

A fourth option (if memory permits) is to convert your key
to an integer and use an array. This one is quite easy to
implement (Boost even has one that is STL compliant, w/o
vector's overhead), and unless memory cache sizes come
heavily into play, this one is unbeatable. An example would
be looking up a state's name by the two letter abbreviation.
An array of 32768 char*'s isn't much, and on most computers
(including any x86/x86_64) you can simply look it up by
array[*(int*)"NY"].

Is This Answer Correct ?    21 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

I completed my B.tech (IT). Actually I want to develop virtual object that which will change software technology in the future. To develop virtual object what course I have to take. can I any professor to help me.

2227


what are enumerations in C

1161


How to create struct variables?

1107


stripos — Find position of first occurrence of a case- insensitive string int stripos ( char* haystack, char* needle, int offset ) Returns the numeric position of the first occurrence of needle in the haystack string. Note that the needle may be a string of one or more characters. If needle is not found, stripos() will return -1. The function should not make use of any C library function calls.

2467


What is the value of uninitialized variable in c?

1033


What is meant by inheritance?

1090


Can static variables be declared in a header file?

1060


what are the different storage classes in c?

1179


What is openmp in c?

1024


Explain what are multidimensional arrays?

1070


Explain what does it mean when a pointer is used in an if statement?

1064


int main() { Int n=20,i; For(i=0;i<=n;i--) { Printf(“-“); Return 0;

1825


What is meant by high-order and low-order bytes?

1048


can anyone suggest some site name..where i can get some good data structure puzzles???

2084


Do you know pointer in c?

1047