SlideShare a Scribd company logo
1 of 3
Download to read offline
Maxima Finding problem: In the 2-dimension space, we shall say that a point A=(A1,A2)
dominates a point B=(b1,B2) if A1>B1 and A2>B2. Design an algorithm to find all maximal
points
Solution
we will use a divide and conquer algorithm of O(n log n) complexity which is merge sort.This
will ensure that each recursive call marks the maximal points among those that it is returning, or
return the maximal points as an additional part of the return value, and produce a merged and
corrected list of maximal points, in order, for its caller.The merge sort can be implemented in
c++
MERGE SORT:
/*This is basically a helper function which is used for finding the maximum of two numbers */
int maximum(int x, int y)
{
if(x > y)
{
return x;
}
else
{
return y;
}
}
/* The left is defined as the index of the leftmost element of the subarray;
On the other hand the right is one past the index of the rightmost element */
void merge_helper_function(int *input, int left, int right, int *scratch1)
{
/* This is the base case: one element */
if(right == left + 1)
{
return;
}
else
{
int i = 0;
int length = right - left;
int midpoint_distance = length/2;
/* The l and r are to the positions in the left and right subarrays */
int l = left, r = left + midpoint_distance;
/* now we will sort each subarray */
merge_helper)function(input, left, left + midpoint_distance, scratch);
merge_helper_function(input, left + midpoint_distance, right, scratch);
/* Finally we will merge the arrays together using scratch for temporary storage */
for(i = 0; i < length; i++)
{
/* First we will check to see if any elements remain in the left array; if so,
The next we check if there are any elements left in the right array; if so, we compare
them. Otherwise, we know that the merge must
* use take the element from the left array */
if(l < left + midpoint_distance &&
(r == right || maximum(input[l], input[r]) == input[l]))
{
scratch1[i] = input[l];
l++;
}
else
{
scratch1[i] = input[r];
r++;
}
}
/*Finally we copy the sorted subarray back to the input */
for(i = left; i < right; i++)
{
input[i] = scratch1[i - left];
}
}
}
/*The mergesort function returns true on success
*/
int mergesortfunction(int *input, int size)
{
int *scratchone = (int *)malloc(size * sizeof(int));
if(scratchone != NULL)
{
merge_helper_function(input, 0, size, scratchone);
free(scratchone);
return 1;
}
else
{
return 0;
}
}

More Related Content

Similar to Maxima Finding problem In the 2-dimension space, we shall say that .pdf

C programming assignment help
C programming assignment helpC programming assignment help
C programming assignment helpHebrew Johnson
 
data structures and algorithms Unit 3
data structures and algorithms Unit 3data structures and algorithms Unit 3
data structures and algorithms Unit 3infanciaj
 
Given below is the completed code along with comments. Output of the.pdf
Given below is the completed code along with comments. Output of the.pdfGiven below is the completed code along with comments. Output of the.pdf
Given below is the completed code along with comments. Output of the.pdfaparnacollection
 
The language is C. Thanks. Write a function that computes the intege.pdf
The language is C. Thanks. Write a function that computes the intege.pdfThe language is C. Thanks. Write a function that computes the intege.pdf
The language is C. Thanks. Write a function that computes the intege.pdfforwardcom41
 
Please help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfPlease help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfankit11134
 
Data structures arrays
Data structures   arraysData structures   arrays
Data structures arraysmaamir farooq
 
Step 1 Implement the getSortedRunLength() methodImplement the get.pdf
Step 1 Implement the getSortedRunLength() methodImplement the get.pdfStep 1 Implement the getSortedRunLength() methodImplement the get.pdf
Step 1 Implement the getSortedRunLength() methodImplement the get.pdfaloeplusint
 
USING JAVAThere are at least two types of nearly sorted array.pdf
USING JAVAThere are at least two types of nearly sorted array.pdfUSING JAVAThere are at least two types of nearly sorted array.pdf
USING JAVAThere are at least two types of nearly sorted array.pdflohithkart
 
هياكلبيانات
هياكلبياناتهياكلبيانات
هياكلبياناتRafal Edward
 
Merge Sort implementation in C++ The implementation for Mergesort gi.pdf
Merge Sort implementation in C++ The implementation for Mergesort gi.pdfMerge Sort implementation in C++ The implementation for Mergesort gi.pdf
Merge Sort implementation in C++ The implementation for Mergesort gi.pdfmdameer02
 
DATA STRUCTURE CLASS 12 COMPUTER SCIENCE
DATA STRUCTURE CLASS 12 COMPUTER SCIENCEDATA STRUCTURE CLASS 12 COMPUTER SCIENCE
DATA STRUCTURE CLASS 12 COMPUTER SCIENCEDev Chauhan
 
#include fstream#include iostream#include cstdlib#includ.docx
#include fstream#include iostream#include cstdlib#includ.docx#include fstream#include iostream#include cstdlib#includ.docx
#include fstream#include iostream#include cstdlib#includ.docxajoy21
 
Part 1)#include stdio.h #include stdlib.h #include pthrea.pdf
Part 1)#include stdio.h #include stdlib.h #include pthrea.pdfPart 1)#include stdio.h #include stdlib.h #include pthrea.pdf
Part 1)#include stdio.h #include stdlib.h #include pthrea.pdfmohammadirfan136964
 
Data Structures Design Notes.pdf
Data Structures Design Notes.pdfData Structures Design Notes.pdf
Data Structures Design Notes.pdfAmuthachenthiruK
 
Quicksort AlgorithmQuicksort is a divide and conquer algorithm. Q.pdf
Quicksort AlgorithmQuicksort is a divide and conquer algorithm. Q.pdfQuicksort AlgorithmQuicksort is a divide and conquer algorithm. Q.pdf
Quicksort AlgorithmQuicksort is a divide and conquer algorithm. Q.pdfanupamfootwear
 
Can you give an example of a binary heap programCan you give an .pdf
Can you give an example of a binary heap programCan you give an .pdfCan you give an example of a binary heap programCan you give an .pdf
Can you give an example of a binary heap programCan you give an .pdfarorasales234
 
Use Applicative where applicable!
Use Applicative where applicable!Use Applicative where applicable!
Use Applicative where applicable!Hermann Hueck
 

Similar to Maxima Finding problem In the 2-dimension space, we shall say that .pdf (20)

C programming assignment help
C programming assignment helpC programming assignment help
C programming assignment help
 
data structures and algorithms Unit 3
data structures and algorithms Unit 3data structures and algorithms Unit 3
data structures and algorithms Unit 3
 
Given below is the completed code along with comments. Output of the.pdf
Given below is the completed code along with comments. Output of the.pdfGiven below is the completed code along with comments. Output of the.pdf
Given below is the completed code along with comments. Output of the.pdf
 
The language is C. Thanks. Write a function that computes the intege.pdf
The language is C. Thanks. Write a function that computes the intege.pdfThe language is C. Thanks. Write a function that computes the intege.pdf
The language is C. Thanks. Write a function that computes the intege.pdf
 
Please help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfPlease help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdf
 
Merge radix-sort-algorithm
Merge radix-sort-algorithmMerge radix-sort-algorithm
Merge radix-sort-algorithm
 
Merge radix-sort-algorithm
Merge radix-sort-algorithmMerge radix-sort-algorithm
Merge radix-sort-algorithm
 
Data structures arrays
Data structures   arraysData structures   arrays
Data structures arrays
 
Step 1 Implement the getSortedRunLength() methodImplement the get.pdf
Step 1 Implement the getSortedRunLength() methodImplement the get.pdfStep 1 Implement the getSortedRunLength() methodImplement the get.pdf
Step 1 Implement the getSortedRunLength() methodImplement the get.pdf
 
USING JAVAThere are at least two types of nearly sorted array.pdf
USING JAVAThere are at least two types of nearly sorted array.pdfUSING JAVAThere are at least two types of nearly sorted array.pdf
USING JAVAThere are at least two types of nearly sorted array.pdf
 
هياكلبيانات
هياكلبياناتهياكلبيانات
هياكلبيانات
 
Merge Sort implementation in C++ The implementation for Mergesort gi.pdf
Merge Sort implementation in C++ The implementation for Mergesort gi.pdfMerge Sort implementation in C++ The implementation for Mergesort gi.pdf
Merge Sort implementation in C++ The implementation for Mergesort gi.pdf
 
DATA STRUCTURE CLASS 12 COMPUTER SCIENCE
DATA STRUCTURE CLASS 12 COMPUTER SCIENCEDATA STRUCTURE CLASS 12 COMPUTER SCIENCE
DATA STRUCTURE CLASS 12 COMPUTER SCIENCE
 
#include fstream#include iostream#include cstdlib#includ.docx
#include fstream#include iostream#include cstdlib#includ.docx#include fstream#include iostream#include cstdlib#includ.docx
#include fstream#include iostream#include cstdlib#includ.docx
 
Part 1)#include stdio.h #include stdlib.h #include pthrea.pdf
Part 1)#include stdio.h #include stdlib.h #include pthrea.pdfPart 1)#include stdio.h #include stdlib.h #include pthrea.pdf
Part 1)#include stdio.h #include stdlib.h #include pthrea.pdf
 
Data Structures Design Notes.pdf
Data Structures Design Notes.pdfData Structures Design Notes.pdf
Data Structures Design Notes.pdf
 
Quicksort AlgorithmQuicksort is a divide and conquer algorithm. Q.pdf
Quicksort AlgorithmQuicksort is a divide and conquer algorithm. Q.pdfQuicksort AlgorithmQuicksort is a divide and conquer algorithm. Q.pdf
Quicksort AlgorithmQuicksort is a divide and conquer algorithm. Q.pdf
 
Heap, quick and merge sort
Heap, quick and merge sortHeap, quick and merge sort
Heap, quick and merge sort
 
Can you give an example of a binary heap programCan you give an .pdf
Can you give an example of a binary heap programCan you give an .pdfCan you give an example of a binary heap programCan you give an .pdf
Can you give an example of a binary heap programCan you give an .pdf
 
Use Applicative where applicable!
Use Applicative where applicable!Use Applicative where applicable!
Use Applicative where applicable!
 

More from arrowit1

If the proportion of an African population that are susceptible to M.pdf
If the proportion of an African population that are susceptible to M.pdfIf the proportion of an African population that are susceptible to M.pdf
If the proportion of an African population that are susceptible to M.pdfarrowit1
 
How have a rock that was formed at the same time as the Earth was fo.pdf
How have a rock that was formed at the same time as the Earth was fo.pdfHow have a rock that was formed at the same time as the Earth was fo.pdf
How have a rock that was formed at the same time as the Earth was fo.pdfarrowit1
 
help me to find a research article on a topic related to plant bodie.pdf
help me to find a research article on a topic related to plant bodie.pdfhelp me to find a research article on a topic related to plant bodie.pdf
help me to find a research article on a topic related to plant bodie.pdfarrowit1
 
Google the four Characteristics of the Climate at Whirlpool, and pos.pdf
Google the four Characteristics of the Climate at Whirlpool, and pos.pdfGoogle the four Characteristics of the Climate at Whirlpool, and pos.pdf
Google the four Characteristics of the Climate at Whirlpool, and pos.pdfarrowit1
 
How do you describe your ethnicity Do you include your family’s cou.pdf
How do you describe your ethnicity Do you include your family’s cou.pdfHow do you describe your ethnicity Do you include your family’s cou.pdf
How do you describe your ethnicity Do you include your family’s cou.pdfarrowit1
 
How are spores produced by seed plants different than those of Bryoph.pdf
How are spores produced by seed plants different than those of Bryoph.pdfHow are spores produced by seed plants different than those of Bryoph.pdf
How are spores produced by seed plants different than those of Bryoph.pdfarrowit1
 
Find the vertex, focus, and directrix of the parabola. Graph the equ.pdf
Find the vertex, focus, and directrix of the parabola. Graph the equ.pdfFind the vertex, focus, and directrix of the parabola. Graph the equ.pdf
Find the vertex, focus, and directrix of the parabola. Graph the equ.pdfarrowit1
 
Exercise 1-7 Identifying accounting principles and assumptions LO C4 .pdf
Exercise 1-7 Identifying accounting principles and assumptions LO C4 .pdfExercise 1-7 Identifying accounting principles and assumptions LO C4 .pdf
Exercise 1-7 Identifying accounting principles and assumptions LO C4 .pdfarrowit1
 
A plant has a unique photosynthetic plagment. The leaves of this pl.pdf
A plant has a unique photosynthetic plagment. The leaves of this pl.pdfA plant has a unique photosynthetic plagment. The leaves of this pl.pdf
A plant has a unique photosynthetic plagment. The leaves of this pl.pdfarrowit1
 
____ 1. Lymph nodules found in the ileum____ 2. Responsible for bi.pdf
____ 1. Lymph nodules found in the ileum____ 2. Responsible for bi.pdf____ 1. Lymph nodules found in the ileum____ 2. Responsible for bi.pdf
____ 1. Lymph nodules found in the ileum____ 2. Responsible for bi.pdfarrowit1
 
Write the correct master horizon designation (e.g. A, E, etc.) for t.pdf
Write the correct master horizon designation (e.g. A, E, etc.) for t.pdfWrite the correct master horizon designation (e.g. A, E, etc.) for t.pdf
Write the correct master horizon designation (e.g. A, E, etc.) for t.pdfarrowit1
 
SQL FILE FROM MOODLEUSE [master]GO Object Databa.pdf
SQL FILE FROM MOODLEUSE [master]GO Object Databa.pdfSQL FILE FROM MOODLEUSE [master]GO Object Databa.pdf
SQL FILE FROM MOODLEUSE [master]GO Object Databa.pdfarrowit1
 
Which of the following statements most accurately reflects the effec.pdf
Which of the following statements most accurately reflects the effec.pdfWhich of the following statements most accurately reflects the effec.pdf
Which of the following statements most accurately reflects the effec.pdfarrowit1
 
Which of the following is (are) a primary focus of public health inf.pdf
Which of the following is (are) a primary focus of public health inf.pdfWhich of the following is (are) a primary focus of public health inf.pdf
Which of the following is (are) a primary focus of public health inf.pdfarrowit1
 
Which of the following is NOT an activity of descriptive epidemiology.pdf
Which of the following is NOT an activity of descriptive epidemiology.pdfWhich of the following is NOT an activity of descriptive epidemiology.pdf
Which of the following is NOT an activity of descriptive epidemiology.pdfarrowit1
 
What is the view of General Billy Mitchell about ‘air power’Sol.pdf
What is the view of General Billy Mitchell about ‘air power’Sol.pdfWhat is the view of General Billy Mitchell about ‘air power’Sol.pdf
What is the view of General Billy Mitchell about ‘air power’Sol.pdfarrowit1
 
what additional component associated with outer skin epithelium is n.pdf
what additional component associated with outer skin epithelium is n.pdfwhat additional component associated with outer skin epithelium is n.pdf
what additional component associated with outer skin epithelium is n.pdfarrowit1
 
What is the effect of this function below, assuming that a is an .pdf
What is the effect of this function below, assuming that a is an .pdfWhat is the effect of this function below, assuming that a is an .pdf
What is the effect of this function below, assuming that a is an .pdfarrowit1
 
unix classesTask 3 (20 points)Write a bash program sort.sh to so.pdf
unix classesTask 3 (20 points)Write a bash program sort.sh to so.pdfunix classesTask 3 (20 points)Write a bash program sort.sh to so.pdf
unix classesTask 3 (20 points)Write a bash program sort.sh to so.pdfarrowit1
 
Reference Health Law and EthicsAnalyze the impact the affordable c.pdf
Reference Health Law and EthicsAnalyze the impact the affordable c.pdfReference Health Law and EthicsAnalyze the impact the affordable c.pdf
Reference Health Law and EthicsAnalyze the impact the affordable c.pdfarrowit1
 

More from arrowit1 (20)

If the proportion of an African population that are susceptible to M.pdf
If the proportion of an African population that are susceptible to M.pdfIf the proportion of an African population that are susceptible to M.pdf
If the proportion of an African population that are susceptible to M.pdf
 
How have a rock that was formed at the same time as the Earth was fo.pdf
How have a rock that was formed at the same time as the Earth was fo.pdfHow have a rock that was formed at the same time as the Earth was fo.pdf
How have a rock that was formed at the same time as the Earth was fo.pdf
 
help me to find a research article on a topic related to plant bodie.pdf
help me to find a research article on a topic related to plant bodie.pdfhelp me to find a research article on a topic related to plant bodie.pdf
help me to find a research article on a topic related to plant bodie.pdf
 
Google the four Characteristics of the Climate at Whirlpool, and pos.pdf
Google the four Characteristics of the Climate at Whirlpool, and pos.pdfGoogle the four Characteristics of the Climate at Whirlpool, and pos.pdf
Google the four Characteristics of the Climate at Whirlpool, and pos.pdf
 
How do you describe your ethnicity Do you include your family’s cou.pdf
How do you describe your ethnicity Do you include your family’s cou.pdfHow do you describe your ethnicity Do you include your family’s cou.pdf
How do you describe your ethnicity Do you include your family’s cou.pdf
 
How are spores produced by seed plants different than those of Bryoph.pdf
How are spores produced by seed plants different than those of Bryoph.pdfHow are spores produced by seed plants different than those of Bryoph.pdf
How are spores produced by seed plants different than those of Bryoph.pdf
 
Find the vertex, focus, and directrix of the parabola. Graph the equ.pdf
Find the vertex, focus, and directrix of the parabola. Graph the equ.pdfFind the vertex, focus, and directrix of the parabola. Graph the equ.pdf
Find the vertex, focus, and directrix of the parabola. Graph the equ.pdf
 
Exercise 1-7 Identifying accounting principles and assumptions LO C4 .pdf
Exercise 1-7 Identifying accounting principles and assumptions LO C4 .pdfExercise 1-7 Identifying accounting principles and assumptions LO C4 .pdf
Exercise 1-7 Identifying accounting principles and assumptions LO C4 .pdf
 
A plant has a unique photosynthetic plagment. The leaves of this pl.pdf
A plant has a unique photosynthetic plagment. The leaves of this pl.pdfA plant has a unique photosynthetic plagment. The leaves of this pl.pdf
A plant has a unique photosynthetic plagment. The leaves of this pl.pdf
 
____ 1. Lymph nodules found in the ileum____ 2. Responsible for bi.pdf
____ 1. Lymph nodules found in the ileum____ 2. Responsible for bi.pdf____ 1. Lymph nodules found in the ileum____ 2. Responsible for bi.pdf
____ 1. Lymph nodules found in the ileum____ 2. Responsible for bi.pdf
 
Write the correct master horizon designation (e.g. A, E, etc.) for t.pdf
Write the correct master horizon designation (e.g. A, E, etc.) for t.pdfWrite the correct master horizon designation (e.g. A, E, etc.) for t.pdf
Write the correct master horizon designation (e.g. A, E, etc.) for t.pdf
 
SQL FILE FROM MOODLEUSE [master]GO Object Databa.pdf
SQL FILE FROM MOODLEUSE [master]GO Object Databa.pdfSQL FILE FROM MOODLEUSE [master]GO Object Databa.pdf
SQL FILE FROM MOODLEUSE [master]GO Object Databa.pdf
 
Which of the following statements most accurately reflects the effec.pdf
Which of the following statements most accurately reflects the effec.pdfWhich of the following statements most accurately reflects the effec.pdf
Which of the following statements most accurately reflects the effec.pdf
 
Which of the following is (are) a primary focus of public health inf.pdf
Which of the following is (are) a primary focus of public health inf.pdfWhich of the following is (are) a primary focus of public health inf.pdf
Which of the following is (are) a primary focus of public health inf.pdf
 
Which of the following is NOT an activity of descriptive epidemiology.pdf
Which of the following is NOT an activity of descriptive epidemiology.pdfWhich of the following is NOT an activity of descriptive epidemiology.pdf
Which of the following is NOT an activity of descriptive epidemiology.pdf
 
What is the view of General Billy Mitchell about ‘air power’Sol.pdf
What is the view of General Billy Mitchell about ‘air power’Sol.pdfWhat is the view of General Billy Mitchell about ‘air power’Sol.pdf
What is the view of General Billy Mitchell about ‘air power’Sol.pdf
 
what additional component associated with outer skin epithelium is n.pdf
what additional component associated with outer skin epithelium is n.pdfwhat additional component associated with outer skin epithelium is n.pdf
what additional component associated with outer skin epithelium is n.pdf
 
What is the effect of this function below, assuming that a is an .pdf
What is the effect of this function below, assuming that a is an .pdfWhat is the effect of this function below, assuming that a is an .pdf
What is the effect of this function below, assuming that a is an .pdf
 
unix classesTask 3 (20 points)Write a bash program sort.sh to so.pdf
unix classesTask 3 (20 points)Write a bash program sort.sh to so.pdfunix classesTask 3 (20 points)Write a bash program sort.sh to so.pdf
unix classesTask 3 (20 points)Write a bash program sort.sh to so.pdf
 
Reference Health Law and EthicsAnalyze the impact the affordable c.pdf
Reference Health Law and EthicsAnalyze the impact the affordable c.pdfReference Health Law and EthicsAnalyze the impact the affordable c.pdf
Reference Health Law and EthicsAnalyze the impact the affordable c.pdf
 

Recently uploaded

Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 

Recently uploaded (20)

Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 

Maxima Finding problem In the 2-dimension space, we shall say that .pdf

  • 1. Maxima Finding problem: In the 2-dimension space, we shall say that a point A=(A1,A2) dominates a point B=(b1,B2) if A1>B1 and A2>B2. Design an algorithm to find all maximal points Solution we will use a divide and conquer algorithm of O(n log n) complexity which is merge sort.This will ensure that each recursive call marks the maximal points among those that it is returning, or return the maximal points as an additional part of the return value, and produce a merged and corrected list of maximal points, in order, for its caller.The merge sort can be implemented in c++ MERGE SORT: /*This is basically a helper function which is used for finding the maximum of two numbers */ int maximum(int x, int y) { if(x > y) { return x; } else { return y; } } /* The left is defined as the index of the leftmost element of the subarray; On the other hand the right is one past the index of the rightmost element */ void merge_helper_function(int *input, int left, int right, int *scratch1) { /* This is the base case: one element */ if(right == left + 1) { return; } else {
  • 2. int i = 0; int length = right - left; int midpoint_distance = length/2; /* The l and r are to the positions in the left and right subarrays */ int l = left, r = left + midpoint_distance; /* now we will sort each subarray */ merge_helper)function(input, left, left + midpoint_distance, scratch); merge_helper_function(input, left + midpoint_distance, right, scratch); /* Finally we will merge the arrays together using scratch for temporary storage */ for(i = 0; i < length; i++) { /* First we will check to see if any elements remain in the left array; if so, The next we check if there are any elements left in the right array; if so, we compare them. Otherwise, we know that the merge must * use take the element from the left array */ if(l < left + midpoint_distance && (r == right || maximum(input[l], input[r]) == input[l])) { scratch1[i] = input[l]; l++; } else { scratch1[i] = input[r]; r++; } } /*Finally we copy the sorted subarray back to the input */ for(i = left; i < right; i++) { input[i] = scratch1[i - left]; } } } /*The mergesort function returns true on success */
  • 3. int mergesortfunction(int *input, int size) { int *scratchone = (int *)malloc(size * sizeof(int)); if(scratchone != NULL) { merge_helper_function(input, 0, size, scratchone); free(scratchone); return 1; } else { return 0; } }