小编Edd*_*nco的帖子

使用Java中的max-heap对数组进行排序

我正在研究一个程序,它通过将数组分成较小的最大堆并从每个数据库中提取最大整数来对数组进行排序,然后将其从堆中删除并再次运行直到每个堆都为空,但我不能似乎弄清楚了.

从我的立场代码看起来不错,但我没有得到我正在寻找的结果.我的输入是随机创建的,并生成512个整数的数组.这是一个例子运行的打印 -

Original Array  -391 176 -380 -262 -474 327 -496 214 475 -255 50 -351 179 -385 -442 -227 465 127 -293 288
Sorted Array 475 465 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 327 
n = 20 k = 2
The number of comparisons is 243
Run Code Online (Sandbox Code Playgroud)

谁能发现我的代码有什么问题?我会很高兴的.

(1)主程序

 import java.io.File;
 import java.util.*;
 import java.io.FileNotFoundException;
 import java.util.Scanner;
 import java.io.IOException;

 public class Project {
    static final int n = …
Run Code Online (Sandbox Code Playgroud)

java arrays sorting heapsort

7
推荐指数
1
解决办法
1128
查看次数

在 PostgreSql 中获取“外键的引用和引用列的数量不一致”

我在 pgAdmin 4 中创建了几个表,但由于某种原因,我一直收到标题错误,你能找出原因吗?我没有看到任何问题,并且我已经查看了与我的类似的其他代码示例,它们完美地编译了。它在 IDEone ( http://ideone.com/ZBn2Nr ) 中也能正常运行。

谢谢!

Create table item
    (iname varchar(30) primary key,
    itype varchar(30));

Create table Cafe
    (license numeric(5,0) primary key,
    cname varchar(30),
    address varchar(30));

Create table Client
    (cid numeric(5,0) primary key,
    name varchar(30),
    phone numeric(9,0));

Create table Likes
    (cid numeric(5,0),
    iname varchar(30),
    primary key(cid,iname),
    foreign key(cid) references Client,
    foreign key(iname) references item);

Create table Sells
    (license numeric(5,0),
    iname varchar(30),
    price float check(price > 0),
    primary key(license,iname),
    foreign key(license) references Cafe,
    foreign key(iname) references item); …
Run Code Online (Sandbox Code Playgroud)

sql postgresql compiler-errors

3
推荐指数
1
解决办法
5515
查看次数

标签 统计

arrays ×1

compiler-errors ×1

heapsort ×1

java ×1

postgresql ×1

sorting ×1

sql ×1