Btree

Disponível somente no TrabalhosFeitos
  • Páginas : 4 (977 palavras )
  • Download(s) : 0
  • Publicado : 7 de novembro de 2012
Ler documento completo
Amostra do texto
#include
#include
#include
#include

#define MAXKEYS 3
#define MINKEYS 1
#define NIL (-1)
#define NOKEY '@'
#define NO 0
#define YES 1
#define PAGESIZE sizeof(BTPAGE)

typedef struct{
short keycount; // number of keys in page
int key[MAXKEYS]; // the actual keys
short child[MAXKEYS+1]; // ptrs to rrns of descendants} BTPAGE;

//PROTOTIPAGEM//

bool btopen();
void btclose();
void putroot(short root);
short btread (short rrn, BTPAGE *page_ptr);
short btwrite(short rrn, BTPAGE *page_ptr);
shortgetroot();
short create_tree();
short getpage();

bool insert (short rrn, int key, short *promo_r_child, char *promo_key);

short create_root(int key, short left, short right);
void pageinit(BTPAGE*p_page);
bool search_node(int key, BTPAGE *p_page, short *pos);
void ins_in_page(int key,short r_child, BTPAGE *p_page);
void split(int key, short r_child, BTPAGE *p_oldpage, char *promo_key, short*promo_r_child, BTPAGE *p_newpage);
void print(int *p, int Nivel);


//VARIAVEISGLOBAIS//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
FILE *btfd;

struct {
int codigo;
char nome[50], seguradora[50], tipo[30];
}registro;////////////////////////////////////////////////////////////////////////////////////
//// ////////////////////////////////////////////////////////////
// Main do programa //////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
int main(void)
{
intescolha=0,
promoted; // boolean: tells if a promotion from below
short root, // rrn of root page
promo_rrn; // rrn promoted from below
char promo_key, // key promoted from below...
tracking img