WGU Postal Service

Class: Data Structures and algorithms ll

image

The main goal of this program is to deliver the packages on time and follow the restrictions. The WGUPS routing program has a self-adjusting data structure that will store the package's data. This program has two algorithms that group the packages with similar restrictions and another algorithm to deliver the packages. The program won't have any issues delivering the packages if a new destination or package is added to the list because the data structures and algorithms are self-adjusting.

The program needs two CSV files that contain a list of packages with its data and another list of addresses. The list of packages is used to store the data into a hash table and the list of addresses is used to create a map.

image Data Structure: Hash Table
The hash table in the WGUPS program contains objects that represent a package from the wgu package file. Each package id represents the unique identification of the package and by using the unique id for each package, it can be inserted into a mod operation. Depending on the results of the mod operation, the package will be stored in a specific location in the hash table. Some packages will have the same result making some packages be stored in the same place. To find the location of that package, the hash table has a search method that will take the id and do the mod operation again. Hash tables are faster for their storing method instead of iterating through a whole list. Each package will have an address and other parameters. After storing the package in the hash table, the Greedy algorithm could locate the package in the hash table and group the packages. The greedy algorithm will first check the id, the deadline, and the special notes. The algorithm will group them according to those parameters. After that process is done, the Nearest Neighbor algorithm will use the hash table again and look for the location ID to compare the distance. Finally, the last method that uses the hash table is to deliver the packages. This method will deliver the packages and change the status of each package by using the hash table.

Algorithms:
The greedyAlgo3() algorithm groups the packages by certain requirements. That makes the grouping simple and avoids any problems with the requirements. The algorithm is designed to check every package’s special notes, delivery deadline, and id. If the package has similar notes or deadlines, they are grouped. Using that simple idea, the algorithm creates various lists for the next algorithm to use.
The NearestN() algorithm creates a path for the delivery trucks to follow. This algorithm uses the simple principle of locating the closest neighbor from the current location. That neighbor is then added to a list and compared with the other neighbors to retrieve the next closet neighbor within the list greedyAlgo3() formed. A path is created much faster using this process.
Also, both algorithms are adaptable which means they won’t be affected if any more packages are added.

image image Space-Time and Big-O
Major Segments:

greedyAlgo3() = n + n+ various constantes = O(n)
NearestN() = n(n+various constantes)= n^2 = O(n^2)
Truck_on_Road()= n + n+n + various constantes = n = O(n)

Whole Program:
greedyAlgo3() + NearestN() + Truck_on_Road =
n + n^2 +
n = O(n^2)

Retrospective:
Many aspects of this project could have been done differently. Identifying how to organize the packages would have saved me so much time. Figuring out how to group the packages first, would have been one of my first steps. The second step would be to implement a path for the packages to be delivered and return the time and the packages in the path. Modifying the program so many times and creating redundant variables could have been avoided if I identified the key features from the start.

Modification:
.Identify the key features for the program
.Decide how to group the packages and look for algorithms that could do it
. Look for ways that would deliver the packages accordingly