解释一个数据*结构*和一个数据*类型*之间的区别* [英] Explain the difference between a data *structure* and a data *type*

查看:163
本文介绍了解释一个数据*结构*和一个数据*类型*之间的区别*的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试回答复合数据类型和数据结构有什么区别?我意识到,虽然我清楚了解数据类型是否是,以及它是如何不一样的作为数据结构,我不能把差异放在一起。如果你正在教一个简介的CS课程,你将如何解释这个差异?

While trying to answer What is the difference between a composite data type and a data structure? I realized that while I have a clear idea of what a data type is, and how it is not the same thing as a data structure, I cannot put the difference into words. If you were teaching an intro CS course, how would you explain the difference?

推荐答案

数据结构是组织数据的方式的抽象描述,以允许有效地执行其上的某些操作。例如,二叉树是数据结构,斐波那契堆,AVL树或滑雪板也是如此。理论家描述数据结构并证明其属性,以表明某些算法或问题可以在某些假设下有效解决。

A data structure is an abstract description of a way of organizing data to allow certain operations on it to be performed efficiently. For example, a binary tree is a data structure, as is a Fibonacci heap, AVL tree, or skiplist. Theoreticians describe data structures and prove their properties in order to show that certain algorithms or problems can be solved efficiently under certain assumptions.

数据类型是一个(潜在的无限)类的具体对象,它们都共享一些属性。例如,integer是包含所有无限多个整数的数据类型,string是包含所有无限多个字符串的数据类型,32位整数是一个数据类型,包含所有可以在30两位。没有要求数据类型是一种语言中的原语 - 例如,在C ++中,类型 int 是一个原语,就像这样:

A data type is a (potentially infinite) class of concrete objects that all share some property. For example, "integer" is a data type containing all of the infinitely many integers, "string" is a data type containing all of the infinitely many strings, and "32-bit integer" is a data type containing all integers expressible in thirty-two bits. There is no requirement that a data type be a primitive in a language - for example, in C++, the type int is a primitive, as is this one:

struct MyStruct {
    int x, y;
};

在这种情况下, MyStruct 是一个数据类型表示标有 MyStruct 的所有可能对象,其中标有 x 的两个 int code>和 y

In this case, MyStruct is a data type representing all possible objects labeled MyStruct that have two ints in them labeled x and y.

可能有一个数据类型表示所有可能的实例数据结构。例如,您可以使用此数据类型对二叉搜索树进行编码:

It is possible to have a data type representing all possible instances of a data structure. For example, you could encode a binary search tree with this data type:

struct BST {
    int data;
    BST* left, *right;
};

简而言之,数据结构是一个数学对象,具有一些属性可以以许多不同的方式实现为数据类型。数据类型只是可以具体构造和表示的一类值。

In short, a data structure is a mathematical object with some set of properties that can be realized in many different ways as data types. A data type is just a class of values that can be concretely constructed and represented.

这篇关于解释一个数据*结构*和一个数据*类型*之间的区别*的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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