6. DETAIL
• Algorithm tells us the procedure that how the program will
work.
• It is commonly used for data processing, calculation and
other related computer and mathematical operations.
• An algorithm is also used to manipulate data in various
ways, such as inserting a new data item, searching for a
particular item or sorting an item.
7. CRITERIA OF ALGORITHM
• Input: Zero or more Input
• Output: Must produce output
• Finiteness: Must have ending
• Definiteness: Clear and Unambiguous
• Effectiveness: Every instruction should be clear, It
should not be complex
9. DIVIDE AND CONQUER:
Divide: Smaller problems are solved recursively
(except, of course, the base cases).
Conquer: The solution to the original problem is then
formed from the solutions to the subproblems.
10. THREE STEPS OF THE DIVIDE AND
CONQUER APPROACH
The most well known algorithm design strategy:
1. Divide the problem into two or more smaller
subproblems.
2. Conquer the subproblems by solving them
recursively.
3. Combine the solutions to the subproblems into the
solutions for the original problem.
12. WHAT IS THE PURPOSE OF DIVIDE AND
CONQUER ALGORITHMS ?
13. PURPOSE OF DIVIDE AND CONQUER
ALGORITHMS
The divide and conquer paradigm is often used to find the optimal
solution of a problem. Its basic idea is to decompose a given problem into
two or more similar, but simpler, sub problems, to solve them in turn, and
to compose their solutions to solve the given problem
15. IMPLEMENTATION OF DIVIDE AND
CONQUER :
Sorting
Types:
▪ Merge Sort
▪ Quick Sort
Searching
Type:
▪ Binary Search
16. SORTING ALGORITHMS:
In computer science, a sorting algorithm is an algorithm that puts
elements of a list in a certain order. The most frequently used orders are
numerical order.
17. MERGE SORT:
In computer science, Merge sort is a sorting technique based on divide
and conquer technique. With worst-case time complexity being Ο(n log n),
it is one of the most respected algorithms
18. MERGE SORT:
▪ Split array A[0..n-1] in two about equal halves and make copies of
each half in arrays B and C
▪ Sort arrays B and C recursively
▪ Merge sorted arrays B and C into array A
▪ All cases have same efficiency
21. QUICK SORT:
Quicksort is a popular sorting algorithm that is often faster in practice
compared to other sorting algorithms. It utilizes a divide-and-conquer
strategy to quickly sort data items by dividing a large array into two
smaller arrays. It was developed by Charles Antony Richard Hoare
commonly known as C.A.R.
22. ANALYSIS OF QUICK SORT:
Improvements:
▪ better pivot selection
▪ switch to insertion sort on small subfiles
▪ elimination of recursion
▪ Quicksort is considered the method of choice for internal sorting of
large files (n ≥ 10000)
▪ Sort the two sub-arrays recursively
24. SEARCHING ALGORITHMS:
A search algorithm is the step-by-step procedure used to locate
specific data among a collection of data. It is considered a
fundamental procedure in computing.
25. BINARY SEARCH:
Binary search compares the target value to the middle
element of the array. If they are not equal, the half in
which the target cannot lie is eliminated and the search
continues on the remaining half, again taking the
middle element to compare to the target value, and
repeating this until the target value is found.