search
HomeDatabaseMysql Tutorial05.线性表(四)链式存储结构.静态链表

链式存储结构.静态链表 一、静态链表 1.静态链表存储结构 单链表是通过指针实现的,但是我们也可以通过数组来代替指针描述单链表,即静态链表。如何实现静态链表?构造数组的元素由两个数据域组成:data和cur,即数组的每个下标都对应一个data和一个cur。数据

链式存储结构.静态链表 一、静态链表 1.静态链表存储结构 单链表是通过指针实现的,但是我们也可以通过数组来代替指针描述单链表,即静态链表。如何实现静态链表?构造数组的元素由两个数据域组成:data和cur,即数组的每个下标都对应一个data和一个cur。 数据域data:用来存放数据元素,即要处理的数据; 游标cur:存放该元素的后继在数组中的下标,相当于单链表中的next指针; 为了方便插入数据,我们通常会把数组建立得大一些,以便有一些空闲空间而不致于出现溢出情况。 线性表的静态链表存储结构: #define MAXSIZE 1000 //假设链表的长度为1000(个元素) typedef struct { ElemType data; //数据域,int类型 int cur; //游标(Cursor),为0时表示无指向 }Component,StaticLinkList(MAXSIZE); 2.备用链表 由于数组的第一个和最后一个元素作为特殊元素处理,不存数据,因此我们把未使用的数组元素称为备用链表。 因此,我们规定: (1)数组第一个元素(即下标为0的元素)的游标cur存放第【本文来自鸿网互联 (http://www.68idc.cn)】一个空闲空间元素的下标(备用链表的第一个元素); (2)数组最后一个元素的游标cur存放第一个有数值的元素的下标(相当于单链表中的头结点作用)。当整个链表为空时则最后一个元素的游标cur为0。 (3)链表的最后一个有值元素的cur为0 \
\

升华笔记:如何将一维数组list中各分量链成一个备用链表? typedef int Status Status InitList(StaticLinkList list) { int i; //i为数组下标,MAXSIZE为链表长度 for(i=0;i 二、静态链表的插入/删除操作喎?http://www.2cto.com/kf/ware/vc/" target="_blank" class="keylink">vc3Ryb25nPgoKCgoKCgogICAgvrLMrMG0se21xLLlyOu6zcm+s/2y2df3o6zX7rnYvPzKx9KqveK+9sjnus7Tw76yzKzEo8Titq/MrMG0se294bm5tcS05rSiv9W85LXEt9bF5KOs0OjSqsqxyerH66Oszt7Tw8qxys23xaGjCjxzdHJvbmc+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w7/Vz9C1xM/CseopCiAgICBpZihsaXN0WzBdLmN1cikgICAgICAgICAgICAvL8jnuftsaXN0WzBdLmN1ciE9MKOs1PLLtcP3yv3X6bqs09C3x7/V1KrL2AogICAgewogICAgICAgICAgICBsaXN0WzBdLmN1cj1saXN0W2ldLmN1cjsgICAgLy/TydPa0qrEw7P20ru49rG408PBtLHttcS94bXjyrnTw6OsztLDx9Do0qq9q8r91+m12tK7uPbUqsvYtcRjdXK05rfFz8LSu7j2v9Wz9sC0tcTUqsvY1/exuNPDCiAgICB9CiAgICByZXR1cm4gaTsvL7e1u9ixu8q508O1xM/CseoKfTxicj4KCgoKLy/XosrNo7q82cjnz8jHsGxpc3RbMF0uY3VyPTcoyv3X6c/CseomIzIwNTQwOykstbHPwrHqzqo3tcS31sG/KMr91+nUqsvYKde8sbixu8q508PBy6Osvs21w9PQvdPM5tXfo6zL+dLUsNG31sG/NyhsaXN0W2ldLmN1cqOsxuTW0Gk9Nym1xGN1ciYjMjA1NDA7PTijrLizJiMyMDU0MDu4+M231KrL2KOobGlzdFswXS5jdXKjqaOs1q66877Nv8nS1LzM0Pi31sXk0MK1xL/Vz9C31sG/oaMvLwoKCi8qMi7U2kzW0LXaabj21KrL2Naux7Cy5cjr0MK1xMr9vt3UqsvYZSovCnR5cGVkZWYgaW50IFN0YXR1cwp0eXBlZGVmIGludCBFbGVtVHlwZQpTdGF0dXMgTGlzdEluc2VydChTdGF0aWNMaW5rTGlzdCBMLGludCBpLEVsZW1UeXBlIGUpCnsKICAgIGludCBqLGssbTsKICAgIGs9TUFYX1NJWkUtMTsgICAgLy/XotLio7prytfPyMrH1+6689K7uPbUqsvYtcTPwrHqICAgIAogICAgaWYoaiZsdDsxIA=="| j>ListLength(L)+1) return ERROR; j=Malloc_SLL(L); //a.获得空闲分量的下标 if(j) { L[j].data=e; //b.将数据赋值给此分量的data for(m=1;m
2.静态链表的删除操作 源码实现 /*1.将下标为k的空闲结点回收到备用链表*/ void Free_SSL(StaticLinkList space,int k) { space[k].cur=space[0].cur; //将数据的第一个元素cur(其值为备用链表的第一个空闲元素下标),赋值给要删除分量的cur space[0].cur=k; //把要删除的分量下标赋值给第一个元素的cur } /*2.删除在L中第i个数据元素e*/ typedef int Status Status ListDelete(StaticLinkList L,int i) { int i,k; if(iListLength(L)) return ERROR; k=MAXSIZE-1; //存储链表最后一个元素的下标 for(j=1;j 三、静态链表的优缺点 1.优点 在插入和删除操作时只需要修改游标,不需要移动元素,从而改进了在顺序存储结构中的插入和删除操作需要移动大量元素的缺点; 2.缺点 (1)没有解决连续存储分配带来的表长度难以确定的问题; (2)失去了顺序存储结构随机存取的特性;

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Explain the InnoDB Buffer Pool and its importance for performance.Explain the InnoDB Buffer Pool and its importance for performance.Apr 19, 2025 am 12:24 AM

InnoDBBufferPool reduces disk I/O by caching data and indexing pages, improving database performance. Its working principle includes: 1. Data reading: Read data from BufferPool; 2. Data writing: After modifying the data, write to BufferPool and refresh it to disk regularly; 3. Cache management: Use the LRU algorithm to manage cache pages; 4. Reading mechanism: Load adjacent data pages in advance. By sizing the BufferPool and using multiple instances, database performance can be optimized.

MySQL vs. Other Programming Languages: A ComparisonMySQL vs. Other Programming Languages: A ComparisonApr 19, 2025 am 12:22 AM

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages ​​such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages ​​have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

Learning MySQL: A Step-by-Step Guide for New UsersLearning MySQL: A Step-by-Step Guide for New UsersApr 19, 2025 am 12:19 AM

MySQL is worth learning because it is a powerful open source database management system suitable for data storage, management and analysis. 1) MySQL is a relational database that uses SQL to operate data and is suitable for structured data management. 2) The SQL language is the key to interacting with MySQL and supports CRUD operations. 3) The working principle of MySQL includes client/server architecture, storage engine and query optimizer. 4) Basic usage includes creating databases and tables, and advanced usage involves joining tables using JOIN. 5) Common errors include syntax errors and permission issues, and debugging skills include checking syntax and using EXPLAIN commands. 6) Performance optimization involves the use of indexes, optimization of SQL statements and regular maintenance of databases.

MySQL: Essential Skills for Beginners to MasterMySQL: Essential Skills for Beginners to MasterApr 18, 2025 am 12:24 AM

MySQL is suitable for beginners to learn database skills. 1. Install MySQL server and client tools. 2. Understand basic SQL queries, such as SELECT. 3. Master data operations: create tables, insert, update, and delete data. 4. Learn advanced skills: subquery and window functions. 5. Debugging and optimization: Check syntax, use indexes, avoid SELECT*, and use LIMIT.

MySQL: Structured Data and Relational DatabasesMySQL: Structured Data and Relational DatabasesApr 18, 2025 am 12:22 AM

MySQL efficiently manages structured data through table structure and SQL query, and implements inter-table relationships through foreign keys. 1. Define the data format and type when creating a table. 2. Use foreign keys to establish relationships between tables. 3. Improve performance through indexing and query optimization. 4. Regularly backup and monitor databases to ensure data security and performance optimization.

MySQL: Key Features and Capabilities ExplainedMySQL: Key Features and Capabilities ExplainedApr 18, 2025 am 12:17 AM

MySQL is an open source relational database management system that is widely used in Web development. Its key features include: 1. Supports multiple storage engines, such as InnoDB and MyISAM, suitable for different scenarios; 2. Provides master-slave replication functions to facilitate load balancing and data backup; 3. Improve query efficiency through query optimization and index use.

The Purpose of SQL: Interacting with MySQL DatabasesThe Purpose of SQL: Interacting with MySQL DatabasesApr 18, 2025 am 12:12 AM

SQL is used to interact with MySQL database to realize data addition, deletion, modification, inspection and database design. 1) SQL performs data operations through SELECT, INSERT, UPDATE, DELETE statements; 2) Use CREATE, ALTER, DROP statements for database design and management; 3) Complex queries and data analysis are implemented through SQL to improve business decision-making efficiency.

MySQL for Beginners: Getting Started with Database ManagementMySQL for Beginners: Getting Started with Database ManagementApr 18, 2025 am 12:10 AM

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.