Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I need a way to implement a fast lookup algorithm / system to find users very quickly in a multi-level department and multi-level employee/manager relation organization structure.

Departments can have any level of departments and users directly connected to departments. User are connected to departments and other users at the same time.

What would be the best approach to implement such a system? There will be approximately 2000 users and 30 departments. Is there a good way to hold all of this information on memory?

share|improve this question

migrated from stackoverflow.com Feb 25 '11 at 13:34

This question came from our site for professional and enthusiast programmers.

3 Answers 3

I'm more than sure that on this scale (2000 users) pretty much any data structure that allows sequential access will do just fine (provided everyting's in memory, of course). What's even more, do you really need to invent complex lookup structure where a simple list will suffice?

Make It Work Make It Right Make It Fast

share|improve this answer

find users very quickly

This sounds like a tree structure.

Something like this:

class Department 
 List<Department> ChildDepartments
 List<User> Users

class User
 List<User> Childusers

This should be fine if you want to list all users of a department.

share|improve this answer

Dictionaries are in general what provide the fastest access. See this link on SO: .Net Data structures: ArrayList, List, HashTable, Dictionary, SortedList, SortedDictionary -- Speed, memory, and when to use each?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.