20172324 2018-2019-1 "program design and data structure" Fourth Week study summary

Source: Internet
Author: User

20172324 2018-2019-1 "program design and data structure" Fourth Week study summary

Collection of summary list of learning contents of textbooks
List Description
Ordered list Its elements are sorted according to some intrinsic characteristics of the element
Unordered list The elements do not have an intrinsic order, and the elements are sorted according to their position in the list (do not be misled by the name, placed in a special order, except that the order is independent of the element itself)
Index list Its elements can be referenced by a numeric index

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

List in the Java API
Method Description
Add (E Element) Add an element to the end of the list
Add (int index, E Element) Inserts an element at the specified index
Get (int index) Returns the element at the specified index
Remove (int index) Deletes the element at the specified index
Remove (O object) Overrides the element at the specified index
Set (int index,e element) Returns the number of elements in a list
Size () Returns the number of elements in a list
Using the array implementation list
    1. Array-based implementation lists first, fix one end of the list at index 0, set an integer variable rear represents the number of elements in the list, and represent the next available location at the end of the list.
    2. The remove operation finds the element passed as a parameter, removes it from the list if found, and then pans the element higher in the array down to fill the gap
    • The Find method is used to find the development element, and returns the index value if it exists
      • Benefits
        • Makes the remove operation easier.
        • Can use the Find method to implement other operations and methods
        • Does not throw an exception
    • The continue method is used to determine whether the specified element is in the list
    • Add method to make multiple comparisons and panning operations
    • Unique operations for unordered lists
      • Addtofront (Complexity of O (n)) and Addtorear (O (1))
      • Addafter
        • Two parameters, one representing the element to be added, one representing the target element, similar to the Remove and add operation, and the complexity bit O (n)
Implementing a list using linked lists
    • The remove operation of a linked list does not require a translation element, but there are four cases:
      • The only element to delete is the list
      • To delete the first element of a list
      • To delete the tail element of a list
      • The middle element of the list to delete.
      In all of these cases, count decrements by 1, while there is still a case in which to do the n comparison operation, so its time complexity is also O (n).
Problems in teaching materials learning and the solving process
    • Issue 1: The relationship between list and linked lists
    • Problem 1 Solution: A linked list is an implementation strategy that lists can be implemented with a linked list or array, and the collection of lists has no intrinsic capacity and can grow by 1 as demand grows

    • The use of problem 2:instanceof
    • Problem 2 Solution:
      A instanceof B, the return value is a Boolean that is used to determine whether a is an instance object of B or an instance object of the B subclass. Returns true if yes, otherwise false.

Person p = new Person() ; //   Man m = new Man() ; //Man是Person的子类   Animal a = new Animal() ;   m instanceof Man //返回true   m instanceof Animal//返回false   m instanceof Person//返回true
Problems in code debugging and the resolution process
    • Problem one: When doing pp5.2, the topic requires to write the ToString method, but after the completion of the prompt there are errors, errors in their own method of ToString.
    • Problem One solution: Before reading a book without noticing this sentence: "ToString becomes more complex because the elements are not stored at 0, and may also wrap around the end of the array." "And I was directly copied 5.1 in the ToString method changed, so there is a problem, found that the problem has been changed after the error has not been
Code Hosting last week exam error summary

No

Peer review and peer reviews blog and code
    • This week's study of the knot
      • Pair of students study No. 21
      • Pairs of learning content
        • Xxxx
        • Xxxx
        • ...
    • Last week's blog comments on the situation
      • Study No. 1
Other (sentiment, thinking, etc, optional) 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 1/1 20/20
Second week 300/500 1/2 18/38
Third week 300/600 1/3 18/38
Resources
    • Java Programming and Data Structure (fourth edition)
    • Queues and stacks are linear tables with limited operations, allowing operations on both ends of the table

20172324 2018-2019-1 "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.