Posted on Categories:Combinatorics, 数学代写, 组合学

# 数学代写|组合学代写Combinatorics代考|Proving That a Network Sorts

avatest™

## avatest™帮您通过考试

avatest™的各个学科专家已帮了学生顺利通过达上千场考试。我们保证您快速准时完成各时长和类型的考试，包括in class、take home、online、proctor。写手整理各样的资源来或按照您学校的资料教您，创造模拟试题，提供所有的问题例子，以保证您在真实考试中取得的通过率是85%以上。如果您有即将到来的每周、季考、期中或期末考试，我们都能帮助您！

•最快12小时交付

•200+ 英语母语导师

•70分以下全额退款

## 数学代写|组合学代写Combinatorics代考|Proving That a Network Sorts

Unlike many software sorts, it is frequently difficult to prove that a network actually sorts all inputs correctly. There is no panacea for this problem. The following two theorems are sometimes helpful.
Theorem 8.2 Zero-One Principle ones, then it correctly sorts all inputs.
If a network correctly sorts all inputs of zeroes and
Theorem 8.3 Adjacent Comparisons If the comparators in a network only connect adjacent lines and if the network correctly sorts the reversed sequence $n, \ldots, 2,1$, then it correctly sorts all inputs.

We will prove the Zero-One Principle shortly. The proof of the other theorem is more complicated and will not be given.

Since the Adjacent Comparisons Theorem requires that only one input be checked, it is quite useful. Unfortunately, the comparators must connect adjacent lines. To see that this is needed, consider a three input network in which the top and bottom lines are connected by a comparator and there are no other comparators. It correctly sorts the inputs $1,2,3$ and $3,2,1$, but it does not sort any other permutations of $1,2,3$ correctly.

The Zero-One Principle may seem somewhat useless because it still requires that many inputs be considered. We will see that it is quite useful for proving that a Batcher sort works.

Proof: We now prove the Zero-One Principle. If the network fails to sort some sequence, we will show how to construct a sequence of zeroes and ones that it fails to sort.

The idea behind our proof is the following simple observation: Suppose that $f$ is a nondecreasing function, then a comparator treats $f(s)$ and $f(t)$ the same as it does $s$ and $t$. This is illustrated in Figure 8.5. It is easy to show by considering the three cases $st$.

Suppose a network has $N$ comparators, has inputs $x_1, \ldots, x_n$ and outputs $y_1, \ldots, y_n$. Let $f$ be a nondecreasing function. We will use induction on $N$ to prove that if $f\left(x_1\right), \ldots, f\left(x_n\right)$ are fed into the network, then $f\left(y_1\right), \ldots, f\left(y_n\right)$ emerge at the other end.

## 数学代写|组合学代写Combinatorics代考|Traversing Trees

A tree traversal algorithm is a systematic method for visiting all the vertices in an RP-tree. We’ve already seen a nonrecursive traversal algorithm in Theorem 3.5 (p.85). As we shall soon see a recursive description is much simpler. It is essentially a local description.

Traversal algorithms fall into two categories called “breadth first” and “depth first,” with depth first being the more common type. After explaining the categories, we’ll focus on depth first algorithms.

The left side of Figure 9.2 shows an RP-tree. Consider the right side of Figure 9.2. There we see the same RP-tree. Take your pencil and, starting at the root $a$, follow the arrows in such a way that you visit the vertices in the order
$$\text { abe } b f j f k f l f b a c a d g d h d i d a \text {. }$$
This manner of traversing the tree diagram, which extends in an obvious manner to any RP-tree $T$, is called a depth-first traversal of the ordered rooted tree $T$. The sequence of vertices (9.1) associated with the depth-first traversal of the RP-tree $T$ will be called the depth-first vertex sequence of $T$ and will be denoted by DFV $(T)$. If you do a depth-first traversal of an RP-tree $T$ and list the edges encountered (list an edge each time your pencil passes its midpoint in the diagram), you obtain the depth-first edge sequence of $T$, denoted by $\operatorname{DFE}(T)$. In Figure 9.2 , the sequence $\mathrm{DFE}(T)$ is
$$\begin{array}{lllllllllll} {a, b} & {b, e} & {b, e} & {b, f} & {f, j} & {f, j} & {f, k} & {f, k} & {f, l} & {f, l} & {b, f} \ {a, b} & {a, c} & {a, c} & {a, d} & {d, g} & {d, g} & {d, h} & {d, h} & {d, i} & {d, i} & {a, d} . \end{array}$$

The other important linear order associated with RP-trees is called breadth-first order. This order is obtained, in the case of Figure 9.2 , by reading the vertices or edges level by level, starting with the root. In the case of vertices, we obtain the breadth-first vertex sequence $(\mathrm{BFV}(T))$. In Figure 9.2 , $\mathrm{BFV}(T)=$ abcdefghijkl. Similarly, we can define the breadth-first edge sequence $(\mathrm{BFE}(T))$.

Although we have defined these orders for trees, the ideas can be extended to other graphs. For example, one can use a breadth first search to find the shortest (least number of choices) route out of a maze: Construct a decision tree in which each vertex corresponds to an intersection in the maze. (More than one vertex may correspond to the same intersection.) A vertex corresponding to an intersection already encountered in the breadth first search has no sons. The decisions at an intersection not previously encountered are all possibilities of the form “follow a passage to the next intersection.”

## 数学代写|组合学代写Combinatorics代考|Proving That a Network Sorts

0 – 1原则可能看起来有些无用，因为它仍然需要考虑许多输入。我们将看到，这对于证明批处理排序是非常有用的。

## 数学代写|组合学代写Combinatorics代考|Traversing Trees

$$\text { abe } b f j f k f l f b a c a d g d h d i d a \text {. }$$

$$\begin{array}{lllllllllll} {a, b} & {b, e} & {b, e} & {b, f} & {f, j} & {f, j} & {f, k} & {f, k} & {f, l} & {f, l} & {b, f} \ {a, b} & {a, c} & {a, c} & {a, d} & {d, g} & {d, g} & {d, h} & {d, h} & {d, i} & {d, i} & {a, d} . \end{array}$$

## MATLAB代写

MATLAB 是一种用于技术计算的高性能语言。它将计算、可视化和编程集成在一个易于使用的环境中，其中问题和解决方案以熟悉的数学符号表示。典型用途包括：数学和计算算法开发建模、仿真和原型制作数据分析、探索和可视化科学和工程图形应用程序开发，包括图形用户界面构建MATLAB 是一个交互式系统，其基本数据元素是一个不需要维度的数组。这使您可以解决许多技术计算问题，尤其是那些具有矩阵和向量公式的问题，而只需用 C 或 Fortran 等标量非交互式语言编写程序所需的时间的一小部分。MATLAB 名称代表矩阵实验室。MATLAB 最初的编写目的是提供对由 LINPACK 和 EISPACK 项目开发的矩阵软件的轻松访问，这两个项目共同代表了矩阵计算软件的最新技术。MATLAB 经过多年的发展，得到了许多用户的投入。在大学环境中，它是数学、工程和科学入门和高级课程的标准教学工具。在工业领域，MATLAB 是高效研究、开发和分析的首选工具。MATLAB 具有一系列称为工具箱的特定于应用程序的解决方案。对于大多数 MATLAB 用户来说非常重要，工具箱允许您学习应用专业技术。工具箱是 MATLAB 函数（M 文件）的综合集合，可扩展 MATLAB 环境以解决特定类别的问题。可用工具箱的领域包括信号处理、控制系统、神经网络、模糊逻辑、小波、仿真等。