Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me in this task. Task : Nearest Neighbor Search: Datasets: There are three datasets: Restaurant, Shop, and Parking Datasets. Each dataset consists of

Please help me in this task.
Task : Nearest Neighbor Search:
Datasets: There are three datasets: Restaurant, Shop, and Parking Datasets. Each dataset
consists of 2D points, stored in a text file with the following format:
id1x-1y1
id2x-2y2
dots
idnx-nyn
Each line includes a unique ID for a point and its geographical coordinates, longitude and
latitude. For example, an entry in the Shop dataset, such as "id_1=1, x_1=33.85,
y_1=151.21" precisely indicates the location of a shop, with "x" representing longitude and
"y" representing latitude.
Queries: We have 200 users interested in finding the nearest facilities. Their locations are
provided in a text file formatted identically to the datasets:
id_1 x_1 y_1
id_2 x_2 y_2
...
id_200 x_200 y_200
For example, id_1=1, x_1=31.45, y_1=150.44 indicates a users location.
Program Design:
Select ONE dataset (Restaurant, Shop, or Parking).
Find the nearest facility (restaurant, shop, or parking lot) for each query using the
following algorithms:
1. Sequential Scan Based Method: Calculate the distance between a query point
to every point in the selected dataset to find the nearest neighbor.
2. Best First (BF) Algorithm: Construct an R-tree for the selected dataset. Then, apply the BF algorithm using the R-tree to find the nearest neighbor for each query point.
3. BF with Divide-and-Conquer: Firstly, divide the dataset into two subspaces (based on X dimension or Y dimension), then construct an R-tree for each subspace. Use the BF algorithm to find the nearest point to the query in each subspace. Finally, compare the distance between the nearest points delivered from each subspace to determine the final nearest neighbor in the entire dataset.
Output: For each algorithm (Sequential Scan Based, BF Algorithm, and BF with Divide- and-Conquer), display and output the following information in a single txt file:
The ID, x, and y coordinates of the nearest neighbor identified for each query point (e.g.,id=56, x=34.15, y=149.21 for query 1).
The total running time for processing all 200 queries and the average time per query (i.e., divide the total running time by 200).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions