From "illustrates the algorithm" in the learned

1. The algorithm is a set of instructions to complete the task, any code segment can be regarded as the algorithm.

2 is a binary search algorithm (from the middle to start looking). Note that: only when the input list is ordered when the binary search can.

3. Find simple: from the beginning to the end of a one lookup.

4. Large 0 notation indicates how fast algorithm. For example, the operation needs to be performed n times, with a large O notation, the running time is O (n). Note: The unit is not s, Big O notation so that you can compare its operands, pointed out that the growth rate of the algorithm running time.

5. Common Big O :( run time from fast to slow)

  • O (logn), also called logarithmic time, such algorithms include binary search .
  • O (n), also known as linear time, such algorithms include simple lookup .
  • O (n * logn), such algorithms include quicksort (s faster sorting algorithm).
  • O (n2), such algorithm includes selecting sorting (Sort one speed slower algorithm).
  • O (n!), This algorithm includes solutions (a very slow algorithm) Traveling Salesman Problem.

The book said little inspiration (probably a little fuzzy now, wait two days to understand, do not worry)

  • Refers to the speed of the algorithm is not time, but the growth of the operand.
  • When talking about the speed of the algorithm, we are talking about with increasing input, the running time will increase what speed.

Special issue "traveling salesman" in. One of the problems.

6. (a computer) to store more data, there are two basic ways: arrays and linked lists, but it is not applicable in all cases.

7. The array is an ordered sequence of elements, for storing a set of a plurality of the same type of data.

Features:

  • Array is a collection of data elements of the same type. ( JS may not be the same data type, js weakly determined language type. )
  • Storing each element in the array is a sequential, according to this order are stored together in the memory continuously.
  • Array element is represented by the name of the entire array and its own ordinal position in the array.

8. list, a physical storage unit on a non-continuous, non-sequential storage structure , the data elements in a logical sequence by a linked list of pointers to achieve the link order. Chain by a series of nodes (each node element is called a linked list), with the node can be dynamically generated at runtime. Each node consists of two parts: a storage data element of the data field, the other is to store a next node address pointer field.

9. arrays and lists the advantages and disadvantages

Array (advantage):

  • Random access and strong
  • Find Fast

Array (disadvantages):

  • Low insertion and deletion efficiency
  • The array size is fixed and can not be dynamically expanded, so the memory space requirements high, there must be enough contiguous memory space (also very likely a waste of memory space).

List (advantage):

  • Insert and delete speed
  • High memory utilization, memory is not wasted
  • There is no fixed size, expanding very flexible.

List (disadvantages):

  • Can not look random, we must begin traversed from the first, low search efficiency

10. In general programming languages are from 0 to start the array elements are numbered, NO 1 , another element position does not call position, called the index . (Xx element at index n in).

/*20191107*/

Published 15 original articles · won praise 26 · views 7676

Guess you like

Origin blog.csdn.net/Big_eyes123/article/details/102946806