The program write a program to analyze all integers

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

Part 1: The Program Write a program to analyze all integers contained in two text files. Both text data input files will contain an unknown number of integers (in the range 1 - 999), separated by whitespace. There may be duplicate integers in the files. The program will: - Read and organize all of the integers from the first data input file into two doubly linked lists, based on whether the integer is odd or even. - Search for all the integers in the second data input file, to determine which list they are in and what their location is within that list. The program must be modular and use correct parameter passing. Use of global variables will NOT be allowed. And object-oriented constructs (classes, objects, templates, STL, etc) may NOT be used. Although we will not be using objects yet, we will begin introducing object-oriented concepts, via Abstract Data Type data definitions and functions. Therefore, you will be required to implement the following doubly linked list data structure and functions. Data Structure Overview This program will maintain a doubly linked list for odd integers, and a second doubly linked list for even integers. The individual nodes in each list should contain one integer and two pointers (one pointer pointing forward to the next node and one pointer pointing backwards to the previous node) only. Sample Node: To create the doubly linked lists, first define a struct type that contains fields for the node data as described above (integer, pointer forward, and pointer backwards). integer forward pointer backward pointer The nodes in each list should contain integers and pointers only. Do not store any other additional information. Also define a second struct type for a doubly linked list. There should be a field for the length of the list (i.e. a count of nodes in the list) and a field for a pointer to a node, which will point to the top node in the list. You must implement the linked list data structures from scratch (no use of templates from the STL allowed). Initially, the lists should not contain any nodes (i.e. the top pointers will be NULL, and the length will be 0). After the lists are built, the backwards pointing pointer of the first node in each list will be NULL, and the forward pointing pointer of the last node in each list will be NULL. Function Overview You will be required to implement the following functions to operate on your doubly linked list data structure: InitializeList - takes a doubly linked list as input, initializes the fields (sets the length/count to 0 and the list top pointer to NULL), and passes back the initialized structure. EmptyList - takes a doubly linked list as input, and returns true if the list is empty (false otherwise). NumInList - takes a doubly linked list and an integer as inputs. Searches for an integer value within the list. If the value is found, returns a pointer to the node containing the value. If the value is not found, or the list is empty, returns NULL. OrderedListInsertIon - takes a doubly linked list and an integer as inputs. Inserts a new node (containing the passed in integer) into the doubly linked list, in ascending numeric order. Returns true if allocation and insertion of the new node was successful, false otherwise. ListLength - takes a doubly linked list as input, and returns the length of the list. PositionInList - takes a doubly linked list and an integer as inputs. Calls NumInList to determine if the integer is in the list. If it is, uses the backward pointers to determine the position of the node within the list. Returns an integer, representing the node position in the list, or 0 if the integer is not in the list. DisplayList - takes a doubly linked list as input. Traverses the list, neatly displaying all integers in the list. DestroyList - takes a doubly linked list as input, and frees the list memory by de-allocating all nodes in the list. length top Only the listed functions will be allowed to access the fields within the list data structure. All other code must use these functions to access the list. Implementation Details Your code must also follow all required coding standards from Content section 1.8. Part 1: Both input data filenames will be given as command line arguments to the program. The program should validate that exactly two filename arguments were given on the command line, and that both the filenames are valid (i.e. the files exist and can be opened), before trying to read data from either of them. If either (or both) filename argument is missing, or one of the files does not exist, the program should prompt the user for the necessary information, until two valid (existing) filenames are obtained. After validating that both data input files exist, the program should initialize both the lists to be empty. Odds 0 Evens 0 Then the program will process the first input data file, as follows: Read one integer at a time from the input file (integers will be separated by whitespace). For each integer the program reads, it should: 1) Determine which doubly linked list the integer belongs in (odd or even). 2) If the integer is unique, insert it into the list (no duplicates). This means you must first search to see if the integer is already in the doubly linked list. a) If the integer is already in the list, issue a message saying so. b) If the integer is not yet in the list, the program should insert the integer into the appropriate doubly linked list in ascending numeric order. NOTE: Your linked list program in CS362 and the first stack/queue assignment in CS372 were implemented by inserting nodes at the beginning (top) or end (bottome) of a linked list. This specification requires you to demonstrate the ability to code a different implementation, by inserting the data into the list in numeric order. NOTE: means the pointer is NULL Be sure to check that memory could be allocated for each new node before using it. c) As you insert numbers into the lists, increment the length to keep track of how many unique integers were inserted into each list. OddList 3 EvenList 2 If memory allocation fails while reading the first input data file, the program should immediately stop reading the file, issue an error message saying that not all numbers were inserted into the lists, and proceed directly to the second part of the program. Part 2: After all of the integers in the first data input file have been read and all unique integers have been inserted into the proper lists (or there was a memory allocation error), display: The filename processed The count of unique numbers inserted into each list The actual numbers in each list (10 numbers per line, formatted neatly in columns) Then process the second input data file to find numbers in the lists. 1) Display the filename of the file containing the numbers to search for. 2) Read one integer at a time from the second input file. Use the forward-pointing links in the doubly linked list, to search for each integer in the appropriate list. NOTE: Do not count nodes as you search in the forward direction! a) If the integer is not found, issue a message saying so. Also state specifically if it was not found because the list was empty. b) If the integer is found, the program should then use the backward-pointing links in the doubly linked list to count how far down in the list the integer was found, and display the results. NOTE: Previously you have traversed lists using forward pointing links to walk down the list. This specification requires you to demonstrate a different ability, using the backwards pointing links to walk up the list. After processing all integers in the second input file, the program should free up all nodes in the doubly linked lists, and exit. 812 413 41 88 339 Program Implementation Notes 1. Your program must conform to the CS372 Coding Standards. The program should include a file header comment block at the top of the program, and each function should include a function header comment block. 2. This program should be of modular design with proper parameter passing. - The breakdown of the code into functions must be logical, not arbitrary! - The main function should do little more than call other functions. - The other functions should each perform ONE well-defined task. 

Reference no: EM13777976

Questions Cloud

Overhead for the job of installing the irrigation system : Water ways has two major public-park projects to provide with comprehensive irrigation in one of its service locations this month. Job J57 and Job K52 involve 15 acres of landscaped terrain which will require special-order sprinkler heads to meet the..
Themartinweight loss clinic maintains two patient files : TheMartinWeight Loss Clinic maintains two patient files—one for male clients and one for female clients. Each record contains the name of a patient and current total weight loss in pounds. Each file is in descending weight loss order. Design the logi..
The amount that was invested in the mutual fund : An investor invested a total of $2,600 in two mutual funds. One fund earned a 7% profit while the other a 3% profit. If the investor's total profit was $138, how much was invested in each mutual fund? The amount that was invested in the mutual fund t..
Upstream and downstream sales : Pace Company owns 85% of the outstanding common stock of Sand Company and all the outstanding common stock of Star Company. Prepare in general journal form the work paper entries necessary to eliminate intercompany sales and intercompany profit in th..
The program write a program to analyze all integers : Part 1: The Program Write a program to analyze all integers contained in two text files. Both text data input files will contain an unknown number of integers (in the range 1 - 999), separated by whitespace. There may be duplicate integers in the fil..
Generally considered to be non-value-added time : Inspection Time is generally considered to be non-value-added time. Operating assets include cash, accounts receivable, and inventory but not any depreciable fixed assets.
Examine the differences between a linear and augmented line : "Developing a Website" Please respond to the following: Examine the differences between a linear and augmented linear structure. Examine the differences between hierarchical and linear structures. Explain why a coherent structure is necessary. Provid..
What interest rate would this be a fair deal : The Perpetual Life Insurance Co is trying to sell you an investment policy that will pay you and your heirs $11,707 per year forever. Suppose the Perpetual Life Insurance Co. told you the policy costs $198,190. At what interest rate would this be a f..
What is bitlocker technology : What is BitLocker technology. Why is it used in the simulation. What are Windows Deployment Services.

Reviews

Write a Review

 

C/C++ Programming Questions & Answers

  Write a program that generates all the factors of a number

Write a program that generates all the factors of a number entered by the user. For instance, the number 12 has the factors 2 * 2 * 3.

  Write a function that moves the largest item

Write a function that moves the largest item on a given linked list to be the final node on the list

  Write a program that will be used to gather statistical data

Write a program that will be used to gather statistical data about the number of movies

  Program to compute and show miles per gallon

Create the program in C++ which will input miles driven and gallons used (both as integers) for each tankful. Program must compute and show miles per gallon.

  Implementation of matrix multiplication

Show the matrix product and implementation of matrix multiplication. Please show me all the working and provide the answer.

  Program user to enter student names and final grades

Write a program that would allow a user to enter student names and Final grades (e.g. A,B,C,D,F) from their courses. You do not know how many students need to be entered. You also do not know how many courses each of the students completed.

  Calculate the celsius equivalent of a fahrenheit temperature

Prepare a program to calculate the Celsius equivalent of a Fahrenheit temperature

  Illustrate example from ansi c programming language

Illustrate example from ANSI C programming language, without using nested procedures, to show the fact that "assignment-by-sharing in conjunction with quasi-dynamic object binding

  Approximately normally distributed

Write a program MakeFile.cpp that creates a file random.dat that contains 200 random numbers where each number is the sum of 12 random values rand( )%9. When we add a sufficient number of uniformly distributed numbers the result is approximately n..

  Find answers of c programming questions

1. int main(void){ int height 3. 5; int width = 25: if(height == 5 && width == 25){printf("the height and width are correct: "); }return 0; }Assuming all libraries are included, what is the result of the code above when run?

  Display the list of all car record

Sales and Profits - show car model, the number of car in stock, car sold, unit cost, selling price and the profit for each car and the total profit for all cars.

  Integerset class create class integerset for which each

integerset class create class integerset for which each object can hold integers in the range 0 through 100. represent

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