0% found this document useful (0 votes)
22 views11 pages

DSA LAB 05 OpenEnded

The student completed various tasks in a data structures and algorithms lab including implementing linear and binary search on student data, extending it to handle multiple subjects with weights, checking if a matrix is sparse and symmetric, analyzing time complexity of linear search, and using binary search on a partially sorted 2D matrix.

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)
22 views11 pages

DSA LAB 05 OpenEnded

The student completed various tasks in a data structures and algorithms lab including implementing linear and binary search on student data, extending it to handle multiple subjects with weights, checking if a matrix is sparse and symmetric, analyzing time complexity of linear search, and using binary search on a partially sorted 2D matrix.

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/ 11

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: 05-OpenEnded Semester:
CS 2023 (Semester- III)
OBE Target: Weight of Marks:
Dated: 01/01/2024 CLO- 2, PLO- 3, P- 3 10
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:
Task 1:
Implement functions for linear search and binary search to find and display the
information (name, contact etc.) of a specific student based on their ID.
Allow the user to choose between linear and binary search for searching.

Task 2:
Extend the program to handle multiple subjects for each student, with each subject
having different weightage. Implement a bubble sort algorithm that takes into
account the weights of each subject and sorts the list of students based on their
weighted average grades in descending order.

Task 3:
Modify the program to determine whether a given square matrix is not only
symmetric but also a sparse matrix. A sparse matrix is one in which most of the
elements are zero.
ZIAUDDIN UNIVERSITY
Faculty Of Engineering Science & Technology
(ZUFEST)
Department of Software Engineering

Task 4:

Analyze the time complexity of linear search. Discuss its performance on sorted and
unsorted data.
Hint:
Time Complexity Analysis:
For Unsorted Data:
 Best-case: O (1) - Target is the first element.
 Average-case: O (n/2) - Average comparison until finding the target.
 Worst-case: O (n) - Target is the last element or not in the array.

Task 5:

Implement an efficient algorithm using binary search to search for a specific


element in a partially sorted 2D matrix. In this case, each row is sorted, but the
columns might not be in sorted order.

Examiner Signature: Student Score:


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

Task 1:
Implement functions for linear search and binary search to find and display the information
(name, contact etc.) of a specific student based on their ID.
Allow the user to choose between linear and binary search for searching.
CODE:

OUTPUT:
ZIAUDDIN UNIVERSITY
Faculty Of Engineering Science & Technology
(ZUFEST)
Department of Software Engineering
Task 2:
Extend the program to handle multiple subjects for each student, with each subject having
different weightage. Implement a bubble sort algorithm that takes into account the weights of
each subject and sorts the list of students based on their weighted average grades in descending
order.
CODE:
ZIAUDDIN UNIVERSITY
Faculty Of Engineering Science & Technology
(ZUFEST)
Department of Software Engineering

OUTPUT:
ZIAUDDIN UNIVERSITY
Faculty Of Engineering Science & Technology
(ZUFEST)
Department of Software Engineering
Task 3:
Modify the program to determine whether a given square matrix is not only symmetric but also a
sparse matrix. A sparse matrix is one in which most of the elements are zero.
CODE:
ZIAUDDIN UNIVERSITY
Faculty Of Engineering Science & Technology
(ZUFEST)
Department of Software Engineering
OUTPUT:
ZIAUDDIN UNIVERSITY
Faculty Of Engineering Science & Technology
(ZUFEST)
Department of Software Engineering

Task 4:

Analyze the time complexity of linear search. Discuss its performance on sorted and unsorted
data.
Hint:
Time Complexity Analysis:
For Unsorted Data:
 Best-case: O (1) - Target is the first element.
 Average-case: O (n/2) - Average comparison until finding the target.
 Worst-case: O (n) - Target is the last element or not in the array.
CODE:
ZIAUDDIN UNIVERSITY
Faculty Of Engineering Science & Technology
(ZUFEST)
Department of Software Engineering
OUTPUT:
ZIAUDDIN UNIVERSITY
Faculty Of Engineering Science & Technology
(ZUFEST)
Department of Software Engineering

Task 5:

Implement an efficient algorithm using binary search to search for a specific element in a partially
sorted 2D matrix. In this case, each row is sorted, but the columns might not be in sorted order.
CODE:

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

SUMMARY:
In the following lab we learnt how to perform binary and linear search using different data
types and while putting different conditions and learning how to apply them, including
bubble sort algorithm by giving numerous data of students. We also found a way how to
check time complexity of a code and opting it’s different cases: best, average and worst
cases.

You might also like