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




1) Binary Tree


2) Hash Table


3) Stack

Answers were Sorted based on User's Feedback



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

Answer / shruti

hash table

Is This Answer Correct ?    26 Yes 4 No

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

Answer / 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

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

Answer / k.kavitha

3)stack

Is This Answer Correct ?    8 Yes 23 No

Post New Answer

More C Interview Questions

How do you do dynamic memory allocation in C applications?

0 Answers  


Who is the founder of c language?

0 Answers  


Why do we write return 0 in c?

0 Answers  


Define the scope of static variables.

0 Answers  


Which of the following is not an infinite loop ? a.while(1){ .... } b.for(;;){ ... } c.x=0; do{ /*x unaltered within theloop*/ ... }while(x==0); d.# define TRUE 0 ... while(TRUE){ .... }

7 Answers   TCS,


Hai what is the different types of versions and their differences

0 Answers  


Why is conio.h not required when we save a file as .c and use clrscr() or getch() ?

2 Answers  


what is the use of call back function in c?tell me with example

2 Answers   Bosch,


Describe the modifier in c?

0 Answers  


Is the below things valid & where it will be stored in memory layout ? static const volatile int i; register struct { } ; static register;

2 Answers   Bosch,


Write a program that accepts a string where multiple spaces are given in between the words. Print the string ignoring the multiple spaces. Example: Input: “ We Are Student “ Output: "We Are Student"

1 Answers  


Program to find larger of the two numbers without using if-else,while,for,switch

11 Answers   iNautix, Wipro,


Categories