資料結構之單鏈表實現

2021-08-20 07:20:15 字數 1383 閱讀 3059

用兩個月的時間好好把資料結構複習一遍,都算不上覆習了,最後的圖的方面完全是新學,希望能堅持下去。

一、單鏈表

煉表相比較於陣列更為靈活,儲存方式是鏈式的,插入刪除操作優於陣列,但是查詢操作優於陣列。還是不多介紹了直接上**吧。(**參考資料結構與演算法分析-c語言版本)

//標頭檔案

#ifndef list_h

#define list_h

struct node;

tydedef struct node *ptrtonode;

typedef ptrtonode list;

typedef ptrtonode position;

typedef int elementtype ;

//return ture if l is empty

int isempty(list l);

//int islast(position p,list l);

//return position of x in l

position find(elementtype x,list l);

//return prveious position of x in l

position findprevious(elementtype x,list l);

//delete x in l

void delete(elementtype x,list l);

//insert x in l

void insert(elementtype x,list l);

//delete l

void deletelist(list l);

struct node

#endif

#include "list.h"

//int isempty(list l)

//int islast(position p,list l);

//return position of x in l

position find(elementtype x,list l)

//return prveious position of x in l

position findprevious(elementtype x,list l)

//delete x in l

void delete(elementtype x,list l); }

//insert x in l

void insert(elementtype x,list l,position p)

//delete l

void deletelist(list l)

}

單鏈表結束。下來應該是雙鏈表。

Python資料結構之單鏈表實現

鍊錶的定義 鍊錶 linked list 是由一組被稱為結點的資料元素組成的資料結構,每個結點都包含結點本身的資訊和指向下乙個結點的位址。由於每個結點都包含了可以鏈結起來的位址資訊,所以用乙個變數就能夠訪問整個結點序列。也就是說,結點包含兩部分資訊 一部分用於儲存資料元素的值,稱為資訊域 另一部分用...

資料結構之單鏈表 C 實現

1.實現乙個單鏈表的定義,生成,長度計算和元素的顯示。include iostream using namespace std typedef struct student listnode 生成乙個單鏈表 listnode creatlist else head head next cur nex...

資料結構之Go實現單鏈表

單向鍊錶是一種線性表,實際上是由節點組成的,乙個鍊錶擁有不定數量的節點。其資料在記憶體中儲存是不連續的,它儲存的資料分散在記憶體中,每個結點只能也只有它能知道下乙個結點的儲存位置。由n各節點 node 組成單向鍊錶,每乙個node記錄本node的資料及下乙個node。向外暴露的只有乙個頭節點 hea...