Introduction to arrays and linked lists of basic algorithms (1)

Source: Internet
Author: User

Collation
Last month, the boss explained to us, "talking about Algorithm And architecture. Due to too much space (there are about 20 or more optical data structures), I have no way to absorb them all. So I can understand it and share it with you in different chapters. This week, I consulted materials to understand various data structures and algorithms. I recommend a few books that I think are good about: I put the ebook here at http://download.csdn.net/user/rtxbc, download it, and download it here. "Pointer art. Cai Mingzhi"-I only read the C language. I personally feel that the C language is more difficult, that is, pointers. Data structure uses the C language [Zhu zhanli]-yan Weimin is also good, but many of the syntaxes in it are abstract syntaxes and cannot be run. I am very impressed if I cannot run it on a terminal. Introduction to algorithms to learn the downloaded ebook (screenshot): algorithm structure

C Language

Introduction to the inventor and structure of Pascal semantics in 1984 Program The creator of the design, Voss proposed "algorithm + Data Structure = Program" to win the Turing Award of the Year. Today's technology is changing with each passing day, and Internet technology is developing constantly, which opens a new chapter in history. At this time, someone proposed "algorithm + architecture = Internet program". What does it mean for programmers living in this age? From this Article At the beginning, I will talk to you about the algorithm and architecture of large websites. Today I will first learn about the basic knowledge, and then we will make a gradual transition. Search Algorithm (Single Machine) 1. There is an unordered array.

2. Find the number between 7 and 20. What is your idea?

The following two points are not surprising:

1. Bubble Sorting

2. Quick Search

3. cCodeImplementation

Execution result

Insert data into the Array

Array problem: insertion is too slow and data needs to be moved.

Please refer to the following code,

Execution result

 

Try linked list

Code structure

 

Insert data to the linked list

A linked list is characterized by fast insertion and slow query.

Code implementation:

Implementation Method

 

See the execution process

 

With binary tree, we can easily find that the two structures (arrays and linked lists) have their own drawbacks. 1. When updating the array, it consumes resources and needs to move the following elements one by one. 2, while the linked list needs to be compared from the beginning to select the content to be queried. In summary, we need a structure with faster query and faster update, so we have a binary tree. Due to the long length, the next article will continue.

 

Recommendation

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.