1 / 4

Path Testing

Path Testing. Class Activity. Path Testing. Bubble sort is well-known sorting algorithm. It starts by comparing each pair of adjacent elements from the beginning of an array and, if they are in reversed order, they are swapped.

mitch
Download Presentation

Path Testing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Path Testing Class Activity

  2. Path Testing Bubble sort is well-known sorting algorithm. It starts by comparing each pair of adjacent elements from the beginning of an array and, if they are in reversed order, they are swapped. If at least one swap has been done, the first step is repeated, otherwise the sorting is stopped.

  3. Exercise Using the following Java source code for the bubble sort algorithm: • Draw the flow graph • Identify the number of independent paths • Write test cases for the bubble sort algorithm using path testing.

  4. publicvoidbubbleSort(int[] arr) { • (1)boolean swapped = true; • (2)int j = 0; • (3) inttmp; • (4) while (swapped) { • (5) swapped = false; • (6) j++; • (7) for(inti = 0; i < arr.length - j; i++) { • (8)if(arr[i] > arr[i + 1]) { • (9)tmp= arr[i]; • (10)arr[i] = arr[i + 1]; • (11)arr[i+ 1] = tmp; • (12) swapped = true; • } //if • }//for • } //while • (13)}

More Related