Memoirs of a Technocrat

by Niroshan Rajadurai

  • Increase font size
  • Default font size
  • Decrease font size

String Analysis and Formatting Test

E-mail Print PDF
User Rating: / 0
PoorBest 

Develop a program using C++ to meet the following requirements.

1. Parse an input file, and produce an output list with the following information

  • list all words consisting of alphabetic characters only
  • the list should be alphabetically sorted
  • next to each word, list the number of times it occurs in the input file
  • next to each word, list the unique line numbers it occurs on

 

2. Tolerances

  • The input file can be of any size
  • The input file can be either binary or ascii
  • A single line in a file can be of any length

 

3. Syntax

  • The executable should be named _sorter.exe
  • calling <your_first_name>_sorter.exe -h should display the following information, with each piece of data on a new line:
    • Your fullname, eg. "Name: Robert Smith"
    • Your contact email, eg. "Email: This e-mail address is being protected from spambots. You need JavaScript enabled to view it "
    • The date you completed the programming test, eg. "Test Date: 6th June 2008"
    • How long it took you to compelete the test, eg. "Time Taken: 03hrs 53mins"
  • Calling <your_first_name>_sorter.exe -f should execute the program and produce results in accordance with requirements 1 and 2.

 

4. Sample input and output Input File -> Fox.txt

Data for Fox.txt

The quick brown fox
Jumps over the big blue fence
The blue fence should have been higher
Command line -> <your_first_name>_sorter.exe -f Fox.txt

Output (stdio)

been 1 3
big 1 2
blue 2 2, 3
brown 1 1
fence 2 2, 3
fox 1 1
have 1 3
higher 1 3
jumps 1 2
over 1 2
quick 1 1
should 1 3
the 3 1, 2, 3

 

5. Limits

  • You may only using string processing, standard I/O, and math libraries in your solution. The use of STL or any other 3rd party library is not permitted.
  • You may use a language reference, and algorithms reference book during the exam
  • You cannot get assistance either directly (from another individual), or indirectly (through a web search, news group, etc) to implement the program

 

Comments (0)
Last Updated on Monday, 24 January 2011 12:26