0% found this document useful (0 votes)
4 views

assignment nov 4

Uploaded by

zionmiguel1207
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

assignment nov 4

Uploaded by

zionmiguel1207
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

CITY GOVERNMENT OF SAN PABLO

PAMANTASAN NG LUNGSOD NG SAN PABLO


CHED Recognized Local College
TESDA Recognized Programs
Patriotism • Leadership • Service • Professionalism ALCU Commission on Accreditation – Level 1 Re-Accredited
Member, Association of Local Colleges and Universities
Member, Local Colleges and Universities Athletic Association, Inc.

Course Code: IT PROF EL 6

Name of Student: GUTIERREZ, ZION MIGUEL

Program Year and Section: BSIT-4D(SD)

Instructor: Ms. Ma. Ara Lovela G. Pahutan,LPT

Date: 5/11/2024

Assignment

Direction:

1. Answer the following guide questions, the length of discussion is


limited to 3-5 sentences is enough to briefly elucidate your
thoughts.
2. Use this learning data sheet as an answer sheet. Indicate your
answer after the questions. Highlight the questions and your
answers. You may indicate your references and sources.
3. Submit it in PDF file format.

Questions

1. What are the main differences between Linear Search and Binary Search
algorithms?
2. How does the time complexity of Linear Search compare to Binary Search?
3. What is required for a Binary Search algorithm to work correctly on a dataset?
4. Can you explain the "divide and conquer" principle used in Binary Search?
5. In what types of real-world applications might Linear Search be preferable
over Binary Search? compared to primary data sources?

Answers

1. Main Differences between Linear Search and Binary Search: Linear Search scans
each element in a list sequentially until it finds a match or reaches the end, while Binary
Search divides the list in half, repeatedly narrowing down the search interval. Linear
Search does not require data to be sorted, whereas Binary Search requires a sorted dataset
to work effectively.
2. Time Complexity Comparison: Linear Search has a time complexity of O(n)O(n)O(n),
as it may require checking each element in the list. Binary Search is much faster with a
time complexity of O(log⁡n)O(\log n)O(logn) because it eliminates half of the remaining
elements with each step, making it more efficient on large, sorted datasets.
3. Requirements for Binary Search: For Binary Search to work, the dataset must be sorted
in either ascending or descending order. This requirement is crucial as Binary Search
relies on comparing the middle element to target values to determine which half of the
dataset to search next.
CITY GOVERNMENT OF SAN PABLO
PAMANTASAN NG LUNGSOD NG SAN PABLO
CHED Recognized Local College
TESDA Recognized Programs
Patriotism • Leadership • Service • Professionalism ALCU Commission on Accreditation – Level 1 Re-Accredited
Member, Association of Local Colleges and Universities
Member, Local Colleges and Universities Athletic Association, Inc.

4. Divide and Conquer Principle: Binary Search employs the "divide and conquer"
principle by dividing the list in half on each iteration, thereby reducing the search space
by half. This approach leverages the sorted order of elements, allowing the algorithm to
discard half of the remaining elements each time, making the search faster.
5. Real-World Applications for Linear Search: Linear Search is preferable in scenarios
where data is unsorted, or when working with small datasets where the overhead of
sorting may outweigh the benefits of a Binary Search. Examples include searching for a
particular item in a small list, or in real-time applications where data is frequently
changing and keeping it sorted is impractical.

References:

 Cormen, T.H., Leiserson, C.E., Rivest, R.L., & Stein, C. (2009). Introduction to
Algorithms (3rd ed.). MIT Press.
 Weiss, M.A. (2013). Data Structures and Algorithm Analysis in C++ (4th ed.). Pearson.

Reminders: AVOID PLAGIARISM, include the source/reference of the


performance task output

You might also like