0% found this document useful (0 votes)
28 views6 pages

Dsa Lab 02

We are working on C++ applications in this lab that locate a target element in an array or matrix using linear searches. In the first program, we work on a 1D array search for a target element. In the second program, we count and display the number of iterations we do in a linear search. In the third program, we search a 2D array for a target element. In the fourth program, we let the user enter multiple target values and show the number of iterations needed to find each target as well as whether or not 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)
28 views6 pages

Dsa Lab 02

We are working on C++ applications in this lab that locate a target element in an array or matrix using linear searches. In the first program, we work on a 1D array search for a target element. In the second program, we count and display the number of iterations we do in a linear search. In the third program, we search a 2D array for a target element. In the fourth program, we let the user enter multiple target values and show the number of iterations needed to find each target as well as whether or not 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/ 6

ZIAUDDIN UNIVERSITY

Faculty Of Engineering Science & Technology


(ZUFEST)
Department of Software Engineering
Course Code/ Title: ASSESSMENT ACTIVITY:
Data Structure and Algorithm DSA LAB Task: 02 Semester:
SE 2022 (Semester- III)
OBE Target: Weight of Marks:
Dated: 09/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.

Task 1:

a. Write a C++ program that performs a basic linear search 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.
b. Modify the above program to count and display the
number of iterations performed during the linear search.

c. Write a C++ program that performs a basic linear search to


find a target element in an MATRIX. Prompt the user to
enter the target value and output whether the element is
found in the array or not.

d. Extend the second program to allow the user to input


multiple target values. For each target, display whether it
is found in the array and the number of iterations taken to
find it.
ZIAUDDIN UNIVERSITY
Faculty Of Engineering Science & Technology
(ZUFEST)
Department of Software Engineering

a. Write a C++ program that performs a basic linear search 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.
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 linear search.
ZIAUDDIN UNIVERSITY
Faculty Of Engineering Science & Technology
(ZUFEST)
Department of Software Engineering
c. Write a C++ program that performs a basic linear search to
find a target element in an MATRIX. Prompt the user to
enter the target value and output whether the element is
found in the array or not.
ZIAUDDIN UNIVERSITY
Faculty Of Engineering Science & Technology
(ZUFEST)
Department of Software Engineering
d. Extend the second program to allow the user to input
multiple target values. For each target, display whether it
is found in the array and the number of iterations taken to
find it.
ZIAUDDIN UNIVERSITY
Faculty Of Engineering Science & Technology
(ZUFEST)
Department of Software Engineering
SUMMARY:
We are working on C++ applications in this lab that locate a target element in an array or matrix using linear searches. In the
first program, we work on a 1D array search for a target element. In the second program, we count and display the number of
iterations we do in a linear search. In the third program, we search a 2D array for a target element. In the fourth program, we
let the user enter multiple target values and show the number of iterations needed to find each target as well as whether or
not it was found.

You might also like