二叉树的各种操作函数

2023-11-19

#include "source.h"

//满与空的问题,计算个数时(判断rear和front的大小1.    2.   )空一个
void InitQueue(Queue u)
{
    u.front = 0;
    u.rear = 0;
}
int sizeQue(Queue u)
{   
    int size;
    if (u.front > u.rear)
        size = max - (u.front - u.rear);
    else
        size = u.rear - u.front;
    return size;

}
void swap(int &a, int &b)
{
    int c = a;
    a = b;
    b = c;
}
void Perm(int arr[], int k, int m)
{
    if (k == m)
    {
        for (int i = 0;i <= m;i++)
            printf("%d ", arr[i]);
        printf("\n");
    }   
    else
    {
        for (int i = k;i<=m;i++)
        {
            swap(arr[k], arr[i]);
            Perm(arr, k+1, m);
            //交换之后恢复原来的位置
            swap(arr[k], arr[i]);
        }
    }
}


void Freenode(BtNode *p)
{
    free(p);
}
/

void PreOrder(BtNode *ptr)
{
    if (ptr != NULL)
    {
        printf("%c ", ptr->data);
        PreOrder(ptr->leftchild);
        PreOrder(ptr->rightchild);
    }
}
void InOrder(BtNode *ptr)
{
    if (ptr != NULL)
    {
        InOrder(ptr->leftchild);
        printf("%c ", ptr->data);
        InOrder(ptr->rightchild);
    }
}
void PastOrder(BtNode *ptr)
{
    if (ptr != NULL)
    {
        PastOrder(ptr->leftchild);
        PastOrder(ptr->rightchild);
        printf("%c ", ptr->data);
    }
}

BtNode * CreateTree1()
{
    BtNode *s = NULL;
    char item;
    scanf_s("%c", &item);
    if (item != '#')
    {
        s = Buynode();
        s->data = item;
        s->leftchild = CreateTree1();
        s->rightchild = CreateTree1();
    }
    return s;
}
BtNode * CreateTree2(char *&str)
{
    BtNode *s = NULL;

    if (*str != '#')
    {
        s = Buynode();
        s->data = *str;
        s->leftchild = CreateTree2(++str);
        s->rightchild = CreateTree2(++str);
    }
    return s;
}
BtNode * CreateTree3(char ** const pstr)
{
    BtNode *s = NULL;
    if (**pstr != '#')
    {
        s = Buynode();
        s->data = **pstr;
        s->leftchild = CreateTree2(++(*pstr));
        s->rightchild = CreateTree2(++(*pstr));
    }
    return s;
}
//通过前序遍历和中序遍历得到原序列
//char *ps = "ABCDEFGH";
//char *is = "CBEDFAGH";

//寻找在中序中的位置
int FindPos(char *is,char ch,int n)
{
    for (int i = 0;i<n+1;i++) {                     //找到返回下标序号
        if (ch == is[i]) {
            return i;
            break;
        }
    }
    return -1;
}

char * substr(char *dst, char src[], int start, int len)
{
    int i;
    int pos = len - start+1;
    dst = new char[pos+1];
    for (i = 0;i<pos;i++)
    {
        dst[i] = src[start + i];    //从第start+i个元素开始向数组内赋值  
    }
    dst[i] = '\0';
    return dst;
}
BtNode * CreatePI(char *ps, char *is)
{
    BtNode *bt = NULL;
    if (strlen(ps) <= 0)
    {
        return bt;
    }
     int n = strlen(ps)-1;      //最后一个元素的下标

    char *lf_child_in = 0;
    char *rg_child_in = 0 ;
    char *lf_child_ps = 0;
    char *rg_child_ps = 0;
    //char *src_pr;

    bt = (BtNode *)malloc(sizeof(BtNode));
    bt->data = ps[0];
    int pos = FindPos(is, ps[0], n);//根在中序序列中的位置  

    lf_child_in = substr(lf_child_in,is, 0,pos-1);//左孩子的中序序列  
    rg_child_in = substr(rg_child_in, is, pos + 1, n);

    int lf_child_len = strlen(lf_child_in); //左孩子长度
    int rg_child_len = strlen(rg_child_in);

    lf_child_ps = substr(lf_child_ps, ps,1 , lf_child_len);     //左孩子的前序序列
    rg_child_ps = substr(rg_child_ps, ps, 1 + lf_child_len, n);
    if (bt!=NULL)
    {
        bt->leftchild = CreatePI(lf_child_ps, lf_child_in);
        bt->rightchild = CreatePI(rg_child_ps, rg_child_in);
    }
    return bt;
}
int FindPos1(char *is,char ch)
{
    int count = 0;
    while (is[count] != ch)
    {
        count++;
    }
    return count;
}
//利用n
int IsIndex(ElemType *is, ElemType x, int n) {
    for (int i = 0;i<n;i++) {                       //找到返回下标序号
        if (x == is[i]) {
            return i;
            break;
        }
    }
    return -1;                  //未找到则返回-1  
}


BtNode * CreatBin(char *ps, char *is, int n)        //n为此次要建树的元素个数
{
    BtNode *temp = NULL;            //如果直接将BtNode *temp=(BtNode *)malloc(sizeof(BtNode));
                                    //在遍历的情况下因为找不到NULL的值而打印出错,没有NULL的话
                                    //是一个随机值,没发打印
    if (n > 0)
    {
        temp = (BtNode *)malloc(sizeof(BtNode));
        temp->data = ps[0];
        int pos = IsIndex(is, ps[0], n);
        temp->leftchild = CreatBin(ps+1, is,  pos);
        temp->rightchild = CreatBin(ps+pos+1, is+pos+1, n-pos-1);
    }
    return temp;
}
BtNode *CreatPI1(char *ps,char *is)
{
    if (ps == NULL || is == NULL)
        return NULL;
    else
        return CreatBin(ps,is,strlen(ps));
}

//通过中序和后续遍历得到前序遍历
//char *ls = "CEFDBHGA";
//char *is = "CBEDFAGH";
BtNode *CrLI(char *ls, char *is ,int n)
{
    BtNode *temp = NULL;
    if (n > 0)
    {
        temp = (BtNode *)malloc(sizeof(BtNode));
        temp->data = ls[n-1];
        int pos = IsIndex(is, ls[n-1], n);
        if (pos == -1)
            exit(0);

        temp->leftchild = CrLI(ls, is, pos);
        temp->rightchild = CrLI(ls + pos, is + pos + 1, n - pos - 1);
    }
    return temp;
}
BtNode * CreateLI(char *ls, char *is)
{
    if (ls == NULL || is == NULL)
        return NULL;
    else
        return CrLI(ls, is, strlen(ls));
}

BtNode * FindValue(BtNode *ptr, ElemType x)
{
    if (ptr == NULL || ptr->data == x)
        return ptr;
    else 
    {
        BtNode *temp;
        temp = FindValue(ptr->leftchild, x);
        if (temp == NULL)
        {
            ptr = FindValue(ptr->rightchild,x);
        }
    }
    return ptr;
}
BtNode * FindParet(BtNode *ptr, BtNode *child)  //外加一个处理函数
{
    if (ptr->leftchild == child || ptr->rightchild == child)
        return ptr;
    BtNode *p = FindParet(ptr->leftchild, child);
    if(p==NULL)
        p = FindParet(ptr->rightchild, child);
    return p;
    //return NULL;
}

//最近双亲结点
/*
    网上有算法:得到前序和后续序列,对先序序列从两结点前从后向前找,对后序序列采取从两结点之后
    从前向后找,找到的第一个公共结点便是双亲结点

    我的思路:
        计算两个结点的高度,最小的高度的父结点便是其最近双亲结点
*/

int Depth_to_node(BtNode *ptr,ElemType e)
{
    if (ptr == NULL)
        return 0;
    else if (ptr->data == e)
        return 0;
    else
    {
            return Depth_to_node(ptr->leftchild, e) + 1;
            return Depth_to_node(ptr->rightchild, e) + 1;
    }
    return 0;
}
//from 网上
BtNode * FindNearParent(BtNode *ptr, BtNode *child1, BtNode*child2)
{
        if (ptr == NULL) //说明是空树,不用查找了,也就找不到对应节点,则返回NULL  
            return  NULL;

        if (ptr == child1 || ptr == child2)//说明在当前子树的根节点上找到两个节点之一  
            return ptr;

        BtNode   *pLeft = FindNearParent(ptr->leftchild, child1, child2);  //左子树中的查找两个节点并返回查找结果  
        BtNode   *pRight = FindNearParent(ptr->rightchild, child1, child2);//右子树中查找两个节点并返回查找结果  

        if (pLeft == NULL)//如果在左子树中没有找到,则断定两个节点都在右子树中,可以返回右子树中查询结果;否则,需要结合左右子树查询结果共同断定  
            return pRight;
        if (pRight == NULL)//如果在右子树中没有找到,则断定两个节点都在左子树中,可以返回左子树中查询结果;否则,需要结合左右子树查询结果共同断定  
            return pLeft;

        return ptr;//如果在左右子树中都找两个节点之一,则pRoot就是最低公共祖先节点,返回即可。  
}
int SizeLeaf(BtNode *ptr)
{
    if (ptr == NULL)
        return NULL;
    if (ptr && ptr->leftchild == NULL &&ptr->rightchild == NULL)
        return 1;
    else 
    {
        return SizeLeaf(ptr->leftchild)+SizeLeaf(ptr->rightchild);
    }
}
int Size(BtNode *ptr)
{
    //中序遍历或者后序等也都可以
    if (ptr == NULL)
        return NULL;
    else
    {
        return Size(ptr->leftchild) + Size(ptr->rightchild)+1;
    }

}
int Depth(BtNode *ptr)
{
    int size = Size(ptr);
    int depth = 0;
    while (1)
    {
        if ((size = (size / 2)) != 0)
        {
            depth++;
        }
        else break;
    }
    return depth+1;
}
int Depth1(BtNode *ptr)
{
    if (ptr == NULL)
        return 0;
    else
    return Depth1(ptr->leftchild) > Depth1(ptr->rightchild)? Depth1(ptr->leftchild)+1:Depth1(ptr->rightchild)+1;
}

void LevelOrder(BtNode *ptr)
{
    queue<BtNode*> que;
    que.push(ptr);
    while (!que.empty())
    {
        BtNode * temp = que.front();
        if(temp->leftchild != NULL)
            que.push(temp->leftchild);
        if(temp->rightchild != NULL)
            que.push(temp->rightchild);
        que.pop();
        printf("%c ", temp->data);
    }
}

int Level_K_prin(BtNode *ptr,int k,int count_tt)  //count_tt代表从那一层开始,0或1
{
//  static int count_tt = 1;
    if (count_tt == k)
    {
        printf("%c ", ptr->data);
        return k;
    }
     if (ptr->leftchild != NULL)
    {
        //count_tt += 1;
        Level_K_prin(ptr->leftchild, k,count_tt+1 );
    }
    if(ptr->rightchild != NULL)
    {
        //count_tt += 1;
        Level_K_prin(ptr->rightchild, k,count_tt+1);
    }
}
//判断两颗二叉树是否相等
bool Equal(BtNode *pa, BtNode *pb)
{
    if ( pa == NULL && pb!=NULL || pa != NULL && pb == NULL || pa->data != pb->data)
        return false;
    if (pa->leftchild != NULL && pb->leftchild != NULL)
    {
        bool temp = Equal(pa->leftchild, pb->leftchild);
        if (temp)
            ;
        else
            return temp;
    }
    if (pa->rightchild != NULL && pb->rightchild != NULL)
    {
        bool temp = Equal(pa->rightchild, pb->rightchild);
        if (temp)
            ;
        else
            return temp;
    }
    if (pa->rightchild == NULL && pb->rightchild == NULL || pa->leftchild == NULL && pb->leftchild == NULL)
        return true;
    if (pa->rightchild == NULL && pb->rightchild != NULL || pa->rightchild != NULL && pb->rightchild == NULL ||
        pa->leftchild != NULL && pb->leftchild == NULL || pa->leftchild == NULL && pb->leftchild != NULL)
        return false;
    //return false;
}

void NicePerOrder(BtNode *ptr)
{
    stack<BtNode*> stac;
    stac.push(ptr);
    BtNode *Node;
    while (!stac.empty())
    {
        Node = stac.top();
        printf("%c ", Node->data);
        stac.pop();
        if (Node->rightchild != NULL)
            stac.push(Node->rightchild);
        if (Node->leftchild != NULL)
        {
            stac.push(Node->leftchild);
        }
    }
}
void NiceInOrder(BtNode *ptr)
{
    stack<BtNode*> stac;
    while (ptr ||!stac.empty())
    {
        while (ptr)
        {
            stac.push(ptr);
            ptr = ptr->leftchild;
        }
        ptr = stac.top();
        stac.pop();
        printf("%c ", ptr->data);
        ptr = ptr->rightchild;
    }
}
void NicePastOrder(BtNode *ptr)
{
    stack<BtNode*> s;
    BtNode *cur;                      //当前结点 
    BtNode *pre = NULL;                 //前一次访问的结点     
    s.push(ptr);
    while (!s.empty())
    {
        cur = s.top();
        if ((cur->leftchild == NULL&&cur->rightchild == NULL) ||
               (pre != NULL && (pre == cur->leftchild || pre == cur->rightchild)))
        {
            cout << cur->data << " ";  //如果当前结点没有孩子结点或者孩子节点都已被访问过 
            s.pop();
            pre = cur;
        }
          else
        {
            if (cur->rightchild != NULL)
                s.push(cur->rightchild);
            if (cur->leftchild != NULL)
                s.push(cur->leftchild);
          }
      }
}
//是不是完全二叉树,设置一个全局的leftFlag
bool Is_Comp_BinaryTree(BtNode *root)
{
    queue<BtNode*> q;
    BtNode *ptr;
    // 进行广度优先遍历(层次遍历),并把NULL节点也放入队列  
    q.push(root);
    while ((ptr = q.front()) != NULL)
    {
        q.pop();
        q.push(ptr->leftchild);
        q.push(ptr->rightchild);
    }

    // 判断是否还有未被访问到的节点  
    while (!q.empty())
    {
        ptr = q.front();
        q.pop();

        // 有未访问到的的非NULL节点,则树存在空洞,为非完全二叉树  
        if (NULL != ptr)
        {
            return false;
        }
    }
    return true;
}

bool Is_Full_BinaryTree(BtNode *ptr);
bool Is_Balance_BinaryTree(BtNode *ptr);



//线索化二叉树 
//ThreadBineary temp;
void  InOrderThread(ThreadBineary ptr,ThreadBineary &temp)
{
    if (ptr != NULL)
    {
        InOrderThread(ptr->lfchild,temp);
        if (ptr->lfchild == NULL)
        {
            ptr->ltag = link;
            ptr->lfchild = temp;
            temp = ptr;
        }
        if (temp->richild ==NULL)
        {
            temp->richild = ptr;
            //ptr = temp->richild;
            temp->rtag = thread;
            temp = ptr;
        }
        InOrderThread(ptr->richild,temp);
    }
}

void THrInOrder(ThreadBineary ptr)
{
    //ThreadBineary p =ptr;
    //while (p != NULL)
    //{
    //  while (p->lfchild != NULL)
    //  {
    //      p = p->lfchild;
    //  }
    //  printf("%c", p->data);
    //  
    //  if(p->richild !=NULL)
    //      p = p->richild;
    //}
}
//求两个叶子节点的最大路径
int MaxPathBineary(BtNode *ptr)
{
    return 0;
}
void main()
{
    char *str = "ABC##DE##F##G#H##";
    char *ps = "ABCDEFGH";
    char *is = "CBEDFAGH";
    char *ls = "CEFDBHGA";

    char *ps1 = "ABCDEFGH";
    char *is1 = "CBEDFAGH";

    BinaryTree root = NULL;
    BinaryTree root1 = NULL;
    //root = CreateTree1();

    //root = CreatPI1(ps, is);
    root = CreateLI(ls, is);
    //root = CreateTree1();
    //root = CreateTree2(str);
    //root = CreateTree3(&str);
    root1 = CreatePI(ps1, is1);

    printf("递归的前序遍历是:\n");
    PreOrder(root);
    printf("\n");
    printf("递归的中序遍历:\n");
    InOrder(root);
    printf("\n");
    printf("递归的后序遍历:\n");
    PastOrder(root);
    printf("\n");

    
    //root = CreatePI(ps, is);

    BtNode *tt = FindValue(root,'G');
    if (tt != NULL)
        printf("找到的值是:%c \n", tt->data);
    else
        printf("没找到!");
    int count = Size(root);
    printf("count的值是:%d\n", count);
    count = SizeLeaf(root);
    printf("count2的值是:%d\n", count);
    count = Depth1(root);
    printf("depth is :%d\n", count);
    count = Depth_to_node(root,'H');
    printf("到%c的值是:%d\n", 'E',count);
    printf("---------------------------------------------------------");
    Level_K_prin(root, 3,1);
    ///
    bool result = Equal(root, root1);
    printf("两个二叉树相等吗? %d\n", result);
    printf("root1 的层次遍历顺序:\n");
    LevelOrder(root);
    //printf("\n");
    printf("非递归前序遍历的顺序:\n");
    NicePerOrder(root1);
    //printf("\n");
    printf("非递归中序遍历的顺序:\n");
    NiceInOrder(root);
    printf("非递归的后续遍历顺序是:\n");
    NicePastOrder(root);
    printf("\n");

    printf("是不是完全二叉树:\n");
    result = Is_Comp_BinaryTree(root);
    printf("%d", result);
}

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

二叉树的各种操作函数 的相关文章

  • U-Boot顶层Makefile详解

    文章目录 一 U Boot工程目录分析 1 打包编译好的uboot 2 目录介绍 1 arch 2 board 3 configs 4 Makefile 5 config 6 README 二 VSCode工程创建 1 新建工程 2 屏蔽不
  • 【docker】文档 [不断补充中...]

    全栈技术分享 文档API化 简单易懂 快速入门 动手党福音 跨界佬福利 直接搞技术 不背八股文 觉得对你有帮助的话点个赞吧 感兴趣的加关注 收藏书签方便随时查阅 同文档会不定期更新补充 有问题欢迎留言讨论 虚拟化 一种资源管理技术 硬件资源

随机推荐

  • 忍3服务器维护奖励,7月3日服务器维护公告

    亲爱的忍村学员 感谢大家对 忍者村大战2 的支持 为给大家带来更好的游戏体验 我们已于7月3日7 00 10 00进行全区停机版本更新 注 请勿擅自修改或替换客户端图片文件 会导致您的游戏崩溃或更新版本失败 如出现以上情况请卸载本地的客户端
  • mysql服务器搭建方法_windows下搭建MySQL服务器步骤详解

    Mysql是一个数据库系统 它包括数据库服务器 并且有一个数据库管理系统对数据库服务器进行管理 同时还包括有一个数据库客户端 用于与用户交互 从官方网站下载Mysql数据库系统的安装包程序 http www mysql com downlo
  • 怎样将好多个字符串组装成一个数组

    最近在写一个项目 在这个写的途中 发现了一个问题 就是不会将字符串组装成数组 然后去问了学长才知道 于是赶紧过来做个笔记 首先 我们需要先创建一个存储字符串的数组 创建数组 String hids new String hrs size 然
  • 不懂优雅停机,搞挂了线上服务,咋办?

    程序员的成长之路 互联网 程序员 技术 资料共享 关注 阅读本文大概需要 7 分钟 来自 陈树义 树哥聊编程 公司项目是用 consul 进行注册的 在发布微服务的时候 总是会导致调用方出现一定几率的调用失败 一开始百思不得其解 后来咨询了
  • shell编程快速入门(二)

    echo命令 输出指定的字符串或者变量 参数 n 不要在最后自动换行 e 激活转义字符 若字符串中出现以下字符 则特别加以处理 而不会将它当成一般文件输出 a 发出警告声 b 删除前一个字符 c 不产生进一步输出 c 后面的字符不会输出 f
  • mysql 批量添加更新_MySql快速插入以及批量更新

    MySql快速插入以及批量更新 插入 MySql提供了可以一次插入多条数据的用法 sql INSERT INTO tbl name a b c VALUES 1 2 3 4 5 6 7 8 9 10 11 12 在程序中可以通过循环 添加V
  • Blender51个基本操作

    一 选择操作 编辑模式 1 右键 选择 2 A 全选 3 B 左键 矩形选择 4 B 中键点击 矩形移除选择 5 C 左键 圆形选择 6 C 中键点击 圆形移除选择 7 滚轮滑动 圆形选择框大小 8 Ctrl 左键 扇形选择 9 Ctrl
  • tcp三次握手和四次挥手的过程以及原因

    简述下TCP三次握手的过程 并解释采用3次握手建立连接的原因 客户端发送连接请求 syn 1 seq x 服务端发送响应请求 syn 1 ack x 1 seq y 表示服务端准备好了 客户端发送确认的请求 ack y 1 seq x 1
  • java.lang.IllegalAccessError: class javax.activation.SecuritySupport12 cannot access its superclass

    最近加入新的项目组 eclipse tomcat7 spring ibatis restful 遇到了这样的问题 说是不能访问父类 我一开始以为是版本的原因 但是久经更改 错误依然 实在累了 最终的解决办法是我把SecuritySuppor
  • uniapp使用uni.createInnerAudioContext()播放指定音频并且切换

    uniapp使用uni createInnerAudioContext播放指定音频并且切换 注意 效果图 主要代码 放上所有的代码 注意 uniapp API 中 uni createInnerAudioContext 是无法多音频播放的
  • 电力行业数字孪生技术应用白皮书(2022)

    白皮书从产学研用多视角出发 结合电力行业的特性 分析阐述了数字孪生概念 核心技术 应用价值以及数字孪生电网标准体系 从数字感知 混合建模 高效仿真 可视化和虚实迭代等不同方面介绍了数字孪生的支撑技术以及应用现状 梳理了当前电力行业数字孪生技
  • C规范编辑笔记(四)

    往期文章 C规范编辑笔记 一 C规范编辑笔记 二 C规范编辑笔记 三 正文 大家好 今天来给大家分享一下C规范编辑笔记第四篇 距离我们C规范编辑笔记第三篇也快过去了一个月 这次继续分享一波 1 以大写形式声明常量 为避免误解 常量值必须根据
  • 信号完整性分析基础知识之传输线和反射(一):阻抗变化引起反射

    阻抗不连续引起的反射和失真可能会导致信号的误触发和误码 这是导致信号失真和质量下降的主要原因 在某些情况下 这看起来像振铃 当信号电平下降时 下冲会影响噪声预算并导致误触发 或者 在下降信号上 峰值可能会上升到低位阈值以上并导致误触发 下图
  • 基于遗传算法(GA)优化高斯过程回归(GA-GPR)的数据回归预测,matlab代码,多变量输入模型。评价指标包括:R2、MAE、MSE、RMSE和MAPE等,代码质量极高,方便学习和替换数据。

    清空环境变量 warning off 关闭报警信息 close all 关闭开启的图窗 clear 清空变量 clc 清空命令行 restoredefaultpath 导入数据 P train xlsread data training s
  • pymongo "ServerSelectionTimeoutError: No servers found yet" 错误的解决

    系统转移过程中 擅自把aptitude安装的mongoengine换成了pip安装 系统启动以后 报这个错误 报错提示 File usr local lib python2 7 dist packages pymongo mongo cli
  • 安装黑苹果双系统专辑贴(持续更新...)

    最近终于开始研究黑苹果 然后浏览了几篇文章贴收集一下 以便需要时随时阅览 和同学们互相学习 零基础篇 1 https blog csdn net a792396951 article details 80230946 2 https zhu
  • eNSP实验一(DHCP服务器)

    实验要求 四个电脑自动获取IP Client可以通过域名访问dhcp服务器 实验步骤及结果 第一步 1 打开eNSP软件 新建拓扑 搭建好所有设备 构建一个简单的局域网 第二步 启动所有设备 第三步 规划IP地址 第四步 点击路由器进入配置
  • 空指针异常:trim(),isEmpty()造成

    Trim 对空的再使用会报空指针异常 空字符串是 会创建一个对象 内容是 有内存空间 而null 不会创建对象 没有内存空间 长度为0 这时候再用isEmpty 的会报 空指针异常 尽量使用 null if role getId null
  • 性能测试知多少

    目录 1 性能测试基本理论 1 1 性能测试概念 1 1 1 什么是性能 1 1 2 什么是性能测试 1 2 性能测试基本内容 1 2 1 性能测试 1 2 2 负载测试 1 2 3 压力测试 1 2 4 稳定性测试 1 3 性能测试常用名
  • 二叉树的各种操作函数

    include source h 满与空的问题 计算个数时 判断rear和front的大小1 2 空一个 void InitQueue Queue u u front 0 u rear 0 int sizeQue Queue u int s