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

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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