ANALYSIS OF ALGORITHM
TEACHER’S NAME:
● SIR HASSAN ZAIDI
PROJECT BY ;
● ZAID M. KHAN (BAI-23S-032)
● ABRAR DAR(BAI-23S-011)
● MARYAM SOHAIL (BAI-23S-003)
PROJECT TOPIC:
“MEDICATION FACILITIES FOR SICK AND PARALYZED PEOPLE
WITH LESS PRICE AND FREE DELIVERY”
Q 1 DISCUSS WHICH ALGORITHMS YOU CAN USE FOR
RESULTS AND WHY?
ANS For this problem, two good candidates for comparison would
be:
● Binary Search: This is useful if the list of medicines is sorted by
price or some other factor.
● Linear Search: This is useful when dealing with unsorted data or
when you want to add constraints like free delivery along with
price.
AND WHY?
BECAUSE
Algorithm 1: Binary Search
● Sort the data based on medicine price.
● Use binary search to efficiently find the medicine at the lowest
price.
● After finding it, check whether free delivery is available.
Algorithm 2: Linear Search
● Perform a linear search through all medicines, checking for both
affordable price and free delivery simultaneously.
● This algorithm will evaluate each item individually, which could take
longer but allows you to apply multiple criteria at once.
Q 2 WHAT STEPS YOU WILL TAKE TO COMPARE PREVIOUS
ALGORITHM?
ANS Comparison of the Algorithms:
● Time Complexity: Binary search has a time complexity of O(log n),
while linear search has O(n).
● Suitability for the Problem:
o Binary search is faster but requires the data to be sorted and
might not handle multiple constraints as efficiently.
o Linear search works with unsorted data and is more flexible
when applying multiple criteria (like price and free delivery).
Q 3 HOW CAN YOU MEASURE RESULTS QUALITY?
ANS For Measuring the results quality of our problem involves
evaluating how effectively and efficiently the algorithms meet our
objectives: finding affordable medicines with free delivery for sick or
paralyzed users. we can assess the quality of the results based on the
following key metrics:
1.Correctness (Accuracy):
Goal : The algorithm should return the correct medicine with the lowest
price and free delivery.
How to Measure :
Compare the results of the algorithm with manual or ground truth
results (i.e., the actual lowest price medicine with free delivery).
Run several test cases with different data sets (sorted and unsorted)
to verify that the algorithm consistently finds the correct solution.
Measure the percentage of times the algorithm selects the optimal
result.
2. Time Complexity (Efficiency) :
Goal: The algorithm should return the result as quickly as possible,
especially for larger datasets.
How to Measure:
Record the execution time of each algorithm for datasets of various
sizes.
Compare the average runtime of Linear Search and Binary
Search.
Use Big O notation to predict scalability: O(n) for linear search and
O (log n) for binary search after sorting.
For larger datasets, linear search might take more time, so measure
how well the algorithms scale as the dataset grows.
3. Memory Usage:
Goal: The algorithm should use memory efficiently, especially if the
dataset is large.
How to Measure :
Track the memory consumed by each algorithm (this can be done
using tools like `memory_profiler` in Python or similar tools in other
languages).
Binary search will require additional memory if sorting is involved,
while linear search may have lower memory usage as it doesn't require
sorting.
4. Usability (User Experience) :
Goal : The results should be usable and practical for people who are
sick or paralyzed.
How to Measure :
Relevance : Evaluate whether the search results are relevant and
useful (i.e., whether the algorithm reliably finds affordable medicines with
free delivery).
Simplicity : Consider whether the algorithm delivers clear and
understandable results, ensuring that the users get the medicines they
need quickly and easily.
Personalization : You can measure how well the algorithm adapts to
additional user preferences, such as prioritizing certain brands or faster
delivery options.
5. Algorithm Robustness (Handling Real Life Constraints):
Goal : The algorithm should handle real life constraints, such as stock
availability, price fluctuations, or delivery eligibility.
How to Measure :
Test how well each algorithm performs under changing conditions
(e.g., adding/removing medicines, adjusting prices, or delivery options).
Measure the algorithm’s ability to adapt and consistently provide
relevant results when the dataset changes dynamically.
Check how well it handles edge cases (e.g., when no medicine
matches the criteria or when there are ties in pricing).
6. User Centered Outcomes :
Goal : The algorithm should improve accessibility for users who are
sick or paralyzed.
How to Measure :
Conduct user testing with real or simulated feedback from the target
group (e.g., users who are sick or paralyzed) to determine how well the
algorithm meets their needs.
Measure user satisfaction with the simplicity and effectiveness of the
system, especially in terms of finding the right medicine with minimal
effort.
7. Result Diversity :
Goal : The algorithm should provide multiple options (if available) so
users can make informed choices.
How to Measure :
Track how often the algorithm provides a list of relevant options,
especially when several medicines fit the affordability and free delivery
criteria.
Evaluate if the algorithm shows diverse results that meet the user's
needs, beyond just returning the cheapest option.
8. Cost Benefit Analysis
Goal : The algorithm should balance speed and accuracy with cost
effectiveness for users (i.e., how affordable the medicine is).
How to Measure :
Compare the overall cost of medicines found by each algorithm,
focusing on whether the algorithm consistently finds lower cost
medicines.
Consider the algorithm’s ability to find not only the cheapest medicine
but also those with extra value (e.g., free delivery, faster shipping).
Conclusion:
To measure the quality of results for your problem, focus on:
1. Correctness : Does the algorithm find the lowest priced medicine
with free delivery?
2. Time Efficiency : How fast is the search for different dataset sizes?
3. Usability : Are the results relevant, user friendly, and helpful for the
target group?
4. Adaptability : Can the algorithm handle real life constraints like
price changes or stock fluctuations?
-By implement both algorithms (Linear and Binary Search), we can run
tests across different datasets and measure these aspects to determine
which algorithm is better suitable for our situation.
Q 4-WHAT WILL BE YOUR RESULTS? DISCUSS IN TERMS OF
QUANTITATIVE AND QUALITATIVE ?
ANS-Let's analyze the qualitative and quantitative results of your
project—using Linear Search and Binary Search to help sick or paralyzed users find
affordable medicines with free delivery from Amazon.
Qualitative Analysis
1. Correctness and Relevance:
- Linear Search:
Since it checks both price and free delivery in a single pass, it guarantees that the
correct result will always be found—i.e., the medicine with the lowest price that also
offers free delivery. The algorithm is highly reliable in handling multiple criteria.
- Binary Search:
While it’s fast in finding the cheapest item in sorted data, its correctness depends on
sorting the data first. Additionally, after finding the lowest price, Binary Search has to
check for free delivery, adding complexity. If there are multiple matches with the
same price, it may not prioritize free delivery as efficiently as Linear Search.
Conclusion:
For this specific problem, Linear Search ensures better correctness and
relevance since it can directly consider both conditions (price and free delivery) at
once.
2.Usability:
- Linear Search :
Simple and intuitive, making it user-friendly. It doesn’t require data to be
pre-processed or sorted, which can be advantageous in real-world applications
where data is often unsorted and dynamic.
- Binary Search :
Requires the dataset to be sorted, which adds a layer of complexity. For a
user-friendly application, this could increase the time it takes for users to get results
if data needs to be processed every time.
Conclusion :
In terms of usability, Linear Search is simpler and better suited for
real-world scenarios, especially when flexibility is needed.
3.Flexibility:
- Linear Search :
Handles additional criteria (like free delivery) naturally. It can easily be extended to
include more filters (e.g., delivery time, brand preference) without significant changes
to the algorithm.
- Binary Search:
Less flexible in handling multiple criteria since it focuses primarily on one attribute
(price). Applying other filters like free delivery adds complexity.
Conclusion: Linear Search is more flexible and adaptable, which is
important for real-life applications involving multiple constraints.
Quantitative Analysis
1. Time Complexity:
- Linear Search:
Time complexity is ( O(n) ), where ( n ) is the number of medicines in the dataset. It
performs well for small to medium datasets but may slow down with very large
datasets.
- Binary Search :
After sorting the data (which takes ( O(n log n) ) time), Binary Search has a time
complexity of O(log n) . While searching is faster after sorting, the sorting step can
add significant overhead, especially when the data is large or frequently updated.
Conclusion:
Binary Search offers better theoretical time complexity for searching, but the
sorting step can slow things down. Linear Search is more practical for
unsorted or small datasets.
2. Performance Measurement (in seconds) :
After implementing and testing the algorithms with simulated datasets, we might
observe:
- For small datasets (e.g., fewer than 10 items):
- Linear Search : Runs in microseconds to milliseconds.
- Binary Search : Slightly slower due to the need for sorting, though
searching after sorting is fast.
- For large datasets (e.g., 1,000 to 10,000 items):
- Linear Search : Performance may degrade as \( O(n) \) increases
linearly with dataset size.
- Binary Search : Performs well, especially once the dataset is sorted,
as \( O(\log n) \) handles large inputs more efficiently.
Conclusion :
Binary Search is more efficient for large, sorted datasets, but Linear Search
is preferable when dealing with unsorted data and multiple constraints.
3. Memory Usage:
- Linear Search : Requires minimal additional memory as it works directly on
the unsorted dataset, using \( O(1) \) extra space.
- Binary Search: May require additional memory for sorting, depending on the
sorting algorithm. In the worst case, this can result in \( O(n) \) extra space,
especially for complex sorting techniques.
Conclusion: Linear Search is more memory-efficient, particularly in cases
where the dataset is unsorted or when frequent updates are needed.
4. Scalability :
- Linear Search:
As the dataset grows, the search time increases linearly. It scales well for small to
medium datasets but may become inefficient for very large datasets.
- Binary Search:
After sorting, it scales well for large datasets due to the \( O(\log n) \) complexity.
However, frequent sorting makes it less scalable for dynamic datasets where data
changes often.
Conclusion:
Binary Search is more scalable in terms of searching large, static datasets, but
Linear Search scales better when frequent data updates and multiple filters are
involved.
Overall Result:
- For Small to Medium Datasets (Practical Context) :
- Linear Search is the preferred algorithm, as it handles both the criteria
(price and free delivery) easily, with better usability and flexibility. In scenarios where
the dataset is unsorted and dynamic (as is often the case in real life), Linear Search
offers simplicity without the overhead of sorting.
- For Large, Static Datasets (Theoretical Context):
- Binary Search may be better suited for very large datasets that are
sorted and static. However, the need for sorting and handling additional constraints
(like free delivery) limits its practical use in dynamic, multi-constraint scenarios like
yours.
Key Takeaways :
1. Linear Search is best for our problem since it handles multiple conditions
and unsorted data, providing more flexibility and usability for the target audience
(sick or paralyzed users).
2. Binary Search offers theoretical efficiency for large datasets but involves
additional complexity, especially with sorting and handling constraints like free
delivery.
Final Recommendation:
For a practical, user-friendly solution aimed at sick or paralyzed users,
Linear Search is more appropriate due to its simplicity, flexibility, and ability to handle
real-world, multi-criteria searches effectively.