03 2019 档案

摘要:最坏情况的时间复杂度:O(N log N) 归并排序是稳定排序,它也是一种十分高效的排序,能利用完全二叉树特性的排序一般性能都不会太差 。java中Arrays.sort()采用了一种名为TimSort的排序算法,就是归并排序的优化版本。从上文的图中可看出,每次合并操作的平均时间复杂度为O(n),而 阅读全文
posted @ 2019-03-28 21:15 Pure_Java 阅读(574) 评论(0) 推荐(0)
摘要:三、堆排序(Heapsort) 优先队列可以用于O(N log N) 存储空间增加一倍 排序类别 排序方法 时间复杂度 时间复 杂度 空间复杂度 稳定性 复杂性 平均情况 最坏情况 最好情况 选择排序 堆排序 O(nlog2n) O(nlog2n) O(nlog2n) O(1) 不稳定 较复杂 堆排 阅读全文
posted @ 2019-03-25 09:53 Pure_Java 阅读(342) 评论(0) 推荐(0)
摘要:• 最坏情况下运行时间为 Θ(N2),此时为Hibbard增量 ( 希尔排序是把记录按下标的一定增量分组,对每组使用直接插入排序算法排序;随着增量逐渐减少,每组包含的关键词越来越多,当增量减至1时,整个文件恰被分成一组,算法便终止。 简单插入排序很循规蹈矩,不管数组分布是怎么样的,依然一步一步的对元 阅读全文
posted @ 2019-03-24 21:32 Pure_Java 阅读(445) 评论(0) 推荐(0)
摘要:Public class InsertionSort{ Public static> AnyType[] insertionSort(AnyType[]a){ intj; for(intp=0;p 0 && tmp.compareTo(a[j-1]) < 0;j--){ a[j]=a[j-... 阅读全文
posted @ 2019-03-24 21:29 Pure_Java 阅读(413) 评论(0) 推荐(0)
摘要:在Java编程语言中,最基本的结构就是两种,一种是数组,一种是模拟指针(引用),所有的数据结构都可以用这两个基本结构构造,HashMap也一样。当程序试图将多个 key-value 放入 HashMap 中时,以如下代码片段为例: HashMap<String,Object> m=new HashM 阅读全文
posted @ 2019-03-20 12:42 Pure_Java 阅读(223) 评论(0) 推荐(0)
摘要:非原创 阅读全文
posted @ 2019-03-16 09:39 Pure_Java 阅读(330) 评论(0) 推荐(0)
摘要:import java.util.Collections;import java.util.Comparator;import java.util.LinkedHashMap;import java.util.LinkedList;import java.util.List;import java. 阅读全文
posted @ 2019-03-12 19:57 Pure_Java 阅读(2472) 评论(0) 推荐(0)
摘要:转载:http://www.cnblogs.com/kristain/articles/2033566.html public static void main(String[] args) { Map<String, String> map = new HashMap<String, String 阅读全文
posted @ 2019-03-12 19:50 Pure_Java 阅读(204) 评论(0) 推荐(0)
摘要:附有连接(https://www.cnblogs.com/jingmoxukong/p/4302891.html),其中很多是引用其他作者,主要是自己学习随笔,如果有问题,请与我联系,万分感谢! 阅读全文
posted @ 2019-03-09 22:19 Pure_Java 阅读(159) 评论(0) 推荐(0)
摘要:The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants. A binary search tree (BST) i 阅读全文
posted @ 2019-03-08 21:02 Pure_Java 阅读(218) 评论(0) 推荐(0)
摘要:Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose that in a game, player #1 阅读全文
posted @ 2019-03-08 21:02 Pure_Java 阅读(405) 评论(0) 推荐(0)
摘要:Among all the factors of a positive integer N, there may exist several consecutive numbers. For example, 630 can be factored as 3×\times×5×\times×6×\t 阅读全文
posted @ 2019-03-08 21:00 Pure_Java 阅读(313) 评论(0) 推荐(0)
摘要:Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy some beads. There were many colorful strings of b 阅读全文
posted @ 2019-03-08 20:58 Pure_Java 阅读(153) 评论(0) 推荐(0)
摘要:For two rational numbers, your task is to implement the basic arithmetics, that is, to calculate their sum, difference, product and quotient. Input Sp 阅读全文
posted @ 2019-03-08 20:57 Pure_Java 阅读(263) 评论(0) 推荐(0)
摘要:On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on sc 阅读全文
posted @ 2019-03-08 20:54 Pure_Java 阅读(431) 评论(0) 推荐(0)
摘要:Given N rational numbers in the form numerator/denominator, you are supposed to calculate their sum. Input Specification: Each input file contains one 阅读全文
posted @ 2019-03-08 20:42 Pure_Java 阅读(257) 评论(0) 推荐(0)
摘要:The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the s 阅读全文
posted @ 2019-03-08 20:40 Pure_Java 阅读(272) 评论(0) 推荐(0)
摘要:Scientific notation is the way that scientists easily handle very large numbers or very small numbers. The notation matches the regular expression [+- 阅读全文
posted @ 2019-03-08 20:39 Pure_Java 阅读(233) 评论(0) 推荐(0)
摘要:For any 4-digit integer except the ones with all the digits being the same, if we sort the digits in non-increasing order first, and then in non-decre 阅读全文
posted @ 2019-03-08 20:38 Pure_Java 阅读(227) 评论(0) 推荐(0)
摘要:Given three integers A, B and C in [−2​63​​,2​63​​], you are supposed to tell whether A+B>C. Input Specification: The first line of the input gives th 阅读全文
posted @ 2019-03-08 20:37 Pure_Java 阅读(135) 评论(0) 推荐(0)
摘要:Sherlock Holmes received a note with some strange strings: Let's date! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm. It took him only a minut 阅读全文
posted @ 2019-03-08 20:36 Pure_Java 阅读(228) 评论(0) 推荐(0)
摘要:If you are a fan of Harry Potter, you would know the world of magic has its own currency system -- as Hagrid explained it to Harry, "Seventeen silver 阅读全文
posted @ 2019-03-08 20:35 Pure_Java 阅读(154) 评论(0) 推荐(0)
摘要:Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of information for each pixel. In an image, the color 阅读全文
posted @ 2019-03-08 20:35 Pure_Java 阅读(219) 评论(0) 推荐(0)
摘要:Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the remaining string after taking all the characters in S​2​​ from S​1​​. Your task 阅读全文
posted @ 2019-03-08 20:34 Pure_Java 阅读(298) 评论(0) 推荐(0)
摘要:The task is really simple: given N exits on a highway which forms a simple cycle, you are supposed to tell the shortest distance between any pair of e 阅读全文
posted @ 2019-03-08 20:33 Pure_Java 阅读(332) 评论(0) 推荐(0)
摘要:Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid "ins 阅读全文
posted @ 2019-03-08 20:31 Pure_Java 阅读(167) 评论(0) 推荐(0)
摘要:Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a numbe 阅读全文
posted @ 2019-03-08 20:29 Pure_Java 阅读(242) 评论(0) 推荐(0)
摘要:Given any string of N (≥5) characters, you are asked to form the characters into the shape of U. For example, helloworld can be printed as: That is, t 阅读全文
posted @ 2019-03-08 20:28 Pure_Java 阅读(393) 评论(0) 推荐(0)
摘要:People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, wher 阅读全文
posted @ 2019-03-08 20:27 Pure_Java 阅读(161) 评论(0) 推荐(0)
摘要:Notice that the number 123456789 is a 9-digit number consisting exactly the numbers from 1 to 9, with no duplication. Double it we will obtain 2469135 阅读全文
posted @ 2019-03-08 20:26 Pure_Java 阅读(249) 评论(0) 推荐(0)
摘要:A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years 阅读全文
posted @ 2019-03-08 20:24 Pure_Java 阅读(218) 评论(0) 推荐(0)
摘要:Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to ou 阅读全文
posted @ 2019-03-08 20:23 Pure_Java 阅读(235) 评论(0) 推荐(0)
摘要:A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number 阅读全文
posted @ 2019-03-08 20:22 Pure_Java 阅读(175) 评论(0) 推荐(0)
摘要:A reversible prime in any number system is a prime whose "reverse" in that number system is also a prime. For example in the decimal system 73 is a re 阅读全文
posted @ 2019-03-08 20:21 Pure_Java 阅读(267) 评论(0) 推荐(0)
摘要:It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that c 阅读全文
posted @ 2019-03-08 20:20 Pure_Java 阅读(308) 评论(0) 推荐(0)
摘要:To evaluate the performance of our first year CS majored students, we consider their grades of three courses only: C - C Programming Language, M - Mat 阅读全文
posted @ 2019-03-08 20:18 Pure_Java 阅读(448) 评论(0) 推荐(0)
摘要:With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excited as the best players from the best teams doing ba 阅读全文
posted @ 2019-03-08 20:16 Pure_Java 阅读(150) 评论(0) 推荐(0)
摘要:Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a 阅读全文
posted @ 2019-03-08 20:15 Pure_Java 阅读(341) 评论(0) 推荐(0)
摘要:This time, you are supposed to find A×BA\times BA×B where AAA and BBB are two polynomials. Input Specification: Each input file contains one test case 阅读全文
posted @ 2019-03-08 20:13 Pure_Java 阅读(334) 评论(0) 推荐(0)
摘要:The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elev 阅读全文
posted @ 2019-03-08 20:12 Pure_Java 阅读(166) 评论(0) 推荐(0)
摘要:1007 Maximum Subsequence Sum (25 分) Given a sequence of K integers { N​1​​, N​2​​, ..., N​K​​ }. A continuous subsequence is defined to be { N​i​​, N​ 阅读全文
posted @ 2019-03-08 20:07 Pure_Java 阅读(320) 评论(0) 推荐(0)
摘要:At the beginning of every day, the first person who signs in the computer room will unlock the door, and the last one who signs out will lock the door 阅读全文
posted @ 2019-03-08 20:06 Pure_Java 阅读(290) 评论(0) 推荐(0)
摘要:Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English. Input Specificat 阅读全文
posted @ 2019-03-08 20:04 Pure_Java 阅读(244) 评论(0) 推荐(0)
摘要:A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child. Input Specification: Each inp 阅读全文
posted @ 2019-03-08 20:03 Pure_Java 阅读(289) 评论(0) 推荐(0)
摘要:As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some ro 阅读全文
posted @ 2019-03-08 20:02 Pure_Java 阅读(723) 评论(0) 推荐(0)
摘要:This time, you are supposed to find A+BA+BA+B where AAA and BBB are two polynomials. Input Specification: Each input file contains one test case. Each 阅读全文
posted @ 2019-03-08 20:00 Pure_Java 阅读(596) 评论(0) 推荐(0)
摘要:1001 A+B Format (20 分) Calculate a+b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (un 阅读全文
posted @ 2019-03-08 19:57 Pure_Java 阅读(439) 评论(1) 推荐(0)