O (nlgk) problem priority queue header file C Language

Source: Internet
Author: User

/* Priorityqueue. H -- Minimum heap file */<br/> # include "head. H "</P> <p>/* interface function declaration */</P> <p>/* operation: before creating and initializing a priority queue */<br/>/*: ppq points to a priority queue, size is the variable */<br/>/* indicating the priority queue size. If size> 0 & memory allocation is successful, true is returned when the priority queue is created and initialized; otherwise false */<br/>/* time complexity: O (1) */<br/> bool initialize_p (priorityqueue * const ppq, const int size ); </P> <p>/* operation: determines whether a priority queue is empty */<br/>/* before the operation: after ppq points to an initialized priority queue */<br/>/*: If the priority queue is empty, true is returned; otherwise, false */<br/>/* is returned. Time Complexity: O (1) */<br/> bool isempty_p (const priorityqueue * const ppq ); </P> <p>/* operation: determines whether a priority queue is full */<br/>/* before the operation: ppq points to an initialized priority queue */<br/>/*: returns true if the priority queue is full; otherwise false */<br/>/* time complexity: O (1) */<br/> bool isfull_p (const priorityqueue * const ppq ); </P> <p>/* operation: Insert a node into a priority queue */<br/>/* before the operation, ppq points to an initialized priority queue, PN is the node to be added to the queue */<br/>/*: If the priority queue is not full, add the Pn to the priority queue and return true; otherwise false */<br/>/* time complexity: O (log n) */<br/> bool insert_p (const priorityqueue * const ppq, const prioritynode PN ); </P> <p>/* operation: delete and return the smallest node of the data field in the priority queue */<br/>/* before: after ppq points to an initialized priority queue */<br/>/*: If the priority queue is not empty, delete the queue and return the smallest node in the data field; otherwise, null is returned */<br/>/* time complexity: O (log n) */<br/> prioritynode deletemin_p (const priorityqueue * const ppq ); </P> <p>/* operation: add the specified data value of the node in the priority queue */<br/>/* before the operation: ppq points to an initialized priority queue. Position indicates the position. Delta indicates the change quantity */<br/>/* before the operation: If position is the valid position & Delta> 0, add Delta to the position node data in the priority queue and return true; otherwise, false */<br/>/* time complexity: O (log n) */<br/> bool increasekey_p (const priorityqueue * const ppq, const int position, const item delta); </P> <p>/* operation: reduce the specified data value of the node at the specified position in the priority queue */<br/>/* before the operation: ppq points to an initialized priority queue with the position specified position, delta is the change volume */<br/>/* operation: if the position is the valid position & Delta> 0, the data of the position node in the priority queue is reduced by Delta, returns true; otherwise, false */<br/>/* time complexity: O (log n) */<br/> bool decreasekey_p (const priorityqueue * const ppq, const int position, const item delta); </P> <p>/* operation: Release the memory space occupied by a priority queue */<br/>/* operation before: ppq points to an initialized priority queue */<br/>/*: the memory occupied by the priority queue is released */<br/>/* time complexity: O (n) */<br/> void release_p (const priorityqueue * const ppq );

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.