本文介绍了使用的实施类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个问题我一直试图解决,但我很难掌握它的正确实现。如果我们编写一个程序来操作数千个记录,每个记录包括产品名称,类型,序列号,零售价等。在下面的每种情况下,解释您将使用哪种抽象数据类型(队列,堆栈,未排序和排序列表) ,以及哪种实现(数组或链接结构)。简要证明你的选择。



1)记录将按照存储的顺序检索。没有预先知道将处理多少记录以及如何处理。



我更喜欢未使用链接列表实现的未排序列表,因为我们不知道开头的记录数量,数据将在存储时被检索,因此它们必须链接,这也可以通过ADT如Queue或Stack进行链接,但它们使用数组实现,因此会出现内存分配问题。



2)
所有记录将在开头插入,一次,无特定顺序。它们将根据序列号非常频繁地检索。



即使在一次打印所有记录数据的情况下,也可以使用未排序列表。



3)将在需要时插入大量但未知数量的产品记录。它们很少单独检索。大多数操作都包括一次处理所有记录,例如打印所有记录。



但是这里排序和未排序的列表使用效率更高但我更喜欢未排序列表,因为它需要时间进行分类会降低效率。



你们觉得怎么样?



我尝试了什么:



我已经尝试过回答上面问题中给出的问题。

There is a question that I have been trying to solve for a while but I'm having difficulty to grasp the correct implementation for it. If we write a program that will manipulate thousands of records, each comprising product name, type, serial number, retail price, etc. In each case below, explain which Abstract Data Type (Queue, Stack, Unsorted and Sorted List) you would use, and which implementation (array or linked structure). Briefly justify your choices.

1) Records will be retrieved in the same order they were stored. There is no telling in advance how many records will be processed and how.

I prefer Unsorted list for this purpose which used linked list implementation because we don't know the number of records at beginning,and data will be retrieved as they are stored hence they must be linked which can also be possible by ADT like Queue or Stack but they use array implementation hence memory allocation problem arises.

2)
All records will be inserted at the beginning, once and in no particular order. They will be retrieved very frequently, based on serial number.

Even in the case of printing all the data of records at one time it will be possible with the Unsorted list.

3) A large but unknown number of product records will be inserted, as and when needed. They will seldom be retrieved individually. Most operations will consist of processing all records at one go e.g., printing all.

However here sorted and Unsorted list had more efficiency to use but I prefer Unsorted list because it takes time for sorting which decreases its efficiency.

What do you guys think?

What I have tried:

I have tried answering the problem as given above in the question.

推荐答案


这篇关于使用的实施类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 10:04