vehicle registration software
The SmartAR ADT is an ADT that combines two ADTs, a Sequence and a Hashtable. The Sequence is implemented using a doubly linked list, and the Hashtable is implemented using an ArrayList that supports separate chaining. Each element of the ArrayList is a bucket. Collisions are handled through inserting the key-value pair node inside its corresponding bucket, and at the head of the bucket. Therefore, the hashCode() function is called upon the key and its result is then converted into an index within the range (<) of the number of buckets. This ArrayList of buckets is set by default to size 10, and doubles if the load factor (n/N) surpasses 0.7. Here, assume the doubling will yield a prime number. Each of the ADTs are implemented in their separate classes and both have their version of the required methods that are: allKeys(), add(key, value), remove(key), getValues(key), nextKey(key), prevKey(key) and previousCars(key). Inside the SmartAR class, the previously mentioned methods along with setThreshold(threshold), setKeyLength(Length) and generate(n) are implemented. The SmartAR is what we instantiate in the driver file. An instance of SmartAR, once created, will simultaneously create an empty Sequence and an empty Hashtable. All of its methods operate around the threshold set by the user (which must be done before calling any other methods). Also, the key length must also be set in order for the driver program to read license plates from provided files. We add or remove one element at a time when operating on the instance of SmartAR. Whenever the SmartAR’s number of elements <= the threshold set by the user, adding new key-value pairs will cause them to be appended to the front(head) of the doubly linked list of the sequence. If ever the element to be added causes the number of elements in the Sequence to go above the threshold, all the elements (key-value pairs) are deleted from the Sequence and are relocated appropriately (hashed) into the empty Hashtable. This is also consistent if removing an element will cause the number of elements inside SmartAR to go below the threshold. In such case, all elements would be deleted from the Hashtable and would be transferred into the Sequence. All other operations/methods that are applicable to a single entry operates in this fashion. That is, depending on which of the two ADTs are used, the corresponding method defined in each individual class will be called. Moreover, in each of the two classes (Sequence & Hashtable, an ArrayList is kept to dynamically keep track of the sorted keys currently present. The choice of using a Hashtable is so that we can add, delete, or search in O(1) when our input size becomes very large. This is compromised by the fact that a lot of memory has to be allocated overhead due to the nature of the load factor. On the contrary, using a slower algorithm is a good trade off with less overhead memory when operating with a smaller input size.