CS608 Assignment 1 Solution Spring 2022

CS608 Assignment 1 Solution Spring 2022


CS608 Assignment 1 Solution Spring 2022
Assignment # 01
Total marks=20




Due Date:10 June, 2022

Assignment No. 1 covers topic-01 to topic-48.

Please carefully read the following instructions before attempting assignment.
It should be clear that your assignment would not get any credit if:
The assignment is submitted after the due date.
he submitted assignment does not open or file is corrupt.
Strict action will be taken if submitted solution is copied from any other student or from the internet.
You should concern the recommended books to clarify your concepts as handouts are not sufficient.
You are supposed to submit your assignment in .doc or docx format.
Any other formats like scanned images, PDF, zip, rar, ppt and bmp etc. will not be accepted.

No assignment will be accepted after the due date via email in any case (whether it is the case of load shedding or Internet issues etc.). Hence refrain from uploading assignment in the last hour of deadline. It is recommended to upload solution file well before its closing date.
If you find any confusion in the assignment (Question statement), please consult with your Instructor before the deadline. After the deadline no queries will be entertained in this regard.
For any query, feel free to email at CS608@vu.edu.pk

Question#1: (10 Marks)
Draw Control Flow Graph (CFG) for the following piece of code. True/False conditions must be mentioned on respective nodes/edges.
Question#2: (10 Marks)
Keeping in view the unit testing performed in Topic#45, perform unit testing by following the steps given below.
The solution should include screenshots of each step from step#3 to step#7 in a sequence. Make sure the screenshot should be of your full desktop screen displaying a visual studio interface with the required information mentioned in each step.
1. Download Microsoft Visual Studio “Community Version (Free)” using this link https://visualstudio.microsoft.com/downloads/. You can download any version as per your system compatibility.
2. Install Microsoft Visual Studio in your system. You can get the installation guide from this video https://youtu.be/4QhKtby3Q3s. Make sure to select only “.Net desktop development” while selecting workloads. Also, add your Google account information for Signing in.
3. Create a new project. The project name should be “Your VUID” i.e. bc120255801.
4. Create a new class inside project. Class name should be “aSearch”. Place the following code in class file inside main method.
public int search(int key, int[] elemArray) {
bottom = 0;

top = elemArray.Length – 1

index = -1; Boolean found = false;
while (bottom <= top && found == false) {
mid = (top + bottom) / 2;
if (elemArray[mid] == key) {
index = mid; found = true; return index;
} else {
if (elemArray[mid] < key)
bottom = mid + 1;
else top = mid – 1;

return index;

1. Create a new test project. The project name should be “Your VUID_Test” i.e. bc120255801_Test.
2. Add your C# project created in step#3 as reference in your test project.
3. Create a new unit test class and place the following code in class file under [TestMethod] attribute. Run the test method and display results.
public class assignmentTest {
public void AssignmentTestMethod1() {
int[] array = { 1, 2, 3, 4 }; int key = 1;
aSearch bs = new aSearch();
Assert.AreEqual(1, bs.search(key, array));


CS608 Assignment 1 Solution Spring 2022

5. Create a new project. The project name should be “Your VUID” i.e. bc120255801.