Reference no: EM13165807
You will continue to extend the program developed in Lab 6, by adding dynamically-allocated arrays, sorting, binary search, and multiple source files.
1. The first optimization is to change the static array of student records into a dynamically-allocated one. When the program starts, your program dynamically allocates an array of student records, and has a pointer (let's call it StudentRecords) point to it. The initial array size should be 40.
Finally, remember to release the dynamic array before terminating the program.
2. The second optimization is to add a sorting algorithm. Each time you add an item to the array (from disk or from keyboard), you call a function called SortMyArray(), which use the bubble sorting algorithm to sort the array in the ascending order, using student ID as the key. If done correctly, the array in the memory will always be sorted, even if the database is not sorted, or if you add new records from keyboard in random orders. Since the array is sorted, you can safely use binary search algorithms to search a record.
3. The 3rd optimization is to change the searc-by-ID function from linear search to binary search.
Bonus points (30%)
When you load entries from the database, or add new records from the keyboard, you will eventually run out of space in the dynamically allocated array. When this happen, you just do the following:
- Allocate another array which size is 10 records bigger the existing one
- Copy the contents of the old array to the new array
- Have the StudentRecords pointer points to the new array
- Delete the old array
- Hints: in addition to the StudentRecords pointer, you also need to maintain at least the following info: the maximum size of the current array, and the number of actual items stored in the current array.
Since you might need to expend the array when you are loading the database or adding records from the keyboard, you may want to put the above operations into a function. For
example, you can create a function called Add_a_record() that handle all of these steps. The Add_a_record() function is then called from the LoadDatabase() and Add_Record_from_Keyboard() function.
To test if your code works or not, change the initial array size to a very small number (say 5).
From time to time words become obsolete
: One more requirement, from time to time words become obsolete. When this happens, such word must be removed from the dictionary. Your program must account for this also.
|
Generate an array of 20 random integers from 0 to 9
: generate an array of 20 random integers from 0 to 9. Search for the first occurrence, if any, of the number 7, and report its position in the array.
|
Create 4 order class fields
: Create 4 Order class fields: order number, customer name, quantity ordered, and total price. Create public accessors for each field except total price.
|
The recommended entry strategy into international markets
: An expert system is used to determine whether the recommended entry strategy into international markets should be Investment (I), Contractual (C), or Export (E).
|
Optimization is to add a sorting algorithm
: The second optimization is to add a sorting algorithm. Each time you add an item to the array (from disk or from keyboard), you call a function called SortMyArray(), which use the bubble sorting algorithm to sort the array in the ascending order, ..
|
The load master for a freighter
: The load master for a freighter wants to determine the mix of cargo to be carried on the next trip. The ship's volume limit for cargo is 100,000 cubic meters, and it weight capacity is 2,310 tons.
|
Storage systems increasingly rely on the internet
: Storage systems increasingly rely on the Internet infrastructure as a transport medium. What are the advantages of this approach? What problems are present in terms of security and reliability?
|
Slugworth candies
: Slugworth Candies, LLC, is a candy maker company that employs 450 people. The company is composed of six departments: Executive Staff (20), Human Relations (6), Finance and Accounting (15), Marketing and Sales (15), Factory (150), and Research & D..
|
We would like to implement the lexical order
: We would like to implement the lexical order for lists. For simplicity, we only consider lists of numbers, where , >= have their usual meaning.
|