20172301 "Program design and data structure" Fourth Week study summary

Source: Internet
Author: User

20172301 "Program design and data Structure" the fourth week study summary textbook Learning content Summary
    • List: The list collection does not have an intrinsic capacity size, it can grow as needed.
      • Ordered tables: Elements in a list have intrinsic associations that define the order of the elements directly.
      • Unordered list: Elements are sorted in any way that the user chooses
      • Indexed lists: Elements can be referenced by an index.
    • Implements the Serializable interface. The goal is for an object to be stored using serialization. there is no method in the interface, just to indicate that the object can be converted to a serialized representation.
    • The Josephus problem is a computational problem that is appropriate for the index list to solve. This kind of problem focuses on when the events in the list are not fetched sequentially but are extracted every other element, until one is left , and the order of the events is found.
    • Using an array implementation list: To pin one end of the list to index 0, set an integer variable rear represents the number of elements in the list, and represents the next available location at the end of the list.
      • Remove action: Finds the element passed as a parameter and removes it from the list.
      • Contains operation: In this case, n comparison operations are required. The N/2 method requires an average of two comparison operations, so the complexity of the operation is O (n).
      • Add operation: N-times comparison and panning are required in the sequence table, and the operation is O (n) in complexity. Addtofront needs to translate n-1 elements in the unordered list, with an O (n) operation Complexity. Addtorear operation Complexity is O (1). The addafter needs to compare and Pan n times, and the operation complexity is O (n).
    • To implement a list using linked lists:
      • Remove action: The linked list implements no need to translate elements to fill the gap. But in the worst case scenario, where n comparisons are required, the target is no longer in the list, and therefore its time complexity is O (n).
Problems in teaching materials learning and the solving process
  • Question 1: The specific difference between a list and a book P93. The list is not a linear table.
  • Problem 1 Solution:
    • First, note that the list here is different from the physical structure chain structure we are learning, which is a linear table.
    • A list is a set of linear tables that let things be organized in a linear list. Simply put, the set of elements that are sorted in order is the table. lists can also be implemented using a linked list or array. There are three types of lists: sequential, unordered, and indexed lists.
    • Linear table has two kinds of storage structure: CIS storage structure, chain storage structure.
    • So, this shows that the list should be a containment relationship for the linked lists. The relationship between the list and the linear table is indeterminate.
  • Question 2: What is the difference between an indexed list and an array? Shouldn't it be capacity? The collapse of P95 in the book is how it should be understood.
  • Problem 2 Solution:
    • The concept of an indexed list is given in the book.

      The index list maintains a sequential numeric index value for its elements.

      And then the book says

      The fundamental difference between an indexed list and an array is that the index value of the index list is always contiguous.

    • Let's not say how this is understood, but I think the fundamental difference between an indexed list and an array is capacity . The size is fixed after the array request space. The spatial capacity of the list can be dynamically increased.
      Because the capacity of the array is fixed, it causes a waste of space when the array is used . When you increase the element to fill the array, you cannot continue adding elements without opening up new space. So how large the array is is a problem to solve, but sometimes you can't determine exactly how large an array is needed to store a table of varying size. One solution is to apply a new larger array when the array is found full, and then move the elements all the way to the new array. But how to dispose of the original array is also a problem.
      So that's when the list appears.
    • And the "collapse"in the book refers to the use of arrays to solve the problem is to increase the efficiency of deleting elements. when an element is inserted or deleted, all elements after its corresponding position need to be moved . The complexity of the time required will increase.
  • ...
Problems in code debugging and the resolution process
    • Question 1: instanceof the meaning and specific usage of the book P103 Code
    • Problem 1 Solution:
      • First of all, according to the context of understanding, give me a first glimpse. Should be a way to determine whether two object types are the same .
      • Then, the query API found no such method. Then I understood. Becauseinstanceof is a two-dollar operator (operator) of Java, it is also a reserved keyword for java. It is not a method or class and is not reflected in the API.
      • Its function is to determine whether its left object is an instance of its right class, and returns a Boolean type of data. Use it to determine whether an object is an instance of a class.
      • Note: Thenull value is not an instance of any object, so the following example returns FALSE, regardless of what type the variable declares.
      String s = null;   if ( s instanceof String )   
      • Instanceof can also correctly report whether an object is an array and a specific interface type.
      if ( foo instanceof byte[] )
Code hosting last week exam wrong title summary 34th Chapter
    • The wrong title 1:inherited variables and methods can be used in the derived class as if they had been declared locally.
      A. True
      B. False
    • Error reason: I think that if the parent class variable is declared private, then the subclass cannot be called directly. So I think it's wrong.
    • Common features should be located as low in a class hierarchy as is reasonable, minimizing maintenance efforts.
      A. True
      B. False
    • Error reason: Public variables should be declared at the highest level for ease of invocation.

      Fifth Chapter
    • The first operation removes an element at the front of the queue and returns a reference to it.
      A. True
      B. False
    • The wrong reason: this question I translated wrong, should be first operation, I think I am the number one operation. Embarrassed.

Peer review and peer reviews blog and code
    • Last week's blog comments on the situation
      • 20172304
      • 20172328
Other
    • 11 of the holiday let us may be a little slack, but ax. Appropriate relaxation can be better studied.
Learning progress Bar
lines of code (new/cumulative) Blog Volume (Add/accumulate) Learning Time (new/cumulative) Important Growth
Goal 5000 rows 30 Articles 400 hours
First week 0/0 1/1 10/10
Second week 610/610 1/2 20/30
Third week 593/1230 1/3 18/48
Week Four 300/1300 2/5 30/78
Resources
    • Data structure-table and linked list
    • What is the difference between a list of Java arrays and arrays?
    • Linear table-Li Xiaobai
    • instanceof usage in Java
    • The use of instanceof

20172301 "Program design and data structure" Fourth Week study summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.