Manager essential algorithm based on the product description of Python

The future of the world, it must be information technology-driven world. Any future product, are inseparable from the support of information technology. Whether you are a product manager which areas to master some basic arithmetic, it is very necessary.

Now some of the more outstanding product manager, such as Apple's Steve Jobs to create products, products to create Lei Jun millet, QQ product founder Ma, micro-channel product manager Zhang Xiaolong, more or less technical background. Of course, does not mean that the product manager must have a technical background, because some non-technical product manager is also doing well.

Want to express the meaning of this article is the product manager to master some basic algorithms, can, logic products, product form acts as icing on the cake for their product design. Therefore, this paper the authors of these years of work experience, to tease out a few relatively simple algorithm based on.

The basic algorithm can indeed play a role in the product design process, you can make a product manager in the design of products, product logic clearer, we can more fully grasp the product features.

Program of the algorithm, we use the more common description language Python.

Basic algorithm

Sorting Algorithm

There are many, such as bubble sort, selection sort, dilute Seoul sort, merge sort, heap sort, insertion sort, quicksort other sorting algorithms. If these types of specialized computer algorithm should be quite familiar with, if not a computer professional students, in fact, did not need to master all.

What sort used unimportant, mainly know the logic.

To facilitate better understanding, directly or in the form of examples to explain; examples is not very complex, mainly to facilitate understanding logic.

Currently there is an array, the array is the number 6, we will need this number in the array are arranged in ascending order.

Array to be sorted: arr = [4,6,3,9,1,3]

The basic realization of ideas:

  1. Construction of a temporary storage of data parameters: temp.
  2. Start from the first element array, two adjacent elements sequentially comparing, if the number is greater than the number to the right of the left, the switching position, the switching position, the need to use temp.
  3. Operation: arr [0] = 4, arr [1] = 6,4 <6, satisfying the condition, continued
  4. arr [2] = 3, and 6> 3, it is necessary to arr [1] and arr [2] the exchange position, so temp = aar [1], value temp time is 6, arr [1] = arr [ 2], then arr [1] value of 3, arr [2] = temp, arr [2] a value of 6.
  5. arr [2] = 6, then [3] = 9 compared with arr, satisfy the condition.
  6. arr [3] = 9 again being compared with arr [4] = 1, 9 is greater than 4, exchange. The arr [3] = 1, arr [4] = 9.
  7. arr [4] = 9 again being compared with arr [5] = 3, 9 is greater than 3, the exchange. The arr [4] = 3, arr [5] = 9.
  8. In this case the order of the array becomes [4,3,6,1,3,9].
  9. Continues from the first element in the array, the process is repeated.

Next we look at in accordance with the above ideas, how the elements in the array changes:

  • The first: [4,3,6,1,3,9]
  • Second: [3,4,1,3,6,9]
  • Third: [3,1,3,4,6,9]
  • Fourth: [1,3,3,4,6,9]

We have to test our ideas, program code is as follows:

Product manager must master the basic algorithm

Clustering Algorithm

Clustering algorithms in real life, more extensive use of production, such as statistical analysis, artificial intelligence to identify objects, such as information classification imputation. More common clustering algorithms: hierarchical clustering cohesion, organization chart detection (Graph Community Detection), K-Means (K-means) clustering mean shift clustering, density-based clustering method (DBSCAN), Gaussian mixture model (GMM) maximum expected (EM) clustering.

Of course, these algorithms professional too strong. If you do not engage in specialized areas of work, product manager likelihood of these algorithms use very small.

This article today talking about one of the most basic clustering algorithm, it is very easy to understand.

We still an array, for example, arr = [1,1,2,3,5,4,5,4,2,3,3,1,3,3,4,5], our so-called clustering, It is to count the number of times each number appears in this array, and ultimately we expect to achieve this output:

  • 1 appears 3 times
  • 2 appears twice
  • 3 appears 5 times
  • 4 appears three times
  • 5 appears three times

The basic realization of ideas:

  1. We first calculate the length numbers, traversing the length.
  2. Build a dictionary. And when the number of values ​​in the array as a dictionary key, appearing as a value.
  3. If an element is not in the dictionary, then recorded this element is key, value is initially 1.
  4. If an element already exists in the dictionary, then update this element of value + 1.
  5. Traversal is complete, the output value of the dictionary.

We have to test our ideas, program code is as follows:

Product manager must master the basic algorithm

Since we are not sorted, the output order as previously thought some differences. If ordering is, the data may be sorted first in the original array, and then calculated.

Rotation algorithm

旋转的应用大家应该不陌生,最常见的就是手机或是电脑中查看照片的时候,照片的左转右转。图片旋转、视频旋转、文字内容旋转,其实归根到底都是数字矩阵的旋转。

所有的这些表现形式,底层都是一个个二进制的数字组成的。接下来,我们就是要在最基础的逻辑展开分析。

我们还是以数组进行讲解。

我们有数组 arr=[[1,2,3],[4,5,6]],准备向右旋转90度。为了便于大家理解,我这样表示:

原数组:

[1,2,3]

[4,5,6]

我们认为,数组的宽度[1,2,3]=3,为x轴;数组的高度2,为y轴。

向右旋转90度的后数组:

[3,6]

[2,5]

[1,4]

这时,宽度x变为2,高度y变为3。

基本实现思路:

1)我们观查上述数组发现,向右旋转90度后,组的维度由 2*3,变为了3*2。

2)而数字位置变化如下:

  • 1:[0][0]->[2][0]
  • 2:[0][1]->[1][0]
  • 3:[0][2]->[0][0]
  • 4:[1][0]->[2][1]
  • 5:[1][1]->[1][1]
  • 6:[1][2]->[0][1]

3)我们观察上述数字变化,大家发现什么规律?每个数的数组x和y坐标都左右进行了对调,变换后的y坐标是原x坐标的倒序。

4)进行对原数组宽度x(设为i)和高度y(设为j)的遍历,x遍历i的增加,正是新数字的坐标的减少。

即:新数组位置([x-1-i][j]=旧数组位置([j][i])

我们为了验证我们的思路,程序代码如下:

Product manager must master the basic algorithm

为了便于大家理解,将原数组的值在遍历的时候也进行了输出展示。

我们再思维扩展一下,按我们这种思路,如果数组要向左旋转90度呢?

原数组:

[1,2,3]

[4,5,6]

向左旋转90度之后的数组:

[4,1]

[5,2]

[6,3]

即:

  • 1:[0][0]->[0][1]
  • 2:[0][1]->[1][1]
  • 3:[0][2]->[2][1]
  • 4:[1][0]->[0][0]
  • 5:[1][1]->[1][0]
  • 6:[1][2]->[2][0]

大家又会发现什么规律呢?

The new array is not consistent with the original y coordinate of the array x coordinate growth trend, while the x coordinate of the new array, the array is the reverse of the original x-coordinate?

That is, the original array width x (set to i) and height y (set j) traversal, traversing the height y j increase, it is reducing the x-coordinate of the new numbers. That is: the new array position ([i] [y-1-j] = old array positions ([j] [i])

We have to test our ideas, program code is as follows:

Product manager must master the basic algorithm

After the above analysis, we are not have a clear understanding of the rotation algorithm?

If you want to rotate 180 degrees it? If you are interested, you can analyze practice in accordance with the above ideas.

to sum up

For product managers, versed in the basics of the art, familiar with the business model and product is a must-have skill. And to understand and master algorithm, can play the role of icing on the cake.

Algorithm, it is to exercise logical thinking, product manager of relatively good training tool. Interested students can look at some of the books in this direction, there are a lot more interesting algorithms can practice your hand in his spare time, regulate mood. After all, the production manager of the port daily, not just write a demand for more, depends on the market, look at the policy, look at the direction of, look at competing products, understand operations, to understand the business, understand management, understand marketing, analyzes, will communicate will write PPT, you need to do a lot of work also.

As for the final product can not be successful, it depends on luck. Personal power too small, many successful product manager, in fact, caught up with the trend. At a time when the rise of the environment, their ability to feel strong, in fact, sometimes a miscarriage of justice. Once the result of changes in the environment, in a downward trend, they often will bring luck in previous years, the accumulation of wealth, all these years on merit lose it.

Therefore, product manager too hard.

Because of this, product managers need to keep a clear objective in mind, and the algorithm is a pretty good friends, so proud of you when you calm, give you confidence when you feel inferior, give you directions when you're lost.

Thank you for reading ~

Published 165 original articles · won praise 45 · views 40000 +

Guess you like

Origin blog.csdn.net/u010199413/article/details/104342803