Optimization is to add a sorting algorithm

Assignment Help C/C++ Programming
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).

Reference no: EM13165807

Questions Cloud

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.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  During the execution of the above code, how many instru

(a) During the execution of the above code, how many instructions are executed? (b) Assuming a standard unicycle machine (CPI = 1) running at 100 KHz, how long will the above code take to complete?

  Calculates the student * averages and quiz averages based

Calculates the student * averages and quiz averages based upon input from the user. Modify this program to read in the following grade text file, * with a maximum number of students set to 35 and having five quiz scores for each student. The output s..

  Calculate the component voltages

Calculate the component voltages for the following series resonant RLC circuit

  Repeat these questions by writing functions

Repeat these questions by writing functions that receive the arrays as constant reference parameters and return the appropriate values through the function name (via return statement). The function header could look like:

  Write a program in c of fibonacci series

Write a program in c of fibonaci series with and without using fibo func, both

  Write a c program which takes a string from command line

Write a c program which takes a string from command line with mainfunction has no parameter and convert the string in upperca

  What constructors do and when they are executed

Explain what constructors do and when they are executed. Explain the two types of constructors. Provide an example class that includes both types of constructor functions and demonstrate how an object would be instantiated using both types of constru..

  Change temperature fahrenheit to celsius and kelvin

Write a program in c++ that takes the temperature in Fahrenheit and convert it to Celsius And Kelvin:

  Write the class definition for a class called complex

. Write the class definition for a class called complex.

  Write a program to analyze students course marks

Write a program to analyze students course marks. The program should read in students course marks from "m2-grading.txt". The data file has a headline including students ID#, course-1marks, course-2 marks and course-3 markes.

  The "continue" and "break" statements

How are the "continue" and "break" statements different from the "exit" and "return" statements?

  Program to output value of tenth component of array

Write a C++ statements to perform the following: Set value of fourth component of array alpha to three times  value of eight component minus 57.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd