0% found this document useful (0 votes)
15 views5 pages

Dsa Lab 03

Three binary search-related tasks make up the given code. To locate a target value in an array in the first task, a simple binary search technique is used. The same algorithm is used in the second task, but it also counts and displays the number of iterations. In the third task, a target value is located within an array containing the first 100 multiples of 5 by using the binary search algorithm. In each job requests the user to input a target value and then searches for it inside the array using the binary search method. After the search, the code displays whether the element was found or not, along with the index of the element if it was found.

Uploaded by

hassanasim373
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views5 pages

Dsa Lab 03

Three binary search-related tasks make up the given code. To locate a target value in an array in the first task, a simple binary search technique is used. The same algorithm is used in the second task, but it also counts and displays the number of iterations. In the third task, a target value is located within an array containing the first 100 multiples of 5 by using the binary search algorithm. In each job requests the user to input a target value and then searches for it inside the array using the binary search method. After the search, the code displays whether the element was found or not, along with the index of the element if it was found.

Uploaded by

hassanasim373
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

ZIAUDDIN UNIVERSITY

Faculty Of Engineering Science & Technology


(ZUFEST)
Department of Software Engineering
Course Code/ Title: ASSESSMENT ACTIVITY:
Data Structure and Algorithm-Lab DSA LAB Task: 03 Semester:
CS 2023 (Semester- III)
OBE Target: Weight of Marks:
Dated: 18/01/2024 CLO- 2, PLO- 3, P- 3 02
Teacher: Score:
Student Name: MENNAM FATIMA
Dr.Syed Atif &
Student ID: 4-38/2023/035
Abdul Basit Naveed

Instructions:

Take snapshots of both input and output and provide a brief summary explaining what you
have learned in this lab.

Lab Tasks:
a. Write a C++ program that performs a Binary search
algorithm to find a target element in an array. Prompt the user to
enter the target value and output whether the element is found
in the array or not with target value location.
b. Modify the above program to count and display the number of
iterations performed during the binary search.
c. Create an array containing multiples of 5, starting from 5, up to a
reasonable size (e.g., 100). Then, use the binary search algorithm to find
the index of the element 35. Output whether 35 is present in the array
and, if present, the index of its first occurrence.

Examiner Signature: Student Score:


ZIAUDDIN UNIVERSITY
Faculty Of Engineering Science & Technology
(ZUFEST)
Department of Software Engineering

Instructions:

Take snapshots of both input and output and provide a brief summary explaining what you
have learned in this lab.

Lab Tasks:
a. Write a C++ program that performs a Binary search
algorithm to find a target element in an array. Prompt the user to
enter the target value and output whether the element is found
in the array or not with target value location.
INPUT:

OUPUT:
ZIAUDDIN UNIVERSITY
Faculty Of Engineering Science & Technology
(ZUFEST)
Department of Software Engineering
b. Modify the above program to count and display the number of
iterations performed during the binary search.
INPUT:

OUPUT:
ZIAUDDIN UNIVERSITY
Faculty Of Engineering Science & Technology
(ZUFEST)
Department of Software Engineering
c. Create an array containing multiples of 5, starting from 5, up to a
reasonable size (e.g., 100). Then, use the binary search algorithm to find
the index of the element 35. Output whether 35 is present in the array
and, if present, the index of its first occurrence.
INPUT:

OUPUT:
ZIAUDDIN UNIVERSITY
Faculty Of Engineering Science & Technology
(ZUFEST)
Department of Software Engineering

SUMMARY:
Three binary search-related tasks make up the given code. To locate a target value in an array in the first task, a
simple binary search technique is used. The same algorithm is used in the second task, but it also counts and
displays the number of iterations. In the third task, a target value is located within an array containing the first 100
multiples of 5 by using the binary search algorithm. In each job requests the user to input a target value and then
searches for it inside the array using the binary search method. After the search, the code displays whether the
element was found or not, along with the index of the element if it was found.

You might also like