24 votes 24 votes Which languages necessarily need heap allocation in the runtime environment? Those that support recursion. Those that use dynamic scoping. Those that allow dynamic data structure. Those that use global variables. Compiler Design gatecse-2010 compiler-design easy runtime-environment + – go_editor asked Sep 29, 2014 • edited Oct 25, 2016 by go_editor go_editor 8.4k views answer comment Share Follow See all 2 Comments See all 2 2 Comments reply Raju Kalagoni commented Feb 24, 2018 reply Follow Share same Q appeared in ISRO 2017 dec .. 4 votes 4 votes smsubham commented Dec 25, 2019 reply Follow Share Same as previous year question https://gateoverflow.in/2226/gate1997-1-10 1 votes 1 votes Please log in or register to add a comment.
Best answer 39 votes 39 votes Those that allow dynamic data structure. malloc etc uses memory from heap area. Sankaranarayanan P.N answered Nov 16, 2014 • edited Jan 27, 2018 by kenzou Sankaranarayanan P.N comment Share Follow See all 4 Comments See all 4 4 Comments reply rtalwar commented Apr 11, 2018 reply Follow Share Why not option A ,because during recursion the stack gets overflowed and hence we need memory from the heap for variables? 0 votes 0 votes sushmita commented Jan 8, 2019 reply Follow Share remember stack overflow:) 1 votes 1 votes jlimbasiya commented Dec 7, 2019 reply Follow Share We store global variable in heap memory. then why not option D also? @sushmita @Sankaranarayanan P.N @jothee 0 votes 0 votes Gaganjot _Kaur commented Jan 22, 2020 reply Follow Share @jlimbasiya Global variables are stored in the data section of the program, not heap, because on heap we can only access memory through pointers. But in many programs we do not necessarily use malloc(), calloc() etc to define global variables. 4 votes 4 votes Please log in or register to add a comment.
5 votes 5 votes C Heap allocation is needed for dynamic data structures like tree, linked list, etc rajoramanoj answered Aug 22, 2017 rajoramanoj comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes All of the options shsould be correct here rajveer43 answered Dec 29, 2023 rajveer43 comment Share Follow See all 0 reply Please log in or register to add a comment.