Home Database Mysql Tutorial 05.线性表(四)链式存储结构.静态链表

05.线性表(四)链式存储结构.静态链表

Jun 07, 2016 pm 04:12 PM
storage Linear structure linked list static

链式存储结构.静态链表 一、静态链表 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/MrMG0se294bm5tcS05rSiv9W85LXEt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148/CseootbHHsMr91+m12tK7uPbUqsvYtcRjdXK05rSitdrSu7j2sbjTw7/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 of this Website
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

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

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Huawei will launch innovative MED storage products next year: rack capacity exceeds 10 PB and power consumption is less than 2 kW Huawei will launch innovative MED storage products next year: rack capacity exceeds 10 PB and power consumption is less than 2 kW Mar 07, 2024 pm 10:43 PM

This website reported on March 7 that Dr. Zhou Yuefeng, President of Huawei's Data Storage Product Line, recently attended the MWC2024 conference and specifically demonstrated the new generation OceanStorArctic magnetoelectric storage solution designed for warm data (WarmData) and cold data (ColdData). Zhou Yuefeng, President of Huawei's data storage product line, released a series of innovative solutions. Image source: Huawei's official press release attached to this site is as follows: The cost of this solution is 20% lower than that of magnetic tape, and its power consumption is 90% lower than that of hard disks. According to foreign technology media blocksandfiles, a Huawei spokesperson also revealed information about the magnetoelectric storage solution: Huawei's magnetoelectronic disk (MED) is a major innovation in magnetic storage media. First generation ME

Vue3+TS+Vite development skills: how to encrypt and store data Vue3+TS+Vite development skills: how to encrypt and store data Sep 10, 2023 pm 04:51 PM

Vue3+TS+Vite development tips: How to encrypt and store data. With the rapid development of Internet technology, data security and privacy protection are becoming more and more important. In the Vue3+TS+Vite development environment, how to encrypt and store data is a problem that every developer needs to face. This article will introduce some common data encryption and storage techniques to help developers improve application security and user experience. 1. Data Encryption Front-end Data Encryption Front-end encryption is an important part of protecting data security. Commonly used

In-depth analysis of the role and usage of the static keyword in C language In-depth analysis of the role and usage of the static keyword in C language Feb 20, 2024 pm 04:30 PM

In-depth analysis of the role and usage of the static keyword in C language. In C language, static is a very important keyword, which can be used in the definition of functions, variables and data types. Using the static keyword can change the link attributes, scope and life cycle of the object. Let’s analyze the role and usage of the static keyword in C language in detail. Static variables and functions: Variables defined using the static keyword inside a function are called static variables, which have a global life cycle

Git installation process on Ubuntu Git installation process on Ubuntu Mar 20, 2024 pm 04:51 PM

Git is a fast, reliable, and adaptable distributed version control system. It is designed to support distributed, non-linear workflows, making it ideal for software development teams of all sizes. Each Git working directory is an independent repository with a complete history of all changes and the ability to track versions even without network access or a central server. GitHub is a Git repository hosted on the cloud that provides all the features of distributed revision control. GitHub is a Git repository hosted on the cloud. Unlike Git which is a CLI tool, GitHub has a web-based graphical user interface. It is used for version control, which involves collaborating with other developers and tracking changes to scripts and

What are the syntax and structure characteristics of lambda expressions? What are the syntax and structure characteristics of lambda expressions? Apr 25, 2024 pm 01:12 PM

Lambda expression is an anonymous function without a name, and its syntax is: (parameter_list)->expression. They feature anonymity, diversity, currying, and closure. In practical applications, Lambda expressions can be used to define functions concisely, such as the summation function sum_lambda=lambdax,y:x+y, and apply the map() function to the list to perform the summation operation.

How to correctly use sessionStorage to protect sensitive data How to correctly use sessionStorage to protect sensitive data Jan 13, 2024 am 11:54 AM

How to correctly use sessionStorage to store sensitive information requires specific code examples. Whether in web development or mobile application development, we often need to store and process sensitive information, such as user login credentials, ID numbers, etc. In front-end development, using sessionStorage is a common storage solution. However, since sessionStorage is browser-based storage, some security issues need to be paid attention to to ensure that the stored sensitive information is not maliciously accessed and used.

Find the nth node from the last linked list in C++ using recursive method Find the nth node from the last linked list in C++ using recursive method Sep 15, 2023 pm 05:53 PM

Given a singly linked list and a positive integer N as input. The goal is to find the Nth node from the end of the given list using recursion. If the input list has nodes a→b→c→d→e→f and N is 4, then the 4th node from the last will be c. We will first traverse until the last node in the list and when returning from the recursive (backtracking) increment count. When count equals N, a pointer to the current node is returned as the result. Let's look at various input and output scenarios for this - Input - List: -1→5→7→12→2→96→33N=3 Output − The Nth node from the last is: 2 Explanation − The third node is 2 . Input − List: -12→53→8→19→20→96→33N=8 Output – Node does not exist

In-depth analysis of the structure and purpose of the MySQL.proc table In-depth analysis of the structure and purpose of the MySQL.proc table Mar 15, 2024 pm 02:36 PM

The MySQL.proc table is a system table that stores stored procedure and function information in the MySQL database. By in-depth understanding of its structure and purpose, you can better understand the operating mechanism of stored procedures and functions in MySQL, and perform related management and optimization. The structure and purpose of the MySQL.proc table will be analyzed in detail below, and specific code examples will be provided. 1. The structure of the MySQL.proc table. The MySQL.proc table is a system table that stores the definitions and related information of all stored procedures and functions.

See all articles