
java
文章平均质量分 77
cs08211317dn
这个作者很懒,什么都没留下…
展开
-
Java代码实现Fibonacci数列
Fibonacci数列 1.定义: 0, 1, 1, 2, 3, 5, 8, 13, 21, . . .; f0 = 0, f1= 1, fn= fn−1 + fn−2for n ≥ 2. 2.两种实现算法: 2.1递归(recursive)T(n)>2n/2证明:T(n)=T(n−1)+T(n−2)>2T(n−2)>原创 2013-02-01 09:37:33 · 3407 阅读 · 2 评论 -
判断一个数是否存在于一个非递减的有序数列中 算法(Ordered Search Problem)
1. DescriptionGiven a list of n numbers in non-decreasing order A={a1,a2,⋯,an} such that a1≤a2≤⋯≤an and a number x, the objective is to determine if x is present in the list A2. Algori原创 2013-02-02 04:52:58 · 1323 阅读 · 0 评论 -
找出两个含有相同元素个数的递增数列中第n小的数
1.DescriptionYou are given two arrays L1 and L2, each with n keys sorted in increasing order. For simplicity,you may assume that the keys are all distinct from each other.(a) Describe原创 2013-02-04 06:05:12 · 1103 阅读 · 0 评论 -
rearrange array (red, white, blue)
1.DescriptionSuppose an array A consists of n elements, each of which is red, white, or blue. We seek to rearrange the elements so that all the reds come before all the whites, which come before原创 2013-02-05 12:11:52 · 920 阅读 · 0 评论 -
找出一堆硬币中较重的一个(java 算法)
1.DescriptionYou have n coins (n may be even or odd) such that n−1 coins are of the same weight and one has different weight. You have a balance scale; you can put any number of coins on each原创 2013-02-05 12:27:34 · 1110 阅读 · 0 评论 -
java 计算26个字母在一段文本中出现的频率(保留小数点后4位)
public class FrequencyCalculator { public static void main(String[] args) { //定义需要计算字母出现频率的文本 String text="some off#acebooksea3rl255 yinvestorssoldofftheirstockatthefirstchancetheygotbutceomarkz原创 2013-09-09 11:11:22 · 3005 阅读 · 0 评论 -
Replace all spaces in string with ' ' (Cracking the Code Interview)
Write a method to replace all spaces in string with '%20'. You may assume that the string has sufficient space at the end of the string to hold the additional characters, and that you are given the "t原创 2014-02-18 03:50:39 · 1376 阅读 · 0 评论