数据结构作业的一系列答案

1、顺序表的插入运算

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <map>
#include <vector>

using namespace std;

const int maxn = 1500;
int a[maxn];

int main()
{
    int elenum;
    memset (a, 0, sizeof(a));
    scanf ("%d", &elenum);
    for (int i = 0; i < elenum; i++) {
        scanf ("%d", &a[i]);
    }
    int x;
    scanf ("%d", &x);
    for (int i = elenum - 1; i >= 0; i--) {
        if (i == 0 && a[0] > x) {
            a[1] = a[0];
            a[0] = x;
            break;
        }
        if (a[i] <= x) {
            a[i + 1] = x;
            //printf ("%d %d\n", a[i], a[i + 1]);
            break;
        }
        a[i + 1] = a[i];
    }
    //printf ("%d", a[0]);
    for (int i = 0; i <= elenum; i++) {
        printf ("%d ", a[i]);
    }
    printf ("\n");
    return 0;
}

2、线性表的就地逆置

#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

typedef struct Node{
    int data;
    struct Node *next;
}Node, *LinkList;

void insert1(int *a, LinkList &head, int elenum)
{
    LinkList p1 = head;
    LinkList p2;
    for (int i = 1; i <= elenum; i++) {
        scanf ("%d", &a[i]);
        p2 = (LinkList)malloc(sizeof(Node));
        p2->data = a[i];
        p1->next = p2;
        p1 = p2;
    }
    p2->next = NULL;
}

void transform1(int *a, int elenum)
{
    for (int i = 1; i <= elenum / 2; i++) {
        int t = a[i];
        a[i] = a[elenum - i + 1];
        a[elenum - i + 1] = t;
    }
}

void Reverse_l(LinkList &L){
    LinkList p=L->next;
    L->next = NULL;
    while (p!=NULL) {
        LinkList r=p->next;
        p->next=L->next;
        L->next=p;
        p=r;
    }
}

void print1(int *a, LinkList head, int elenum)
{
    for (int i = 1; i <= elenum; i++) {
        printf ("%d ", a[i]);
    }
    printf ("\n");
    LinkList p = head->next;
    while (p != NULL) {
        printf ("%d ", p->data);
        p = p->next;
    }
    printf ("\n");
}

void CreatList_head(LinkList &head, int elenum)
{
    head = (LinkList)malloc(sizeof(LinkList));
    head->next = NULL;
}

int main()
{
    int elenum;
    scanf ("%d", &elenum);
    int a[elenum + 1];
    LinkList head;
    CreatList_head (head, elenum);
    insert1 (a, head, elenum);
    transform1 (a, elenum);
    Reverse_l (head);
    print1 (a, head, elenum);
    return 0;
}

3、顺序表的删除

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;
const int maxn = 200;
const int maxm = 2000000;
int a[maxn];
int vis[maxm];

int main()
{
    int m, n, p, b, c;
    memset (vis, 0, sizeof(vis));
    scanf ("%d%d%d", &m, &n, &p);
    for (int i = 0; i < m; i++) {
        scanf ("%d", &a[i]);
    }
    for (int i = 0; i < n; i++) {
        scanf ("%d", &b);
        vis[b] = 1;
    }
    for (int i = 0; i < p; i++) {
        scanf ("%d", &c);
        if (vis[c] == 1) vis[c] = 2;
    }
    int j = 0, k = 0;
    for (int i = 0; i < m; i++) {
        if (vis[a[i]] != 2) printf ("%d ", a[i]);
    }
    printf ("\n");
    return 0;
}

4、单链表的归并

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef struct Node
{
    int data;
    struct Node *next;
}Node, *LinkList;

void CreatList(LinkList &p, int n)
{
     p = (LinkList) malloc (sizeof(Node));
     p->next = NULL;
    LinkList p1 = p;
    LinkList p2;
    for (int i = 0; i < n; i++) {
        int a;
        scanf ("%d", &a);
        p2 = (LinkList) malloc (sizeof(Node));
        p1->next = p2;//将p1->next设为p2,不是把p1->next的值赋给p2
        p2->data = a;
        p1 = p2;
    }
    p1->next = NULL;
}

void Merge(LinkList &a, LinkList &b)
{
    LinkList p1 = a->next;
    LinkList p2 = b->next;
    a->next = NULL;
    LinkList p3;
    while (p1 && p2) {
        if (p1->data <= p2->data) {
            p3 = p1->next;
            p1->next = a->next;
            a->next = p1;
            p1 = p3;
        } else {
            p3 = p2->next;
            p2->next = a->next;
            a->next = p2;
            p2 = p3;
        }
    }
    if (p2) p1 = p2;
    while (p1) {
        p3 = p1->next;
        p1->next = a->next;
        a->next = p1;
        p1 = p3;
    }
    free (b);
}

void PrintList(LinkList a)
{
    LinkList p = a->next;
    while (p) {
        printf ("%d ", p->data);
        p = p->next;
    }
    printf ("\n");
}

int main()
{
    int n, m;
    scanf ("%d%d", &n, &m);
    LinkList a, b;
    CreatList (a, n);
    CreatList (b, m);
    Merge (a, b);
    PrintList (a);
    return 0;
}

5、单链表的删除

#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

struct Node;
typedef Node *PNode;
struct Node{
    int data;
    PNode next;
}Node;

void CreatList(PNode &root, int num)
{
    root = (PNode)malloc(sizeof(Node));
    PNode p, now;
    p = root;
    int cnt = num;
    while (cnt--) {
        int data;
        scanf ("%d", &data);
        now = (PNode)malloc(sizeof(Node));
        now->data = data;
        p->next = now;
        p = now;
    }
    now->next = NULL;//&Otilde;&acirc;&frac34;&auml;±&eth;&Iacute;ü
}

void PrintList(PNode root)
{
    if (root != NULL) {
        printf ("%d ", root->data);
        PrintList (root->next);
    }
}

void Delete(PNode &a, PNode b, PNode c)
{
    PNode p1 = a->next, p2 = b->next, p3 = c->next, p = a;
    while (p1 && p2 && p3) {
        while (p2 && p2->data < p1->data) p2 = p2->next;
        while (p3 && p3->data < p1->data) p3 = p3->next;
        if (p2 && p3) {
            if (p1->data == p2->data && p1->data == p3->data) {
                while (p1 && p1->data == p2->data) {
                    p->next = p1->next;
                    free (p1);
                    p1 = p->next;
                }
                p2 = p2->next;
                p3 = p3->next;
            } else if (p1->data != p2->data && p1->data != p3->data){
                p = p1;
                p1 = p1->next;
            } else if (p1->data == p2->data) {
                p2 = p2->next;
                p = p1;
                p1 = p1->next;
            } else if (p1->data == p3->data) {
                p3 = p3->next;
                p = p1;
                p1 = p1->next;
            }

        }
    }
}

int main()
{
    int m, n, p;
    scanf ("%d%d%d", &m, &n, &p);
    PNode ra, rb, rc;
    CreatList (ra, m);
    CreatList (rb, n);
    CreatList (rc, p);
    Delete (ra, rb, rc);
    PrintList (ra->next);
    printf ("\n");
    return 0;
}

6、LOCATE操作

#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

struct Node;
typedef Node *PNode;
struct Node{
    char data;
    int freq;
    PNode pre, next;
}Node;

void CreatList(int n, PNode &head)
{
    head = (PNode) malloc (sizeof (Node));
    head->next = head->pre = head;//这句话不要忘,判空的时候有用
    int cnt = n;
    PNode p = head, p1;
    while (cnt--) {
        char c;
        cin >> c;
        p1 = (PNode) malloc (sizeof (Node));
        p1->data = c;
        p1->freq = 0;
        p1->next = p->next;
        p->next = p1;
        p1->pre = p;
        p = p1;
    }
}

void Locate(char c, PNode head)
{
    PNode p = head->next;
    while (p->next != head->next) {
        if (p->data == c) {
            p->freq++;
        }
        p = p->next;
    }
}

void Arrange(PNode &head)
{
    PNode p2 = head->next;
    while (p2->next != head->next) {
        PNode p3 = p2->next;
        if (p2->pre->freq < p2->freq) {
            PNode p1 = p2->pre;
            while (p1 != head && p1->freq < p2->freq) p1 = p1->pre;
            PNode p6 = p1->next, p4 = p2->pre;
            p1->next = p2;
            p6->pre = p2;
            p4->next = p3;
            p2->pre = p1;
            p2->next = p6;
            p3->pre = p4;
        }
        p2 = p3;
    }
}

void PrintList(PNode head)
{
    PNode p = head->next;
    while (p->next != head->next) {
        cout << p->data << " ";
        p = p->next;
    }
}

int main()
{
    int m, n;
    cin >> m >> n;
    PNode head;
    CreatList (m, head);
    while (n--) {
        char c;
        cin >> c;
        Locate (c, head);
    }
    Arrange (head);
    PrintList (head);
    return 0;
}

7、表达式括号匹配

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>

using namespace std;

struct Node;
typedef Node *PNode;
struct Node{
    char c;
    PNode link;
};

struct LinkStack{
    PNode top;
};
typedef struct LinkStack *PLinkStack;

void Pop(PLinkStack &a)
{
    PNode p = a->top;
    a->top = a->top->link;
    free (p);
}

void Push(PLinkStack &a, char c)
{
    PNode p = (PNode)malloc(sizeof(Node));
    p->c = c;
    p->link = a->top;
    a->top = p;
}

char Front(PLinkStack a)
{
    return (a->top->c);
}

int IsEmpty(PLinkStack a)
{
    return (a->top == NULL);
}

int check(string s)
{
    int l = s.length();
    PLinkStack a;
    a = (PLinkStack)malloc(sizeof(struct LinkStack));
    a->top = NULL;
    for (int i = 0; i < l; i++) {
        if (s[i] == '(' || s[i] == '{' || s[i] == '[') {
            Push (a, s[i]);
            continue;
        }
        if (!IsEmpty (a)) {
            if (s[i] == ')') {
                if (Front (a) == '(') Pop (a);
                else return 0;
                continue;
            } else if (s[i] == ']') {
                if (Front (a) == '[') Pop (a);
                else return 0;
                continue;
            } else if (s[i] == '}') {
                if (Front (a) == '{') Pop (a);
                else return 0;
                continue;
            }
        } else {
            if (s[i] == ')' || s[i] == ']' || s[i] == '}') return 0;
        }
    }
    if (!IsEmpty (a)) {
        return 0;
    }
    return 1;
}

int main()
{
    string s;
    cin >> s;
    if (check (s)) cout << "yes";
    else cout << "no";
    return 0;
}

8、逆波兰式

#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

struct Node;
typedef Node *PNode;
struct Node{
    char data;
    PNode link;
};

struct Stack{
    PNode top;
};

void InitStack(Stack &a)
{
    a.top = NULL;
}

void Push(char c, Stack &a)
{
    PNode p;
    p = (PNode)malloc(sizeof(Node));
    p->data = c;
    p->link = a.top;
    a.top = p;
}

void Pop(Stack &a)
{
    PNode b = a.top;
    a.top = b->link;
    free (b);
}

char Front(Stack a)
{
    return a.top->data;
}

bool IsEmpty(Stack a)
{
    if (a.top == NULL) return true;
    else return false;
}

char Compare(char c1, char c2)
{
    if (c2 == '+' || c2 == '-') {
        if (c1 == '(') return '<';
        else return '>';
    }
    if (c2 == '*' || c2 == '/') {
        if (c1 == '+' || c1 == '-' || c1 == '(') return '<';
        else return '>';
    }
    if (c2 == '(') {
        return '<';
    }
    if (c2 == ')') {
        if (c1 == '*') return '<';
        if (c1 == '(') return '=';
        return '>';
    }
}

bool IsOperater(char c)
{
    if (c == '+' || c == '-' || c == '*' || c == '/' || c == '(' || c == ')') return true;
    return false;
}

int main()
{
    Stack s2;
    InitStack (s2);
    string s;
    cin >> s;
    int l = s.length();
    for (int i = 0; i < l; i++) {
        if (!IsOperater (s[i])) cout << s[i];
        else {
            if (s[i] == '(') Push (s[i], s2);
            else if (s[i] == ')') {
                char c = Front(s2);
                while (c != '(') {
                    cout << c;
                    Pop (s2);
                    c = Front(s2);
                }
                Pop (s2);
            } else {
                if (IsEmpty (s2)) {
                    Push (s[i], s2);
                } else {
                    while (!IsEmpty(s2) && Front(s2) != '(' && Compare (Front (s2), s[i]) != '<') {
                        char c = Front (s2);
                        Pop (s2);
                        cout << c;
                    }
                    Push (s[i], s2);
                }
            }
        }
    }

    while (!IsEmpty (s2)) {
        char c = Front (s2);
        Pop (s2);
        cout << c;
    }
    return 0;
}

//(a+b)*c

9、循环队列(循环队列的题直接用数组做的、、、、就不贴了)
10、k阶斐波那契数列

#include <iostream>
#include <cstdlib>
#include <cstring>

using namespace std;

int main()
{
    int Max, k;
    cin >> Max >> k;
    int f[200];
    memset (f, 0, sizeof(f));
    f[k] = 1;
    int sum = 0;
    int n;
    for (int i = k + 1; ; i++) {
        sum -= f[i - k - 1];
        sum += f[i - 1];
        f[i] = sum;
        if (f[i] > Max && f[i - 1] <= Max) {
            n = i - 1;
            break;
        }
    }
    for (int i = n - k + 1; i <= n; i++) {
        cout << f[i] << " ";
    }
    return 0;
}

11、循环右移

#include <iostream>
#include <cstdlib>

using namespace std;

struct QNode;
typedef QNode *PNode;
struct QNode{
    int data;
    PNode next;//指向下一个节点
};

struct Queue{
    PNode Front;
    PNode Rear;//指向最后一个节点
};

void InitQueue(Queue &q)
{
    q.Front = new (QNode);
    q.Rear = q.Front;
    q.Front->next = NULL;//Front的作用和头结点一样,没有数据
}

void Push(Queue &q, int a)
{
    PNode p;
    p = new (QNode);
    p->data = a;
    p->next = NULL;
    q.Rear->next = p;
    q.Rear = p;
}

bool Pop(Queue &q)
{
    if (q.Front == q.Rear) return false;//队列为空
    PNode p = q.Front->next;
    q.Front->next = p->next;
    if (q.Rear == p) {
        q.Rear = q.Front;
    }
    free (p);
    return true;
}

int Front(Queue q)
{
    return q.Front->next->data;
}

bool IsEmpty(Queue q)
{
    if (q.Front == q.Rear) return true;
    return false;
}

int main()
{
    Queue q;
    InitQueue (q);
    int n, k;
    cin >> n >> k;
    int b1[1000], b2[1000];
    for (int i = 0; i < n; i++) {
        cin >> b1[i];
    }
    for (int i = n - 1; i >= 0; i--) {
        Push (q, b1[i]);
    }
    for (int i = 0; i < k; i++) {
        int a = Front (q);
        Pop (q);
        Push (q, a);
    }
    int cnt = 0;
    while (!IsEmpty (q)) {
        b2[cnt++] = Front (q);
        Pop (q);
    }
    for (int i = n - 1; i >= 0; i--) {
        cout << b2[i] << " ";
    }
    cout << endl;
    return 0;
}

12、以三元组表作为存储结构实现矩阵的相加

#include <iostream>

using namespace std;

struct Node{
    int row, column, data;
};

int main()
{
    int t1, t2;
    cin >> t1 >> t2;
    Node a[200], b[200], c[400];
    for (int l = 0; l < t1; l++) {
        cin >> a[l].row >> a[l].column >> a[l].data;
    }
    for (int l = 0; l < t2; l++) {
        cin >> b[l].row >> b[l].column >> b[l].data;
    }
    int i = 0, j = 0, k = 0;
    while (i != t1 && j != t2) {
        if (a[i].row < b[j].row) {
            while (j != t2 && i != t1 && a[i].row < b[j].row) {
                c[k].row = a[i].row;
                c[k].column = a[i].column;
                c[k].data = a[i].data;
                i++;
                k++;
            }
        } else if (a[i].row > b[j].row) {
            while (j != t2 && i != t1 && a[i].row > b[j].row) {
            c[k].row = b[j].row;
            c[k].column = b[j].column;
            c[k].data = b[j].data;
            j++;
            k++;
            }
        } else if (a[i].row == b[j].row) {
            if (a[i].column < b[j].column) {
                c[k].row = a[i].row;
                c[k].column = a[i].column;
                c[k].data = a[i].data;
                i++;
                k++;
            } else if (a[i].column > b[j].column) {
                c[k].row = b[j].row;
                c[k].column = b[j].column;
                c[k].data = b[j].data;
                j++;
                k++;
            } else if (a[i].column == b[j].column) {
                if (a[i].data + b[j].data != 0) {//可能加起来是0
                    c[k].row = b[j].row;
                    c[k].column = b[j].column;
                    c[k].data = b[j].data + a[i].data;
                    k++;
                }
                j++;
                i++;
            }
        }
    }
    while (i != t1) {
        c[k].row = a[i].row;
        c[k].column = a[i].column;
        c[k].data = a[i].data;
        k++;
        i++;
    }
    while (j != t2) {
        c[k].row = b[j].row;
        c[k].column = b[j].column;
        c[k].data = b[j].data;
        k++;
        j++;
    }
    for (int l = 0; l < k; l++) {
        cout << c[l].row << " " << c[l].column << " " << c[l].data << endl;
    }
    return 0;
}

13、以十字链表作为存储结构实现矩阵相加

#include <iostream>
#include <cstdlib>

using namespace std;

struct OLNode;
typedef OLNode *PNode;
struct OLNode{
    int data;
    int row, col;
    PNode Right, Down;
};

struct CrossLink{
    int m, n, t;
    PNode *Row, *Column;
};

void Insert(CrossLink &a, int data, int r, int c)
{
    PNode p;
    p = (PNode)malloc(sizeof(OLNode));
    p->col = c;
    p->row = r;
    p->data = data;
    p->Right = p->Down = NULL;
    if (a.Row[r] == NULL || a.Row[r]->col > c) {
        p->Right = a.Row[r];
        a.Row[r] = p;
    } else {
        PNode p1 = a.Row[r];
        while (p1->Right != NULL && p1->Right->col < c) p1 = p1->Right;
            p->Right = p1->Right;
            p1->Right = p;
    }
    if (a.Column[c] == NULL || a.Column[c]->row > r) {
        p->Down = a.Column[c];
        a.Column[c] = p;
    } else {
        PNode p1 = a.Column[c];
        while (p1->Down != NULL && p1->Down->row < r) p1 = p1->Down;
            p->Down = p1->Down;
            p1->Down = p;
    }
}

void CreatCrossLink(CrossLink &a, int t, int m, int n)
{
    a.Row = (PNode*)malloc(sizeof(PNode) * (m + 1));
    a.Column = (PNode*)malloc(sizeof(PNode) * (n + 1));
    for (int i = 0; i <= m; i++) {
        a.Row[i] = NULL;
    }
    for (int i = 0; i <= n; i++) {
        a.Column[i] = NULL;
    }
    a.m = m;
    a.n = n;
    a.t = t;
    for (int i = 0; i < t; i++) {
        int r, c, data;
        cin >> r >> c >> data;
        Insert (a, data, r, c);
    }
}

void Print(CrossLink a)
{
    int m = a.m;
    for (int i = 1; i <= m; i++) {
        if (a.Row[i] != NULL) {
            PNode p = a.Row[i];
            while (p != NULL) {
                cout << p->row << " " << p->col << " " << p->data << endl;
                p = p->Right;
            }
        }
    }
}

void Add(CrossLink a, CrossLink b, CrossLink &c)
{
    int m = a.m, n = a.n;
    c.Row = (PNode*)malloc(sizeof(PNode) * (m + 1));
    c.Column = (PNode*)malloc(sizeof(PNode) * (n + 1));
    for (int i = 0; i <= m; i++) {
        c.Row[i] = NULL;
    }
    for (int i = 0; i <= n; i++) {
        c.Column[i] = NULL;
    }
    c.m = m;
    c.n = n;
    int cnt = 0;
    for (int i = 1; i <= m; i++) {
        PNode p1 = a.Row[i], p2 = b.Row[i];
        while (p1 != NULL && p2 != NULL) {
            if (p1->col < p2->col) {
                Insert (c, p1->data, p1->row, p1->col);
                cnt++;
                p1 = p1->Right;
            } else if (p1->col > p2->col) {
                Insert (c, p2->data, p2->row, p2->col);
                p2 = p2->Right;
                cnt++;
            } else {
                int data = p1->data + p2->data;
                if (data != 0) {
                    Insert (c, data, p1->row, p1->data);
                    cnt++;
                }
                p1 = p1->Right;
                p2 = p2->Right;
            }
        }
        while (p1 != NULL) {
            Insert (c, p1->data, p1->row, p1->col);
            cnt++;
            p1 = p1->Right;
        }
        while (p2 != NULL) {
            Insert (c, p2->data, p2->row, p2->col);
            cnt++;
            p2 = p2->Right;
        }
    }
    c.t = cnt;
}

int main()
{
    int m, n, t1, t2;
    cin >> m >> n >> t1 >> t2;
    CrossLink a, b, c;
    CreatCrossLink (a, t1, m, n);
    CreatCrossLink (b, t2, m, n);
    Add (a, b, c);
    Print (c);
    return 0;
}

/*
3 4 3 2
1 1 1
1 3 1
2 2 2
1 2 1
2 2 3
*/
  • 2
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
第1章 绪论 1.1 数据结构的基本概念和术语 1.1.1 引言 1.1.2 数据结构有关概念及术语 1.1.3 数据结构和抽象数据类型(ADT) 1.2 算法描述与分析 1.2.1 什么是算法 1.2.2 算法描述工具——C语言 1.2.3 算法分析技术初步 习题一 第2章 线性表 2.1 线性表的定义及其运算 2.1.1 线性表的定义 2.1.2 各种运算简介 2.2 线性表的顺序存储结构(向量) 2.2.1 顺序存储结构(向量) 2.2.2 向量中基本运算的实现 2.3 线性表的链表存储结构 2.3.1 单链表与指针 2.3.2 单链表的基本运算 2.4 循环链表和双向链表 2.4.1 循环链表 2.4.2 双向链表 2.4.3 顺序存储结构与链表存储结构的综合分析与比较 2.5 多项式相加问题 2.5.1 多项式相加的链表存储结构 2.5.2 多项式相加的算法实现 2.6 线性表的算法实现举例 2.6.1 实现线性表顺序存储结构及运算的C语言源程序 2.6.2 单链表处理的C语言源程序 习题二 第3章 栈和队列 3.1 栈 3.1.1 栈的定义及其运算 3.1.2 栈的顺序存储结构(向量) 3.1.3 栈的链表存储结构 3.1.4 栈的应用 3.2 队列 3.2.1 队列的定义及运算 3.2.2 队列的顺序存储结构(向量) 3.2.3 队列的链表存储结构 3.3 栈和队列的算法实现举例 习题三 第4章 串 4.1 串的基本概念 4.2 串的存储结构 4.2.1 串的顺序存储 4.2.2 串的链表存储 4.2.3 串变量的存储映象 4.3 串的运算 4.3.1 串的运算简介 4.3.2 串的匹配运算 4.4 文本编辑 习题四 第5章 数组和广义表 5.1 数组的基本概念 5.1.1 数组的概念 5.1.2 数组的顺序表示 5.1.3 特殊矩阵的压缩存储 5.2 稀疏矩阵的三元组存储 5.2.1 三元组表 5.2.2 稀疏矩阵的运算 5.3 稀疏矩阵的十字链表存储 5.3.1 十字链表的组成 5.3.2 十字链表的有关算法 5.4 广义表 5.4.1 广义表的概念和特性 5.4.2 广义表的存储结构 5.4.3 求广义表的深度 5.4.4 广义表的输出 5.4.5 建立广义表的存储结构 5.5 迷宫问题 习题五 第6章 树 6.1 树的基本概念和术语 6.1.1 树的定义 6.1.2 树的常用术语 6.1.3 树的表示方法 6.2 二叉树 6.2.1 二叉树的定义 6.2.2 二叉树的重要性质 6.2.3 二叉树的存储结构 6.2.4 二叉树二叉链表的一个生成算法 6.3 遍历二叉树 6.3.1 先根遍历 6.3.2 中根遍历 6.3.3 后根遍历 6.3.4 二叉树遍历算法的应用 6.4 线索二叉树 6.4.1 线索二叉树的基本概念 6.4.2 线索二叉树的逻辑表示图 6.4.3 中根次序线索化算法 6.4.4 在中根线索树上检索某结点的前趋或后继 6.4.5 在中根线索树上遍历二叉树 6.5 二叉树、 树和森林 6.5.1 树的存储结构 6.5.2 树与二叉树之间的转换 6.5.3 森林与二叉树的转换 6.5.4 一般树或森林的遍历 6.6 树的应用 6.6.1 二叉排序树 6.6.2 哈夫曼树及其应用 6.7 二叉树的建立和遍历C语言源程序示例 习题六 第7章 图 7.1 图的基本概念和术语 7.1.1 图的基本概念 7.1.2 路径和回路 7.1.3 连通图 7.1.4 顶点的度 7.2 图的存储结构 7.2.1 邻接矩阵 7.2.2 邻接链表 7.3 图的遍历和求图的连通分量 7.3.1 图的建立 7.3.2 图的遍历 7.3.3 求图的连通分量 7.4 图的生成树 7.4.1 生成树的概念 7.4.2 最小生成树 7.4.3 普里姆(Prim)算法和克鲁斯卡尔(Kruskal)算法 7.5 最短路径 7.5.1 单源顶点最短路径问题求解 7.5.2 求有向网中每对顶点间的路径 7.6 有向无环图及应用 7.6.1 拓扑排序 7.6.2 关键路径 7.7 图的算法C语言程序实现举例 7.7.1 无向图的邻接表的建立和遍历 7.7.2 有向无环图的拓扑排序和求关键路径 习题七 第8章 查找 8.1 基本概念
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值