C-Dynamic Memory Allocation and Data Structure Questions and Answers

Take Exam

Data Structure and Algorithms questions with answers are crucial for technical interviews and competitive exams like GATE, Infosys, and TCS. This topic tests understanding of arrays, linked lists, stacks, queues, trees, and sorting algorithms. Programming interview questions with answers in this section focus on time complexity, optimization, and problem-solving efficiency. Practicing DSA MCQs strengthens core programming logic, helping candidates excel in both written tests and coding interviews.

Detailed questions on dynamic memory use. For further practice, try database data models and data structures algorithms

C-Dynamic Memory Allocation and Data Structure

Showing 10 of 104 questions

51. I have implemented the queue with a linked list, keeping trck of a front pointer nd a rear pointer. Which of these pointers will change during tan insertion into a NONEMPTY queue?

  • Neither changes
  • Only front_ptr changes
  • Only rear_ptr changes
  • Both change
Show Answer Report

52. Suppose top is called on a priority queue that has exactly two entries with equal priority. How is the return value of top selected ?

  • The implementation gets to choose either one.
  • The one which was inserted first.
  • The one which was inserted most recently.
  • This can never happen (violates the perconditon)
Show Answer Report

53. Find the output void main ( ) { int *p, *q, *r; q=(int *) malloc (sizeof (int)); p=q-1 r=q+1; *p=100; *q=200; *r=300; p++; printf ("%d %d %d", *p, *q, *r); }

  • 200 200 300
  • 100 200 300
  • 200 200 200
  • None of these
Show Answer Report

54. Which datastructure works to handle multiple request in a time sharing system for use of CPU time sheduling

  • tree
  • Queue
  • Stack
  • Linked list
Show Answer Report

55. Circular buffer concept in computer system is based on which data structure

  • Queue
  • Stack
  • Trees
  • Graph
Show Answer Report

56. Circular buffer concept in computer system is based on which data structure

  • queue
  • Stack
  • Trees
  • Graph
Show Answer Report

57. Find the output void main ( ) { void *p; p=malloc(2); *p=(int) 100; printf("%d", *p; }

  • 100
  • Garbage output
  • Prints address where 100 is stored
  • Compilation error
Show Answer Report

58. In the array version of the stack class (with a fixed-sized array), which operations require linea time for their worst-case behavior?

  • is_empty
  • peek
  • pop
  • None of these operations require linear time.
Show Answer Report

59. Find the output, if the input is 2c3 void main ( ) { int *hi=25, *hello=4; hi=(int*) malloc (sizeof (int)); scanf("%dc%d", &hi, &hello); printf("%d %d", hi, hello); }

  • 2c3
  • 2d3
  • 2 3
  • 2 4
Show Answer Report

60. For a queue built using an array and containg n elements, the value of frong and rear would be respectively

  • (-1, n)
  • (0, n)
  • (0, n-1)
  • (-1, n)
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test