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

Previous Q& A

  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.

  Bond that is issued at a discount-about the date of record

Bradley Corporation issued 10,000 shares of common stock on January 1, 2013. The stock has par value of $0.01 per share and was sold at $25 per share. The journal entry for this transaction would: Which of the following statements is TRUE about a bon..

  Do you make in the sound intensity level

If you install special sound-reflecting windows that reduce the sound intensity level by 32.0 dB, by what factor have you reduced the sound intensity - do you make in the sound intensity level?

  Case study on bring your own device

Explain how businesses apply cryptography in maintaining information security.Use technology and information resources to research issues in information systems security.Write clearly and concisely about network security topics using proper writing m..

  Explain the courts decision

Estate of Fry v. Labor and Industry Review Commission case, explain the courts decision. Identifiy circumstances in which you could feel the out come could have been different

  American dream of social mobility a myth

In your opinion, is the American dream of social mobility a myth? Why or why not? Defend your answer.

  Interest rate to fund retirement goal

George Just hit the jackpot in Las Vegas and won $55,000! if he invests it now, at a 12% interest rate, how much will it be worth 15 years from now? Zach would like to have $4,000,000 saved by the time he retires 40 years from now. How much does he n..


Write a Review


Similar Q& A

  Prefetching is a technique that leverages predictable

Prefetching is a technique that leverages predictable address patterns to speculatively bring in additional cache blocks when a particular cache block is accessed. One example of prefetching is a stream buffer that prefetches sequentially adjacent..

  The imperial system of measurements

The Imperial system of measurements uses feet and inches for length, where 1 foot is equal to 12 inches. Write a class named Imperial that will represent distance measurements in feet and inches. Your class should include the following.

  Write mergesort code for data instead of as array

Write mergesort code for data instead of as array - which takes a linked list of integers, as in the bubblesort example code. The decclaration of the struct listnode is the same as in the bubblesort on lists example.

  Implementation of data member counter of type int

Write the implementation (.cpp file) of Counter class. Here is the full specification of the class: A data member counter of type int.

  Write program function prompt user for number of elements

Write a C++ program main function which will prompt the user for the number of elements called N desired for an array which has the capacity to store 50 elements.

  Use the top-down modular approach to design program

Use the top-down modular approach and pseudocode to design a suitable program to solve it. Where appropriate, use defensive programming techniques.

  Calculates the factorial value of its single int parameter

Write a method called fact that recursively calculates the factorial value of its single int parameter.

  Concept of object-oriented programming

Determine the manner in which each of the provided concepts relates to the concept of object-oriented programming. Justify your response - Analyze the fundamental manner in which they each relate to C++ coding of programs.

  By a minimal interpretation that makes a formula

By a minimal interpretation that makes a formula true, we mean that if one atom is removed from the interpretation then the resulting interpretation does no longer make the formula true.

  Write a program that convert fahrenheit to degrees celsius

Write a program that will convert Degrees Fahrenheit to Degrees Celsius.

  Programming questions

Write a program (including timing measurements) for the following scenario. Generate 20 million random numbers, one at a time, and insert them into an array that doubles every time it runs out of space (starting size of 2), into an array that can..

  A stack is referred to as a last-in first-out

This lab, along with your TA, will help you navigate through designing, implementing, and testing a dynamic stack. Recall, a stack data structure is a restricted linked list, where only the top node in the stack may be accessed at any given time

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