“数据结构"和“数据类型"之间有区别吗? [英] Is there a difference between 'data structure' and 'data type'?

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

问题描述

在我学习的大学考试中经常出现的两个问题是:

  • 定义数据类型.分类和解释数据类型
  • 定义数据结构.分类和解释数据结构
  • Two of the questions that often come up in the Uni exam, where I study, are:

  • Define data types. Classify and explain datatypes
  • Define data structures. Classify and explain data structures
  • 不知道是不是同一回事?
    考虑到您正在用Java编写Tree<E>.您将为Tree<E>声明您的类,向其中添加方法,并在要执行Tree<String> myTree = new Tree<>();的位置创建树对象.

    Somehow, aren't they the same thing ?
    Consider that you are making a Tree<E> in Java. You'd declare your class for Tree<E>, add methods to it and somewhere you would do Tree<String> myTree = new Tree<>(); to make a tree object.

    您的数据结构"现在是数据类型".
    假设您被问到以下问题:变量myTree是什么类型?答案是Tree<E>.您的数据结构"现在是数据类型".

    Your data 'structure' is now a data 'type'.
    Say if you were asked a question: Of what type is the variable myTree? The answer would be, Tree<E>. Your data 'structure' is now a data 'type'.

    现在,由于它们相同,因此将根据您希望对其进行分类的基础以相同的方式对其进行分类.原始或非原始.均质或异质的.线性或分层.

    Now since they are the same, they will be classified in the same way depending on what basis you want to classify them on. Primitive or non primitive. Homogeneous or heterogeneous. Linear or hierarchical.

    这是我的理解.理解是错误的吗?

    That is my understanding. Is the understanding wrong ?

    推荐答案

    我想更正以下内容-您创建了一个名为树"的 class 和一个对象 strong>称为"myTree",而不是数据类型树"的称为"myTree"的变量.这些是不同的东西.

    I would like to correct the following to start - you created a class called "Tree" and an object called "myTree", not a variable called "myTree" of datatype "Tree". These are different things.

    以下是数据类型的定义:

    The following is the definition of a data type:

    数据类型或简单类型是一种标识各种数据类型的分类, 例如实值,整数或布尔值,它们确定了该类型的可能值; 可以对该类型的值执行的操作;数据的含义; 以及该类型值的存储方式.

    A data type or simply type is a classification identifying one of various types of data, such as real-valued, integer or Boolean, that determines the possible values for that type; the operations that can be done on values of that type; the meaning of the data; and the way values of that type can be stored.

    现在,根据Wikipedia ,类型".

    您提出的问题是一个很好的问题.当今的现代语言中有一些数据类型,简称为抽象数据类型或ADT. ADT的定义是:

    The question you have asked is a good one. There are data types in today's modern languages, that are referred to as Abstract Data Types or ADT in short. The definition of an ADT is:

    抽象数据类型(ADT)是用于具有类似行为的特定类数据结构的数学模型;或针对一种或多种具有相似语义的编程语言的某些数据类型.抽象数据类型只能通过可能对其执行的操作以及对这些操作的影响(可能是成本)的数学约束来间接定义.

    An abstract data type (ADT) is a mathematical model for a certain class of data structures that have similar behavior; or for certain data types of one or more programming languages that have similar semantics. An abstract data type is defined indirectly, only by the operations that may be performed on it and by mathematical constraints on the effects (and possibly cost) of those operations.

    还写着:

    抽象数据类型是纯粹的理论实体,除其他事项外,还用于简化抽象算法的描述,对数据结构进行分类和评估以及正式描述编程语言的类型系统.但是,可以通过多种方式和多种编程语言,通过特定的数据类型或数据结构来实现ADT.或以正式的规范语言进行描述.

    Abstract data types are purely theoretical entities, used (among other things) to simplify the description of abstract algorithms, to classify and evaluate data structures, and to formally describe the type systems of programming languages. However, an ADT may be implemented by specific data types or data structures, in many ways and in many programming languages; or described in a formal specification language.

    意味着ADT可以使用数据类型或数据结构来实现.

    Meaning that ADT's can be implemented using either data types or data structures.

    关于数据结构:

    数据结构是一种在计算机中存储和组织数据以便有效利用的特殊方式.

    A data structure is a particular way of storing and organizing data in a computer so that it can be used efficiently.

    许多教科书,这些单词可以互换使用.对于更复杂的类型,可能会导致混乱.

    Many textbooks, use these words interchangeably. With more complex types, that can lead to confusion.

    举个小例子:使用b树来实现数据库是一种标准.意思是,我们知道,这种类型的ADT非常适合此类问题,并且可以更有效地处理.但是,为了在ADT中注入这种效果,您将需要创建一个数据结构,该结构将为您提供所需的输出.

    Take a small example: it's something of a standard to use b-tree for implementation of databases. Meaning, we know that this type of ADT is well suited for such type of a problem and can handle it more effectively. But in order to inject this effectiveness in an ADT you will need to create a data structure that will give you the desired output.

    另一个例子:有很多树,例如b树,二叉搜索树,AA树等.所有这些基本上都是树的类型,但是每个树都拥有一个数据结构.

    Another example: there are so many trees like b-tree, binary-search tree, AA tree, etc. All these are essentially of the type of a tree, but each one is in it's own a data structure.

    参考:数据结构列表,其中包含大量可用结构.

    Refer: List of data structures for a huge list of available structures.

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

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