Site icon T4Tutorials.com

Memory Management in data structures MCQs

1. : What is the primary purpose of memory management in data structures?

(A) To store data permanently


(B) To efficiently allocate and deallocate memory


(C) To increase processing speed


(D) To compress data



2. : Which of the following is a type of memory allocation?

(A) Static allocation


(B) Dynamic allocation


(C) Both A and B


(D) None of the above



3. : What is static memory allocation?

(A) Memory is allocated at runtime


(B) Memory is allocated at compile time


(C) Memory is allocated using pointers


(D) Memory is allocated in heap



4. : What is dynamic memory allocation?

(A) Memory is allocated before the program starts


(B) Memory is allocated during program execution


(C) Memory is never freed


(D) Memory is allocated using fixed sizes



5. : Which function is used to allocate memory dynamically in C?

(A) malloc()


(B) alloc()


(C) new


(D) reserve()



6. : What happens if memory allocated using malloc() is not freed?

(A) Memory leak occurs


(B) The program runs faster


(C) No effect


(D) The program terminates



7. : Which function is used to deallocate memory in C?

(A) free()


(B) delete


(C) release()


(D) dealloc()



8. : What is a memory leak?

(A) Memory used by the program is freed


(B) Memory allocated but not released


(C) Memory allocated at compile time


(D) Memory used for global variables



9. : Which of the following is a disadvantage of dynamic memory allocation?

(A) Flexibility


(B) Fragmentation


(C) Easy to implement


(D) Efficient memory usage



10. : What is fragmentation in memory management?

(A) Allocation of memory in large blocks


(B) Inefficient use of memory due to allocation and deallocation


(C) Memory being accessed by multiple programs


(D) None of the above



11. : What is the purpose of the ‘sizeof’ operator in C/C++?

(A) To determine the size of a variable in bytes


(B) To allocate memory dynamically


(C) To free allocated memory


(D) To copy data from one variable to another



12. : What is the difference between stack and heap memory?

(A) Stack is used for static allocation, heap for dynamic


(B) Stack is faster than heap


(C) Stack memory is managed automatically, heap is manually managed


(D) All of the above



13. : What type of memory allocation does the ‘new’ keyword perform in C++?

(A) Static allocation


(B) Dynamic allocation


(C) Stack allocation


(D) None of the above



14. : Which operator is used to deallocate memory allocated with ‘new’ in C++?

(A) delete


(B) free


(C) dealloc


(D) release



15. : What can cause a dangling pointer?

(A) Allocating memory correctly


(B) Freeing memory that is still in use


(C) Using static memory


(D) None of the above



16. : Which of the following methods can help prevent memory leaks?

(A) Using static memory only


(B) Properly freeing all allocated memory


(C) Allocating large chunks of memory


(D) Using global variables



17. : In which scenario would you prefer dynamic memory allocation?

(A) When the size of data is known at compile time


(B) When data size may vary during execution


(C) When you want to optimize execution time


(D) When you want to minimize memory usage



18. : What is the main advantage of using dynamic memory allocation?

(A) Faster execution


(B) Greater control over memory usage


(C) No need for memory management


(D) Simpler code



19. : Which of the following is NOT a memory management technique?

(A) Paging


(B) Segmentation


(C) Compiling


(D) Fragmentation



20. : What is a memory pool?

(A) A single large block of memory


(B) A collection of fixed-size memory blocks


(C) A way to allocate stack memory


(D) A method to sort memory addresses



21. : What is the purpose of garbage collection?

(A) To improve program execution speed


(B) To automatically free unused memory


(C) To allocate more memory


(D) To manage static memory



22. : What is the impact of not managing memory properly in a program?

(A) Increased performance


(B) Reduced memory consumption


(C) Crashes and unpredictable behavior


(D) Simplified code structure



23. : In what situation would stack memory be preferred over heap memory?

(A) When the size of data is unknown


(B) When data needs to be persistent


(C) When speed is critical and size is fixed


(D) When data needs to be shared



24. : Which of the following is a common method to detect memory leaks?

(A) Code reviews


(B) Memory profiling tools


(C) Reducing the number of variables


(D) Using static memory



25. : What does the term ‘stack overflow’ refer to?

(A) Excessive allocation of heap memory


(B) The stack exceeding its size limit


(C) Memory being allocated incorrectly


(D) None of the above



26. : What is a sentinel value in memory management?

(A) A value that indicates the end of a data structure


(B) A type of memory allocation


(C) A pointer to a memory address


(D) A method of freeing memory



27. : What is the primary function of the operating system in memory management?

(A) To allocate memory to running programs


(B) To compile programs


(C) To monitor program execution


(D) To free unused memory



28. : How does segmentation differ from paging?

(A) Segmentation is based on variable-size blocks, while paging is fixed-size


(B) Segmentation is faster than paging


(C) Paging uses less memory than segmentation


(D) There is no difference



29. : What is ‘thrashing’ in the context of memory management?

(A) Excessive swapping of data between memory and disk


(B) An efficient use of memory


(C) An increase in memory speed


(D) None of the above



30. : What is an object in memory management?

(A) A pointer to a memory address


(B) A block of memory that has a specific type


(C) A variable


(D) None of the above



31. : What is the main disadvantage of static memory allocation?

(A) It is faster


(B) It is less flexible


(C) It requires more coding


(D) It is not portable



32. : Which of the following best describes a heap?

(A) A specific area of memory used for stack allocation


(B) A memory area for dynamic allocation


(C) A method of memory management


(D) None of the above



33. : What are memory addresses?

(A) Locations in the CPU


(B) Locations in the RAM


(C) The speed of memory


(D) The data types of variables



34. : How can memory fragmentation be reduced?

(A) By using dynamic allocation only


(B) By using fixed-size memory blocks


(C) By allocating all memory at once


(D) By increasing memory size



35. : What does a pointer represent in memory management?

(A) A variable


(B) An address in memory


(C) A type of allocation


(D) A memory error



36. : What type of memory is automatically managed by the compiler?

(A) Heap memory


(B) Stack memory


(C) Global memory


(D) Static memory



 

 

Data Structures MCQs

Basic Concepts

  1. Introduction to Data Structures
  2. Complexity Analysis MCQs

Linear Data Structures MCQs

  1. Arrays MCQs
  2. Linked Lists MCQs
  3. Stacks MCQs
  4. Queues MCQs

Non-Linear Data Structures MCQs

  1. Trees MCQs
  2. Heaps MCQs
  3. Graphs MCQs

Hashing MCQs MCQs

  1. Hash Tables

Sorting and Searching Algorithms MCQs 

  1. Sorting Algorithms MCQs
  2. Searching Algorithms MCQs

Miscellaneous

  1. Memory Management in data structures MCQs
  2. String Manipulation Algorithms MCQs
  1. Data Structures MCQs 1
  2. Data Structures MCQs 2
  3. Data Structures MCQs 3
  4. Data Structures MCQs 4
  5. Data Structures MCQs 5
  6. Stacks Solved MCQs
  7. Queues MCQs
  8. pointer mcqs
  9. Array MCQs

 

Exit mobile version