Post date: Jan 14, 2015 5:59:55 PM
Pseudocode example
Algorithm Sum of two number
Input: x, y
Output: z
Method:
Step 1: Input two real numbers
Step 1.1: Assign both numbers to x and y
Step 2: x is added with y
Step 2.1: Assign the result to z
Step 3: Return z
Step 4: End
Algorithm Product of two number
Input: x, y
Output: z
Method:
Step 1: Input two real numbers
Step 1.1: Assign both numbers to x and y
Step 2: x is times with y
Step 2.1: Assign the result to z
Step 3: Return z
Step 4: End
Algorithm Find the Largest
Input: a, b, c, d, e
Output: Largest
Method:
Step 1: Input five data
Step 1.1: Assign the data to the memory respectively
Step 2: Assign the Largest to -infinity
Step 3: While (the number is larger than the Largest)
Step 3.1: Do (assign the number to Largest)
Step 4: Return Largest
Step 5: End
Algorithm Find the Smallest
Input: a, b, c, d, e
Output: Smallest
Method:
Step 1: Input five data
Step 1.1: Assign the data to the memory respectively
Step 2: Assign the Smallest to +infinity
Step 3: While (the number is smaller than the Smallest)
Step 3.1: Do (assign the number to Smallest)
Step 4: Return Smallest
Step 5: End
Algorithm Selection Sorting
Input: 23, 78, 45, 8, 32, 45
Output: 8, 23, 32, 45, 56, 78
Method:
Step 1: Input five data
Step 1.1: Assign the data to the memory respectively
Step 2: Do (swap the smallest to the first position (unsorted))
Step 2.1: While (there is remaining a few unsorted)
Step 3: 8, 23, 32, 45, 56, 78
Step 4: End
Algorithm Bubble Sorting
Input: 23, 78, 45, 8, 32, 45
Output: 8, 23, 32, 45, 56, 78
Method:
Step 1: Input five data
Step 1.1: Assign the data to the memory respectively
Step 2: Do (write the smallest to the first position (unsorted))
Step 2.1: While (there is remaining a few unsorted)
Step 3: Return (8, 23, 32, 45, 56, 78)
Step 4: End
Algorithm Insertion Sorting
Input: 23, 78, 45, 8, 32, 45
Output: 8, 23, 32, 45, 56, 78
Method:
Step 1: Input five data
Step 1.1: Assign the data to the memory respectively
Step 2: Do (compare the data with sorted and insert to the left/right position)
Step 2.1: While (there is remaining a few unsorted)
Step 3: Return (8, 23, 32, 45, 56, 78)
Step 4: End
Algorithm Sequential Search
Input: 4, 21, 36, 14, 62, 91, 8, 22, 7, 81, 77, 10
Output: 62
Method:
Step 1: Input twelve data
Step 1.1: Assign the data to the memory respectively
Step 2: Input a data (wanna to search)
Step 3: Do (the second data is compared with the data in order)
Step 3.1: While (the second data is not equal to the data)
Step 4: Return 62
Step 5: End
Algorithm Binary Search
Input: 4, 21, 36, 14, 62, 91, 8, 22, 7, 81, 77, 10
Output: 22
Method:
Step 1: Input twelve data
Step 1.1: Assign the data to the memory respectively
Step 2: Sorting the data
Step 3: Input a data (wanna to search)
Step 4: Do (the second data is compared with the middle data)
Step 4.1: If (the second data > middle data)
Step 4.1.1: Set the compare area after the middle data
Step 4.2: Else set the compare area before the middle data
Step 4.3: While (the second data is not equal to middle data)
Step 5: Return 22
Step 6: End
Binary search is searching the sorted data whereas the Sequential search is searching the unsorted data. Hence, the Binary searching is slow but more efficient, the Sequential searching is faster but less efficient.
Glass-box testing (or white-box testing)
It is based on knowing the internal structure of the software.
Black-box testing
It is the concept of testing software without knowing the internal structure of software.