logo

Dynamic Memory Allocation

   

Added on  2022-09-01

19 Pages2420 Words18 Views
Test Plan and Results:
As per the given requirement in the assignment, There will be 7 options available in
the menu and user will be asked to specify the data structure and based on the
selection the memory is allocated and the value is stored in it. The two data
structure which are used are linked list and stack.
Class Diagram:
Below is the sequence diagram for insertion of object in the linked list. The flow will
be the user is prompted to enter the object type, if selected Linked list then
memory is allocated, the user is prompted to enter the value and if entered then
value is stored in the memory. Once done then the object is added.

Following are the test case for the program:
Test case 1: Stack object needs to be created and 5 is added into it.
Expected Result: User is prompted to select the type and then for values.
The value should be entered in the stack object.
Test case 2: Linked List object needs to be created and 5 is added into it.
Expected Result: User is prompted to select the type and then for values.
The value should be entered in the Linked list object.
Test case 3: Display the content of the Linked List
Expected Result: User is prompted to select the type and then all the values of
Linked List will be displayed and it should not display the content of Stack.
Test case 4: Display the content of the Stack
Expected Result: User is prompted to select the type and then all the values of
Linked List will be displayed and it should not display the content of Linked List.
Test case 5: Save file with the content of the Linked List
Expected Result: User is prompted to select the type and then all the values of
Linked List will be saved in the file and it should not save the content of Stack.
Test case 6: Save file with the content of the Stack

Expected Result: User is prompted to select the type and then all the values of
Stack will be saved in the file and it should not save the content of Linked List.
Test case 7: Quit the Program
Expected Result: It will exit the program
Test case 8: Linear Search option is selected then it will display the time for Linked
List and Stack.
Expected Result: It will show the time.
Evaluation of the Program:
Strength Of the program:
The main strength of this program is that dynamic data structures vector and stack
are used and it provides user of the program to select anyone of it. This program
does not allocate the memory until unless the type of data structure is chosen. The
strength of the program is that it provides option to user of the program to enter
manually the type of object and store in the data structure or insert from the file
(there is no restriction on the number of objects). Additionally user of the program
can by himself validate which data structure is better by comparing the execution of
linear search on each of the data structure. This program every time ask user to
provide the name of the data structure on which the action needs to be performed.
In this way user can experiment on both the type of data structures.
Weakness of the program:
Both the stack and vector are objects and hence consuming more memory as
compared to arrays. Because of dynamic memory allocation nature if not all
memory is used then it leads to complete wastage of the memory. Insertion and
deletions are slow. This program in every option ask again and again the data
structure on which the operation need to be performed.
Performance of data structure with linear search:
If we compare both the data structure then the performance of linear search is good
in Stack as compared to vector. The reason behind is that stack has first pop and

push operation as compared to vector which slow performance at tail. The snapshot
is attached below.
Main Functionality in the program:
The important aspect in the program is the template usage, the class for Link and
List are created and which help to create the data structure for Linked List. The
methods are defined inside the List class and the list class is made friend class in
Link class. Hence the object of Link class is created and made used of this data
structure. Below is the code snapshot.
The important functionality is to dump the data structure in the file:

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Working Program using C++ : Report
|3
|1237
|618

ITECH1400 Fundamentals of Programming - Australian Tax Office
|12
|1191
|15

Software for Call Centre Queue Management | Desklib
|6
|611
|425

PI306 C++ Programming Name of the Student Name of the University Authors
|14
|2251
|265

Understanding Buffer Overflow: Stack and Heap Buffer Overflows, Exploiting Buffer Overflow, JOP and ROP
|11
|1080
|283

Developing a Command Line Text-Based User Interface for Memory Database
|13
|1316
|373