C language for the Fibonacci heap File

Source: Internet
Author: User
Tags constant definition

Calling... today, I spent a day at home, except for the procedures for going out to the House at the office at noon. Although I have not done so, there are fewer necessary conditions.

The rest have been tired recently... I think, stick to it. what else. this is the only option. haha. it sounds very pessimistic. In fact, it is still very optimistic.

I haven't gotten any code for a long time. It's really depressing! Yes! Depressing! It's all because of this...

Okay... today, after a hard day, My ass hurts, but I wrote it. A little pleased.

After researching on paper and implementing code again, it took about 20 hours to add up. It was only more time than the time. It was no less time.

Writing this stuff actually deepens understanding of pointers. although there is nothing to say about pointers consciously, when "*" is used, it is always a little scary. okay. I thought more about it this time, so it was smooth.

After writing this article, I don't want to talk too much about it... it's all in my head.

Sometimes, loneliness is dying... No way. Hard work.

Unfortunately, this Fibonacci Heap has never been used with a real knife, but it is estimated that there will be no problem. After all, it has been tested enough.

Fibonacci heap, haha. Very advanced data structure. I wrote it out.

This chapter is Chapter 11, which is still analyzed and unclear. It adds a dimension to the problem and is very scientific. I will continue to study it.

Okay, paste the code and wait a long time!

/* Fibonacciheap. H -- the Fibonacci heap file */<br/>/* The Code stage takes 14 hours. 2011-03-01-22.32 completed */<br/> # include <stdio. h> <br/> # include <stdlib. h> <br/> # include <assert. h> </P> <p>/* explicit constant definition */</P> <p> # define false (0) <br/> # define true (1) <br/> # define empty (1 <31) <br/> # define negative_infinty (1 <30) <br/> # define be_released (1 <31) </P> <p>/* data type definition */</P> <p> typedef int bool; </P> <p> typedef int item; <br/> typedef struct node <br/> {<br/> item; <br/> struct node * left, * right, * parent, * child; <br/> int degree; <br/> bool index; <br/>} node; <br/> typedef struct fibonacciheap <br/>{< br/> node * min; <br/> int current; <br/>}* fibonacciheap; </P> <p>/* interface function declaration */</P> <p>/* operation: create and initialize a Fibonacci heap */<br/>/* before the action: PFH points to a Fibonacci heap */<br/>/* after the action: if the memory allocation is successful, create and initialize the Fibonacci heap, and return true; otherwise, false; */<br/>/* return time: O (1) */<br/> bool initialize_f (maid * const PFH); </P> <p>/* operation: determine whether a Fibonacci heap is empty */<br/>/* before the operation: PFH points to an initialized Fibonacci heap */<br/>/* after the operation: if the Fibonacci heap is empty, true is returned. Otherwise, false */<br/>/* is returned. The return time is O (1) */<br/> bool isempty_f (const fibonacciheap * const PFH); </P> <p>/* operation: insert a node with specified data into the Fibonacci heap */<br/>/* before the operation: PFH points to an initialized Fibonacci heap, after the PI points to the data to be added */<br/>/*: if the memory allocation is successful, insert a data domain to the Fibonacci heap and return true; otherwise false */<br/>/* return time: O (1) */<br/> bool insert_f (const fibonacciheap * const PFH, const item * const PI); </P> <p>/* operation: delete and return the data of the most summarized points in the Fibonacci heap */<br/>/* before the operation: PFH points to an initialized Fibonacci heap */<br/>/*: If the Fibonacci heap is not empty, delete the most summarized point in the Fibonacci heap, data of the node is returned; otherwise, empty */<br/>/* return time: O (log n) */<br/> item deletemin_f (const fibonacciheap * const PFH); </P> <p>/* operation: reduce the value of the specified data in the Fibonacci heap */<br/>/* before the operation: PFH points to an initialized Fibonacci heap, and Pn points to the specified node, delta indicates the size of the change */<br/>/* operation: If the Fibonacci heap is not empty, reduce the value of the PN pointing to the node data in the Fibonacci heap by Delta, returns true; otherwise, returns false */<br/>/* amortize time: O (1) */<br/> bool decreasekey_f (const fibonacciheap * const PFH, node * const Pn, const int delta); </P> <p>/* operation: before deleting the specified node in the Fibonacci heap */<br/>/* operation: PFH points to an initialized Fibonacci heap, and Pn points to the node to be deleted */<br/>/*: If the Fibonacci heap is not empty, delete the node to which the PN points, returns true; otherwise, false */<br/>/* amortized return time: O (log n) */<br/> bool delete_f (const fibonacciheap * const PFH, node * const PN); </P> <p>/* operation: Release the memory space occupied by a Fibonacci heap */<br/>/* before the operation: PFH points to an initialized Fibonacci heap */<br/>/* after the operation: the memory space occupied by the Fibonacci heap is released */<br/>/* amortize time: O (N) */<br/> void release_f (const fibonacciheap * const PFH );

Related Article

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.