Why must we deallocate the NetworkNodes at the end of the program, don they get destructed automatically?
A. Destructors only get called automatically for things that go out of scope (i.e., when the loop or function that contained it ends). Dynamically-allocated things exist beyond the scope in which they were created. So, you must “delete” them. If, however, the dynamic thing does have a destructor (NetworkNodes don’t), it will be called when the thing is deleted. Thus, although the queue will destroy itself, the things stored in it do not. You must do that explicitly. While it is true (on most machines) that all the program’s memory gets reclaimed when the program ends anyhow, this is not necessarily true. Thus, you should get in the habit of making sure you deallocate everything before a program ends. • Q. Why are we sending in the key to probe_amount() when we are going to be probing the hash table linearly? A. Linear probing is not the only option. Some probing strategies compute how much to probe via the key, thus any good “generic” hash table class (like StrTable) must take it as a
Related Questions
- We have been accredited by the College of American Pathologists (CAP) through their Laboratory Accreditation Program (LAP). Do we automatically receive full Ontario Accreditation?
- How do I stop the Janus program installer automatically starting when I put the CD in the CD-ROM drawer?
- Does participating in the First-Time Homebuyer Program automatically qualify me to buy a home?