hello all-
i need some help implementing a priority queue which works by using
min heaps for storing the data. appropriate stuff it should have is
adding an event to the queue, creating an empty one, getting and
removing the even with lowest eta, and seeing if it is empty.
it should also contain something similar to a struct like this one:
struct item { event, eta }
it doesn't have to be anything extremely fancy, just a good
implementation of it. if you have any questions please feel free to
ask. thanks alot for the help |
Request for Question Clarification by
mathtalk-ga
on
04 May 2003 06:37 PDT
Hi, balzack-ga:
You don't explicitly state what programming language you are
interested in, but from the mention of struct's, I assume it's in the
C-family of languages.
The C++ Standard Library (STL) provides a template class:
std::priority_queue<T>
in the same header file as ordinary queues. Please clarify whether
the STL approach interests you, and any additional "design" issues.
regards, mathtalk
|
Request for Question Clarification by
dogbite-ga
on
04 May 2003 13:03 PDT
Hey balzack-ga,
If you're not interested in using templates
and simply want somebody to write you a
priority queue for event structures, I'm
willing to do that.
dogbite-ga
|
Clarification of Question by
balzack-ga
on
04 May 2003 14:09 PDT
Hi-
First off, i am talking in C++ preferrably, otherwise C is ok.
I do not want to use templates, just a simple event structure using
priority queues like in the intial post is what i'm looking for. just
like dogbite suggested. also i liked dogbite's previous help with one
of my questions alot so dogbite, if you want to answer it, i'd be glad
to see that.
thanks!
|
Hi balzack-ga,
I have put the code for your priority
queue here:
http://nms.lcs.mit.edu/~gch/google/priorityqueue.tar.gz
The instructions for how to compile
and run it are in the top of the file.
Please let me know if it works for you.
dogbite-ga |
Request for Answer Clarification by
balzack-ga
on
05 May 2003 15:02 PDT
Hi there-
I have a few questions.
1) What arguments are supposed to be passed to the program via the
command line? Or is that a mistake?
2) After I run the program, it works fine but at the end, after it
correctly prints out the testing code, it gives me an error message.
Do you have any idea what this could be from? Not a compiler error, it
happens when I am running the program.
3) Just want to make sure, when using heaps its easier not to include
[0], that is what is going on, correct?
Thanks for the help!
|
Clarification of Answer by
dogbite-ga
on
05 May 2003 15:08 PDT
Hi balzack-ga,
I'll take the questions in order:
1) There are no command line arguments for
the program. Your question didn't specify
that it took any arguments. Are you asking
why the main() function has int argc and
char *argv[] in the function declaration?
If so, that's just standard form, even when
there are no command-line arguments.
2) What error are you receiving? I'm guessing that
is because the priority queue is empty for the
last cout. It printed (null) on my system, but
maybe it breaks on yours. I have updated the
priorityqueue.tar.gz file -- hopefully you won't
get an error now.
3) Yes, I ignore the zeroth element in the array because
it makes the math easier. You're correct.
I hope that helps.
dogbite-ga
|
Request for Answer Clarification by
balzack-ga
on
05 May 2003 15:55 PDT
OK, I just usually use a void main(void) if there aren't any
arguments.
It works fine now, you're right, it was trying to print an empty
holder and it caused the error.
Great job, thanks alot for the help.
|
Clarification of Answer by
dogbite-ga
on
05 May 2003 16:00 PDT
Hey balzack-ga,
I'm very happy that I could help.
Let me know if you need me to
answer something else in the future.
And, thanks for the tip!
dogbite-ga
|