Hanshunping _php Programmer Open Class (first quarter) 02_ single-linked list in memory form anatomy _ Learning Notes _ source code illustration _ppt document collation

Source: Internet
Author: User
Tags php language

Vencimaron: http://blog.csdn.net/wenximalong/
Linked List-The most flexible data structure
It is convenient to solve complex problems and algorithms with linked lists.

Content Introduction
1. What is a linked list
2. One-way linked list
3. Doubly linked list
4. Ring Linked List
5. Using the ring list to solve the Joseph problem

Linked List--what is a linked list
A linked list is an ordered listing, but it is distributed in memory.

Linked lists are ubiquitous, such as in the operating system, between files and files, between file blocks and file blocks, and by chain links.
The use of linked lists can solve similar Joseph problems, sort, index, binary tree, generalized table ...

Linked List--Quick start of a single linked list
Implementation of one-way linked list using head head--The management of the list of heroes in the margin

Using the PHP language to implement, if it is C#/c/c++/java, the idea is exactly the same.

Now let's look at what kind of data structures are linked lists? Memory Graph Analysis
singlelink.php
[PHP] View plaincopy
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<body>
<a href= "#" > Search Heroes </a>
<a href= "#" > Add Heroes </a>
<a href= "#" > Delete Heroes </a>
<a href= "#" > Modify Heroes </a>

<?php
First, you need basic knowledge. Knowing what variables are, there are some basics of object-oriented programming.
Know the three main control statements if for while

Defining a Hero Class
Class hero{
public $no;//Ranking
public $name;//real name
public $nickname;//Nickname
public $next;//$next is a reference to an object instance that points to another hero.

constructor function
Public function __construct ($no = ', $name = ', $nickname = ') {
Assign value
$this->no= $no;
$this->name= $name;
$this->nickname= $nickname;
}
}
Because some students, the PHP syntax is a little unfamiliar, I demonstrate
Create a Hero
$hero =new Hero (1, ' Song Jiang ', ' timely rain ');

echo Output
Echo $hero->name;
?>
</body>
Memory Analysis Diagram
Big picture, open the picture in a new window, watch the full picture

The bottom of PHP is C, when a program runs, memory is divided into five zones [stack/heap/global/constant/code area]
Once the program runs, how things are distributed in these five areas, it is very clear, otherwise it is a group of fog.
C/c++/java their memory analysis diagrams are usually painted in this way, as this is the bottom of the story.

Hanshunping _php Programmer Open Class (first quarter) 02_ single-linked list in memory form anatomy _ Learning Notes _ source code illustration _ppt document collation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.