Data Structures and Algorithms Interview Questions

What is an algorithm?

An algorithm is a collection of instructions, a set of operations prescribed to solve a particular problem.

time complexity

The law that the execution time of the algorithm changes with the growth of the problem size.

The execution time of an algorithm is affected by the following four factors:

  • Hardware level: the speed at which the computer executes each instruction
  • Software level: quality of compiled code
  • Algorithmic Strategy: Good and Bad Algorithms
  • problem size

space complexity

Space complexity is a measure of the amount of storage space temporarily occupied by an algorithm during its execution.

For example: the algorithm complexity of insertion sort is O(1). The time complexity of the general recursive algorithm is O(n), because each recursion has to store the result.

Changshu order O(1), logarithmic order O(logn), linear order O(n), linear logarithmic order O(nlogn), square order O(n^2), cubic order O(n^3), k Power order O(n^k), exponential order O(2^n);

Describe the collection system of Java, what is the difference between List, Set and Map?

Java collections use interfaces to define functions, which is a complete inheritance system. Iterator is the general interface of all collections, and all other interfaces are inherited from it. This interface defines the traversal operation of collections. The Collection interface inherits from Iterator, which is the secondary interface of collections (except Map exists independently), which defines some of the collections. General operation.

The class structure diagram of a Java collection is shown below:

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325943718&siteId=291194637