类别归档:数据结构

数据结构是计算机存储、组织数据的方式。数据结构是指相互之间存在一种或多种特定关系的数据元素的集合。

RSS feed of 数据结构

POJ 1862 优先队列 priority_queue

Stripies (POJ 1862)

Time Limit: 1000MS Memory Limit: 30000K

Description

Our chemical biologists have invented a new very useful form of life called stripies (in fact, they were first called in Russian - polosatiki, but the scientists had to invent ...

继续阅读

字典树(Trie树)的C语言实现

字典树也称Trie树,是一种哈希树,适用于字符串的查找,存储,统计,排序等操作。

Trie树的C语言实现代码如下:


#define MAX 26    //26个字母
#define SLEN 100   //节点中存储的字符串长度
//Trie结构体定义
struct Trie
{
    struct Trie *next[MAX];
    char s[SLEN];      //节点处存储的字符串
    int isword;         //节点处是否为单词
    char val;           //节点的代表字符
} *root;
//初始化Trie树
struct Trie *init()
{
    struct Trie *root ...

继续阅读

C语言实现循环冗余码CRC12

CRC是一种常用的错误侦测编码,例如,字符串"test"的CRC12余数计算结果为:

CRC12 remainder of str "test" is 679
The binary string is:
01110100 01100101 01110011 01110100 011001111001

计算CRC12的C语言代码如下:


/**
CRC12
*/
#include <cstring>
#include <stdlib.h>
#include <cstdio>
#include <iostream>
#define CHAR_SIZE 8
#define CRC_SIZE 12
using namespace ...

继续阅读

POJ 2833 The Average 优先队列

The Average (POJ 2833)
Time Limit: 6000MS Memory Limit: 10000K
Case Time Limit: 4000MS

Description

In a speech contest, when a contestant finishes his speech, the judges will then grade his performance. The staff remove the highest grade and ...

继续阅读