计算机问题求解一论题2-11 抽象数据结构 2022年04月27日
计算机问题求解 – 论题2-11 - 抽象数据结构 2022年04月27日
问题:任意输入一行字符串,以#结束。输 出这个字符串的反串 Program reverse(input,output); var elements:array[0:n]of char; (*n is big enough*) index:int;length:int;c:char; begin 问题:N.Wirth说过 read(c);length:=0; 程序=算法+数据结构。 while (c<>'#)do 你能就这个例子解释这句 begin 话的含义吗? elements[length]:=c; length :length+1; read(c); end for index:=length-1 to 0 do write(elements[index]); end
问题:任意输入一行字符串,以#结束。输 出这个字符串的反串 Program reverse(input, output); var elements: array[0:n] of char; (*n is big enough*) index: int; length: int; c: char; begin read(c); length:=0; while (c<>’#’) do begin elements[length]:=c; length := length+1; read(c); end for index:=length-1 to 0 do write(elements[index]); end. 问题1:N.Wirth说过 程序=算法+数据结构。 你能就这个例子解释这句 话的含义吗?
问题2: 你能从上例中的”var elements:array[O:n]of char;”以及某个 具体输入“damrngiz”中解释以下几个概念的关系吗? 数据;数据类型;数据结构 我们引入Dynamic set这个概念的用意是什么?
问题2: 你能从上例中的” var elements: array[0:n] of char; ”以及某个 具体输入“damrnqiz”中解释以下几个概念的关系吗? 数据;数据类型;数据结构 我们引入Dynamic set这个概念的用意是什么?
SEARCH(S,k) A query that,given a set S and a key value k,returns a pointer x to an element 问题3:你 in S such that x.key =k,or NIL if no such element belongs to S. INSERT(S.x) A modifying operation that augment ement pointed to 除了能看出 by x.We usually a ded by the set impl 动态集合上 DE 本质上,我们所采用 re- 的所有表达动态集合 not 常见的操作 的高级数据结构,定 外,能否看 义其上的操作,少不 了上述基本功能 element of S 出“结构” SUCCES 来? A query tre an ey is from a totally ordered set S. returns a pointer to the next n ment in S,or NIL if x is the maximum element. PREDECESSOR(S.x) A query that,given an element x whose key is from a totally ordered set S. returns a pointer to the next smaller element in S,or NIL if x is the minimum element
问题 3:你 除了能看出 动态集合上 常见的操作 外,能否看 出“结构” 来? 本质上,我们所采用 的所有表达动态集合 的高级数据结构,定 义其上的操作,少不 了上述基本功能
问题4:我们只能采用数组来组织和管理动态 集合吗? Out Roughly,a stack is a set of objects which arrive at different points in time and are added to the set.When elements are deleted from the set, the object which was inserted last is removed first. A stack can be visualised as a pile of objects where objects can be added to or removed from the pile only from the top (see figure 2.3). Figure 2.3 Pictorial model of a stack
问题4:我们只能采用数组来组织和管理动态 集合吗?