堆栈与堆栈和堆与堆 [英] a stack vs the stack and a heap vs the heap

查看:41
本文介绍了堆栈与堆栈和堆与堆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的数据组织决赛学习,我正在研究堆栈和堆,因为我知道它们将进入决赛,我将需要了解差异.我知道堆栈是什么,堆是什么.

但是我对什么是堆栈和什么是堆感到困惑.

堆栈是 RAM 中存储内存的地方,如果空间不足,就会发生堆栈溢出.对象默认存放在这里,当对象超出范围时会重新分配内存,而且速度更快.

堆是 RAM 中存储内存的地方,如果空间不足,操作系统会分配更多空间.对于要存储在堆上的对象,需要使用 new 运算符来告知它,并且只有在告知后才会被释放.可能会出现碎片问题,它比 Stack 慢,但它可以更好地处理大量内存.

但是什么是栈,什么是堆?它是存储内存的方式吗?例如静态数组或静态向量是堆栈类型和动态数组,链表是堆类型?

谢谢大家!

解决方案

堆栈"和堆"是程序或操作系统以特定方式使用的内存块.例如,调用堆栈可以保存与函数调用和 是专门用于动态分配空间的内存区域.

将这些与堆栈和堆进行对比数据结构.>

stack 可以被认为是一个数组,其中的最后一个元素将第一个元素出来.对此的操作称为 push 和 pop.

heap 是一种表示特殊类型图的数据结构,其中每个节点的值都大于节点的子节点的值.

附带说明,请记住,堆栈"或堆"或任何堆栈/堆数据结构对于任何给定的编程语言都是独一无二的,但只是计算机科学领域的概念.

I'm studying for my data organization final and I'm going over stacks and heaps because I know they will be on the final and I'm going to need to know the differences. I know what the Stack is and what the Heap is.

But I'm confused on what a stack is and what a heap is.

The Stack is a place in the RAM where memory is stored, if it runs out of space, a stackoverflow occurs. Objects are stored here by default, it reallocates memory when objects go out of scope, and it is faster.

The Heap is a place in the RAM where memory is stored, if it runs out of space, the OS will assign it more. For an object to be stored on the Heap it needs to be told by using the, new, operator, and will only be deallocated if told. fragmentation problems can occur, it is slower then the Stack, and it handles large amounts of memory better.

But what is a stack, and what is a heap? is it the way memory is stored? for example a static array or static vector is a stack type and a dynamic array, linked list a heap type?

Thank you all!

解决方案

"The stack" and "the heap" are memory lumps used in a specific way by a program or operating system. For example, the call stack can hold data pertaining to function calls and the heap is a region of memory specifically used for dynamically allocating space.

Contrast these with stack and heap data structures.

A stack can be thought of as an array where the last element in will be the first element out. Operations on this are called push and pop.

A heap is a data structure that represents a special type of graph where each node's value is greater than that of the node's children.

On a side note, keep in mind that "the stack" or "the heap" or any of the stack/heap data structures are unique to any given programming language but are simply concepts in the field of computer science.

这篇关于堆栈与堆栈和堆与堆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆