20182322 2019-2020-1 "Object-oriented programming and data structures" Experimental Report 7

Course: "Programming and Data Structures"

Class: 1823

Name: Wang Meihao

Student ID: 20182322

Experiment Teacher: Wang Zhiqiang

Experiment Date: October 30, 2019

Compulsory / Elective: Compulsory

1. Experimental content

Sorting and Searching 1. Define a class and implement linearSearch, SelectionSort class methods, and finally to complete the test.
After the test requires less than 10, the design submitted test cases (normal, abnormal, boundary, positive sequence, reverse), the data to be included with the Example No. learn their four

2. refactor your code
to Sorting.java Searching.java into cn.edu.besti.cs1823 (initials + four-digit student number) package. (Example: cn.edu.besti.cs1823.G2301)
to test code discharge test package

3. Reference http://www.cnblogs.com/maybe2030/p/4715035.html, learn a variety of search algorithm and added search algorithm and test Searching

4. The method of sorting the spoken added to achieve Class: Hill sort, heap sort, binary tree sorting (at least 3)
algorithm (normal, abnormal, boundary) implemented test

5. Android app to achieve a variety of sorting algorithms to find and test run results submitted screenshots

2. Experimental procedure and results

- Find and Sort -1
-

- Find and Sort -2
-

-

-

-

- Find and Sort -3
-

-

- Find and Sort -4
-

-

-

3. Experimental problems encountered in the process and settlement process

  • Question 1: Sorting test to experiment 1, when there was a problem
Comparable[] arr9 = new Comparable[1];//9
        EXP1test i =new EXP1test();
        assertEquals("[null]",i.selectionSort(arr9));

You can run

Comparable[] arr10 = new Comparable[999]; //空指针异常10
        EXP1test j =new EXP1test();
        assertEquals("[null]",j.selectionSort(arr10));

Can not run, why

  • Problem 1 Solution: homework when I was thinking is this: arr9 and arr10 should all borders should be abnormal, but when I tested, I found arr9 can run but arr10 boundary will be reported abnormal situation. I began to think that perhaps because of too much arr10, so put the 999 into 99, but this result is still out of the border anomaly, I size of the array into two, the result is still the boundary exception. Explanation is that when the array is to 1, the test is out of the [null], it has been the anomaly. When the array is increased when it is test 2 [null] [null]. With the increase in size of the array, an increasing number of empty array, too often it does not show up.
  • Question 2: Requires use Junit testing in a node in, but relevant test methods have been somewhat forgotten, always test can not be normal at the beginning of the test class to write.
  • Problem 2 Solution: query information learned all Junit test classes need extends TestCaseor can not be tested; the names of all of the test method must be to testbegin with, for example, find the test sequence, which is named Junit method testSequenceSearch(), otherwise it would not be test.
  • Question 3: two nodes need to do on the command line Searchingand Sortingconduct class test, but Junit test methods themselves are not familiar with the command line.
  • Question 3 Solution: After the query how to search for information online Junit test found himself in command line Linux system and related components are not installed, and finally ask students how they tested did not use Junit, so he will give up Junit test, wrote a number of mainmethods for testing.

Other (perception, thinking, etc.)

  • The experiments in general, or too difficult, time cards for a long time, some operations or unfamiliar, need more practice.
  • The test is an in-depth study to find and sort of knowledge, through this experiment to acquire knowledge deepened.

Reference material

Guess you like

Origin www.cnblogs.com/wmh20182322/p/11874400.html