`
to_zoe_yang
  • 浏览: 142314 次
  • 性别: Icon_minigender_2
  • 来自: 01
社区版块
存档分类
最新评论
文章列表
在Java语言中, abstract class 和interface 是支持抽象类定义的两种机制。正是由于这两种机制的存在,才赋予了Java强大的 面向对象能力。abstract class和interface之间在对于抽象类定义的支持方面具有很大的相似性,甚至可以相互替换, ...
题目:   题目:输入一个整数和一棵二元树。从树的根结点开始往下访问一直到叶结点所经过的所有结点形成一条路径。打印出和与输入整数相等的所有路径。例如 输入整数22和如下二元树  10     / \     5 12     / \     4 7 则打印出两条路径:10, 12和10, 5, 7。 思路:有两种方法,递归和非递归。其中非递归使用前序遍历,一条路走到底,并且每次访问一个节点,就判断当前访问的节点是否符合要求,符合就进栈保持,不然就退栈,对退出来的节点判断是否有右子树,有就继续往下,否则就继续退栈。 代码:   递归: public void findPath(Bi ...
问题描述: 判断整数序列是不是二元查找树的后序遍历结果题目:输入一个整数数组,判断该数组是不是某二元查找树的后序遍历的结果。如果是返回true,否则返回false。例如输入5、7、6、9、11、10、8,由于这一整数序列是如下树的后序遍历结果:  8  / \  6 10  / \ / \  5 7 9 11因此返回true。如果输入7、4、6、5,没有哪棵树的后序遍历的结果是这个序列,因此返回false。       import java.util.Arrays; public class Judge { public static boolean judge(i ...
题目:输入一棵二元查找树,将该二元查找树转换成一个排序的双向链表。要求不能创建任何新的结点,只调整指针的指向。      10  / \ 6 14 / \ / \4 8 12 16     转换成双向链表4=6=8=10=12=14=16。   中序遍历,遍历的过程生成双向链表。   先实现双线链表,然后实现二叉查找树。   class Node { private int value; private Node pre = null; private Node next = null; private Node prior = null; public No ...
据传说是MS/Google等等IT名企业的面试题: 有一组数字,从1到n,中减少了一个数,顺序也被打乱,放在一个n-1的数组里 请找出丢失的数字,最好能有程序,最好算法比较快   假如有1,2,3,···,10十个数字,并且少了5,那么遍历数组求和得到50,在遍历的过程中得知最大数字为10,那么如果不少5,全部数字和为55,则缺少的数字为55-50=5 如果少了10,那么遍历数组得到的和为45,最大数字为9,和依然为45,45-45=0,则丢失的数字为9+1=10   或者就是申请n-1个空间,遍历标记!   import java.util.Arrays; import ...

Problem 52

问题描述: It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order. Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits.       解决问题:     package projecteuler; import java.util.Arr ...

Problem 51

问题描述:     By replacing the 1st digit of *3, it turns out that six of the nine possible values: 13, 23, 43, 53, 73, and 83, are all prime. By replacing the 3rd and 4th digits of 56**3 with the same digit, this 5-digit number is the first example having seven primes among the ten gene ...
前言    了解你所使用的编程语言究竟是如何实现的,对于C++程序员可能特别有意义。首先,它可以去除我们对于所使用语言的神秘感,使我们不至于对于编译器干的 活感到完全不可思议;尤其重要的是,它使我们在Debug ...
面向对象三要素是封装 继承 多态     封装  封装就是事物抽象为类,把对外接口暴露,将实现和内部数据隐藏。 继承 面向对象编程 (OOP) 语言的一个主要功能就是“继承”。继承是指这样一种能力:它可以使用现有 ...

Problem 50

问题描述:   The prime 41, can be written as the sum of six consecutive primes: 41 = 2 + 3 + 5 + 7 + 11 + 13 This is the longest sum of consecutive primes that adds to a prime below one-hundred. The longest sum of consecutive primes below one-thousand that adds to a prime, contains 21 terms, and is ...

Problem 49

问题描述:   The arithmetic sequence, 1487, 4817, 8147, in which each of the terms increases by 3330, is unusual in two ways: (i) each of the three terms are prime, and, (ii) each of the 4-digit numbers are permutations of one another. There are no arithmetic sequences made up of three 1-, 2-, or 3- ...

Problem 47

问题描述:     The first two consecutive numbers to have two distinct prime factors are: 14 = 2 715 = 3 5 The first three consecutive numbers to have three distinct prime factors are: 644 = 2² 7 23645 = 3 5 43646 = 2 17 19. Find the first four consecutive integers to have four distinct pr ...

Problem 46

问题描述: It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a prime and twice a square. 9 = 7 + 21215 = 7 + 22221 = 3 + 23225 = 7 + 23227 = 19 + 22233 = 31 + 212 It turns out that the conjecture was false. What is the smallest odd composite that cann ...
JNDI全攻略之(一) 关键字:JNDI,J2EE,Java,命名和目录接口,Java Naming and Directory Interface 摘要: 本文详细介绍了JNDI的架构与实现,JNDI的工作原理,并给出了具体代码,帮助读者更理解J2EE主要常用技术---JNDI.本文为系列文章的第一篇,其它相关文章会在近期推出。   名词解释     jndi是Java 命名和目录接口(Java Naming and Directory Interface,JNDI)的简称.从一开始就一直是 java 2 平台企业版(JEE)的核心技术之一。在JMS,JMail,JDBC ...

Problem 45

问题描述:   Triangle, pentagonal, and hexagonal numbers are generated by the following formulae: Triangle   Tn=n(n+1)/2   1, 3, 6, 10, 15, ... Pentagonal   Pn=n(3n1)/2   1, 5, 12, 22, 35, ... Hexagonal   Hn=n(2n1)   1, 6, 15, 28, 45, ... It can be verified that T285 = P165 = H ...
Global site tag (gtag.js) - Google Analytics