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

  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