SlideShare a Scribd company logo
1 of 28
GROUP MEMBERS
▪ Ali Raza (006)
▪ Zain UL Abideen (048)
▪ Usama Gulraiz (050)
▪ Usama Bin Khalid (060)
DESIGNING
ALGORITHMS USING
DIVIDE AND CONQUER
APPROACH
Submitted to:
Sir Zubair Tahir
What Is Algorithm?
ALGORITHM
DEFINITION:
An Algorithm is a set of finite instructions that can be
written in any simple language even in English.
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.
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
WHAT IS A DIVIDE AND CONQUER?
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.
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.
WORKING DIAGRAM:
WHAT IS THE PURPOSE OF DIVIDE AND
CONQUER ALGORITHMS ?
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
IMPLEMENTATION OF DIVIDE
AND CONQUER
IMPLEMENTATION OF DIVIDE AND
CONQUER :
Sorting
Types:
▪ Merge Sort
▪ Quick Sort
Searching
Type:
▪ Binary Search
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.
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
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
MERGE SORT WORKING DIAGRAM:
8 3 2 9 7 1 5 4
8 3 2 9 7 1 5 4
8 3 2 9 7 1 5 4
8 3 2 9 7 1 5 4
3 8 2 9 1 7 4 5
2 3 8 9 1 4 5 7
1 2 3 4 5 7 8 9
HOW MERGE SORT WORKS WITH
EXAMPLE
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.
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
HOW WORKS QUICK SORT
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.
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.
Algorithm and Graphical Representation
Designing Algorithms using Divide and Conquer Approach

More Related Content

What's hot

Data structure and its types
Data structure and its typesData structure and its types
Data structure and its types
Navtar Sidhu Brar
 

What's hot (20)

Radix and Shell sort
Radix and Shell sortRadix and Shell sort
Radix and Shell sort
 
Elementary data structure
Elementary data structureElementary data structure
Elementary data structure
 
Shellshort ppt
Shellshort pptShellshort ppt
Shellshort ppt
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 
Introduction To Data Structures.
Introduction To Data Structures.Introduction To Data Structures.
Introduction To Data Structures.
 
Bca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structureBca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structure
 
Data structures project
Data structures projectData structures project
Data structures project
 
Data structures using c
Data structures using cData structures using c
Data structures using c
 
Data structure and its types
Data structure and its typesData structure and its types
Data structure and its types
 
Introduction to Data Structure
Introduction to Data Structure Introduction to Data Structure
Introduction to Data Structure
 
Lecture 1 and 2
Lecture 1 and 2Lecture 1 and 2
Lecture 1 and 2
 
Data structures Basics
Data structures BasicsData structures Basics
Data structures Basics
 
Introduction to data structure
Introduction to data structure Introduction to data structure
Introduction to data structure
 
Radix and shell sort
Radix and shell sortRadix and shell sort
Radix and shell sort
 
Data Structures (BE)
Data Structures (BE)Data Structures (BE)
Data Structures (BE)
 
Data structure
Data structureData structure
Data structure
 
Data structure
Data structureData structure
Data structure
 
Introduction to data structure by anil dutt
Introduction to data structure by anil duttIntroduction to data structure by anil dutt
Introduction to data structure by anil dutt
 
Shell Sort and Selection Sort Algorithm
Shell Sort and Selection Sort AlgorithmShell Sort and Selection Sort Algorithm
Shell Sort and Selection Sort Algorithm
 

Similar to Designing Algorithms using Divide and Conquer Approach

Similar to Designing Algorithms using Divide and Conquer Approach (20)

Basic terminologies & asymptotic notations
Basic terminologies & asymptotic notationsBasic terminologies & asymptotic notations
Basic terminologies & asymptotic notations
 
ADS Introduction
ADS IntroductionADS Introduction
ADS Introduction
 
Data Structures 6
Data Structures 6Data Structures 6
Data Structures 6
 
Algorithms and Data Structures
Algorithms and Data StructuresAlgorithms and Data Structures
Algorithms and Data Structures
 
Algorithm analysis (All in one)
Algorithm analysis (All in one)Algorithm analysis (All in one)
Algorithm analysis (All in one)
 
Algorithms 1
Algorithms 1Algorithms 1
Algorithms 1
 
data_structure_Chapter two_computer.pptx
data_structure_Chapter two_computer.pptxdata_structure_Chapter two_computer.pptx
data_structure_Chapter two_computer.pptx
 
Binary Sort
Binary SortBinary Sort
Binary Sort
 
Alogorithm ppr slideshow
Alogorithm ppr slideshowAlogorithm ppr slideshow
Alogorithm ppr slideshow
 
Presentation merge sort.pptx
Presentation merge sort.pptxPresentation merge sort.pptx
Presentation merge sort.pptx
 
CPP12 - Algorithms
CPP12 - AlgorithmsCPP12 - Algorithms
CPP12 - Algorithms
 
Data structure Unit-I Part A
Data structure Unit-I Part AData structure Unit-I Part A
Data structure Unit-I Part A
 
Searching Algorithms
Searching AlgorithmsSearching Algorithms
Searching Algorithms
 
Data structures and algorithms Module-1.pdf
Data structures and algorithms Module-1.pdfData structures and algorithms Module-1.pdf
Data structures and algorithms Module-1.pdf
 
Three steps to untangle data traffic jams
Three steps to untangle data traffic jamsThree steps to untangle data traffic jams
Three steps to untangle data traffic jams
 
Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Spars...
Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Spars...Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Spars...
Unit I- Data structures Introduction, Evaluation of Algorithms, Arrays, Spars...
 
DSJ_Unit I & II.pdf
DSJ_Unit I & II.pdfDSJ_Unit I & II.pdf
DSJ_Unit I & II.pdf
 
Data structure and algorithm.
Data structure and algorithm. Data structure and algorithm.
Data structure and algorithm.
 
Data Structure and Algorithms
Data Structure and AlgorithmsData Structure and Algorithms
Data Structure and Algorithms
 
Rahat & juhith
Rahat & juhithRahat & juhith
Rahat & juhith
 

Recently uploaded

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 

Recently uploaded (20)

%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 

Designing Algorithms using Divide and Conquer Approach

  • 1.
  • 2. GROUP MEMBERS ▪ Ali Raza (006) ▪ Zain UL Abideen (048) ▪ Usama Gulraiz (050) ▪ Usama Bin Khalid (060)
  • 3. DESIGNING ALGORITHMS USING DIVIDE AND CONQUER APPROACH Submitted to: Sir Zubair Tahir
  • 5. ALGORITHM DEFINITION: An Algorithm is a set of finite instructions that can be written in any simple language even in English.
  • 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
  • 8. WHAT IS A DIVIDE AND CONQUER?
  • 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
  • 19. MERGE SORT WORKING DIAGRAM: 8 3 2 9 7 1 5 4 8 3 2 9 7 1 5 4 8 3 2 9 7 1 5 4 8 3 2 9 7 1 5 4 3 8 2 9 1 7 4 5 2 3 8 9 1 4 5 7 1 2 3 4 5 7 8 9
  • 20. HOW MERGE SORT WORKS WITH EXAMPLE
  • 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.
  • 26.
  • 27. Algorithm and Graphical Representation