Part III Data Structures (chapter 10 ~ chapter 14)

Part III Data Structures (chapter 10 ~ chapter 14)

  • Sets are as fundamental to computer science as they are to mathematics. Whereas mathematical sets are unchanging, the sets manipulated by algorithms can grow, shrink, or otherwise change over time. We call such sets dynamic.
  • Algorithms may require several different types of operations to be performed on sets.
  • We call a dynamic set that supports these operations a dictionary.

Elements of a dynamic set

  • In a typical implementation of a dynamic set, each element is represented by an object whose attributes can be examined and manipulated if we have a pointer to the object.
  • Some kinds of dynamic sets assume that one of the object’s attributes is an identifying key.

Operations on dynamic sets

  • Operations on a dynamic set can be grouped into two categories:
    1.queries, which simply return information about the set.
    2.modifying operations, which change the set.
  • Here is a list of typical operations:
SEARCH(S,k)
A query that, given a set S and a key value k, returns a pointer x to an element in S such that x.key = k, or NIL if no such element belongs to S.
INSERT(S,x)
A modifying operation that augments the set S with the element pointed to by x. We usually assume that any attributes in element x needed by the set implementation have already been initialized.
DELETE(S,x)
A modifying operation that, given a pointer x to an element in the set S, removes x from S. (Note that this operation takes a pointer to an element x, not a key value.)
MINIMUM(S)
A query on a totally ordered set S that returns a pointer to the element of S with the smallest key.
MAXIMUM(S)
A query on a totally ordered set S that returns a pointer to the element of S with the largest key.
SUCCESSOR(S,x)
A query that, given an element x whose key is from a totally ordered set S, returns a pointer to the next larger element 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.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值