(data structure) sorting algorithm

I am having my first assignment about data structure in C++. It is about a sorting algorithm.

It is suggested to use (1) MSD radix sort, (2) std 2D-vectors.

The task is that to sort the words (stored in a file, namely test, one word a line, all of lower case letters) alphabetically.

A. one vector is used to hold buckets
B. each bucket contains a vector of words
C. each bucket should be storing a sorting algorithm

The user is supposed to be able (in the command prompt) to:
(1) press 'R' to read the file, and add a word to the file
(2) press 'S' to sort the words in the file
(3) press 'P' to print the sorted words
(4) press 'Q' to quit


The followings are the sample input-output:
[content of the file storing the unsorted words]
beaus
adapter
bogeys
aardvark
anamorphic
astronomical
badgering
airframes
biochemist
approximates


[sample input]
R test
S
P
R does-not-exist
Q

[sample output]
R
S
aardvark adapter airframes anamorphic approximates astronomical badgering beaus biochemist bogeys
Could not read file: does-not-exist
Q

The followings are the functions that I have to implement:
(and maybe adding new functions if needed)
they are in the file datastructure.cpp

1
2
3
4
5
6
Datastructure::Datastructure()
Datastructure::~Datastructure() 
void Datastructure::add(string& word)
void Datastructure::sort()
void Datastructure::print()
void Datastructure::empty()


There is another file datastructure.h with similar contents.

How am I going to do this?

I am quite new to these stuffs and obviously I cannot be friends with the C++ language and I don't really know how to start at all.

Thank you if anyone can give me a generous help.
Last edited on
(1) MSD radix sort

http://en.wikipedia.org/wiki/Radix_sort

(2) std 2D-vectors.

Maybe you mean a vector of strings, something like: std::vector<std::string>?
Something 2D would be a matrix, like a vector of vectors of strings.

I am quite new to these stuffs and obviously I cannot be friends with the C++ language and I don't really know how to start at all.

http://www.cplusplus.com/doc/tutorial/

You must read the links and try again. I would suggest that you read the C++ tutorial first, and as soon as you are ready, start implementing the Datastructure class.

When you get to Datastructure::sort() start reading the Wikipedia article.
I'll try it, thank you.
Topic archived. No new replies allowed.