数据结构——线性表

本文贴出顺序表、链表 的例子代码,以及实例通讯录的代码。
文中代码均已在VS2015上测试,空指针均为nullptr(C++11)。参考来源:慕课网

线性表

线性表是n个数据元素的有限序列。

  • 分类:顺序表(即数组)、链表(分为 静态链表、单链表、循环链表、双向链表)

  • 应用场景:通讯录、一元多项式

顺序表

前驱、后继

BOOL InitList(List **list);//创建线性表
void DestroyList(List *list);//销毁线性表
void CleanList(List *list);//清空线性表
BOOL ListEmpty(List *list);//判断线性表是否是空
int ListLength(List *list);//获取线性表长度
BOOL GetElem(List *list,int i,Elem *e);//获取指定元素
int LocateElem(List *list,Elem *e);//寻找第一个满足e的数据元素的位序
BOOL PriorElem(List *list,Elem *currentElem,Elem *preElem);//获取指定元素的前驱
BOOL NextElem(List *list,Elem *currentElem,Elem *nextElem);//获取指定元素的后继
BOOL ListInsert(List *list,int i,Elem *e);//在第i个位置上插入元素
BOOL ListDelete(List *list,int i,Elem *e);//删除第i个位置的元素
void ListTraverse(List *list);//遍历线性表

示例:

#ifndef MYLIST_H
#define MYLIST_H

/****************************/
/*顺序表C++类[MyList.h]    */
/****************************/
class MyList
{
public:
    MyList(int size);
    ~MyList();
    void CleanList();
    bool ListEmpty();
    int ListLength();
    bool GetElem(int i, int *e);
    int LocateElem(int *e);
    bool PriorElem(int *currentElem, int *preElem);
    bool NextElem(int *currentElem, int *nextElem);
    bool ListInsert(int i, int *e);
    bool ListDelete(int i, int *e);
    void ListTraverse();
private:
    int *m_pList;
    int m_iSize;
    int m_iLength;
};

#endif // !MYLIST_H

/******************************/
/*顺序表C++实现[MyList.cpp]   */
/******************************/
#include "MyList.h"
#include <iostream>
using namespace std;
MyList::MyList(int size)
{
    m_iSize = size;
    m_pList = new int[m_iSize];
    m_iLength = 0;
}

MyList::~MyList()
{
    delete []m_pList;
    m_pList = nullptr;
}

void MyList::CleanList()
{
    m_iLength = 0;
}

bool MyList::ListEmpty()
{
    //return m_iLength==0?true:false;
    if (m_iLength == 0)
    {
        return true;
    }
    return false;
}

int MyList::ListLength()
{
    return m_iLength;
}

bool MyList::GetElem(int i, int * e)
{
    if (i < 0 || i >= m_iLength)
    {
        return false;
    }
    else 
    {
        *e = m_pList[i];
        return true;
    }
}

int MyList::LocateElem(int * e)
{
    for (int i = 0;i < m_iLength;i++)
    {
        if (m_pList[i] == *e)
        {
            return i;
        }
    }
    return -1;
}

bool MyList::PriorElem(int * currentElem, int * preElem)
{
    int temp = LocateElem(currentElem);
    if (temp == -1)
    {
        return false;
    }
    else if (temp == 0)
    {
        return false;
    }
    else
    {
        *preElem = m_pList[temp - 1];
        return true;
    }
}

bool MyList::NextElem(int * currentElem, int * nextElem)
{
    int temp = LocateElem(currentElem);
    if (temp == -1)
    {
        return false;
    }
    else if (temp == m_iLength - 1)
    {
        return false;
    }
    else
    {
        *nextElem = m_pList[temp + 1];
        return true;
    }
}

bool MyList::ListInsert(int i, int * e)
{
    if (i<0 || i>m_iLength)
    {
        return false;
    }
    for (int k = m_iLength - 1;k >= i;k--)
    {
        m_pList[k + 1] = m_pList[k];
    }
    m_pList[i] = *e;
    m_iLength++;
    return true;
}

bool MyList::ListDelete(int i, int * e)
{
    if (i < 0 || i >= m_iLength)
    {
        return false;
    }
    *e = m_pList[i];
    for (int k = i;k < m_iLength - 1;k++)
    {
        m_pList[k] = m_pList[k + 1];
    }
    m_iLength--;
    return true;
}

void MyList::ListTraverse()
{
    for (int i = 0;i < m_iLength;i++)
    {
        cout << m_pList[i] << " ";
    }
    cout << endl;
}

/******************************/
/*顺序表使用实例[Main.cpp]    */
/******************************/
#include "MyList.h"
#include <iostream>
using namespace std;

int main(void)
{
    int e1 = 3;
    int e2 = 5;
    int e3 = 7;
    int e4 = 2;
    int e5 = 9;
    int e6 = 1;
    int e7 = 8;
    int e8 = 10;
    int temp = -1;
    MyList *list1 = new MyList(10);
    list1->ListInsert(0, &e1);
    list1->ListInsert(1, &e2);
    list1->ListInsert(2, &e3);
    list1->ListInsert(3, &e4);
    list1->ListInsert(4, &e5);
    list1->ListInsert(5, &e6);
    list1->ListInsert(6, &e7);
    cout << list1->ListLength() << endl;
    list1->ListTraverse();
    /*cout << list1->ListEmpty() << endl;
    list1->CleanList();
    cout << list1->ListEmpty() << endl;
    list1->ListInsert(0, &e8);
    list1->ListTraverse();
    list1->ListDelete(0, &temp);
    cout << temp << endl;
    cout << list1->ListLength() << endl;*/


    if (list1->GetElem(0, &temp))
    {
        cout << temp << endl;
    }
    temp = 8;

    int m = list1->LocateElem(&temp);
    if(m!=-1)
    cout << m << endl;

    list1->PriorElem(&e4, &temp);
    cout <<temp<< endl;

    list1->NextElem(&e4, &temp);
    cout << temp << endl;

    delete list1;
    list1 = nullptr;
    return 0;
}

链表

结点:头结点、数据域、指针域。

分类:

链表

示例:

#ifndef MYLIST_H
#define MYLIST_H
/****************************/
/*单链表C++类[MyList.h]     */
/****************************/
#include "MyNode.h"
class MyList
{
public:
    MyList();
    ~MyList();
    void ClearList();
    bool ListEmpty();
    int ListLength();
    bool GetElem(int i,MyNode *pNode);
    int LocateElem(MyNode *pNode);
    bool PriorElem(MyNode *pCurrentNode, MyNode *pPreNode);
    bool NextElem(MyNode *pCurrentNode, MyNode *pNextNode);
    void ListTraverse();
    bool ListInsert(int i, MyNode *pNode);
    bool ListDelete(int i, MyNode *pNode);
    bool ListInsertHead(MyNode *pNode);
    bool ListInsertTail(MyNode *pNode);
private:
    MyNode *m_pList;
    int m_iLength;
};
#endif

/******************************/
/*单链表C++实现[MyList.cpp]   */
/******************************/
#include "MyList.h"
#include<iostream>
using namespace std;
MyList::MyList()
{
    m_pList = new MyNode;
    m_pList->data = 0;
    m_pList->next = nullptr;
    m_iLength = 0;
}

MyList::~MyList()
{
    ClearList();
    delete m_pList;
    m_pList = nullptr;
}

void MyList::ClearList()
{
    MyNode *currentNode = m_pList->next;
    while (currentNode != nullptr)
    {
        MyNode *temp = currentNode->next;
        delete currentNode;
        currentNode = temp;
    }
    m_pList->next = nullptr;
}

bool MyList::ListEmpty()
{
    if (m_iLength == 0)
    {
        return true;
    }
    return false;
}

int MyList::ListLength()
{
    return m_iLength;
}

bool MyList::GetElem(int i, MyNode * pNode)
{
    if (i < 0 || i >= m_iLength)
    {
        return false;
    }
    MyNode *currentNode = m_pList;
    MyNode *currentNodeBefore = nullptr;
    for (int k = 0;k <= i;k++)
    {
        currentNodeBefore = currentNode;
        currentNode = currentNode->next;
    }
    pNode->data = currentNode->data;
    return true;
}

int MyList::LocateElem(MyNode * pNode)
{
    MyNode *currentNode = m_pList;
    int count = 0;
    while (currentNode->next != nullptr)
    {
        currentNode = currentNode->next;
        if (currentNode->data == pNode->data)
        {
            return count;
        }
        count++;
    }
    return -1;
}

bool MyList::PriorElem(MyNode * pCurrentNode, MyNode * pPreNode)
{
    MyNode *currentNode = m_pList;
    MyNode *tempNode = nullptr;
    while (currentNode->next!=nullptr)
    {
        tempNode = currentNode;
        currentNode = currentNode->next;
        if (currentNode->data== pCurrentNode->data)
        {
            if (tempNode==m_pList)
            {
                return false;
            }
            pPreNode->data = tempNode->data;
            return true;
        }
    }
    return false;
}

bool MyList::NextElem(MyNode * pCurrentNode, MyNode * pNextNode)
{
    MyNode *currentNode = m_pList;
    while (currentNode->next!=nullptr)
    {
        currentNode = currentNode->next;
        if (currentNode->data == pCurrentNode->data)
        {
            if (currentNode->next == nullptr)
            {
                return false;
            }
            pNextNode->data = currentNode->next->data;
            return true;
        }
    }
    return false;
}

void MyList::ListTraverse()
{
    MyNode *currentNode = m_pList;
    while (currentNode->next!=nullptr)
    {
        currentNode = currentNode->next;
        currentNode->printNode();
    }
    cout << endl;
}

bool MyList::ListInsert(int i, MyNode * pNode)
{
    if (i<0 || i>m_iLength)
    {
        return false;
    }
    MyNode *currentNode = m_pList;
    for (int k=0;k<i;k++)
    {
        currentNode = currentNode->next;
    }
    MyNode *newNode = new MyNode;
    if (newNode==nullptr)
    {
        return false;
    }
    newNode->data = pNode->data;
    newNode->next = currentNode->next;
    currentNode->next = newNode;
    m_iLength++;
    return true;
}

bool MyList::ListDelete(int i, MyNode * pNode)
{
    if (i<0||i>=m_iLength)
    {
        return false;
    }
    MyNode *currentNode = m_pList;
    MyNode *currentNodeBefore = nullptr;
    for (int k = 0;k <= i;k++)
    {
        currentNodeBefore = currentNode;
        currentNode = currentNode->next;
    }
    currentNodeBefore->next = currentNode->next;
    pNode->data = currentNode->data;
    delete currentNode;
    currentNode = nullptr;
    m_iLength--;
    return true;
}

bool MyList::ListInsertHead(MyNode * pNode)
{
    MyNode *temp = m_pList->next;
    MyNode *newNode = new MyNode;
    if (newNode==nullptr)
    {
        return false;
    }
    newNode->data = pNode->data;
    m_pList->next = newNode;
    newNode->next = temp;
    m_iLength++;
    return true;
}

bool MyList::ListInsertTail(MyNode * pNode)
{
    MyNode *currentNode = m_pList;
    while (currentNode->next!=nullptr)
    {
        currentNode = currentNode->next;
    }
    MyNode *newNode = new MyNode;
    if (newNode==nullptr)
    {
        return false;
    }
    newNode->data = pNode->data;
    newNode->next = nullptr;
    currentNode->next = newNode;
    m_iLength++;
    return true;
}


/******************************/
/*结点类C++头文件[MyNode.h]   */
/******************************/
#ifndef MYNODE_H
#define MYNODE_H
#include <iostream>
using namespace std;
class MyNode
{
public:
    int data;
    MyNode *next;
    void printNode();
};
#endif

/******************************/
/*结点类C++实现[MyNode.cpp]   */
/******************************/
#include "MyNode.h"
#include <iostream>
using namespace std;
void MyNode::printNode()
{
    cout << data << " ";
}

/******************************/
/*单链表使用实例[Main.cpp]    */
/******************************/
#include "MyList.h"
#include<iostream>
using namespace std;
int main()
{
    MyNode node1;
    node1.data = 1;
    MyNode node2;
    node2.data = 2;
    MyNode node3;
    node3.data = 3;
    MyNode node4;
    node4.data = 4;
    MyNode node5;
    node5.data = 5;

    MyList *pList = new MyList();
    //插入头元素
    pList->ListInsertHead(&node1);
    pList->ListInsertHead(&node2);
    pList->ListInsertHead(&node3);
    pList->ListInsertHead(&node4);
    pList->ListInsertHead(&node5);
    //插入尾元素
    pList->ListInsertTail(&node1);
    pList->ListInsertTail(&node2);
    pList->ListInsertTail(&node3);
    pList->ListInsertTail(&node4);
    pList->ListInsertTail(&node5);
    pList->ListTraverse();
    //在某位置插入元素
    pList->ListInsert(1, &node5);
    pList->ListTraverse();

    MyNode temp;
    //删除某位置元素
    pList->ListDelete(1, &temp);
    pList->ListTraverse();
    cout <<temp.data << endl;
    //取某位置元素
    pList->GetElem(1,&temp);
    cout << temp.data << endl;
    //取前驱
    pList->PriorElem(&node4, &temp);
    cout << temp.data << endl;
    //取后继
    pList->NextElem(&node4, &temp);
    cout << temp.data << endl;
    //元素位置
    cout<<pList->LocateElem(&node5)<<endl;

    delete pList;
    pList = nullptr;
    return 0;
}

进阶(通讯录实现)

MyList.h

#ifndef MYLIST_H
#define MYLIST_H
#include "MyNode.h"
class MyList
{
public:
    MyList();
    ~MyList();
    void ClearList();
    bool ListEmpty();
    int ListLength();
    bool GetElem(int i,MyNode *pNode);
    int LocateElem(MyNode *pNode);
    bool PriorElem(MyNode *pCurrentNode, MyNode *pPreNode);
    bool NextElem(MyNode *pCurrentNode, MyNode *pNextNode);
    void ListTraverse();
    bool ListInsert(int i, MyNode *pNode);
    bool ListDelete(int i, MyNode *pNode);
    bool ListInsertHead(MyNode *pNode);
    bool ListInsertTail(MyNode *pNode);
private:
    MyNode *m_pList;
    int m_iLength;
};
#endif

MyList.cpp

#include "MyList.h"
#include "MyNode.cpp"//不加总是报错(VS2015中)
#include<iostream>
using namespace std;
MyList::MyList()
{
    m_pList = new MyNode;
    //m_pList->data = 0;
    m_pList->next = nullptr;
    m_iLength = 0;
}

MyList::~MyList()
{
    ClearList();
    delete m_pList;
    m_pList = nullptr;
}

void MyList::ClearList()
{
    MyNode *currentNode = m_pList->next;
    while (currentNode != nullptr)
    {
        MyNode *temp = currentNode->next;
        delete currentNode;
        currentNode = temp;
    }
    m_pList->next = nullptr;
}

bool MyList::ListEmpty()
{
    if (m_iLength == 0)
    {
        return true;
    }
    return false;
}

int MyList::ListLength()
{
    return m_iLength;
}

bool MyList::GetElem(int i, MyNode * pNode)
{
    if (i < 0 || i >= m_iLength)
    {
        return false;
    }
    MyNode *currentNode = m_pList;
    MyNode *currentNodeBefore = nullptr;
    for (int k = 0;k <= i;k++)
    {
        currentNodeBefore = currentNode;
        currentNode = currentNode->next;
    }
    pNode->data = currentNode->data;
    return true;
}

int MyList::LocateElem(MyNode * pNode)
{
    MyNode *currentNode = m_pList;
    int count = 0;
    while (currentNode->next != nullptr)
    {
        currentNode = currentNode->next;
        if (currentNode->data == pNode->data)
        {
            return count;
        }
        count++;
    }
    return -1;
}

bool MyList::PriorElem(MyNode * pCurrentNode, MyNode * pPreNode)
{
    MyNode *currentNode = m_pList;
    MyNode *tempNode = nullptr;
    while (currentNode->next!=nullptr)
    {
        tempNode = currentNode;
        currentNode = currentNode->next;
        if (currentNode->data== pCurrentNode->data)
        {
            if (tempNode==m_pList)
            {
                return false;
            }
            pPreNode->data = tempNode->data;
            return true;
        }
    }
    return false;
}

bool MyList::NextElem(MyNode * pCurrentNode, MyNode * pNextNode)
{
    MyNode *currentNode = m_pList;
    while (currentNode->next!=nullptr)
    {
        currentNode = currentNode->next;
        if (currentNode->data == pCurrentNode->data)
        {
            if (currentNode->next == nullptr)
            {
                return false;
            }
            pNextNode->data = currentNode->next->data;
            return true;
        }
    }
    return false;
}

void MyList::ListTraverse()
{
    MyNode *currentNode = m_pList;
    while (currentNode->next!=nullptr)
    {
        currentNode = currentNode->next;
        currentNode->printNode();
    }
    cout << endl;
}

bool MyList::ListInsert(int i, MyNode * pNode)
{
    if (i<0 || i>m_iLength)
    {
        return false;
    }
    MyNode *currentNode = m_pList;
    for (int k=0;k<i;k++)
    {
        currentNode = currentNode->next;
    }
    MyNode *newNode = new MyNode;
    if (newNode==nullptr)
    {
        return false;
    }
    newNode->data = pNode->data;
    newNode->next = currentNode->next;
    currentNode->next = newNode;
    m_iLength++;
    return true;
}

bool MyList::ListDelete(int i, MyNode * pNode)
{
    if (i<0||i>=m_iLength)
    {
        return false;
    }
    MyNode *currentNode = m_pList;
    MyNode *currentNodeBefore = nullptr;
    for (int k = 0;k <= i;k++)
    {
        currentNodeBefore = currentNode;
        currentNode = currentNode->next;
    }
    currentNodeBefore->next = currentNode->next;
    pNode->data = currentNode->data;
    delete currentNode;
    currentNode = nullptr;
    m_iLength--;
    return true;
}

bool MyList::ListInsertHead(MyNode * pNode)
{
    MyNode *temp = m_pList->next;
    MyNode *newNode = new MyNode;
    if (newNode==nullptr)
    {
        return false;
    }
    newNode->data = pNode->data;
    m_pList->next = newNode;
    newNode->next = temp;
    m_iLength++;
    return true;
}

bool MyList::ListInsertTail(MyNode * pNode)
{
    MyNode *currentNode = m_pList;
    while (currentNode->next!=nullptr)
    {
        currentNode = currentNode->next;
    }
    MyNode *newNode = new MyNode;
    if (newNode==nullptr)
    {
        return false;
    }
    newNode->data = pNode->data;
    newNode->next = nullptr;
    currentNode->next = newNode;
    m_iLength++;
    return true;
}

MyNode.h

#ifndef MYNODE_H
#define MYNODE_H
#include "Person.h"
#include <iostream>
using namespace std;
class MyNode
{
public:
    Person data;
    MyNode *next;
    void printNode();
};
#endif

MyNode.cpp

#include "MyNode.h"
#include <iostream>
using namespace std;

void MyNode::printNode()
{
    cout << data << " ";
}

Person.h

#ifndef PERSON_H
#define PERSON_H

#include <string>
#include <ostream>
using namespace std;
class Person
{
    friend ostream &operator<<(ostream &out, Person &person);
public:
    string name;
    string phone;
    Person &operator=(Person &person);
    bool operator==(Person &person);
};
#endif // !PERSON_H

Person.cpp

#include "Person.h"

Person & Person::operator=(Person & person)
{
    this->name = person.name;
    this->phone = person.phone;
    return *this;
}

bool Person::operator==(Person &person)
{
    if (this->name == person.name&&this->phone == person.phone)
    {
        return true;
    }
    return false;
}

ostream & operator<<(ostream & out, Person & person)
{
    out << person.name << ":" << person.phone << " ";
    return out;
}

Main.cpp

#include "MyList.h"
#include<iostream>
using namespace std;
int menu()
{
    cout << "功能菜单" << endl;
    cout << "1.新建联系人" << endl;
    //cout << "2.删除联系人" << endl;
    cout << "3.浏览通讯录" << endl;
    cout << "4.退出通讯录" << endl;
    int order;
    cout << "请输入:" << ends;
    cin >> order;
    return order;
}
void createPerson(MyList *pList)
{
    MyNode node;
    Person person;
    cout << "请输入姓名:" << ends;
    cin >> person.name;
    cout << "请输入电话:" << ends;
    cin >> person.phone;
    node.data = person;
    pList->ListInsertTail(&node);
}
int main()
{

    int userOrder=0;
    MyList *pList = new MyList();
    while (userOrder != 4)
    {
        userOrder = menu();
        switch (userOrder)
        {
        case 1:
            createPerson(pList);
            break;
        case 2:
            break;
        case 3:
            cout << "liulan" << endl;
            pList->ListTraverse();
            break;
        case 4:
            exit(0);
        default:
            break;
        }
    }

    delete pList;
    pList = nullptr;
    return 0;
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 211,639评论 6 492
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,277评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 157,221评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,474评论 1 283
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,570评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,816评论 1 290
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,957评论 3 408
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,718评论 0 266
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,176评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,511评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,646评论 1 340
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,322评论 4 330
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,934评论 3 313
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,755评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,987评论 1 266
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,358评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,514评论 2 348

推荐阅读更多精彩内容

  • 完整代码需结合前面一篇顺序表数据结构学习-线性表之顺序表各种操作网易云课堂小甲鱼课程链接:数据结构与算法 线性表的...
    NotFunGuy阅读 9,167评论 0 9
  • 定义:零个或多个数据元素的有限序列 线性表的顺序存储的结构代码。 这里,我们就发现描述顺序存储结构需要三个属性: ...
    大荣言午阅读 396评论 2 0
  • 基础概念 数据结构的分类 在数据结构中,按照不同的角度,数据结构分为逻辑结构和物理结构(存储结构)。 逻辑结构:指...
    IAM四十二阅读 1,095评论 2 5
  • 本文主要内容:线性表的逻辑结构和存储结构以及相应算法; 1. 定义和特点 1. 定义: 由N(N>=0)个数据特性...
    Lost_Robot阅读 564评论 0 0
  • 身体壮实、肌肉凸起的人脾气急躁,心宽的人脾气和顺。为人深沉、话少的人有福。心有志向的人,性格刚柔并济。要亲善就多接...
    小柑橘阅读 1,031评论 0 0