Write the sorted data to the specified output file

Assignment Help C/C++ Programming
Reference no: EM131236021

Your task for this assignment is to create, in C89, a stand-alone sorting program.

1 Documentation

You must thoroughly document your code using C comments (/*....*/).

For each function you define and each datatype you declare (e.g. using struct or typedef), place a comment immediately above it explaining its purpose, how it works, and how it relates to other functions and types. Collectively, these comments should explain your design. (They are worth substantial marks - see Section 7.)

2 Program Outline

Your program will deal with one input file: a .csv text file to sort (the "user file"). and a single output file containing the sorted text.
Your program must do the following:

a) Take two command-line parameters - the names of the input and output files. these can be in either order. so you will also need command line switches ( i and ,c,)

Examples:

sortingAssignment i infile o outfile

sortingAssignment o outfile i infile

Invalid command line arguments should cause the program to output a usage message, and exit.

b) Read the input file and store its contents in a (generic) linked list. The format of the input file is specified in section 2.1

c) Output a menu to the user requesting how the user would like the contents of the file sorted. The user must be able to sort on any of the columns. in ascending or descending order

d) Sort the rows of the input file using a generic insertion sort (in-place). Your insertion sort function MUST be generic - that is it must import a generic linked list and a compare function, export the sorted linked list, and return an integer specifying if anything went wrong 0 for success. or a negative value for any specific errors.
Note. Insertion sort is fully described in appendix a

e) Write the sorted data to the specified output file using the same format as the input file.

4 Testing (or "How to Actually Get Marks, part 2")

Your program must work on either:

 The lab machines in building 314, and/or One of the saeshell0Xp.curtin.edu.au machines (where "X" is 1. 2, 3 or 4).

To begin with, construct a small-scale test file containing only a few columns and lines. As you begin to fix bugs, try larger test files.
All user input must be "sanity" checked. Invalid user input should not cause the program to stop (other than invalid command line arguments).

Ensure there are no memory leaks - you must not rely on the program closing to free your memory. You will lose marks for any memory issues.

5 README.txt

Prepare a text file called README.txt (not using Word or any other word processor), that contains the following:
A list of all files you're submitting and their purpose.
A statement of how much of the assignment you completed; specifically:
- How much of the required functionality you attempted to get working, and
- How much actually does work, to the best of your knowledge.
A list of any bugs or defects you know about. if any.
A statement of which computer you tested your code on. This must be either
- One of the four saeshell0Xp machines, or
- One of the building-314 lab machines. In this case, specify the room number (e.g. 314.220) and the "Service Tag" - a unique 7-character ID found on a black sticker on the top of the each machine.

6 Submission

You must keep a copy of all required files in your $HOME/UCP/assignment directory, including files that you used for testing. These must not be touched after the due date and time for the assignment. You must also submit the following electronically, via the assignment area on Blackboard, inside a single .tar.gz file (not .rar or other formats):
- Your makefile and README.txt.
- All .c and .h files (everything needed for the make command to work).
- a completed "Declaration of Originality' (appendix b)

You are responsible for ensuring that your submission is correct and not corrupted (download and check it!). You may make multiple submissions. but only your newest submission will be marked. The late submission policy (see the Unit Outline) will be strictly enforced. A submission 1 second late, according to Blackboard, will be considered 1 day late. A submission 24 hours and 1 second late will be considered 2 days late. and so on.

2.1 The input file

The input file will be in .csv format, with the column names specified on the first line, and its data type (string or integer) specified after the name in brackets. There could be any number of columns, and any number of rows.

This is an example of a valid input file:
name (string) , age (integer) mark, 21, at home
jordan, 19, his place
etc
Sorted on age, ascending: address (string)

name (string), age (integer), address (string) jordan, 19, his place
mark, 21, at home
etc
and another
The (string), desc (string) , in (integer), long (integer) shark bay, nice and warm, 12593, 39216
esperance, cold and windy, 4287
etc
Sorted on loc, ascending:
lac (string), desc (string), lat (integer), long (integer) esperance, cold and windy, 9287
shark bay, nice and warm, 12593, 34216
etc

Note: You must state any valid assumptions you make about the input file.

If a value is missing from the file, the sorting algorithm must place it last in the sorted list.

If there is an unrecognised datatype name, or the file is otherwise not in the expected format, your program must issue an error message detailing the problem. When this happens, your program must not attempt to sort anything.

3 Makefile (or "How to Actually Get Marks, part 1")

You must create a makefile, and it must actually work. That is, the marker will type: (user@dirl$ make

This is the only way the marker will attempt to compile your code. If your makefile does not work, then. according to the marking guide, your code does not compile or run. (The marker will delete all existing .o files and executable files beforehand.)

Your Makefile must be written by you, and not automatically generated. It must be structured properly in accordance with the lecture notes.

Appendix a - insertion sort

Inspired from the idea of adding items to a list in sorted order. Every time a new item is added, insert it in sorted position.

Can also be applied to sorting an existing list.

Maintain a marker and insertion-sort the element at the marker into the items to the left of the marker.
ie: take the next item and insert it in sorted order into the sub-list that precedes the item.

Start the marker at the front of the list and move it up by one after each inserted item. Then items before marker will be sorted.

Searches for the insert position backwards so that we can take advantage of semi-sorted lists.

Pseudo-code for insertion sort using integers in an array.

METHOD InsertionSort IMPORT array EXPORT array

FOR nn < 1 TO array.length-1 DO                               < Start inserting at element 1 (0 is pointless)

ii <- nn                                                                                    <- Start from the last item and go backwards

temp e- array[ii]

WHILE (ii > 0) AND (array[ii-1] > temp) DO                 Insert into sub-array to left of nn

Use > to keep the sort stable

array[ii] < array[ii-1]                                              < Shuffle until correct location

ii<- - 1

ENDWHILE

array[ii] <- temp

ENDFOR

Note carefully - this algorithm is for integer arrays - you will need to convert it to sort LinkedLists of strings/integers. Remember that a LinkedList is of unknown length, so you should NOT use a for loop.

Reference no: EM131236021

Questions Cloud

Confidence interval estimate of mean red blood cell count : A simple random sample of 50 adults Is obtained and each person's red blood cell count is measured (in microliters).The sample mean is 4.23.The population standard deviation for red blood cell counts is .40.Construct a 99% confidence interval esti..
Describe the security problems that are created by employees : Describe the security problems that are created by employees. What are some special concerns about security with remote employees and employees who use wireless equipment?
What is the probability of more : A measuring device makes errors with a probability of 0.001 on each measurement. What is the probability of more than 20 errors in 10,000 measurements?
Percentage of scores falls between the mean : In a normal curve, what percentage of scores falls Between the mean and -2 SD's below the mean?
Write the sorted data to the specified output file : How the user would like the contents of the file sorted. The user must be able to sort on any of the columns. in ascending or descending order - Write the sorted data to the specified output file using the same format as the input file.
Necessary to estimate the proportion of interest : How large a sample is necessary to estimate the proportion of interest to within 2% in a 95% confidence interval?
What kinds of strategies did samsung use : What is Samsung's' approach toward managing the global environment? What kinds of strategies did Samsung use to become the global leader in the smartphone industry
Explain solid waste generation and management : Explain solid waste generation and management in a technological society. To what extent do you think we are equipped to handle solid waste issues in the future as the population continues to increase?
What is the probability that the satellite will function : On a rainy day each of the components independently functions with probability p1, whereas on a dry day they each independently function with probability p2. If the probability of rain tomorrow is α, what is the probability that the satellite will..

Reviews

len1236021

10/8/2016 6:28:59 AM

If you accept or copy code (or other material) from other people, websites, etc. and submit it, you are guilty of plagiarism, unless you correctly cite your source(s). Even if you extensively modify their code, it is still plagiarism. Exchanging assignment solutions, or parts thereof, with other students is collusion. Engaging in such activities may lead to a grade of ANN (Result Annulled Due to Academic Misconduct) being awarded for the unit, or other penalties. Serious or repeated offences may result in termination or expulsion. You are expected to understand this at all times, across all your university studies, with or without warnings like this.

len1236021

10/8/2016 6:28:27 AM

Every valid assignment will be initially awarded 100 marks. Marks will then be deducted for the following: up to -50% Commenting. You will not lose any marks if you have provided good. meaningful explanations of all the files, functions and data structures needed for your implementation. up to -50% Coding practices You will not lose any marks if you have followed good coding practices. and your code is well-structured, including being separated into various, appropriate .c and .h files. up to -100% functionality. - You have correctly implemented the required functionality. according to a visual inspection of your code by the marker.

Write a Review

C/C++ Programming Questions & Answers

  Write a program that creates an array of 200 random numbers

Write a program that creates an array of 200 random real numbers between 0 and 200.  Using the statistics library, calculate and output the following: mean, median, variance, standard deviation, maximum value, and minimum value.

  Write main function to compute stress-strain in steel rod

Write a main function and the following functions to compute the stress and strain in a steel rod of diameter D (inches) and length L (inches) subject to the compression loads.

  Problem 1greatest common divisor write code for a recursive

problem 1greatest common divisor write code for a recursive implementation of euclids algorithm for searching the

  Enrolling courses for students and for enrolledclass

A summary of business activities for enrolling courses for students and for enrolledclass lists for faculty members at an online university is as follows:

  Assignment 1write a program using vectors and iterators

assignment 1write a program using vectors and iterators that allows a user to maintain a personal list of dvd titles.

  Write a program using vectors and iterators that allows a

write a program using vectors and iterators that allows a user to maintain a personal list of dvd titles. the user

  Write a c program that will accept the name of a country

Write an interactive C program that will accept the name of a country as input display the corresponding capital and vice versa. Design the program so that it executes repeatedly until the word End is entered as input

  Generate a random number each time the operator is used

The function call operator is overloaded and will generate a random number each time the operator is used and objects can be created with the lower and upper bound of the random number specified.

  Create a main function to test the split function

Create a main function to test the split function, display the string prior to calling the split() function. Display the return value of the split function. Display each element of the vector after the split() function returns.

  Write a program that calculates the user''s bmi

Write a program that calculates the user's body mass index (BMI) and categorizes it as underweight, normal, overweight, or obese, based on the following table from the United States Centers for Disease Control

  Receive a number and determine whether it is odd or even

Receive a number and determine whether it is odd or even - Obtain two numbers from the keyboard, and determine and display which (if either) is the larger of the two numbers.

  Child process to take the role of the number guesser

Write a program in C that takes a number between 1 and 1024 as input on the command line, and then forks a child process to take the role of the number guesser

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