CIS3355: Business Data Structures in C/C++

Dr. Peeter Kirs

 

Dynamic Memory Allocation

Short Answer/Problem Questions

 

NOTE: Checking the answers before you have tried to answer the questions doesn’t help you at all

 

1000. What are the advantages of allocating memory dynamically?

 

            SEE SOLUTION

 

Assume that we created the data type:

 

Struct mydata

{

            char name[20];

            short DOB;

            struct mydata * next;

};

 

And then we associate a variables with the data type struct mydata:

 

Struct mydata * newdata, * firstdata, * lastdata;

 

1050. How do we request RAM dynamically?

 

            SEE SOLUTION

 

1070. How much RAM would be given to us?

 

            SEE SOLUTION

 

1090. How do we know that we will get the memory requested?

 

            SEE SOLUTION

 

1100.  Suppose we wish to link records together. EXPLAIN how we would go about doing it.

   

            SEE SOLUTION

 

1110.  Illustrate (graphically) how three records might be stored in RAM

   

            SEE SOLUTION

 

1120.  How do we free-up memory when we no longer need it?

   

            SEE SOLUTION

 

1130.  What is the procedure needed to remove a record from a list?

   

            SEE SOLUTION