CMSC 246 Systems Programming
This assignment builds on top of last weeks' Airport assignment.
The general idea in this assignment is to assume that you do not know the number of airports when you start. You will handle this problem by creating a data structure akin to the java ArrayList. Briefly, an array list has an underlying array in which data is stored. Whenever the number of items grows too large to fit within the current underlying array, the size of the underlying array grows by some amount. Growth occurs by creating a new, larger array. Then items in the old array are copied to the new, larger space and the old array is disposed.
After reading in all of the airports, (No you may not use unix wc to determine the number of lines in the file and thereby avoid the need to have a growable arraylist) rather than performing linear search (as in the previous assignment) use binary search to find airports given a code. The data in the file is sorted by code so binary search is possible without additional sorting.
Assignment #6: : Structs and Airports and Malloc!
Sample output: Once done, show your program's output for the following inputs: BMC, 172 (One Seven Two), 00M (Zero Zero Em), TCS, BUZ, 5A8, DAR, ZZV, 22M, PHL.
- Your program should take 1 command line argument, the name of the data file to be read
- Data for use during development is in the file /home/gtowell/Public/246/a05/code.txt. Your program must be able to read from whatever file is specified on the command line, NOT just this file.
- You may assume that the data file will follow precisely the format of the one named above.
- You may assume that the data file contains no errors.
- The data file for testing may be much larger, or smaller, than the one for development
- Data about each airport must be stored in struct(s)
- The airport file should be read only once.
- The array list should initially hold 100 items (or fewer). It should grow by a factor of 1.62 (the golden mean) each time the number of data items exceeds the current capacity. That is, if the initial capacity of the array list is 100, then after the first growth the capacity should be 162, after the second 262, etc
- When growing your array list, use malloc (and free). Do not use calloc or realloc to talloc
- Growth of the array list should not involve replicating the airport structures.
- You may use any mix of array and pointer notation that you find convenient
- Your program must use at least two source files (.c) and one header file (.h) -- you can use more. Think about using good object oriented design and break things up accordingly. For example, my implementation creates something similar to a Java Generic ArrayList.
- You must include a make file that will build your program. (You are not required to use your own makefile, but I will use it and will grade accordingly.)
- You may start this assignment from your own code from the prior assignment.
- On a successful search for an airport, also print the number of binary search steps required to find the ariport
What to submit:
- README file. This is a file literally named README. This file should follow the format of https://cs.brynmawr.edu/cs246/README.txt Your readme file should clearly state how to compile and run you program.
- All program files for this task.
- A script showing the use of your code tested as specified above.
- Your makefile
- Include in your README a brief reflection about what went well or poorly
- Do NOT include temp files from any editor or any compiled files (consider have a clean rule in your makefile delete these.)
How to submit
- Do not use submit
- Use tar to create an compressed archive of your submission. Name the tar file something clever like YOURLOGIN_qwe_6.tar.gz where "qwe" is a set of three "secret characters".
- Copy your tar file to /home/gtowell/submissions/spring2021/cmsc246/project6. Only I can get a directory listing of this directory so the three secret characters keeps other students from accidentally overwriting (or reading) your work.
- Set permissions on your submission so that anyone can read but only you can write to the file. That way no one can accidentally overwrite your submission. If you do not allow anyone to read then I will not be able to read. This will result in a poor grade for the assignment (think zero).