"Data Structures and object-oriented programming" Week 10 learning summary

Student ID 20182329 2019-2020-1 "Object-oriented programming and data structures" Week 10 learning summary

Learning content summary

  • Achieve binary sort tree, and learn to write, delete, add, insert, and traverse the binary sort tree
  • Knowledge learning map, to map and understand the distinction undirected graph,
  • Learn weighted graph, weighted graph algorithm learn, the best algorithm.
  • Figure traverse a variety of learning, such as depth-first traversal and breadth-first traversal.
  • The method of learning generated the most trees
  • The method of generating learn FIG adjacency matrix, there is calculated for each node of the penetration-implemented method
  • The method of calculation of the learn each graph, there is not performed by traversing.

Problems and Solutions process of teaching learning ah

  • Question 1: learning calculation on each path of FIG weighted value when the weighted sum, the method finds himself in preorder total of the calculated weighted graph, but with the full value of each node on a computing when, some nodes are always a few full-time.
  • Problem 1 Solution: later realized drawings are not necessarily complete binary tree, so when traversing this will be less during off some full-time or cotyledon, and then I learned the depth-first traversal of the code, although the algorithm is slower, but can not omission, what is the depth-first traversal code:
public void dFS_AM(int site) {                //输入深度优先遍历的开始顶点
     System.out.println(this.vexs[site]);          //输出该顶点
     this.visited[site] = true;                //置访问标志为true
     for(int i = 0; i < this.vexs.length; i++) {      //依次查找未访问邻接点,并以该邻接点为始点调用深度优先遍历算法
         if(this.arcs[site][i] != 0 && !this.visited[i]) {
             this.dFS_AM(i);
         }
     }
 }
  • Question 2 :: I started using the write cycle code inside the class, to find and implement a while statement to judge, but later I found myself in the cycle will always go to the end of a chain, then pop up, is not I need to find numbers.
  • Problem 2 Solution: conditional statements I later found a lot of problems of 11, after correction, they have a way to rewrite recursive call, reducing the amount of code a lot more than the previous cycle method.
  • Question 3: When I write a method breadth-first traversal, should be in class listening to is not recursive algorithm and recursive algorithm in both cases, then I do first non-recursive algorithm, as well as teachers with the help of students class to explain, it is easy to make out, but in doing recursive algorithm, found himself always will traverse the bottom layer of less than midnight.
  • Question 3 Solution: Set error conditions of the process, and traversal methods do not match,
    this is the code:
 public void bFSTraverse() {
          
      this.visited = new boolean[this.vexs.length];      //初始化访问标志数组
      for(int i = 0; i < this.visited.length; i++) {
          this.visited[i] = false;
      }
          
      for(int i = 0; i < this.visited.length; i++) {
          if(!this.visited[i]) {                 //对未访问的顶点调用广度优先遍历算法
             bFS_AM(i);
         }
     }
 }

Code debugging and problem solving in the process

  • Question 1: During the test code, I first they adjacency matrix listed in the code to be tested if it is true according to the adjacency matrix
  • Problem 1 Solution: how to test whether this method is correct, with the results of the test results has always been incorrect
  • Question 2: When writing test code read me files, and then follow the character output only to find the address of the output path.

  • Solution: I was reading directly to the digital character and method of reading their previous written directly move over, there is no correct return value, and there is no writing read.

    Code hosting

(Run results screenshot statistics.sh script)

Last week exam wrong question summary

The wrong questions


## and the mutual junction of the assessment

Grading

Comments template:

  • Worth learning problems or blog:
    • This blog reflects the many problems connected java, we found some of the advantages of sorting and searching.
    • But the blog there is no problem in terms of self-study textbooks, and did not list all the knowledge, but to solve the problem of textbook learning real programming column.
    • Code issues in this blog and no matter the various sorting methods listed, also did not find the algorithm listed.
  • Code is worth learning or problem:
    • When writing this blog in Wu made the wrong code, although resolved more complete, did not show a more comprehensive picture.
    • There was an error in this blog settings class (abstract class), hope to correct.
  • Based on score, I give this blog scoring: 10 points. Scores are as follows:
  • Correct typographical elements complete (+1)
  • Use makedown format (+1)
  • Teaching Materials (+3)
  • Code debugging problems (+3)
  • The wrong questions in depth (+1)
  • Comments seriously (+1)

  • Reference Example

    Comments had students blog and code

  • Pair this week learning
    • Student ID 20182324
    • Pair Photo
    • Pair learning content
      • Achieve binary sort tree, and learn to write, delete, add, insert, and traverse the binary sort tree
    • Knowledge learning map, to map and understand the distinction undirected graph,
      • Learn weighted graph, weighted graph algorithm learn, the best algorithm.
      • Figure traverse a variety of learning, such as depth-first traversal and breadth-first traversal.
      • The method of learning generated the most trees
      • The method of generating learn FIG adjacency matrix, there is calculated for each node of the penetration-implemented method
      • The method of calculation of the learn each graph, there is not performed by traversing.
    • School No. 1

Other (perception, thinking, etc., optional)

Achieve learning map, I found that each specific diagram is an instance of an object class, so we can achieve the creation of graphs in the constructor. After you create a good map, we have to realize traverse the map. FIG Since we have been abstracted into a class, so we can graph traversal method as defined class. For the connected graph traversal algorithm can be accessed after calling all the nodes, but for non-connected graph, after calling traversal algorithm still some nodes have not been accessed, a need for an alternative vertex is not accessible from the graph traversal algorithm call again . Accordingly array requires access flag attached to a visited [n], to the node record is accessed.
FIG codes are as follows:

public AMGraph(int vexNum,int arcNum) {          //输入点的个数和边的个数
          
      this.vexs = new String[vexNum];
      this.arcs = new int[vexNum][vexNum];
          
      System.out.print("请依次输入顶点值,以空格隔开:");
      Scanner sc = new Scanner(System.in);
     for(int i = 0; i < vexNum; i++) {           //根据输入建立点集
          this.vexs[i] = sc.next();
     }
              for(int i = 0; i < vexNum; i++) {           //初始化边集
         for(int j = 0; j < vexNum; j++) {
             this.arcs[i][j] = 0;              //0表示该位置所对应的两顶点之间没有边
         }
     }
         
 start:for(int i = 0; i < arcNum; i++) {       //开始建立边集
     
         sc = new Scanner(System.in);
         int vex1Site = 0;
         int vex2Site = 0;
         String vex1 = null;
         String vex2 = null;
             
         System.out.print("请输入第" + (i+1) + "条边所依附的两个顶点,以空格隔开:");
         vex1 = sc.next();
         vex2 = sc.next();
         for(int j = 0; j < this.vexs.length; j++) {    //查找输入的第一个顶点的位置
             if (this.vexs[j].equals(vex1)) {
                 vex1Site = j;
                 break;
             }
             if (j == this.vexs.length - 1) {
                 System.out.println("未找到第一个顶点,请重新输入!");
                 i--;
                 continue start;
             }
         }
         for (int j = 0; j < this.vexs.length; j++) {   //查找输入的第二个顶点的位置
             if(this.vexs[j].equals(vex2)) {
                 vex2Site = j;
                 break;
             }
             if (j == this.vexs.length - 1) {
                 System.out.println("未找到第二个顶点,请重新输入!");
                 i--;
                 continue start;
             }
         }
         if(this.arcs[vex1Site][vex2Site] != 0) {      //检测该边是否已经输入
            System.out.println("该边已存在!");
             i--;
             continue start;
         }else {
             this.arcs[vex1Site][vex2Site] = 1;       //1表示该位置所对应的两顶点之间有边
             this.arcs[vex2Site][vex1Site] = 1;       //对称边也置1
         }
     }
     System.out.println("基于邻接矩阵的无向图创建成功!");
     sc.close();
 }

Reference
Java programming
Android programming
----------

Learning progress bar

The number of lines of code (add / accumulate) Blog amount (add / accumulate) Learning time (add / accumulate) Important growth
aims 6000 Line 30 400 hours
the first week 107/107 2/2 15/15
the second week 454/526 2/4 32/47
The third week 988/1514 2/6 31/78
fifth week 757/2271 2/8 31/109
Sixth Week 875/3146 1/9 31/140
Week Seven 1282/4428 2/11 58/198
Eighth Week 1972/6400 2/13 36/234
Week Nine 3799/10199 3/13 55/289
The tenth week 1397/11596 2/13 28/317

Try recording "planned learning time" and "actual learning time" to the end see if you can improve their ability to plan. This study is very important work, is also useful.
Consuming an estimated equation: Y = X + X / N , Y = XX / N, training more often, X, Y will close.

  • Plan study time: 60 hours

  • The actual study time: 58 hours

  • Improvements: tree so hard ah.

Reference material

Guess you like

Origin www.cnblogs.com/lyz182329/p/11922407.html