基本数据结构

栈是后进先出

class Stack
{
    int[] items;
    public Stack(int i = 10)
    {
        Length = i;
        Top = -1;
        items = new int[10];
    }
    //栈的最大大小
    public int Length { get; set; }
    //栈当前元素
    public int Top { get; set; }
    //栈是否为空
    public bool Empty() { return Top == -1; }
    //入栈
    public int Push(int value)
    {
        Top++;
        items[Top] = value;
        return Top;
    }
    //出栈
    public int Pop()
    {
        if (Empty())
            throw new Exception("empty");
        Top--;
        return items[Top + 1];
    }
    public string ToString()
    {
        string s = "";
        for (int i = 0; i <= Top; i++)
            s += items[i] + " ";
        return s;
    }
}

队列

队列是先进先出

链表

分为双向链表(prev、next)、单向链表(next)、循环链表。

对于链表,可以设置一个哨兵,分别指向链表头和链表尾部。

二叉树(root、left、right),多叉树(root、child1、child2...)

原文地址:https://www.cnblogs.com/qiusuo/p/5215550.html