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

Aoa Expt3

The document outlines an experiment focused on finding the minimum and maximum values in an array using the divide and conquer strategy. It details the objectives, expected outcomes, algorithmic steps, and applications of the method across various fields. The experiment aims to enhance algorithm design skills, analyze performance, and validate the correctness of the implemented algorithm.

Uploaded by

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

Aoa Expt3

The document outlines an experiment focused on finding the minimum and maximum values in an array using the divide and conquer strategy. It details the objectives, expected outcomes, algorithmic steps, and applications of the method across various fields. The experiment aims to enhance algorithm design skills, analyze performance, and validate the correctness of the implemented algorithm.

Uploaded by

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

Experiment No : 03

NAME: SAYALI KULKARNI


SE COMPS A
ROLL NO: 58
BATCH: C

Problem Statement: Finding out Minimum and Maximum using Divide and Conquer
Strategy.

Objective: 1. To introduce the methods of designing and analyzing


algorithms.
2. Design and implement efficient algorithms for a
specified application
3. Strengthen the ability to identify and apply the suitable
algorithm for the given real-world problem.
4. Analyze worst-case running time of algorithms and
understand fundamental algorithmic problems.
Expected Outcome: Expected Outcome:
 Algorithm Implementation: Successfully implement the
divide and conquer strategy to find both the minimum and
maximum numbers in a given array.
 Correctness Verification: Validate the algorithm's
correctness through rigorous testing with various input
sizes and types.
 Performance Analysis: Analyze the time complexity of the
algorithm and compare it with other approaches like linear
search to demonstrate efficiency.
Expected Learning:

 Understanding Divide and Conquer: Gain a deep


understanding of the divide and conquer strategy and its
application in solving computational problems.

 Algorithmic Problem Solving: Develop skills in


designing and implementing efficient algorithms to solve
specific problems.

 Critical Analysis: Evaluate the pros and cons of divide


and conquer compared to other algorithmic paradigms for
similar problems.

 Technical Writing: Enhance technical writing skills by


documenting the experiment, results, and conclusions
effectively.

Subject: CSL401-Analysis of Algorithm Lab Sem: IV(2023-24) Subject In-charge: Dr. Shaikh Phiroj
Theory:
Step-by-Step Algorithmic Explanation
Step 1: Base Case (Single Element)
 If the array contains only one element, the function returns that
element as both minimum and maximum.
 This serves as the base case for the recursive function.
Step 2: Divide the Array
 If the array has more than one element, it is split into two halves:
o The left half from low to mid
o The right half from mid + 1 to high
 The midpoint is calculated as: mid=low+high2mid = \frac{low +
high}{2}mid=2low+high
Step 3: Recursive Calls
 The algorithm recursively calls itself to find the min and max in both
halves:
o left = findMaxMin(arr, low, mid) → Finds min & max in the
left half.
o right = findMaxMin(arr, mid + 1, high) → Finds min & max
in the right half.
Step 4: Conquer (Merge the Results)
 Once the recursive calls return, the results are merged:
o The overall maximum is the greater of the left and right
maximum values:
result.max=max (left.max,right.max)result.max =
\max(left.max, right.max)result.max=max(left.max,right.max)
o The overall minimum is the smaller of the left and right
minimum values:
result.min=min (left.min,right.min)result.min =
\min(left.min, right.min)result.min=min(left.min,right.min)
Step 5: Return the Final Result
 The function returns the final result, which contains both:
o result.max → The maximum value in the entire array
o result.min → The minimum value in the entire array

Pseudo Code:
FUNCTION findMaxMin(arr, low, high)
DECLARE result, left, right

IF low == high THEN // Only one element


result.max = arr[low]
result.min = arr[low]
RETURN result

mid = (low + high) / 2 // Find the middle index

left = findMaxMin(arr, low, mid) // Recursively find min/max in left half


right = findMaxMin(arr, mid + 1, high) // Recursively find min/max in right
half

result.max = MAX(left.max, right.max) // Get the maximum of both halves


result.min = MIN(left.min, right.min) // Get the minimum of both halves

RETURN result

Subject: CSL401-Analysis of Algor ithm Lab Sem: IV(2023-24) Subject In-charge: Dr. Shaikh Phiroj
Algorithm: Function: findMaxMin (Recursive Approach)
1. Input: Array arr, indices low, and high.
2. Base Case:
o If low == high,
 Set result.max = arr[low]
 Set result.min = arr[low]
 Return result

3. Divide the Array:


o Compute mid = (low + high) / 2
o Recursively call findMaxMin(arr, low, mid) →
Stores result in left
o Recursively call findMaxMin(arr, mid + 1, high) →
Stores result in right
4. Merge the Results:
o Set result.max = max(left.max, right.max)
o Set result.min = min(left.min, right.min)
5. Return result (contains global max and min)

Program Code:

Subject: CSL401-Analysis of Algorithm Lab Sem: IV(2023-24) Subject In-charge: Dr. Shaikh Phiroj
Output Snapshot:

Application 1. Computer Science & Data Processing


 Sorting algorithms: Used as a subroutine in QuickSort
and MergeSort.
 Searching in large datasets: Helps in optimizing binary
search.
 Data analysis: Finding extreme values in datasets
(temperature, stock prices, etc.).
2 . Artificial Intelligence & Machine Learning
 Feature scaling: Min-max normalization in data
preprocessing.
 Anomaly detection: Identifying extreme values in sensor
readings.
3 . Image Processing
 Brightness correction: Detecting the darkest and
brightest pixels in an image.

Subject: CSL401-Analysis of Algorithm Lab Sem: IV(2023-24) Subject In-charge: Dr. Shaikh Phiroj
 Edge detection: Finding intensity peaks in pixel arrays.
4 . Network and Cybersecurity
 Load balancing: Identifying max-min load in distributed
systems.
 Traffic control: Finding highest and lowest network
speeds in real-time monitoring.
5 . Financial Applications
 Stock market analysis: Finding highest and lowest stock
values in a dataset.
 Risk assessment: Identifying extreme financial
transactions.
6 . Scientific Computing
 Climate and weather prediction: Identifying the hottest
and coldest days.
 Geographical data analysis: Finding highest mountains
and lowest valleys from elevation maps.

Outcome: 1. Correctly finds the minimum and maximum numbers


from the given input array.
2. Uses fewer comparisons than brute force (linear search
method).
3. Demonstrates the working of Divide and Conquer
strategy effectively.
4. Recursive approach reduces redundant operations and
optimizes the process.
5. Efficient for larger datasets compared to traditional
methods.

Subject: CSL401-Analysis of Algorithm Lab Sem: IV(2023-24) Subject In-charge: Dr. Shaikh Phiroj

You might also like