SlideShare a Scribd company logo
1 of 7
CSC 440 Assignment 2: Convex Hull
Out: Tuesday, Feb 9th
Due: Monday, Feb 22nd, by 11:59PM
Introduction
In this assignment, you will be implementing a convex hull
algorithm. Specifically,
you must implement the divide-and-conquer algorithm for
computing a convex
hull.
You will be provided with a zip file on Sakai, convexhull.zip,
which contains a
GUI called draw_hull.py. This GUI allows you to click in a
window to add
points, click a button to compute and draw the convex hull
around those points
using the algorithm that you have implemented. note that the
“points” are
not points in the mathematical sense; They have some size to
them due to
implementation details of the GUI, so the convex hull actually
goes through
the center of each one. You can run this GUI by executing from
the terminal $
python draw_hull.py.
In the same zip file, there is some starter code in
convex_hull.py, which is the
file you will ultimately submit to GradeScope. It contains
several functions that
you will find useful (and should not modify). You will have to
implement the
compute_hull function which takes as input a list of points and
returns only
those points that are on the hull, in clockwise order. Currently,
compute_hull
is incorrect; it simply returns the input instead of the actual
convex hull.
In this implementation, we represent a point as a 2-tuple of
integers (x, y). As
is usually the case with computer graphics, the upper-left of the
drawing canvas
is the origin (0, 0), the positive x-axis is directed rightwards,
and the positive
y-axis is directed downwards. As a result of this, all coordinates
are positive in
this implementation.
You must implement compute_hull and then benchmark its
running
time.
You may write any helper functions and/or classes you deem
useful; they should
all live in convex_hull.py.
You should also write a separate function for your base case,
which should be
the naive algorithm. Call it whenever you need to compute the
hull on fewer
than something like 5 or 6 points.
1
You also need to benchmark you code. For this purpose, we
have provided some
starter code in benchmarks.py. Report the time taken by your
implementation
on inputs of various sizes. Draw a plot and discuss the shapes of
any curves that
you see.
I have given you some trickier functions for the trickier
geometric tasks, including
a function for sorting a set of points counter-clockwise. Even
without those,
what you still have to implement took me roughly 6 hours. Start
now.
For this assignment, your solution must be in
Python.
Pair Programming
You should work with a partner for this entire assignment.
Please refer to the
pair programming policy in the syllabus.
Lateness
Submissions will not be accepted after the due date, except with
the intervention
of the Dean’s Office in the case of serious medical, family, or
other personal
crises.
Grading Rubric
Your grade will be based on three components:
• Functional Correctness (50%)
• Design and Representation (15%)
• Invariant Documentation (10%)
• Benchmarking and Analysis (25%)
Functional Correctness means passing tests on GradeScope.
Remember
that your function compute_hull must return the points in the
convex hull in
clockwise order. We have provided you with a minimal test-
suite that uses the
hypothesis library for some automated testing. We do not
provide any specific
test cases, so woy would be wise to write some tests for
yourself. You should use
the GUI for small tests, and for building your intuition.
Note: you may modify draw_hull.py in any way you see fit to
assist with
debugging. That file need not be submitted to GradeScope.
Design and Representation is our evaluation of the structure of
your program,
the choice of representations (de-emphasized here because some
choices have
already been made for you), and the use of appropriate (not
excessive) comments.
2
Invariant Documentation is to get you to reason about the
correctness and
running-time of the algorithm.
• Invariant: A statement that can be checked at any point in
time. It should
relate to how the algorithm makes progress.
• Initialization: how is the problem set up
• Maintenance: how do I know I’m making progress?
• Termination: how do I know I’m done?
• Usually, these should be closely related.
• Properly documenting invariants can save you a great deal of
time thinking
about your algorithm.
• The wise lumberjack takes time to sharpen the axe.
Benchmarking and Analysis is similar to assignment 1. You
should include
a PDF in your upload to GradeScope, along with your code.
• You should not use the GUI for benchmarking. The GUI is
there for you
to play with, but proper benchmarking should be non-
interactive.
• You must also benchmark your base-case (which should
actually work for
any reasonably small number of points) and plot its running
time.
• Benchmark your implementation on a wide enough set of
inputs that you
can plot a meaningful curve.
• Write a brief summary of your benchmarking results. Do they
support
your expectation of the asymptotic complexity of this
algorithm? Why or
why not? What about the naive (base case) algorithm?
Tips and Pitfalls
• You may find it useful to modify draw_hull.py so that it puts
something
other than the Rams logo on the canvas. What data might be
more helpful
to you?
• One common pitfall is to end up with two points having the
same x-
coordinates in two different hulls. The merge algorithm will fail
in this
case! Make sure that this never happens when you divide an
input for the
recursive calls.
• Remember that the intercept between two parallel lines does
not exist. If
you’re seeing divide-by-zero errors, check this first.
• Your base case should work for any small-ish number of
points. You may
find it’s easier to stop the divide-and-conquer when you reach a
set of 5 or
6 points, rather than going all the way down to 3, as this can
help avoid
some difficult edge cases.
3
Property-based testing
This assignment can drive you insane because it can be hard to
reproduce a
failing test, and the auto-grader gives you little feedback.
Should you wish to preserve your sanity, use unit tests. I
recommend property-
based testing using the hypothesis framework. Why is
hypothesis so great?
Because not only will it try to find an input that breaks your
solution, but it
will then try to shrink that input to the smallest input it can find
that breaks
your solution!
We have provided some basic tests in tests.py. You should first
install the
hypothesis library using the command $ pip install hypothesis
Run the tests by executing the command $ python -m unittest
discover
4
IntroductionFor this assignment, your solution must be in
Python.Pair ProgrammingLatenessGrading RubricTips and
PitfallsProperty-based testing

More Related Content

Similar to Csc 440 assignment 2 convex hull out tuesday, feb 9th

Workshop - The Little Pattern That Could.pdf
Workshop - The Little Pattern That Could.pdfWorkshop - The Little Pattern That Could.pdf
Workshop - The Little Pattern That Could.pdfTobiasGoeschel
 
The "Evils" of Optimization
The "Evils" of OptimizationThe "Evils" of Optimization
The "Evils" of OptimizationBlackRabbitCoder
 
Agile and fixed budget projects
Agile and fixed budget projectsAgile and fixed budget projects
Agile and fixed budget projectsGul Mohammad
 
Analytics tools and Instruments
Analytics tools and InstrumentsAnalytics tools and Instruments
Analytics tools and InstrumentsKrunal Soni
 
CS101- Introduction to Computing- Lecture 44
CS101- Introduction to Computing- Lecture 44CS101- Introduction to Computing- Lecture 44
CS101- Introduction to Computing- Lecture 44Bilal Ahmed
 
Project 1 Instructions.htmlCompetencyIn this project, you .docx
Project 1 Instructions.htmlCompetencyIn this project, you .docxProject 1 Instructions.htmlCompetencyIn this project, you .docx
Project 1 Instructions.htmlCompetencyIn this project, you .docxstilliegeorgiana
 
Agile_SDLC_Node.js@Paypal_ppt
Agile_SDLC_Node.js@Paypal_pptAgile_SDLC_Node.js@Paypal_ppt
Agile_SDLC_Node.js@Paypal_pptHitesh Kumar
 
Software development best practices & coding guidelines
Software development best practices & coding guidelinesSoftware development best practices & coding guidelines
Software development best practices & coding guidelinesAnkur Goyal
 
Performant Django - Ara Anjargolian
Performant Django - Ara AnjargolianPerformant Django - Ara Anjargolian
Performant Django - Ara AnjargolianHakka Labs
 
Professional JavaScript: AntiPatterns
Professional JavaScript: AntiPatternsProfessional JavaScript: AntiPatterns
Professional JavaScript: AntiPatternsMike Wilcox
 
7 ways to execute scheduled jobs with python
7 ways to execute scheduled jobs with python7 ways to execute scheduled jobs with python
7 ways to execute scheduled jobs with pythonHugo Shi
 
Topic production code
Topic production codeTopic production code
Topic production codeKavi Kumar
 
CODE TUNINGtertertertrtryryryryrtytrytrtry
CODE TUNINGtertertertrtryryryryrtytrytrtryCODE TUNINGtertertertrtryryryryrtytrytrtry
CODE TUNINGtertertertrtryryryryrtytrytrtrykapib57390
 
Building of systems of automatic C/C++ code logging
Building of systems of automatic C/C++ code loggingBuilding of systems of automatic C/C++ code logging
Building of systems of automatic C/C++ code loggingPVS-Studio
 
Autotools, Design Patterns and more
Autotools, Design Patterns and moreAutotools, Design Patterns and more
Autotools, Design Patterns and moreVicente Bolea
 
Dev buchan 30 proven tips
Dev buchan 30 proven tipsDev buchan 30 proven tips
Dev buchan 30 proven tipsBill Buchan
 

Similar to Csc 440 assignment 2 convex hull out tuesday, feb 9th (20)

Workshop - The Little Pattern That Could.pdf
Workshop - The Little Pattern That Could.pdfWorkshop - The Little Pattern That Could.pdf
Workshop - The Little Pattern That Could.pdf
 
The "Evils" of Optimization
The "Evils" of OptimizationThe "Evils" of Optimization
The "Evils" of Optimization
 
Agile and fixed budget projects
Agile and fixed budget projectsAgile and fixed budget projects
Agile and fixed budget projects
 
Analytics tools and Instruments
Analytics tools and InstrumentsAnalytics tools and Instruments
Analytics tools and Instruments
 
CS101- Introduction to Computing- Lecture 44
CS101- Introduction to Computing- Lecture 44CS101- Introduction to Computing- Lecture 44
CS101- Introduction to Computing- Lecture 44
 
Project 1 Instructions.htmlCompetencyIn this project, you .docx
Project 1 Instructions.htmlCompetencyIn this project, you .docxProject 1 Instructions.htmlCompetencyIn this project, you .docx
Project 1 Instructions.htmlCompetencyIn this project, you .docx
 
DAA Unit 1.pdf
DAA Unit 1.pdfDAA Unit 1.pdf
DAA Unit 1.pdf
 
Instant DBMS Homework Help
Instant DBMS Homework HelpInstant DBMS Homework Help
Instant DBMS Homework Help
 
Agile_SDLC_Node.js@Paypal_ppt
Agile_SDLC_Node.js@Paypal_pptAgile_SDLC_Node.js@Paypal_ppt
Agile_SDLC_Node.js@Paypal_ppt
 
Software development best practices & coding guidelines
Software development best practices & coding guidelinesSoftware development best practices & coding guidelines
Software development best practices & coding guidelines
 
Put to the Test
Put to the TestPut to the Test
Put to the Test
 
Performant Django - Ara Anjargolian
Performant Django - Ara AnjargolianPerformant Django - Ara Anjargolian
Performant Django - Ara Anjargolian
 
Professional JavaScript: AntiPatterns
Professional JavaScript: AntiPatternsProfessional JavaScript: AntiPatterns
Professional JavaScript: AntiPatterns
 
7 ways to execute scheduled jobs with python
7 ways to execute scheduled jobs with python7 ways to execute scheduled jobs with python
7 ways to execute scheduled jobs with python
 
Architecture presentation 4
Architecture presentation 4Architecture presentation 4
Architecture presentation 4
 
Topic production code
Topic production codeTopic production code
Topic production code
 
CODE TUNINGtertertertrtryryryryrtytrytrtry
CODE TUNINGtertertertrtryryryryrtytrytrtryCODE TUNINGtertertertrtryryryryrtytrytrtry
CODE TUNINGtertertertrtryryryryrtytrytrtry
 
Building of systems of automatic C/C++ code logging
Building of systems of automatic C/C++ code loggingBuilding of systems of automatic C/C++ code logging
Building of systems of automatic C/C++ code logging
 
Autotools, Design Patterns and more
Autotools, Design Patterns and moreAutotools, Design Patterns and more
Autotools, Design Patterns and more
 
Dev buchan 30 proven tips
Dev buchan 30 proven tipsDev buchan 30 proven tips
Dev buchan 30 proven tips
 

More from RAJU852744

2222020 Report Pagehttpsww3.capsim.comcgi-bindispla.docx
2222020 Report Pagehttpsww3.capsim.comcgi-bindispla.docx2222020 Report Pagehttpsww3.capsim.comcgi-bindispla.docx
2222020 Report Pagehttpsww3.capsim.comcgi-bindispla.docxRAJU852744
 
2212020 Soil Colloids (Chapter 8) Notes - AGRI1050R50 Intro.docx
2212020 Soil Colloids (Chapter 8) Notes - AGRI1050R50 Intro.docx2212020 Soil Colloids (Chapter 8) Notes - AGRI1050R50 Intro.docx
2212020 Soil Colloids (Chapter 8) Notes - AGRI1050R50 Intro.docxRAJU852744
 
20 Other Conditions That May Be a Focus of Clinical AttentionV-c.docx
20 Other Conditions That May Be a Focus of Clinical AttentionV-c.docx20 Other Conditions That May Be a Focus of Clinical AttentionV-c.docx
20 Other Conditions That May Be a Focus of Clinical AttentionV-c.docxRAJU852744
 
223 Case 53 Problems in Pasta Land by Andres Sous.docx
223 Case 53 Problems in Pasta Land by  Andres Sous.docx223 Case 53 Problems in Pasta Land by  Andres Sous.docx
223 Case 53 Problems in Pasta Land by Andres Sous.docxRAJU852744
 
222111Organization N.docx
222111Organization N.docx222111Organization N.docx
222111Organization N.docxRAJU852744
 
22-6  Reporting the Plight of Depression FamiliesMARTHA GELLHOR.docx
22-6  Reporting the Plight of Depression FamiliesMARTHA GELLHOR.docx22-6  Reporting the Plight of Depression FamiliesMARTHA GELLHOR.docx
22-6  Reporting the Plight of Depression FamiliesMARTHA GELLHOR.docxRAJU852744
 
2012 © Laureate Education, Inc. ASSIGNMENT AND FINAL P.docx
2012 © Laureate Education, Inc. ASSIGNMENT AND FINAL P.docx2012 © Laureate Education, Inc. ASSIGNMENT AND FINAL P.docx
2012 © Laureate Education, Inc. ASSIGNMENT AND FINAL P.docxRAJU852744
 
216Author’s Note I would like to thank the Division of Wo.docx
216Author’s Note I would like to thank the Division of Wo.docx216Author’s Note I would like to thank the Division of Wo.docx
216Author’s Note I would like to thank the Division of Wo.docxRAJU852744
 
2019 International Conference on Machine Learning, Big Data, C.docx
2019 International Conference on Machine Learning, Big Data, C.docx2019 International Conference on Machine Learning, Big Data, C.docx
2019 International Conference on Machine Learning, Big Data, C.docxRAJU852744
 
2018 4th International Conference on Green Technology and Sust.docx
2018 4th International Conference on Green Technology and Sust.docx2018 4th International Conference on Green Technology and Sust.docx
2018 4th International Conference on Green Technology and Sust.docxRAJU852744
 
202 S.W.3d 811Court of Appeals of Texas,San Antonio.PROG.docx
202 S.W.3d 811Court of Appeals of Texas,San Antonio.PROG.docx202 S.W.3d 811Court of Appeals of Texas,San Antonio.PROG.docx
202 S.W.3d 811Court of Appeals of Texas,San Antonio.PROG.docxRAJU852744
 
200 wordsResearch Interest Lack of minorities in top level ma.docx
200 wordsResearch Interest Lack of minorities in top level ma.docx200 wordsResearch Interest Lack of minorities in top level ma.docx
200 wordsResearch Interest Lack of minorities in top level ma.docxRAJU852744
 
2019 14th Iberian Conference on Information Systems and Tech.docx
2019 14th Iberian Conference on Information Systems and Tech.docx2019 14th Iberian Conference on Information Systems and Tech.docx
2019 14th Iberian Conference on Information Systems and Tech.docxRAJU852744
 
200520201ORG30002 – Leadership Practice and Skills.docx
200520201ORG30002 – Leadership Practice and Skills.docx200520201ORG30002 – Leadership Practice and Skills.docx
200520201ORG30002 – Leadership Practice and Skills.docxRAJU852744
 
2182020 Sample Content Topichttpspurdueglobal.brights.docx
2182020 Sample Content Topichttpspurdueglobal.brights.docx2182020 Sample Content Topichttpspurdueglobal.brights.docx
2182020 Sample Content Topichttpspurdueglobal.brights.docxRAJU852744
 
21 hours agoMercy Eke Week 2 Discussion Hamilton Depression.docx
21 hours agoMercy Eke Week 2 Discussion Hamilton Depression.docx21 hours agoMercy Eke Week 2 Discussion Hamilton Depression.docx
21 hours agoMercy Eke Week 2 Discussion Hamilton Depression.docxRAJU852744
 
2192020 Originality Reporthttpsucumberlands.blackboar.docx
2192020 Originality Reporthttpsucumberlands.blackboar.docx2192020 Originality Reporthttpsucumberlands.blackboar.docx
2192020 Originality Reporthttpsucumberlands.blackboar.docxRAJU852744
 
20810chapter Information Systems Sourcing .docx
20810chapter       Information Systems Sourcing    .docx20810chapter       Information Systems Sourcing    .docx
20810chapter Information Systems Sourcing .docxRAJU852744
 
21720201Chapter 14Eating and WeightHealth Ps.docx
21720201Chapter 14Eating and WeightHealth Ps.docx21720201Chapter 14Eating and WeightHealth Ps.docx
21720201Chapter 14Eating and WeightHealth Ps.docxRAJU852744
 
2020221 Critical Review #2 - WebCOM™ 2.0httpssmc.grte.docx
2020221 Critical Review #2 - WebCOM™ 2.0httpssmc.grte.docx2020221 Critical Review #2 - WebCOM™ 2.0httpssmc.grte.docx
2020221 Critical Review #2 - WebCOM™ 2.0httpssmc.grte.docxRAJU852744
 

More from RAJU852744 (20)

2222020 Report Pagehttpsww3.capsim.comcgi-bindispla.docx
2222020 Report Pagehttpsww3.capsim.comcgi-bindispla.docx2222020 Report Pagehttpsww3.capsim.comcgi-bindispla.docx
2222020 Report Pagehttpsww3.capsim.comcgi-bindispla.docx
 
2212020 Soil Colloids (Chapter 8) Notes - AGRI1050R50 Intro.docx
2212020 Soil Colloids (Chapter 8) Notes - AGRI1050R50 Intro.docx2212020 Soil Colloids (Chapter 8) Notes - AGRI1050R50 Intro.docx
2212020 Soil Colloids (Chapter 8) Notes - AGRI1050R50 Intro.docx
 
20 Other Conditions That May Be a Focus of Clinical AttentionV-c.docx
20 Other Conditions That May Be a Focus of Clinical AttentionV-c.docx20 Other Conditions That May Be a Focus of Clinical AttentionV-c.docx
20 Other Conditions That May Be a Focus of Clinical AttentionV-c.docx
 
223 Case 53 Problems in Pasta Land by Andres Sous.docx
223 Case 53 Problems in Pasta Land by  Andres Sous.docx223 Case 53 Problems in Pasta Land by  Andres Sous.docx
223 Case 53 Problems in Pasta Land by Andres Sous.docx
 
222111Organization N.docx
222111Organization N.docx222111Organization N.docx
222111Organization N.docx
 
22-6  Reporting the Plight of Depression FamiliesMARTHA GELLHOR.docx
22-6  Reporting the Plight of Depression FamiliesMARTHA GELLHOR.docx22-6  Reporting the Plight of Depression FamiliesMARTHA GELLHOR.docx
22-6  Reporting the Plight of Depression FamiliesMARTHA GELLHOR.docx
 
2012 © Laureate Education, Inc. ASSIGNMENT AND FINAL P.docx
2012 © Laureate Education, Inc. ASSIGNMENT AND FINAL P.docx2012 © Laureate Education, Inc. ASSIGNMENT AND FINAL P.docx
2012 © Laureate Education, Inc. ASSIGNMENT AND FINAL P.docx
 
216Author’s Note I would like to thank the Division of Wo.docx
216Author’s Note I would like to thank the Division of Wo.docx216Author’s Note I would like to thank the Division of Wo.docx
216Author’s Note I would like to thank the Division of Wo.docx
 
2019 International Conference on Machine Learning, Big Data, C.docx
2019 International Conference on Machine Learning, Big Data, C.docx2019 International Conference on Machine Learning, Big Data, C.docx
2019 International Conference on Machine Learning, Big Data, C.docx
 
2018 4th International Conference on Green Technology and Sust.docx
2018 4th International Conference on Green Technology and Sust.docx2018 4th International Conference on Green Technology and Sust.docx
2018 4th International Conference on Green Technology and Sust.docx
 
202 S.W.3d 811Court of Appeals of Texas,San Antonio.PROG.docx
202 S.W.3d 811Court of Appeals of Texas,San Antonio.PROG.docx202 S.W.3d 811Court of Appeals of Texas,San Antonio.PROG.docx
202 S.W.3d 811Court of Appeals of Texas,San Antonio.PROG.docx
 
200 wordsResearch Interest Lack of minorities in top level ma.docx
200 wordsResearch Interest Lack of minorities in top level ma.docx200 wordsResearch Interest Lack of minorities in top level ma.docx
200 wordsResearch Interest Lack of minorities in top level ma.docx
 
2019 14th Iberian Conference on Information Systems and Tech.docx
2019 14th Iberian Conference on Information Systems and Tech.docx2019 14th Iberian Conference on Information Systems and Tech.docx
2019 14th Iberian Conference on Information Systems and Tech.docx
 
200520201ORG30002 – Leadership Practice and Skills.docx
200520201ORG30002 – Leadership Practice and Skills.docx200520201ORG30002 – Leadership Practice and Skills.docx
200520201ORG30002 – Leadership Practice and Skills.docx
 
2182020 Sample Content Topichttpspurdueglobal.brights.docx
2182020 Sample Content Topichttpspurdueglobal.brights.docx2182020 Sample Content Topichttpspurdueglobal.brights.docx
2182020 Sample Content Topichttpspurdueglobal.brights.docx
 
21 hours agoMercy Eke Week 2 Discussion Hamilton Depression.docx
21 hours agoMercy Eke Week 2 Discussion Hamilton Depression.docx21 hours agoMercy Eke Week 2 Discussion Hamilton Depression.docx
21 hours agoMercy Eke Week 2 Discussion Hamilton Depression.docx
 
2192020 Originality Reporthttpsucumberlands.blackboar.docx
2192020 Originality Reporthttpsucumberlands.blackboar.docx2192020 Originality Reporthttpsucumberlands.blackboar.docx
2192020 Originality Reporthttpsucumberlands.blackboar.docx
 
20810chapter Information Systems Sourcing .docx
20810chapter       Information Systems Sourcing    .docx20810chapter       Information Systems Sourcing    .docx
20810chapter Information Systems Sourcing .docx
 
21720201Chapter 14Eating and WeightHealth Ps.docx
21720201Chapter 14Eating and WeightHealth Ps.docx21720201Chapter 14Eating and WeightHealth Ps.docx
21720201Chapter 14Eating and WeightHealth Ps.docx
 
2020221 Critical Review #2 - WebCOM™ 2.0httpssmc.grte.docx
2020221 Critical Review #2 - WebCOM™ 2.0httpssmc.grte.docx2020221 Critical Review #2 - WebCOM™ 2.0httpssmc.grte.docx
2020221 Critical Review #2 - WebCOM™ 2.0httpssmc.grte.docx
 

Recently uploaded

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 

Recently uploaded (20)

Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
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
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 

Csc 440 assignment 2 convex hull out tuesday, feb 9th

  • 1. CSC 440 Assignment 2: Convex Hull Out: Tuesday, Feb 9th Due: Monday, Feb 22nd, by 11:59PM Introduction In this assignment, you will be implementing a convex hull algorithm. Specifically, you must implement the divide-and-conquer algorithm for computing a convex hull. You will be provided with a zip file on Sakai, convexhull.zip, which contains a GUI called draw_hull.py. This GUI allows you to click in a window to add points, click a button to compute and draw the convex hull around those points using the algorithm that you have implemented. note that the “points” are not points in the mathematical sense; They have some size to them due to implementation details of the GUI, so the convex hull actually goes through the center of each one. You can run this GUI by executing from the terminal $ python draw_hull.py. In the same zip file, there is some starter code in convex_hull.py, which is the file you will ultimately submit to GradeScope. It contains
  • 2. several functions that you will find useful (and should not modify). You will have to implement the compute_hull function which takes as input a list of points and returns only those points that are on the hull, in clockwise order. Currently, compute_hull is incorrect; it simply returns the input instead of the actual convex hull. In this implementation, we represent a point as a 2-tuple of integers (x, y). As is usually the case with computer graphics, the upper-left of the drawing canvas is the origin (0, 0), the positive x-axis is directed rightwards, and the positive y-axis is directed downwards. As a result of this, all coordinates are positive in this implementation. You must implement compute_hull and then benchmark its running time. You may write any helper functions and/or classes you deem useful; they should all live in convex_hull.py. You should also write a separate function for your base case, which should be the naive algorithm. Call it whenever you need to compute the hull on fewer than something like 5 or 6 points. 1
  • 3. You also need to benchmark you code. For this purpose, we have provided some starter code in benchmarks.py. Report the time taken by your implementation on inputs of various sizes. Draw a plot and discuss the shapes of any curves that you see. I have given you some trickier functions for the trickier geometric tasks, including a function for sorting a set of points counter-clockwise. Even without those, what you still have to implement took me roughly 6 hours. Start now. For this assignment, your solution must be in Python. Pair Programming You should work with a partner for this entire assignment. Please refer to the pair programming policy in the syllabus. Lateness Submissions will not be accepted after the due date, except with the intervention of the Dean’s Office in the case of serious medical, family, or other personal crises. Grading Rubric Your grade will be based on three components: • Functional Correctness (50%)
  • 4. • Design and Representation (15%) • Invariant Documentation (10%) • Benchmarking and Analysis (25%) Functional Correctness means passing tests on GradeScope. Remember that your function compute_hull must return the points in the convex hull in clockwise order. We have provided you with a minimal test- suite that uses the hypothesis library for some automated testing. We do not provide any specific test cases, so woy would be wise to write some tests for yourself. You should use the GUI for small tests, and for building your intuition. Note: you may modify draw_hull.py in any way you see fit to assist with debugging. That file need not be submitted to GradeScope. Design and Representation is our evaluation of the structure of your program, the choice of representations (de-emphasized here because some choices have already been made for you), and the use of appropriate (not excessive) comments. 2 Invariant Documentation is to get you to reason about the correctness and running-time of the algorithm. • Invariant: A statement that can be checked at any point in
  • 5. time. It should relate to how the algorithm makes progress. • Initialization: how is the problem set up • Maintenance: how do I know I’m making progress? • Termination: how do I know I’m done? • Usually, these should be closely related. • Properly documenting invariants can save you a great deal of time thinking about your algorithm. • The wise lumberjack takes time to sharpen the axe. Benchmarking and Analysis is similar to assignment 1. You should include a PDF in your upload to GradeScope, along with your code. • You should not use the GUI for benchmarking. The GUI is there for you to play with, but proper benchmarking should be non- interactive. • You must also benchmark your base-case (which should actually work for any reasonably small number of points) and plot its running time. • Benchmark your implementation on a wide enough set of inputs that you can plot a meaningful curve. • Write a brief summary of your benchmarking results. Do they support your expectation of the asymptotic complexity of this algorithm? Why or why not? What about the naive (base case) algorithm?
  • 6. Tips and Pitfalls • You may find it useful to modify draw_hull.py so that it puts something other than the Rams logo on the canvas. What data might be more helpful to you? • One common pitfall is to end up with two points having the same x- coordinates in two different hulls. The merge algorithm will fail in this case! Make sure that this never happens when you divide an input for the recursive calls. • Remember that the intercept between two parallel lines does not exist. If you’re seeing divide-by-zero errors, check this first. • Your base case should work for any small-ish number of points. You may find it’s easier to stop the divide-and-conquer when you reach a set of 5 or 6 points, rather than going all the way down to 3, as this can help avoid some difficult edge cases. 3 Property-based testing This assignment can drive you insane because it can be hard to reproduce a
  • 7. failing test, and the auto-grader gives you little feedback. Should you wish to preserve your sanity, use unit tests. I recommend property- based testing using the hypothesis framework. Why is hypothesis so great? Because not only will it try to find an input that breaks your solution, but it will then try to shrink that input to the smallest input it can find that breaks your solution! We have provided some basic tests in tests.py. You should first install the hypothesis library using the command $ pip install hypothesis Run the tests by executing the command $ python -m unittest discover 4 IntroductionFor this assignment, your solution must be in Python.Pair ProgrammingLatenessGrading RubricTips and PitfallsProperty-based testing