Tree data structure to represent category and subcategory of products

Given a product category and sub­category representation:
a. Come up with a tree data structure to minimally (in terms of storage) represent this
b. Write a program to convert the given representation (shown in example below) to this
c. Write a function to output the tree structure in a nice human readable format

Note:
a. There can be any number of levels of depth
b. Rows may be repeated in input, but need to feature only once in the final tree.

Example category list (read this input from a file):

everything else|office supplies
electronics|video games
electronics|video games|accessories
electronics|video games|accessories|headsets
electronics|video games|accessories|flight controls
electronics|video games|accessories|joysticks
Please note, that this is not a homework site. We won't do your homework for you. The purpose of homework is that you learn by doing. However we are always willing to help solve problems you encountered, correct mistakes you made in your code and answer your questions.

We didn't see your attempts to solve this problem yourself and so we cannot correct mistakes you didn't made and answer questions you didn't ask. To get help you should do something yourself and get real problems with something. If your problem is "I don't understand a thing", then you should go back to basics and study again.
Try to define the data structure for a category first. Then create a method called findOrAdd() that takes the name of a subcategory and returns a reference to the subcategory, adding it if it doesn't already exist. Last, write the code to parse the input file and print the result.
anybody here who has written the code for the same problem?
Why do you ask?
some one please tell me the running code of this problem its urgent
Topic archived. No new replies allowed.