This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define INITIAL_TABLE_SIZE 163 | |
typedef struct hash_item { | |
void* p_elem; | |
struct hash_item* next; | |
} hash_item, *p_hash_item; | |
typedef struct hash_table { | |
int item_num; | |
int table_size; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
#include "heap.h" | |
PriorityQueue pq_init(int capacity) | |
{ | |
PriorityQueue H; | |
H=(PriorityQueue )malloc(sizeof(struct HeapStruct)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
void hanoi(int n, char src, char bri, char dst) | |
{ | |
if(n == 1) | |
{ | |
cout<<"Move"<<n<<"from"<<src<<"to"<<dst<<endl; | |
}else | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
void down(int * p, int k, int i) | |
{ | |
int value=p[i]; | |
int t; | |
for(t=i*2;t<=k;t=t*2) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 回溯法解N皇后问题 | |
* 使用一个一维数组表示皇后的位置 | |
* 其中数组的下标表示皇后所在的行 | |
* 数组元素的值表示皇后所在的列 | |
* 这样设计的棋盘,所有皇后必定不在同一行 | |
* | |
* 假设前n-1行的皇后已经按照规则排列好 | |
* 那么可以使用回溯法逐个试出第n行皇后的合法位置 | |
* 所有皇后的初始位置都是第0列 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#define SIZE 1024 | |
#define true 1 | |
#define false 0 | |
struct bt_node { | |
int value; | |
struct bt_node * left; |
NewerOlder