"Program Design and Data Structure" Week 8 Learning Summary

Student number 20172326 "Program Design and Data Structure" Week 8 Learning Summary

Textbook learning content summary

  • Post binding is executed when the program executes
  • Polymorphism can be achieved by inheritance and interfaces
  • Sorting Selective Sorting and Insertion Sorting
  • Search is divided into linear search and binary search
  • Algorithms, different methods of the same type may solve the same problem, but differ in efficiency and difficulty

    Problems and Solving Processes in Teaching Materials Learning

  • Question: Binding mechanism in Java
  • First, compile-time binding and dynamic binding are also known as early binding and late binding, respectively. Early binding: The method has been bound before the program is executed, and it is implemented by the compiler or other linker at this time. For example: C. Late binding: Binding at runtime based on the type of a concrete object. The actual calling version of the overloaded function is determined by the compiler binding, while the actual calling version of the overridden function is determined by the dynamic binding.
  • Overriding and overloading
  • Override: When a subclass inherits a parent class, and the method in the subclass is exactly the same as the method in the parent class, the number and type of parameters are exactly the same, the method in the subclass is said to be overridden method in the parent class.
  • Overload: For the same class, if there are two or more methods with the same name in the class, but the number, type, and order of the parameters of the method are at least one different, then it constitutes method overloading
  • Difference: Overloading has the same function name, different parameter lists, and nothing else (access control character, return value type). Rewritten as the function name must be the same and the parameter list must be the same.
    The return value type of the subclass must be equal to or less than the return value of the superclass.

    Problems and solutions in code debugging

  • Question: Writing of PP10.5
  • Problem Solution: Modify Movies so that they can be sorted alphabetically by movie name. At first, I followed the example in the book and wrote it, but which program should I "connect" the Comparable interface with? In the following analysis, the movie name and director name should be compared in CompareTo, but there is only an array method in DVDCollection, which contains these two variables in DVD, so add the getter method. Once these two variables are obtained, the comparison can be made. Then there is the problem of sorting. Here, you can use the Sorting method to compare by selection sorting.

    code hosting

Summary of last week's exam mistakes

  • wrong question 1
  • The algorithm efficiency of Insertion Sort and Selection Sort is the same, and both are the power of n.
  • wrong question 2
  • The efficiency of the two algorithms is the same, and both are two nested loops, so no additional loops are required
  • wrong question 3
  • There can be non-abstract methods in abstract methods, and abstract methods have only declarations and no bodies
  • wrong question 4
  • Method overloading is also a manifestation of polymorphism
  • wrong question 5
  • The efficiency of the algorithm is n^2, and since there are n data elements, the number of times the data can be halved before the amount of data is less than one element is log2n.
  • wrong question 6
  • A reference variable can point to any object of any class that has an inheritance relationship
  • wrong question 7
  • Outputting different strings reflects the characteristics of polymorphism
  • wrong question 8
  • Class references can directly call methods of other classes

learning progress bar

Lines of code (added/accumulated) Blog volume (new/cumulative) Study time (added/accumulated) important growth
Target 5000 lines 30 articles 400 hours
the first week 110/110 1/1 20/20
the second week 315/425 1/2 18/38
The third week 475/900 2/4 22/60
the fourth week 600/1500 1/5 30/90
fifth week 1215/2715 1/6 20/110
Week 6 382/3097 1/7 20/130
Week 7 721/3818 1/8 15/145
eighth week

References

Guess you like

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