相关疑难解决方法(0)

如何在O(n)中找到长度为n的未排序数组中的第k个最大元素?

我相信有一种方法可以在O(n)中找到长度为n的未排序数组中的第k个最大元素.或许它是"预期的"O(n)或其他东西.我们应该怎么做?

algorithm performance big-o

216
推荐指数
6
解决办法
22万
查看次数

这个delaunay三角测量代码如何工作?

我有这个Java代码,它带有一组Point in输入,返回一组代表Delaunay三角剖分的图形边缘.

我想知道使用什么策略,如果存在,使用的算法名称.

在此代码中,GraphEdge包含两个awt Point并表示三角剖分中的边,GraphPoint扩展Awt Point,并在TreeSet对象中返回最终三角剖分的边.

我的目的是了解这种方法的工作原理:

public TreeSet getEdges(int n, int[] x, int[] y, int[] z)
Run Code Online (Sandbox Code Playgroud)

在这个三角测量的完整源代码下面:

import java.awt.Point;
import java.util.Iterator;
import java.util.TreeSet;

public class DelaunayTriangulation
{
   int[][] adjMatrix;

   DelaunayTriangulation(int size)
   {
     this.adjMatrix = new int[size][size];
   }
   public int[][] getAdj() {
     return this.adjMatrix;
   }

   public TreeSet getEdges(int n, int[] x, int[] y, int[] z)
   {
     TreeSet result = new TreeSet();

     if (n == 2)
     {
       this.adjMatrix[0][1] = 1;
       this.adjMatrix[1][0] = 1;
       result.add(new GraphEdge(new GraphPoint(x[0], y[0]), new GraphPoint(x[1], y[1])));

       return …
Run Code Online (Sandbox Code Playgroud)

java delaunay triangulation

9
推荐指数
1
解决办法
1万
查看次数

标签 统计

algorithm ×1

big-o ×1

delaunay ×1

java ×1

performance ×1

triangulation ×1