Algorithms notes - Getting Started - Data structure chapter

Algorithms notes - Getting Started - Data structure chapter
no studies after graduating from college had algorithm, almost forgotten, and now open a new pit, to learn from scratch algorithm, ha ha, I hope to be able to hold on, but I will be able to hold the I like Yi Jin pulp washing, as his body broken, reshape their all, return to the beginning of the heart, in the name of a listener treat everything, because I do all my own favorite thing.

The basic data structure of

What is a data structure

To put it plainly is very simple, the data stored in the computer, must have a deposit law, not out of hand, just as you look up, you can find the word child turned page after page, you can also press the alphabet to jump directly to the word child, this is the dictionary data structure, the data structure is to determine the relationship between the data sequence and location .

Data structure subclass - list

List, this thing will be to understand some of the abstract, it represents college textbooks is a linear array of data, I'd say not too much trouble, the list is actually a train, for example, there are now four cars, you must pass a carriage to go to the next section, that is to say, the carriage (list) has a sign (pointer), you have one down to the underlying carriage (pointing to the next address).
List this stuff now, slowly, things you have to check one by one down, add, delete data must first change the pointer.
A check things, Canada O notation, its complexity is O (n-), an algorithm is quite slow up.

Class data structure of the sub - array

Data structure array, is also linear array, remember what the list, the list is a pointer to rely on, you tell me who my brother was next, but the array is not the same, it is called by a subject under an array of things to tell you, I was the first of several, in Python, this stuff is used in the list, just like a = [1,2,3,4,5] this form, a [0] = 1, a [1] = 2. ......
in fact, you want to check an array of things inside, are generally random access, direct access to the array index, something that is equivalent to the number of children you get to eat, to you, the people called, " No. XXX of the meal! "array subscript on this function.
Inside the array, you want to add or delete an element, it can be a bit of trouble, you have to at the end of the array, plus a number of storage space, the total can not make new elements had no place to go, and then you let the old elements to new friends Teng position, and then rush back to old friends, new friends and to successfully jump the queue. . .

Class data structure of the sub - Stack

The stack brother will understand a little trouble, think, anytime you can eat the freshest fruit, have new fruit every day, you can always get a new fruit, old fruit only in the following, so if you eat the old fruit, you would turn out a little box of fruit, known as the stack , put the fruit back, called into the stack , this thing is that you can only get up to date, LIFO, LIFO structure, this stuff children was quite inconvenient.
But in business, if you need to keep in front of the latest data, for example, current events, people in the vicinity, and so on, take this stuff is like with more.

Class data structure of the sub - queue

And above stack brother Instead, the queue means is that you advanced to the ah, you move along the edges, which needed time to my old data on first, get to take data from the oldest data, the new data while playing go . Want to take the new data? Sorry, you come out one by one, until you go out that far.

Class data structure of the sub - hash table

He said this in a little get at, but ah, you should know Python written to, which has a Python dict (dictionary), this stuff is a key dictionary corresponding to a value, for example,

{
    "蔡徐坤" :"篮球",
    "吴亦凡" :"说唱"
}

This enables a dictionary, you might ask, what's this relationship and TM hash table, hash tables this stuff is kept dict thing, it is something like an array, but kept things very abnormal, generally we we will use the hash function to calculate "Cai Xu Kun" key, i.e. "Cai Xu Kun" hash value, the hash value divided by the length of the array (hash table length) will be obtained and then take the remainder calculated "Cai Xu Kun" array in position, and then put it in a bag. Here more abstract, behind will specifically talk about the hash algorithm.
So how to check it, first of all we got, "Cai Xu Kun" hash value, then you will find "Cai Xu Kun 'position in the hash table by computing the just.

Class data structure of the sub - stack

Highlight came, this stuff is a tree, the tree, by definition, is bifurcated, imagine a tree look, this stuff is used to engage with the priority queue, heap which has a boss, vertices called nodes, all data points are brother nodes, covered by him, in which a plurality of hands he called a child node, a child node of the parent node is greater than a generic point, typically a minimum value in the stack .
Stack top data is always the minimum, so no matter how much the amount of data, taking the smaller are the time complexity O (1).
Further, because of the need to move the data from the last top of data taken out, and then compare it to size while the sub junction point data, while moving down, is extracted and the height is proportional to the operating time required for the tree data. Suppose the amount of data is n, the shape characteristics of the stack height of the tree is known log2n, then the time complexity is then reconstructed tree O (logn).
Adding data is the same. After the final addition the size of the data stack, the data while comparing it with the parent node data, while moving upward, until meet the conditions of the stack, so the need to add data proportional to the height of the tree run time, is O ( logn)

Subcategory data structures - binary search tree

Upstairs and, just as a tree structure, is not the same, the value of a binary tree each node is greater than any of the left subtree of a node value, abstract right, a view of FIG

means that, regardless of how, always left my brother younger than me.
The second difference is that the right is better than my big brother, continued Figure

this is part of the foundation, made a rough writing, well written, forgive me, over!

Guess you like

Origin www.cnblogs.com/Yemilice/p/11828667.html