[Data structures]Depth first search forest

2019-7-23 写技术

#include <stdio.h> #include <stdlib.h> #define MAX 20 #define INFINIT 65535 typedef struct _ArcCell{ int adj; // Weight or flag about connection int *info; // Other information }ArcCell; typedef char VertexType; typedef enum{ DG, DN, UDG, UDN }GraphKind; ty...

阅读全文>>

标签: Data Structures data_structures

评论(0) 浏览(1099)

[Data structures]Graph travers (DFS and BFS)

2019-7-23 写技术

#include <stdio.h> #include <stdlib.h> #define MAX 20 #define INFINIT 65535 typedef struct _ArcCell{ int adj; // Weight or flag about connection int *info; // Other information }ArcCell; typedef char VertexType; typedef enum{ DG, DN, UDG, UDN }GraphKind; ty...

阅读全文>>

标签: Data Structures data_structures

评论(0) 浏览(1177)

[Data structures]Hash table

2019-7-17 写技术

#include <stdio.h> #include <stdlib.h> #define NULLKEY -1 int hashsize[] = {10, 20, 40, 100, 1024}; typedef struct _HashTable{ int *elem; int count; // count of the elements of the table now; int sizeIndex; // hashsize[sizeIndex] is the size of the table now; }HashTabl...

阅读全文>>

标签: Data Structures data_structures

评论(0) 浏览(1102)

[Data structures]Digital search tree - Trie tree

2019-7-16 写技术

#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #define MAX_LEN 8 typedef struct _TrieTree{ int kind; // 0-leaf; 1-branch union{ struct {char keys[MAX_LEN]; char *infoptr;} leaf; struct {struct _TrieTree *ptr[27]; int num;} bra...

阅读全文>>

标签: Data Structures data_structures

评论(0) 浏览(1274)

[Data structures]Digital search tree - Double link tree

2019-7-15 写技术

#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> typedef struct _DLTree{ char symbol; // key struct _DLTree *next; int kind; // 0-leaf; 1-branch union{ char *infoptr; //Pointer to the data struct _DLTree *first; }; }DLTree; ...

阅读全文>>

标签: Data Structures data_structures

评论(0) 浏览(1034)

[Data structures]B-Tree

2019-7-12 写技术

#include <stdio.h> #include <stdlib.h> #include <math.h> #define m 3 typedef struct _BTree{ int keynum; struct _BTree *parent; //Record *data[m+1]; /* Begin from 1 */ int key[m+1]; /* Begin from 1 */ struct _BTree *child[m+1]; /* Begin from 0 */ }BTree; ...

阅读全文>>

标签: Data Structures data_structures

评论(0) 浏览(1119)

[embeded] A sample of searial port communication

2019-7-10 写技术

#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <unistd.h> #include <fcntl.h> #include <sys/stat.h> #include <termios.h> void main() { struct termios opt; int tty; int len; int i; unsigned...

阅读全文>>

标签: embedded C linux

评论(0) 浏览(1282)

[Data structures]Balance binary search tree (AVL)

2019-7-9 写技术

#include <stdio.h> #include <stdlib.h> typedef struct _BinaryTree{ int key; int bf; struct _BinaryTree *left; struct _BinaryTree *right; }BinaryTree; void R_Rotate(BinaryTree **T) { BinaryTree *lc; lc = (*T)->left; (*T)->left = lc->right; lc->right = ...

阅读全文>>

标签: Data Structures data_structures

评论(0) 浏览(1129)

[Data structures]Binary search tree

2019-7-5 写技术

#include <stdio.h> #include <stdlib.h> typedef struct _BinaryTree{ int key; struct _BinaryTree *left; struct _BinaryTree *right; }BinaryTree; int searchBST(BinaryTree *T, int key, BinaryTree *f, BinaryTree **p) { if(T == NULL){ *p = f; return 0; } if(T->key ...

阅读全文>>

标签: Data Structures data_structures

评论(0) 浏览(1185)

[Data structures]Second optimal search tree

2019-7-5 写技术

#include <stdio.h> #include <stdlib.h> typedef struct _BinaryTree{ int key; struct _BinaryTree *left; struct _BinaryTree *right; }BinaryTree; /* seq[] from 1 to n; sw[0] = 0 */ void secondOptimal(BinaryTree **T, int seq[], float sw[], int low, int high) { BinaryTree *p=...

阅读全文>>

标签: Data Structures data_structures

评论(0) 浏览(1097)

Powered by anycle 湘ICP备15001973号-1