What is the difference between the stack and the heap?

1 Answer

Answer :

The stack is a local memory reserve where the program stores variable and function data. The heap is a special memory reserve where the programmer can dynamically allocate memory from. The heap is useful when the programmer doesn't know how large to make certain variables, he just constructs one of the right size during run-time.

Related questions

Description : Is a struct stored on the heap or stack? 

Last Answer : Stack

Description : What is a heap and a stack?

Last Answer : There are 2 kinds of heap - 1: a chunk of memory where data is stored and 2: a tree based data structure. When we talk about the heap and the stack we mean the first kind of ... a LIFO data structure that stores variables and flow control information. Typically each thread will have its own stack.

Description : In UNIX operating system, when a process creates a new process using the fork() system call, which of the following state is shared between the parent process and child process? (A) Heap (B) Stack (C) Shared memory segments (D) Both Heap and Stack

Last Answer : (C) Shared memory segments 

Description : Match the following types of variables with the corresponding programming languages: (a) Static variables (i) Local variables in Pascal (b) Stack dynamic (ii) All variables in APL (c) Explicit heap dynamic (iii) Fortran 77 (d) Implicit ... (ii) (C) (iii) (i) (iv) (ii) (D) (ii) (i) (iii) (iv)

Last Answer : (C) (iii) (i) (iv) (ii) 

Description : Can you dispose of paper in a compost heap?

Last Answer : There’s chemicals used in paper manufacturing; bleaches and dyes and so forth, that can leech into the compost, I’d imagine. I wouldn’t put paper in the compost, no.

Description : Does anyone know how to build a compost heap?

Last Answer : This link has a pretty good explanation as to how to do so.

Description : A heap of wheat is in the form of a cone whose diameter is 10.5 m and height is 3 m. -Maths 9th

Last Answer : Diameter of cone = 10.5 m Radius of cone (r) = 5.25 m Height of cone (h) = 3 m Volume of cone = 1 / 3 πr2h = 1 / 3 × 22 / 7 × 5.25 × 5.25 × 3 = 86.625m3 Cost of 1m3 of wheat = 10 ∴ Cost of 86.625 m3 of wheat = 10 × 86.625 = 86.625

Description : A heap of wheat is in the form of a cone whose diameter is 10.5 m and height is 3 m. -Maths 9th

Last Answer : Diameter of cone = 10.5 m Radius of cone (r) = 5.25 m Height of cone (h) = 3 m Volume of cone = 1 / 3 πr2h = 1 / 3 × 22 / 7 × 5.25 × 5.25 × 3 = 86.625m3 Cost of 1m3 of wheat = 10 ∴ Cost of 86.625 m3 of wheat = 10 × 86.625 = 86.625

Description : A heap of wheat is in the form of a cone whose diameter is 10.5 m -Maths 9th

Last Answer : Radius of the conical heap of wheat (r) = 10.5/2 m Height of the conical heap of wheat (h) = 3 m Volume of the conical heap of wheat = 1/3 πr2h = 1/3 x 22/7 x (10.5/2)2 x 3 = 173.25/2 = 86.625 ... = 6.05 m Area of canvas required = curved surface area of cone πrl = 22/7 x 10.5/2 x 6.05 = 99.825 m2

Description : what is a heap

Last Answer : Need Answer

Description : When Marrion divided 24 oranges into 3 heaps in the ratio 4 to 5 to 3 how many oranges were in each heap?

Last Answer : There are 8, 10 and 6.

Description : What is the collective noun heap?

Last Answer : The noun 'heap' is used as a collective noun for: a heap oftrash.

Description : The layers of vegetable wastes and night soil alternatively piled above the ground to form a mound, is called A. A heap B. Plateau C. Windrow D. None of these

Last Answer : ANS: D

Description : Safe condition for storage of high V.M. bituminous coal is that (A) Height of the coal heap should be < 3 metres (B) Maximum 200 tons should be stored in a heap (C) Both (A) and (B) (D) Neither (A) nor (B)

Last Answer : (C) Both (A) and (B)

Description : Define what are the advantages and disadvantages of a heap?

Last Answer : Storing data on the heap is slower than it would take when using the stack. Define, However, the main advantage of using the heap is its flexibility. That's because the memory in this ... particular order. Slowness in the heap can be compensated if an algorithm was well designed and implemented.

Description : Which of the following is not the internal sort? A) Insertion Sort B) Bubble Sort C) Merge Sort D) Heap Sort

Last Answer : C) Merge Sort

Description : Which of the following algorithms has lowest worst case time complexity? a) Insertion sort b) Selection sort c) Quick sort d) Heap sort

Last Answer : d) Heap sort

Description : Consider the situation in which assignment operation is very costly. Which of the following sorting algorithm should be performed so that the number of assignment operations is minimized in general? a) Insertion sort b) Selection sort c) Heap sort d) None

Last Answer : b) Selection sort

Description : Which of the following is not an in-place sorting algorithm? a) Selection sort b) Heap sort c) Quick sort d) Merge sort

Last Answer : merge sort

Description : Which of the following is a stable sorting algorithm? a) Merge sort b) Typical in-place quick sort c) Heap sort d) Selection sort

Last Answer : a) Merge sort

Description : Which one of the following array represents a binary max-heap? (A) [26, 13, 17, 14, 11, 9, 15] (B) [26, 15, 14, 17, 11, 9, 13] (C) [26, 15, 17, 14, 11, 9, 13] (D) [26, 15, 13, 14, 11, 9, 17]

Last Answer : (C) [26, 15, 17, 14, 11, 9, 13]

Description : Heap allocation is required for languages  A) That support recursion B) That support dynamic data structures C) That use dynamic scope rules D) None of the above

Last Answer : Heap allocation is required for languages That support dynamic data structures

Description : How do Ants stack their hills?

Last Answer : One grain at a time.

Description : How do the yellow, red, white, and other potaotes stack up healthwise?

Last Answer : answer:The same. Purple potatoes are very similar to the popular Russet potatoes in nutritional value. One-half cup of purple potatoes contains 70 calories, 15 grams of carbohydrates, 1 gram of fiber, 2 ... kind, since they have more surface area (skin) per amount of starchy inside (total volume).

Description : Do you clean as you go along, stack until later, or call Jeeves to finish it off?

Last Answer : We have staff for that, none go by the name of Jeeves though.

Description : How do you find a needle in a hay stack?

Last Answer : answer:Er, I was gonna cheat and look on your FaceBook, but unless you really are seven years old, the date there isn't right. (so I'm guessing it's your relationship) 8 and 18. Doesn't tell me ... today? Also yeah, the haystack, just set that shit on fire, or go buy another needle. Cmon, tell me.

Description : Is it a bad idea to drop peanut butter cups or other small candies into a cake you're going to stack?

Last Answer : We put together multilayer wedding cakes, by using dowel rods in the cake to support the weight, and each layer on its own cardboard separator.

Description : What does "Stack overflow at line 356" mean on the facebook site?

Last Answer : Have you tried it with a different browser? Do you get the same error?

Description : In terms of memory of the story (or information), how does an audio book stack up to a paper (or electronic) one?

Last Answer : I find things read remembered better than things heard, but that could just be me =]

Description : Is there a good way to determine if a stack is a palindrome?

Last Answer : Since palimdrome stacks are by definition symmetric, you can cut the stack in half, reverse the second half, and compare it to the unaltered first half. This is the fastest possible strategy to do ... your time, since all combinations in the last half have already been checked in the first half.

Description : You have eight bowls, four red and four blue. Aside from the color, they are identical. How do you stack them?

Last Answer : Random, for I am a bowl stacking rebel! ;)

Description : Have you ever used the ECA stack for weight loss?

Last Answer : I’ve never used it, but it gives me a bad taste in my mouth just hearing about it. I don’t believe for one second that you can ingest a combination of stimulants like that and it wouldn’t have a negative effect on your body. Namely your heart.

Description : My stack dryer is kaput. Washer is okay. Do I have to buy a set?

Last Answer : If you have a little bit of extra space in your home, get one of these.

Description : Why do iron ore mines first stack the ore with stackers and then reclaim it via reclaimers to transfer it to export conveyors?

Last Answer : Stacking and reclaiming allow mines to create stockpiles of ore between stages of the operation. These stockpiles act as buffers that insulate the various stages from uneven flows upstream and downstream. ... the flow by creating reserves along the way that can be expanded or depleted as necessary.

Description : The zookeepers are having fun as earthlings are trying to stack the boxes - What do you think about the zoo hypothesis?

Last Answer : Um, isn’t that the “Prime Directive” from Star Trek?

Description : I'm trying to use the stack application on my iPod Touch but I can't install the stack. It says: Error. Unable to write springboard configuration. How can I fix this?

Last Answer : answer:Depending on how dedicated you are, restoring the phone and creating a new backup will most likely solve your issue. btw: the Stacks app is not as cool as it sounds. Its very sloppy.

Description : First made but last gone. Always at the bottom of the stack. What am I? -Riddles

Last Answer : The First Pancake.

Description : Should I put it up to the wall? Or fold it a short distance from the wall.

Last Answer : I stacked wood a short distance from the wall so that air could flow behind it. I don't cut anymore, I don't cut, I don't fold ... :(

Description : small,plastic,food,containers,the,stack,kind

Last Answer : Need Answer

Description : Wondering what's the best tech stack for mobile app development?

Last Answer : The most popular tech stack for mobile app development is Java. Other options are: Flutter; it is created by Google. Python is also relatively popular Swift Kotlin

Description : What is a flattened stack of membrane that modifies sorts and package proteins?

Last Answer : Need answer

Description : If you made a stack of nickeis 100 inches tall how many nickels would you need?

Last Answer : What is the answer ?

Description : How many nickels are there in 100 inches tall stack?

Last Answer : There are 1302 of them.

Description : How high can you stack the Decorative Stone Landscape Garden Edging?

Last Answer : The Decorative Stone landscaping edging can be stacked about four inches high. If it gets any higher it may collapse on itself.

Description : Does LG have a washer and dryers that stack on top of each other for space saving?

Last Answer : Yes, they have multiple stackable dryer/washers.

Description : How does the overall power and performance stack up to its full sized counterparts?

Last Answer : This computer has a slightly longer than average battery life, but the graphics and processing speed will pale in comparison to a larger notebook or desktop. It is a sturdy business machine, and that's exactly what it was intended to be.

Description : I need a stack washer and dryer for my new apartment.What is the cost?

Last Answer : the price range for stackable washer & dryer is $848.00-1200.00 depending on the store. Lowes and Home Depot have excellent prices.

Description : Tex-Mex Tortilla Stack?

Last Answer : Ingredients1 9-oz. pkg. (2 cups) frozenChopped cooked chicken 1 c Finely chopped, peeledJicama 1/2 c Taco sauce8 10-inch flour tortillas1 6-oz. container frozenAvocado dip, thawed 2 c Chopped lettuce1 16-oz. can ... g fiber, 24 g pro. Daily values 13% vit A, 26% vit. C, 29% calcium, 24% iron.