当前位置: 首页 > wzjs >正文

三门峡网站建设价格区块链开发语言

三门峡网站建设价格,区块链开发语言,怎么给网站在百度地图上做爬虫,浙江省住建和城乡建设厅官方网站一、树状结构 1.特征:在任意一个非空树中, (1),有且仅有一个特定的根结点 (2),当n>1 时,其余结点可分为m个互不相交的有限集合T1,T2,T3.。。。。Tm&…

一、树状结构

1.特征:在任意一个非空树中,
        (1),有且仅有一个特定的根结点
        (2),当n>1 时,其余结点可分为m个互不相交的有限集合T1,T2,T3.。。。。Tm,其中每一个集合又是一个树,并且称为子树。

2.度:结点拥有子树的个数称谓结点的度。度为0的结点称谓叶结点。度不为0,称谓分支结点。

(1)树的度数:这棵树中,最大的结点的度数,称谓树的度数

3.树的深度和高度:从根开始,根为第一层,根的孩子为第二层。

4.二叉树

        n个结点的有限集合,集合要么为空树,要么由一个根结点和两棵互不相交,分别称谓根结点的左子树和右子树的二叉树组成。

(1)特点:1,每个结点最多两个子树。
                    2,左子树和右子树是有顺序的,次序不能颠倒。
                    3,如果某个结点只有一个子树,也要区分左,右子树。

(2)特殊的二叉树:1,斜树,所有的结点都只有左子树,左斜树,所有结点都只有右子树,右树。


                                  2,满二叉树,所有的分支结点都存在左右子树,并且叶子都在同一层上。


                                  3,完全二叉树,对于一颗有n个结点的二叉树按层序编号,如果编号i(1<=i<=n)的结点于同样深度的满二叉树中编号为i的结点在二叉树中位置完全相同,则这可树为完全二叉树。

(3)特性:1,在二叉树的第i层上最多有2^(i-1)个结点 i>=1
                    2,深度为k的二叉树至多有2^k  -1 个结点 k>=1
                    3,任意一个二叉树T,如果其叶子结点的个数是n0,度数为2的结点数为n2, n0 = n2 +1;
                    4,有n个结点的完全二叉树深度为(logn/log 2) +1

(4)二叉树的遍历:前序,根左右,先访问根,然访问左,访问右。
                                  中序,左根右,先从根开始(不是先访问根),从左开始访问,在访问根,在访问右结点。
                                  后序,左右根,先从根开始(不是先访问根),先访问左,在访问右。在访问根。

(5)二叉树的基础操作

①创建二叉树

typedef char DATATYPE;
typedef struct _treenode_
{
    DATATYPE data;
    struct _treenode_ *left ,*right;
}TreeNode;

char data[] = "abd#f###c#eg###";
int ind = 0;
void CreateTree(TreeNode **root)
{
    char c = data[ind++];
    if('#' == c)
    {
        *root = NULL;
        return ;
    }
    else
    {
        *root = malloc(sizeof(TreeNode));
        if(NULL == *root)
        {
            fprintf(stderr,"CreateTree malloc error\n");
            return ;
        }
        (*root) -> data = c;
        CreateTree(&(*root) -> left);
        CreateTree(&(*root) -> right);
    }
}

(2)前序

void PreOrderTraverse(TreeNode *root)
{
    if(NULL == root)
    {
        return ;
    }
    printf("%c",root -> data);
    PreOrderTraverse(root -> left);
    PreOrderTraverse(root -> right);
}

(3)中序

void InOrderTraverse(TreeNode *root)
{
    if(NULL == root)
    {
        return ;
    }
    InOrderTraverse(root -> left);
    printf("%c",root -> data);
    InOrderTraverse(root -> right);
}

(4)后序

void PostOrderTraverse(TreeNode *root)
{
    if(NULL == root)
    {
        return;
    }
    PostOrderTraverse(root -> left);
    PostOrderTraverse(root -> right);
    printf("%c",root -> data);
}

(5)销毁

void DestoryTree(TreeNode *root)
{
    if(NULL == root)
    {
        return ;
    }
    DestoryTree(root -> left);
    DestoryTree(root -> right);
    free(root);
}

二、哈希表

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef int DATATYPE;

typedef struct
{
    DATATYPE *head;
    int tlen;
}HSTable;

HSTable *CreateHstable(int len)//创建哈希表
{
    HSTable *hs = malloc(sizeof(HSTable));
    if(NULL == hs)
    {
        fprintf(stderr,"CreateHstable malloc error");
        return ;
    }
    hs -> head = malloc(sizeof(DATATYPE));
    if(NULL == hs -> head)
    {
        fprint(stderr,"CreateHstable head malloc error");
        return ;
    }
    hs -> tlen = 0;
    int i = 0;
    for(i = 0;i < len;++i)
    {
        hs -> head[i] = -1;
    }
    return hs;
}

int HSFun(HSTable *hs,DATATYPE *data)
{
    return *data % hs -> tlen;

}

int HSInsert(HSTable *hs,DATATYPE *data)//将数据插入哈希表
{
    int ind = HSFun(hs, data);
  int old_ind = ind;
  while (hs->head[ind] != *data)
    {
      ind = (ind + 1) % hs->tlen;
      if (old_ind == ind)
        {
          return -1;
        }
    }
  return ind;
}

int HsSearch(HSTable* hs, DATATYPE* data)//查找

{

int ind = HSFun(hs, data);

int old_ind = ind;

while (hs->head[ind] != *data)

{

ind = (ind + 1) % hs->tlen;

if (old_ind == ind)

{

return -1;

}

}

return ind;

}

int main(int argc, char** argv)
{
  HSTable* hs = CreateHsTable(12);
  int array[] = {12, 67, 56, 16, 25, 37, 22, 29, 15, 47, 48, 34};
  int i = 0;
  for (i = 0; i < 12; i++)
    {
      HSInsert(hs, &array[i]);
    }

  int want_num = 37;
  int ret = HsSearch(hs, &want_num);
  if (-1 == ret)
    {
      printf("not find \n");
    }
  else
    {
      printf("find ,%d\n", hs->head[ret]);
    }

三、内核链表:

1.思想:将数据摘出来,降低代码耦合性,需自己定义结构体,结构体内部包括节点和数据,可按照自己的需求设计。

2.Linux第一宏:offset(地址偏移量) 和 contrainof(求地址)

3.基础操作

(1)klist.c

#include "./klist.h"
 
void klist_init(KLIST* head)
{
    head->prev = head;
    head->next = head;
}
 
void klist_add(KLIST* newnode,KLIST*prev,KLIST* next)
{
    newnode->next =next;
    newnode->prev = prev;
    prev->next = newnode;
    next->prev = newnode;
 
 
}
 
void klist_add_head(KLIST* head,KLIST* newnode)
{
    klist_add(newnode,head,head->next);
}
void klist_add_tail(KLIST* head,KLIST* newnode)
{
 
    klist_add(newnode,head->prev,head);
}
 
void klist_del(KLIST*prev,KLIST*next)
{
    prev->next = next;
    next->prev = prev;
}

(2)klist.h

#ifndef __KLIST_H__
#define __KLIST_H__
 
 
typedef struct __klist
{
    struct __klist *next;
    struct __klist* prev;
}KLIST;
 
#define offset(type,mem) ((size_t)  &((type*)0)->mem)
/**
 * @brief ptr 结构体node的指针
            type 结构体 per 
 *       mem  node在结构中的变量名
 */
#define containerof(ptr,type,mem) ({ const typeof(((type*)0)->mem) * _mptr = (ptr);\
   (type*) ((char*)_mptr- offset(type,mem)); })
 
#define klist_for_entry(ptr,type,mem)  containerof(ptr,type,mem)
/**
 * @brief p , 指向结构体的指针
 *        n, 指向当前结构体的下一个指针
         head, 链表的头节点指针
         mem, node在结构体中变量的名字
 */
//for(p=klist_for_entry(&(head)->next,typeof(*p),mem),n=klist_for_entry((p)->mem.next,typeof(*p),mem);
#define klist_for_each(p,n,head,mem) \
for(p=klist_for_entry(head->next,typeof(*p),mem),n=klist_for_entry((p)->mem.next,typeof(*p),mem);\
&p->mem != (head); p=n,n=klist_for_entry((n)->mem.next,typeof(*n),mem))
 
// #define offset(type,mem) ((size_t) &((type*)0)->mem)
// #define containerof(p,type,mem) ({\
// const typeof(  ((type*)0)->mem ) * _mptr = (p);\
// (type*)((char*)_mptr - offset(type,mem));})
// #define klist_entry(p,type,mem) containerof(p,type,mem)
 
// #define klist_for_each(p,n,head,node)\
// for(p=klist_entry((head)->next,typeof(*p),node),\
//     n=klist_entry(p->node.next,typeof(*p),node);        \
//     &p->node != (head);p=n,n=klist_entry(n->node.next,typeof(*n),node))
 
void klist_init(KLIST* head);
void klist_add_head(KLIST* head,KLIST* newnode);
void klist_add_tail(KLIST* head,KLIST* newnode);
void klist_del(KLIST*prev,KLIST*next);
 
#endif 

(3)per.c

#include "./per.h"
#include "klist.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
 
int add_per(int id,char *name,KLIST* head)
{
    PER* per = malloc(sizeof(PER));
    if(NULL == per)
    {
        perror("add_per malloc\n");
        return 1;
    }
    strcpy(per->name,name);
    per->id = id;
    klist_add_tail(head,&per->node);
    return 0;
}
 
int show_per(KLIST* head)
{
    PER *p ,*n;
   klist_for_each(p,n,head,node)
   {
    printf("%d %s\n",p->id,p->name);
   }
    return 0;
}
 
int del_per(KLIST* head,int id)
{
     PER *p ,*n;
   klist_for_each(p,n,head,node)
   {
    //printf("%d %s\n",p->id,p->name);
    if(p->id == id)
    {
        klist_del(p->node.prev, p->node.next);
        free(p);
    }
   }
 
   return 0;
 
}

(4)per.h

#ifndef __PER_H__
#define __PER_H__
#include "./klist.h"
typedef struct 
{
    int id;
    char name[40];
    KLIST node;
} PER;
 
 
int add_per(int id,char *name,KLIST* head);
int show_per(KLIST* head);
int del_per(KLIST* head,int id);
#endif 


文章转载自:

http://MHTwGiV6.tLLhz.cn
http://OGViS7sd.tLLhz.cn
http://ezeRdnjR.tLLhz.cn
http://LUNbbwSO.tLLhz.cn
http://X5WXUC9l.tLLhz.cn
http://moZCho2r.tLLhz.cn
http://KB1tFnDJ.tLLhz.cn
http://BT11UgFt.tLLhz.cn
http://RnYQmEZ8.tLLhz.cn
http://U8lfO5vn.tLLhz.cn
http://zdFaUoR7.tLLhz.cn
http://ABtKuRMW.tLLhz.cn
http://QsFQZOdp.tLLhz.cn
http://IIavPyOi.tLLhz.cn
http://qpxGEsJw.tLLhz.cn
http://5hWPhaWb.tLLhz.cn
http://Eoo93ssZ.tLLhz.cn
http://AWowaTYQ.tLLhz.cn
http://tkBCMtSN.tLLhz.cn
http://ojqTPidv.tLLhz.cn
http://hjbuGzMR.tLLhz.cn
http://QQ2KwwXK.tLLhz.cn
http://QuXntWPz.tLLhz.cn
http://ViQzSgtu.tLLhz.cn
http://TTORHZY3.tLLhz.cn
http://gBcefSVu.tLLhz.cn
http://K5fQuco6.tLLhz.cn
http://qdTB6uxB.tLLhz.cn
http://RzMmDTXE.tLLhz.cn
http://aywPFuBa.tLLhz.cn
http://www.dtcms.com/wzjs/688376.html

相关文章:

  • 创建网站的流程是什么电子商务网站开发难点
  • 网站后台是什么用html5做的网站代码
  • 潍坊网站制作策划东城东莞网站建设
  • 网站备案密码忘wordpress主题如何破解
  • 大学生兼职网站建设策划书快速搭建网站 数据存储
  • 建设电子商务网站步骤运动鞋建设网站前的市场分析
  • 龙岗建网站物流公司网站模板
  • 安徽网站建设详细策划花卉网站建设策划
  • 泉州建站软件临海市建设局网站
  • 广西贺州建设局网站网站建设公司包括哪些方面
  • wordpress多站点开启新手做网站流程
  • 优惠的网站快排公司电话psd转wordpress模板
  • 驾校网站建设重庆建设厅网站首页
  • 遵义住房和城乡建设厅网站海尔工业互联网公司排名
  • 盐城做网站哪家最好在线网站建设系统
  • 免费自助建站有域名就可以做网站吗
  • 如何保存自己做的网站上海网站建设模板
  • 网站开发测量像素工具seo搜索排名影响因素主要有
  • 中文域名网站 被搜索lamp wordpress 一键
  • 做网站的案例网站建设微信公众号小程序app
  • 千万别学广告学三秦seo
  • 青海高端网站建设公司买网站服务器要多少钱
  • 站长网站模板怎么做网站注册名密码
  • seo优化师培训合肥网站推广优化
  • 昆山建设工程招聘信息网站iphone怎么开通互联网
  • 静态网页模板免费网站网站建设时间查询
  • 中小企业网站用什么技术做阿里巴巴的网站的费用
  • 东莞市国外网站建设平台软件外包产业是什么意思
  • 网站能不能一边用 一边备案电子商务网站分析
  • 合适做服装的国际网站代做底单的网站