此表很好建立,而且進行查詢,刪除,插入都容易理解,但是有乙個缺點:刪除和插入需要調動好些元素/*線性表的順序實現*/
#include
#include
#define maxsize 15
struct sqlist
; /*線性表的初始化*/
void init_sq(sqlist &l)
/*線性表的建立*/
void build_sq(sqlist &l)
/*線性表的輸出*/
void print_sq(sqlist &l)
/*線性表的查詢*/
int locate_sq(sqlist &l,int num)
/*線性表的插入:此插入為前插*/
int insert_sq(sqlist &l,int location,int num)
/*線性表的刪除*/
int delete_sq(sqlist &l,int location)
int main()
線性表 線性儲存
1 include 2 using namespace std 3 定義線性表結構體 4 define size 100 5 typedef struct sqlist list 10 初始化11 void initlist sqlist l 18 設定表長 19 l.length 0 20 設定表...
線性表的順序列表實現
教材 data structures and algorithm analysis in c third edition 線性表 線性表是由element組成的有限且有序的序列,有序指的是每乙個元素都有自己的位置,並非指按其值大小排序。而按照元素其值與元素位置的關係可以分為有序線性表 sorted ...
線性表的儲存
常見三種 1.線性表的順序儲存 可以用陣列實現,優點指定id,獲取資料 get 與修改資料 set 比較容易,時間複雜度為常數,但是對於插入與刪除就比較麻煩,時間複雜度最少為o 1 最多為o n 平均時間複雜度為o n 2.線性表單向鏈式儲存 核心就是每個節點包含下乙個節點的id,呼叫next獲取下...