Minimum Heap/hash table/binary tree/balanced binary tree/red/black tree meaning (when to use)

Source: Internet
Author: User

Meanings of least Heap/hash table/binary tree/balanced binary tree/red/black tree (under what conditions)

The data structure of the contact heap is described in sorting. The space complexity O (1), the time complexity O (nlogn ), however, in practice, it is better to sort quickly (it seems that fast sorting can better utilize hardware features ). The significance of heap lies in: finding the Maximum/minimum values as quickly as possible, and inserting a value in the Heap Structure to reconstruct the heap structure, the maximum/lowest value is removed and the time complexity of the heap structure is O (logn), while that of other methods is O (n ). in heap practice, sorting is not used. It is mainly used in scheduling algorithms, such as priority scheduling, the highest priority, the time-driven, and the least time/the longest wait, divided into the maximum Heap/minimum heap.

Hash Tables can locate the search objects in O (1) time, but in fact, if the input set is uncertain, a large number of conflicts may occur. Although there are many good hash functions, however, with the random input, a large number of conflicts are inevitable, and the worst case may occur. Therefore, if the hash table is used to determine the input set (that is, only query operations will be performed later), select the appropriate function and the method for resolving the conflict (perfect hash) search can be completed within O (1) Time (with proof, do not understand ).

The binary tree supports dynamic insertion and search to ensure that the operation is at O (height) time. This is the work that cannot be completed by the hash table and is dynamic. However, a binary tree may contain worst-case. If the input sequence is sorted, the time complexity is O (n)

The balanced binary tree/red/black tree aims to ensure that the time complexity of the search is within the O (logn) range.

Therefore, if the input is combined with the query, you can consider using a hash table. If the input set is not sure, you need to use a balanced binary/red/black tree to ensure maximum efficiency.

 

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/javatalk/archive/2007/05/15/1609555.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.