SlideShare a Scribd company logo
1 of 10
EECS 214/395--‐Data Structures and Data Management
Fall 2014
Programming Assignment No.2—PR Quadtrees
Due: Nov. 11, 2014 midnight
Background
For this project you will build a simple Geographic
Information System for storing point data. The
focus is organizing city records into a database
for fast search. For each city you will store
the name and its
location (X and Y coordinates). Searches can be
by either name or location. Thus, your project will
actually implement two trees: you will implement a
Binary Search Tree to support searches by name,
and you will implement a variation on the PR
Quadtree to support searches by position.
Consider what happens if you store the city
records using a linked list. The cost of key
operations (insert,
remove, search) using this representation would be
Θ(n) where n is the number of cities. For a few
records this is acceptable, but for a large
number of records this becomes too slow. Some
other
representation is needed that makes these operations
much faster. In this project, you will implement a
variation on one such representation, known as a
PR Quadtree. A binary search tree gives O(log n)
performance for insert, remove, and search
operations (if you ignore the possibility that it
is unbalanced).
This would allow you to insert and remove
cities, and locate them by name. However, the
BST does not help
when doing a search by coordinate. In particular,
the primary search operation that we are
concerned with in
this project is a form of range query called
“regionsearch.” In a regionsearch, we want to
find all cities that are
within a certain distance of a query point.
You could combine the (x, y) coordinates into a
single key and store cities using this key in a
second BST. That
would allow search by coordinate, but does nothing
to help regionsearch. The problem is that the BST
only works well for one--‐dimensional keys, while
a coordinate is a two--‐dimensional key. To solve
these
problems, you will implement a variant of the PR
Quadtree. The PR Quadtree is one of many
hierarchical data
structures commonly used to store data
such as city coordinates. It allows
for efficient insertion,
removal, and regionsearch queries. You should
pay particular attention to the discussion regarding
parameter passing in recursive functions.
Invocation and I/O Files:
Your program must be named PRprog, and should
be inovoked as: PRprog <filename>
1
where <filename> is a commandline argument for
the name of the command file. Your program
should write
to standard output (System.out). The program should
terminate when it reads the end of file mark from
the input file. The input for this project will
consist of a series of commands (some with
associated
parameters, separated by spaces), one command for
each line. Commands are free format in that an
arbitrary number of additional spaces may be
interspersed between parameters. The input file
may also
contain blank lines, which your program should
ignore. Each input command should result in
meaningful
feedback in terms of an output message. In
addition, some indication of success or error should
be
reported. Some of the command specifications below
indicate particular additional information that is
to
be output. Commands and their syntax are as
follows. Note that a name is defined to be a
string containing
only upper and lower case letters and the
underscore character.
insert x y name
ra
Highlight
A city at coordinate (x, y) with name name is
entered into the database. That means you will store
the city record once in the BST, and once in the
PR Quadtree. Spatially, the database should be viewed
as a square whose origin
is in the upper left (NorthWest) corner at
position (0, 0). The world is 214 by 214 units
wide, and so x and y
are integers in the range 0 to 214 −1. The x -
‐‐ coordinate increases to the right, the y--
‐coordinate
increases going down. Note that it is an error to
insert two cities with identical coordinates, but not
an
error to insert two cities with identical names.
remove x y
The city with coordinate (x, y) is removed from
the database (if it exists). That means it must be
removed from both the PR Quadtree and the BST.
Be sure to print the name and coordinates of
the city that is
removed.
remove name
A city with name name is removed from the database
(if any exists). That means it must be removed
from both the PR Quadtree and the BST. Be sure
to print the name and coordinates of the city
that is removed.
find name
Print the name and coordinates from all city
records with name name. You would search the
BST for this
information.
search x y radius
All cities within radius distance from location (x, y)
are listed. A city that is exactly radius distance
from the query point should be listed. x and y
are (signed) integers with absolute value less than
214.
radius is a non-‐‐ negative integer.
debug
Print a listing of the PR Quadtree nodes in preorder.
PR Quadtree children will appear in the order
NW, NE, SW, SE. The node listing should appear
as a single string (without internal newline characters
or spaces) as follows:
• For an internal node, print “I”.
• For an empty leaf node, print “E”.
• For a leaf node containing one or more data
points, for each data point print X,Y,NAME where X
is
the x -‐‐ coordinate, Y is the y--‐coordinate, and
NAME is the city name. After all of the city
records for that node
have been printed, print a “bar” or “pipe”
symbol (the | character).
The tree corresponding to the following Figure
would be printed as:
nw se
(70, 10) (69,50)
(55,80)(80, 90)
ne sw
A
C D
B
E F
(40,45) (15,70)
makenull
Initialize the database to be empty.
Example:
Note: in this example, statements enclosed in {} are
comments to help you under the example;
comments do NOT appear in the data file! insert
900 500 Evanston
3
insert 500 140 Skokie
insert 910 510 Chicago
debug { print coords, name for 3 cities }
remove 500 140 { its there to remove }
search 901 501 5 { print info for one city }
makenull { reinitialize }
Implementation suggestions:
.
• It is recommended that you access tree
nodes ONLY through set and get methods
in the
node classes (this holds true for the PR QuadTree
and the BST )
• All operations that traverse or
descend the BST or the PR
Quadtree structures should be
implemented recursively.
• You should use inheritance to implement PR
Quadtree nodes. You should have an abstract base
class
with separate subclasses for the internal nodes and
leaf node. A PR quadtree internal node
should store references to its children. Leaf nodes
should store a (reference to a) city record
object.
• For the BST you should deal with the case
of allowing multiple city names. You may want
to consider
using a BST with data stored only at the external
nodes.
• The PR Quadtree should be able to handle
more than just hard--‐coded access to “city”
records. In
other words you should be able to search for
different types of objects in a certain region.
Requirements
Environment:
Make sure your program is able to work on T--
‐lab machine. (Note the version of compiler: g++
(GCC)
4.4.7 20120313 (Red Hat 4.4.7--‐3))
Program:
Your code should be well commented and explain
what you are doing. Make sure your runs
correctly, efficiently.
Writing:
Give a brief and clear explanation (less than 1
page) about your design and thought.
Submission:
The format of your writing is required to be in
.pdf format
A Makefile is required to automatically compile
your code into executable file.
Everything you do for this project should be
included in a folder (e.g. named as project).
Compress
it in tar.gz format named by your
“FirstName_LastName”. Submit it to blackboard.
Late policy:
Programs will be accepted for at most two days
later with a penalty of 10% off for each day.
After
submission, if want to modify and submit it, you
may upload it again via blackboard.
Good Luck!

More Related Content

Similar to EECS 214395--‐Data Structures and Data Mana.docx

Background This course is all about data visualization. However, we.docx
Background This course is all about data visualization. However, we.docxBackground This course is all about data visualization. However, we.docx
Background This course is all about data visualization. However, we.docxrosemaryralphs52525
 
Graph Analyses with Python and NetworkX
Graph Analyses with Python and NetworkXGraph Analyses with Python and NetworkX
Graph Analyses with Python and NetworkXBenjamin Bengfort
 
R programming slides
R  programming slidesR  programming slides
R programming slidesPankaj Saini
 
Best corporate-r-programming-training-in-mumbai
Best corporate-r-programming-training-in-mumbaiBest corporate-r-programming-training-in-mumbai
Best corporate-r-programming-training-in-mumbaiUnmesh Baile
 
R Programming - part 1.pdf
R Programming - part 1.pdfR Programming - part 1.pdf
R Programming - part 1.pdfRohanBorgalli
 
Programming in python
Programming in pythonProgramming in python
Programming in pythonIvan Rojas
 
Automatic Task-based Code Generation for High Performance DSEL
Automatic Task-based Code Generation for High Performance DSELAutomatic Task-based Code Generation for High Performance DSEL
Automatic Task-based Code Generation for High Performance DSELJoel Falcou
 
23. Advanced Datatypes and New Application in DBMS
23. Advanced Datatypes and New Application in DBMS23. Advanced Datatypes and New Application in DBMS
23. Advanced Datatypes and New Application in DBMSkoolkampus
 
R Spatial Analysis using SP
R Spatial Analysis using SPR Spatial Analysis using SP
R Spatial Analysis using SPtjagger
 
Get started with R lang
Get started with R langGet started with R lang
Get started with R langsenthil0809
 
Query Optimization - Brandon Latronica
Query Optimization - Brandon LatronicaQuery Optimization - Brandon Latronica
Query Optimization - Brandon Latronica"FENG "GEORGE"" YU
 
MAP REDUCE IN DATA SCIENCE.pptx
MAP REDUCE IN DATA SCIENCE.pptxMAP REDUCE IN DATA SCIENCE.pptx
MAP REDUCE IN DATA SCIENCE.pptxHARIKRISHNANU13
 

Similar to EECS 214395--‐Data Structures and Data Mana.docx (20)

Starting work with R
Starting work with RStarting work with R
Starting work with R
 
Background This course is all about data visualization. However, we.docx
Background This course is all about data visualization. However, we.docxBackground This course is all about data visualization. However, we.docx
Background This course is all about data visualization. However, we.docx
 
Graph Analyses with Python and NetworkX
Graph Analyses with Python and NetworkXGraph Analyses with Python and NetworkX
Graph Analyses with Python and NetworkX
 
R programming slides
R  programming slidesR  programming slides
R programming slides
 
Best corporate-r-programming-training-in-mumbai
Best corporate-r-programming-training-in-mumbaiBest corporate-r-programming-training-in-mumbai
Best corporate-r-programming-training-in-mumbai
 
R Programming - part 1.pdf
R Programming - part 1.pdfR Programming - part 1.pdf
R Programming - part 1.pdf
 
Data analytics with R
Data analytics with RData analytics with R
Data analytics with R
 
Lecture_R.ppt
Lecture_R.pptLecture_R.ppt
Lecture_R.ppt
 
Programming in python
Programming in pythonProgramming in python
Programming in python
 
Wk1to4
Wk1to4Wk1to4
Wk1to4
 
Automatic Task-based Code Generation for High Performance DSEL
Automatic Task-based Code Generation for High Performance DSELAutomatic Task-based Code Generation for High Performance DSEL
Automatic Task-based Code Generation for High Performance DSEL
 
23. Advanced Datatypes and New Application in DBMS
23. Advanced Datatypes and New Application in DBMS23. Advanced Datatypes and New Application in DBMS
23. Advanced Datatypes and New Application in DBMS
 
R Spatial Analysis using SP
R Spatial Analysis using SPR Spatial Analysis using SP
R Spatial Analysis using SP
 
Get started with R lang
Get started with R langGet started with R lang
Get started with R lang
 
Query Optimization - Brandon Latronica
Query Optimization - Brandon LatronicaQuery Optimization - Brandon Latronica
Query Optimization - Brandon Latronica
 
Datamining with R
Datamining with RDatamining with R
Datamining with R
 
Compiler unit 5
Compiler  unit 5Compiler  unit 5
Compiler unit 5
 
MAP REDUCE IN DATA SCIENCE.pptx
MAP REDUCE IN DATA SCIENCE.pptxMAP REDUCE IN DATA SCIENCE.pptx
MAP REDUCE IN DATA SCIENCE.pptx
 
Lecture1_R.ppt
Lecture1_R.pptLecture1_R.ppt
Lecture1_R.ppt
 
Lecture1_R.ppt
Lecture1_R.pptLecture1_R.ppt
Lecture1_R.ppt
 

More from jack60216

Anorexia1-Definition2-Epidemiology in united states2.docx
Anorexia1-Definition2-Epidemiology in united states2.docxAnorexia1-Definition2-Epidemiology in united states2.docx
Anorexia1-Definition2-Epidemiology in united states2.docxjack60216
 
Annotated BibliographyIn preparation of next weeks final as.docx
Annotated BibliographyIn preparation of next weeks final as.docxAnnotated BibliographyIn preparation of next weeks final as.docx
Annotated BibliographyIn preparation of next weeks final as.docxjack60216
 
Annual Report to the Nation on the Status of Cancer,Part I .docx
Annual Report to the Nation on the Status of Cancer,Part I .docxAnnual Report to the Nation on the Status of Cancer,Part I .docx
Annual Report to the Nation on the Status of Cancer,Part I .docxjack60216
 
Annotated BibliographyDue 1212019 @ 12pm Eastern Time (Unite.docx
Annotated BibliographyDue 1212019 @ 12pm Eastern Time (Unite.docxAnnotated BibliographyDue 1212019 @ 12pm Eastern Time (Unite.docx
Annotated BibliographyDue 1212019 @ 12pm Eastern Time (Unite.docxjack60216
 
Annotated BibliographyFor this assignment, you will create an .docx
Annotated BibliographyFor this assignment, you will create an .docxAnnotated BibliographyFor this assignment, you will create an .docx
Annotated BibliographyFor this assignment, you will create an .docxjack60216
 
Annotated bibliography due in 36 hours. MLA format Must incl.docx
Annotated bibliography due in 36 hours. MLA format Must incl.docxAnnotated bibliography due in 36 hours. MLA format Must incl.docx
Annotated bibliography due in 36 hours. MLA format Must incl.docxjack60216
 
Analyzing a Short Story- The Necklace by Guy de MaupassantIntro.docx
Analyzing a Short Story- The Necklace by Guy de MaupassantIntro.docxAnalyzing a Short Story- The Necklace by Guy de MaupassantIntro.docx
Analyzing a Short Story- The Necklace by Guy de MaupassantIntro.docxjack60216
 
Andy Sylvan was the assistant director of the community developm.docx
Andy Sylvan was the assistant director of the community developm.docxAndy Sylvan was the assistant director of the community developm.docx
Andy Sylvan was the assistant director of the community developm.docxjack60216
 
Annotated Bibliography Althaus, F. U.S. Maternal Morta.docx
Annotated Bibliography  Althaus, F. U.S. Maternal Morta.docxAnnotated Bibliography  Althaus, F. U.S. Maternal Morta.docx
Annotated Bibliography Althaus, F. U.S. Maternal Morta.docxjack60216
 
Ann, a community nurse, made an afternoon home visit with Susan and .docx
Ann, a community nurse, made an afternoon home visit with Susan and .docxAnn, a community nurse, made an afternoon home visit with Susan and .docx
Ann, a community nurse, made an afternoon home visit with Susan and .docxjack60216
 
Andrea Walters Week 2 Main Post       The key functional area of n.docx
Andrea Walters Week 2 Main Post       The key functional area of n.docxAndrea Walters Week 2 Main Post       The key functional area of n.docx
Andrea Walters Week 2 Main Post       The key functional area of n.docxjack60216
 
and emergency CPR all changed ways of thinking about risk of death.docx
and emergency CPR all changed ways of thinking about risk of death.docxand emergency CPR all changed ways of thinking about risk of death.docx
and emergency CPR all changed ways of thinking about risk of death.docxjack60216
 
analyze, and discuss emerging ICT tools and technologies present.docx
analyze, and discuss emerging ICT tools and technologies present.docxanalyze, and discuss emerging ICT tools and technologies present.docx
analyze, and discuss emerging ICT tools and technologies present.docxjack60216
 
Analyzing a Research ArticleNote Please complete this dis.docx
Analyzing a Research ArticleNote Please complete this dis.docxAnalyzing a Research ArticleNote Please complete this dis.docx
Analyzing a Research ArticleNote Please complete this dis.docxjack60216
 
Analyze the Civil Rights Movement of the 1950s and 1960s. What p.docx
Analyze the Civil Rights Movement of the 1950s and 1960s. What p.docxAnalyze the Civil Rights Movement of the 1950s and 1960s. What p.docx
Analyze the Civil Rights Movement of the 1950s and 1960s. What p.docxjack60216
 
Analytical Research Project InstructionsINFA 630 – Intrusion.docx
Analytical Research Project InstructionsINFA 630 – Intrusion.docxAnalytical Research Project InstructionsINFA 630 – Intrusion.docx
Analytical Research Project InstructionsINFA 630 – Intrusion.docxjack60216
 
Analyze the performance of the leadership of an organization (Netfli.docx
Analyze the performance of the leadership of an organization (Netfli.docxAnalyze the performance of the leadership of an organization (Netfli.docx
Analyze the performance of the leadership of an organization (Netfli.docxjack60216
 
Analyze the subjective portion of the note. List additiona.docx
Analyze the subjective portion of the note. List additiona.docxAnalyze the subjective portion of the note. List additiona.docx
Analyze the subjective portion of the note. List additiona.docxjack60216
 
Analyze the measures your state and local community have in pl.docx
Analyze the measures your state and local community have in pl.docxAnalyze the measures your state and local community have in pl.docx
Analyze the measures your state and local community have in pl.docxjack60216
 
Analyze two (2) advantages and two (2) disadvantages of creati.docx
Analyze two (2) advantages and two (2) disadvantages of creati.docxAnalyze two (2) advantages and two (2) disadvantages of creati.docx
Analyze two (2) advantages and two (2) disadvantages of creati.docxjack60216
 

More from jack60216 (20)

Anorexia1-Definition2-Epidemiology in united states2.docx
Anorexia1-Definition2-Epidemiology in united states2.docxAnorexia1-Definition2-Epidemiology in united states2.docx
Anorexia1-Definition2-Epidemiology in united states2.docx
 
Annotated BibliographyIn preparation of next weeks final as.docx
Annotated BibliographyIn preparation of next weeks final as.docxAnnotated BibliographyIn preparation of next weeks final as.docx
Annotated BibliographyIn preparation of next weeks final as.docx
 
Annual Report to the Nation on the Status of Cancer,Part I .docx
Annual Report to the Nation on the Status of Cancer,Part I .docxAnnual Report to the Nation on the Status of Cancer,Part I .docx
Annual Report to the Nation on the Status of Cancer,Part I .docx
 
Annotated BibliographyDue 1212019 @ 12pm Eastern Time (Unite.docx
Annotated BibliographyDue 1212019 @ 12pm Eastern Time (Unite.docxAnnotated BibliographyDue 1212019 @ 12pm Eastern Time (Unite.docx
Annotated BibliographyDue 1212019 @ 12pm Eastern Time (Unite.docx
 
Annotated BibliographyFor this assignment, you will create an .docx
Annotated BibliographyFor this assignment, you will create an .docxAnnotated BibliographyFor this assignment, you will create an .docx
Annotated BibliographyFor this assignment, you will create an .docx
 
Annotated bibliography due in 36 hours. MLA format Must incl.docx
Annotated bibliography due in 36 hours. MLA format Must incl.docxAnnotated bibliography due in 36 hours. MLA format Must incl.docx
Annotated bibliography due in 36 hours. MLA format Must incl.docx
 
Analyzing a Short Story- The Necklace by Guy de MaupassantIntro.docx
Analyzing a Short Story- The Necklace by Guy de MaupassantIntro.docxAnalyzing a Short Story- The Necklace by Guy de MaupassantIntro.docx
Analyzing a Short Story- The Necklace by Guy de MaupassantIntro.docx
 
Andy Sylvan was the assistant director of the community developm.docx
Andy Sylvan was the assistant director of the community developm.docxAndy Sylvan was the assistant director of the community developm.docx
Andy Sylvan was the assistant director of the community developm.docx
 
Annotated Bibliography Althaus, F. U.S. Maternal Morta.docx
Annotated Bibliography  Althaus, F. U.S. Maternal Morta.docxAnnotated Bibliography  Althaus, F. U.S. Maternal Morta.docx
Annotated Bibliography Althaus, F. U.S. Maternal Morta.docx
 
Ann, a community nurse, made an afternoon home visit with Susan and .docx
Ann, a community nurse, made an afternoon home visit with Susan and .docxAnn, a community nurse, made an afternoon home visit with Susan and .docx
Ann, a community nurse, made an afternoon home visit with Susan and .docx
 
Andrea Walters Week 2 Main Post       The key functional area of n.docx
Andrea Walters Week 2 Main Post       The key functional area of n.docxAndrea Walters Week 2 Main Post       The key functional area of n.docx
Andrea Walters Week 2 Main Post       The key functional area of n.docx
 
and emergency CPR all changed ways of thinking about risk of death.docx
and emergency CPR all changed ways of thinking about risk of death.docxand emergency CPR all changed ways of thinking about risk of death.docx
and emergency CPR all changed ways of thinking about risk of death.docx
 
analyze, and discuss emerging ICT tools and technologies present.docx
analyze, and discuss emerging ICT tools and technologies present.docxanalyze, and discuss emerging ICT tools and technologies present.docx
analyze, and discuss emerging ICT tools and technologies present.docx
 
Analyzing a Research ArticleNote Please complete this dis.docx
Analyzing a Research ArticleNote Please complete this dis.docxAnalyzing a Research ArticleNote Please complete this dis.docx
Analyzing a Research ArticleNote Please complete this dis.docx
 
Analyze the Civil Rights Movement of the 1950s and 1960s. What p.docx
Analyze the Civil Rights Movement of the 1950s and 1960s. What p.docxAnalyze the Civil Rights Movement of the 1950s and 1960s. What p.docx
Analyze the Civil Rights Movement of the 1950s and 1960s. What p.docx
 
Analytical Research Project InstructionsINFA 630 – Intrusion.docx
Analytical Research Project InstructionsINFA 630 – Intrusion.docxAnalytical Research Project InstructionsINFA 630 – Intrusion.docx
Analytical Research Project InstructionsINFA 630 – Intrusion.docx
 
Analyze the performance of the leadership of an organization (Netfli.docx
Analyze the performance of the leadership of an organization (Netfli.docxAnalyze the performance of the leadership of an organization (Netfli.docx
Analyze the performance of the leadership of an organization (Netfli.docx
 
Analyze the subjective portion of the note. List additiona.docx
Analyze the subjective portion of the note. List additiona.docxAnalyze the subjective portion of the note. List additiona.docx
Analyze the subjective portion of the note. List additiona.docx
 
Analyze the measures your state and local community have in pl.docx
Analyze the measures your state and local community have in pl.docxAnalyze the measures your state and local community have in pl.docx
Analyze the measures your state and local community have in pl.docx
 
Analyze two (2) advantages and two (2) disadvantages of creati.docx
Analyze two (2) advantages and two (2) disadvantages of creati.docxAnalyze two (2) advantages and two (2) disadvantages of creati.docx
Analyze two (2) advantages and two (2) disadvantages of creati.docx
 

Recently uploaded

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
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
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
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
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
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
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
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
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 

Recently uploaded (20)

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
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
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
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
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
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
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
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...
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 

EECS 214395--‐Data Structures and Data Mana.docx

  • 1. EECS 214/395--‐Data Structures and Data Management Fall 2014 Programming Assignment No.2—PR Quadtrees Due: Nov. 11, 2014 midnight Background For this project you will build a simple Geographic Information System for storing point data. The focus is organizing city records into a database for fast search. For each city you will store the name and its location (X and Y coordinates). Searches can be by either name or location. Thus, your project will actually implement two trees: you will implement a Binary Search Tree to support searches by name, and you will implement a variation on the PR Quadtree to support searches by position. Consider what happens if you store the city records using a linked list. The cost of key operations (insert, remove, search) using this representation would be Θ(n) where n is the number of cities. For a few records this is acceptable, but for a large number of records this becomes too slow. Some other representation is needed that makes these operations
  • 2. much faster. In this project, you will implement a variation on one such representation, known as a PR Quadtree. A binary search tree gives O(log n) performance for insert, remove, and search operations (if you ignore the possibility that it is unbalanced). This would allow you to insert and remove cities, and locate them by name. However, the BST does not help when doing a search by coordinate. In particular, the primary search operation that we are concerned with in this project is a form of range query called “regionsearch.” In a regionsearch, we want to find all cities that are within a certain distance of a query point. You could combine the (x, y) coordinates into a single key and store cities using this key in a second BST. That would allow search by coordinate, but does nothing to help regionsearch. The problem is that the BST only works well for one--‐dimensional keys, while a coordinate is a two--‐dimensional key. To solve these problems, you will implement a variant of the PR Quadtree. The PR Quadtree is one of many hierarchical data structures commonly used to store data such as city coordinates. It allows for efficient insertion, removal, and regionsearch queries. You should pay particular attention to the discussion regarding parameter passing in recursive functions.
  • 3. Invocation and I/O Files: Your program must be named PRprog, and should be inovoked as: PRprog <filename> 1 where <filename> is a commandline argument for the name of the command file. Your program should write to standard output (System.out). The program should terminate when it reads the end of file mark from the input file. The input for this project will consist of a series of commands (some with associated parameters, separated by spaces), one command for each line. Commands are free format in that an arbitrary number of additional spaces may be interspersed between parameters. The input file may also contain blank lines, which your program should ignore. Each input command should result in meaningful feedback in terms of an output message. In addition, some indication of success or error should be reported. Some of the command specifications below indicate particular additional information that is to be output. Commands and their syntax are as follows. Note that a name is defined to be a string containing only upper and lower case letters and the underscore character. insert x y name
  • 4. ra Highlight A city at coordinate (x, y) with name name is entered into the database. That means you will store the city record once in the BST, and once in the PR Quadtree. Spatially, the database should be viewed as a square whose origin is in the upper left (NorthWest) corner at position (0, 0). The world is 214 by 214 units wide, and so x and y are integers in the range 0 to 214 −1. The x - ‐‐ coordinate increases to the right, the y-- ‐coordinate increases going down. Note that it is an error to insert two cities with identical coordinates, but not an error to insert two cities with identical names. remove x y The city with coordinate (x, y) is removed from the database (if it exists). That means it must be removed from both the PR Quadtree and the BST. Be sure to print the name and coordinates of the city that is removed. remove name
  • 5. A city with name name is removed from the database (if any exists). That means it must be removed from both the PR Quadtree and the BST. Be sure to print the name and coordinates of the city that is removed. find name Print the name and coordinates from all city records with name name. You would search the BST for this information. search x y radius All cities within radius distance from location (x, y) are listed. A city that is exactly radius distance from the query point should be listed. x and y are (signed) integers with absolute value less than 214. radius is a non-‐‐ negative integer. debug Print a listing of the PR Quadtree nodes in preorder. PR Quadtree children will appear in the order NW, NE, SW, SE. The node listing should appear as a single string (without internal newline characters or spaces) as follows: • For an internal node, print “I”. • For an empty leaf node, print “E”. • For a leaf node containing one or more data points, for each data point print X,Y,NAME where X is the x -‐‐ coordinate, Y is the y--‐coordinate, and NAME is the city name. After all of the city
  • 6. records for that node have been printed, print a “bar” or “pipe” symbol (the | character). The tree corresponding to the following Figure would be printed as: nw se (70, 10) (69,50) (55,80)(80, 90) ne sw A C D B E F (40,45) (15,70) makenull Initialize the database to be empty. Example: Note: in this example, statements enclosed in {} are comments to help you under the example;
  • 7. comments do NOT appear in the data file! insert 900 500 Evanston 3 insert 500 140 Skokie insert 910 510 Chicago debug { print coords, name for 3 cities } remove 500 140 { its there to remove } search 901 501 5 { print info for one city } makenull { reinitialize } Implementation suggestions: . • It is recommended that you access tree nodes ONLY through set and get methods in the node classes (this holds true for the PR QuadTree and the BST ) • All operations that traverse or descend the BST or the PR Quadtree structures should be implemented recursively. • You should use inheritance to implement PR
  • 8. Quadtree nodes. You should have an abstract base class with separate subclasses for the internal nodes and leaf node. A PR quadtree internal node should store references to its children. Leaf nodes should store a (reference to a) city record object. • For the BST you should deal with the case of allowing multiple city names. You may want to consider using a BST with data stored only at the external nodes. • The PR Quadtree should be able to handle more than just hard--‐coded access to “city” records. In other words you should be able to search for different types of objects in a certain region. Requirements Environment: Make sure your program is able to work on T-- ‐lab machine. (Note the version of compiler: g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7--‐3)) Program:
  • 9. Your code should be well commented and explain what you are doing. Make sure your runs correctly, efficiently. Writing: Give a brief and clear explanation (less than 1 page) about your design and thought. Submission: The format of your writing is required to be in .pdf format A Makefile is required to automatically compile your code into executable file. Everything you do for this project should be included in a folder (e.g. named as project). Compress it in tar.gz format named by your “FirstName_LastName”. Submit it to blackboard. Late policy:
  • 10. Programs will be accepted for at most two days later with a penalty of 10% off for each day. After submission, if want to modify and submit it, you may upload it again via blackboard. Good Luck!