Bangladesh Oil, Gas & Mineral Corporation
Post: Assistant Manager (hardware/software)
Exam Date: 16/09/2022, Exam Taker:BUET
#include <iostream> using namespace std; int main { int i, arr[10], num, first, last, middle; cout << "Enter 10 elements in ascending order: "; for(i = 0; i < 10; i++) cin >> arr[i]; cout << "\nEnter the element you want to search: "; cin >> num; first = 0; last = 9; middle = (first + last) / 2; while(first <= last) { if(arr[middle] < num) first = middle + 1; else if(arr[middle] == num) { cout << "\nThe number " << num << " is found at position " << middle + 1 << "."; break; } else last = middle - 1; middle = (first + last) / 2; } if(first > last) cout << "\nThe number " << num << " is not found in the given array."; cout << endl; return 0; }

Black Box Testing
Black Box Testing is a software testing technique where the functionality of an application is tested without knowing the internal code, logic, or implementation details. It focuses only on input and output behavior to verify whether the system meets specified requirements. It is also called Behavioral Testing because testing is based on external behavior.
Boundary Value Analysis (BVA)
Boundary Value Analysis (BVA) is a technique of Black Box Testing that checks errors at the boundary values of the input range. Since most errors occur at the edges rather than in the middle of the range, BVA tests the minimum, maximum, and just outside these limits.
Equivalence Class Test Cases
For a program that calculates the square root of an integer in the range 0 to 5000, the input domain can be divided into three equivalence classes:
• Negative integers (invalid input)
• Integers from 0 to 5000 (valid input)
• Integers greater than 5000 (invalid input)
One representative value from each class is selected.
Possible test set: { -5, 500, 6000 }
Here,
• -5 → represents negative integers
• 500 → represents valid range
• 6000 → represents values greater than 5000
Boundary Value Analysis Test Cases
Using BVA for the same program, test cases should include boundary and near-boundary values:
• -1 → just below lower boundary
• 0 → lower boundary
• 5000 → upper boundary
• 5001 → just above upper boundary
Thus, Boundary Value Analysis test set is { -1, 0, 5000, 5001 }.
Black Box Testing
Black Box Testing হলো একটি software testing technique যেখানে application-এর internal code, logic বা implementation না জেনেই testing করা হয়। এখানে শুধুমাত্র input ও output behavior যাচাই করা হয় যাতে system specified requirement পূরণ করে কিনা তা নিশ্চিত করা যায়। একে Behavioral Testing ও বলা হয়, কারণ এটি external behavior-এর উপর ভিত্তি করে।
Boundary Value Analysis (BVA)
Boundary Value Analysis (BVA) হলো Black Box Testing-এর একটি technique যা input range-এর boundary value-এ error খুঁজে বের করে। সাধারণত range-এর মাঝখানে নয়, বরং শুরু ও শেষ সীমায় বেশি error ঘটে, তাই minimum, maximum এবং তাদের ঠিক পাশের মান পরীক্ষা করা হয়।
Equivalence Class Test Cases
যদি একটি program 0 থেকে 5000 এর মধ্যে integer-এর square root নির্ণয় করে, তাহলে input তিনটি equivalence class-এ ভাগ করা যায়:
• Negative integer (invalid input)
• 0 থেকে 5000 পর্যন্ত integer (valid input)
• 5000-এর বেশি integer (invalid input)
প্রতিটি class থেকে একটি প্রতিনিধি মান নেওয়া হয়।
সম্ভাব্য test set: { -5, 500, 6000 }
এখানে,
• -5 → negative integer class
• 500 → valid range class
• 6000 → 5000-এর বেশি class
Boundary Value Analysis Test Cases
একই program-এর জন্য BVA ব্যবহার করলে boundary মানগুলো পরীক্ষা করতে হবে:
• -1 → lower boundary-এর ঠিক নিচে
• 0 → lower boundary
• 5000 → upper boundary
• 5001 → upper boundary-এর ঠিক উপরে
অতএব, Boundary Value Analysis test set হলো { -1, 0, 5000, 5001 }।
Single Source Shortest Path in a Negative Weighted Graph
What is a Negative Weighted Graph?
A negative weighted graph is a graph in which one or more edges have negative weight. If a cycle exists whose total sum of edge weights is negative, it is called a Negative Weight Cycle.
How to Detect a Negative Weight Cycle?
To detect a negative weight cycle, we use the Bellman-Ford Algorithm.
Steps:
1) Initialize distance of source vertex as 0 and others as infinity.
2) Relax all edges (V−1) times, where V is the number of vertices.
3) Perform one more relaxation.
If any distance decreases in the Vth iteration, then a negative weight cycle exists in the graph.
Justification:
In a graph without a negative cycle, the shortest path can have at most (V−1) edges. If after (V−1) relaxations the distance still decreases, it means a cycle with negative total weight is repeatedly reducing the path cost.
How to Find Single Source Shortest Path?
• If the graph has negative edges but no negative cycle → Use Bellman-Ford Algorithm to find shortest paths.
• If a negative weight cycle is reachable from the source → The shortest path does not exist because the path cost can be reduced infinitely by traversing the negative cycle repeatedly.
Therefore, single source shortest path is defined only when there is no reachable negative weight cycle.
Negative Weighted Graph-এ Single Source Shortest Path
Negative Weighted Graph কী?
যে graph-এ এক বা একাধিক edge-এর weight negative থাকে তাকে negative weighted graph বলে। যদি কোনো cycle-এর মোট edge weight negative হয়, তাহলে তাকে Negative Weight Cycle বলা হয়।
Negative Weight Cycle কীভাবে নির্ণয় করা হয়?
Negative weight cycle নির্ণয়ের জন্য Bellman-Ford Algorithm ব্যবহার করা হয়।
ধাপসমূহ:
1) Source vertex-এর distance 0 এবং অন্যগুলোর infinity সেট করতে হবে।
2) সব edge (V−1) বার relax করতে হবে, যেখানে V হলো vertex সংখ্যা।
3) অতিরিক্ত একবার relax করতে হবে।
যদি এই ধাপে কোনো distance আরও কমে যায়, তাহলে graph-এ negative weight cycle আছে।
যুক্তি (Justification):
যদি graph-এ negative cycle না থাকে, তাহলে shortest path সর্বোচ্চ (V−1) টি edge নিয়ে গঠিত হয়। কিন্তু (V−1) বার relax করার পরও যদি distance কমে, তাহলে বুঝতে হবে একটি negative cycle বারবার path cost কমাচ্ছে।
Single Source Shortest Path কীভাবে নির্ণয় করা হয়?
• যদি graph-এ negative edge থাকে কিন্তু negative cycle না থাকে → Bellman-Ford Algorithm দিয়ে shortest path নির্ণয় করা যায়।
• যদি source থেকে reachable negative weight cycle থাকে → তাহলে shortest path সংজ্ঞায়িত নয়, কারণ negative cycle বারবার ঘুরে path cost অসীমভাবে কমানো যায়।
অতএব, negative weight cycle থাকলে single source shortest path নির্ণয় সম্ভব নয়।
Not collected
