24小时热门版块排行榜    

查看: 81  |  回复: 0
当前主题已经存档。
【悬赏金币】回答本帖问题,作者njlizhen将赠送您 40 个金币

njlizhen

银虫 (小有名气)

[求助] java试题求助

时间限定在今天晚上之前,先谢谢各位了!
1.  Given a sorted array of ints,  write a method to remove the duplicates.
    Do not use any classes from the java.util package.
    example:  1,2,3,3,3,4,4,10,13,15,15,17  -> 1,2,3,4,10,13,15,17

    int[] removeDuplicates(int[] vals)
     {


     }


2. Given two database tables

  EMPLOYEES                       COMPENSATION
  ________________________        _____________________
  EMPID  NAME  SUPERVISOR         EMPID  BONUS         
  ------------------------        ---------------------
   34    Amy                       17     5000
   17    Ben       34              10     2000
    5    Chris     34              34     5000
   10    Don       5               ...
   ...

A)  Write a SQL statement to return the names of everyone who got a bonus greater than 1000.


B)  Given an EMPID write a SQL statement to return the names of everyone who directly reports to that person
    (everyone who has the person as a supervisor)


C)  GIVEN an EMPID Write a SQL statement to return everyone who is in that person's organization
    (everyone who either directly or who's supervisor ultimately reports to that person)





3. We define a Node in a binary tree to have a value and both left and right references to other Nodes. The left reference must point to either null or
to a Node with a smaller value. The right reference must either point to null or to a Node with an equal or larger value.

public Node
{
public int value;
public Node left;
public Node right;
}

We can build a tree by inserting one value at a time.  The insertion is done by starting at the root and finding the first node with an
appropriate null reference. If we insert 8,5,9,3,3,2,12,4,10  the tree at each step would look like:


       8

       8
      5  

       8
      5 9

       8
      5 9
     3

       8
      5 9
     3
      3

       8
      5 9
     3   
    2 3

       8
      5 9
     3   12
    2 3

       8
      5 9
     3   12
    2 3
       4

       8
     5   9
    3  10 12
   2 3
      4

A) Write a method that given the root Node prints out the all the values in sorted order.

   void printOrdered(Node node)
   {
   }


B) Write a method that given the root Node of the tree inserts a new value.
   
   void insertValue(Node node, int value)
   {
   }

C) If the tree has N nodes what is the average big O time for an insert?


D) what is the worst case big O time for an insert?  What would the input data look like to generate the worst case.

[ Last edited by njlizhen on 2008-4-15 at 11:13 ]
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 njlizhen 的主题更新
不应助 确定回帖应助 (注意:应助才可能被奖励,但不允许灌水,必须填写15个字符以上)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[基金申请] 咱们一起用铁证分析2026国家社科基金中标与否 +7 启萌科技 2026-08-12 25/1250 2026-08-16 10:53 by hmhminy
[基金申请] 我的国基提前知道中了,可是同事的操作让我实在接受不了,怎么会有这样的人 +11 家与远方 2026-08-10 16/800 2026-08-16 10:28 by ray43
[基金申请] 欢迎发来filecode的Mz6后的代码验证其规律 +31 医学老男孩 2026-08-13 70/3500 2026-08-16 08:29 by 医学老男孩
[基金申请] 有时候,自然基金真的不能太认真 (我的申报经验) +10 majunge000 2026-08-11 12/600 2026-08-16 08:18 by xli1984
[精细化工] 招聘 金属平磨液,抛光液研发工程师 +3 小天0311 2026-08-14 3/150 2026-08-16 07:31 by H9PLUS
[基金申请] 时间戳又变了8-15 +12 archvillain 2026-08-15 23/1150 2026-08-15 20:47 by foyo404
[基金申请] filecode=后面第一个是大写字母 +6 wangze12014 2026-08-14 7/350 2026-08-15 20:12 by gltch
[基金申请] 关于Filecode分析方法 +10 majunge000 2026-08-10 13/650 2026-08-15 12:26 by hanpeng972
[基金申请] 奇怪,两个人的filecode固定段从头到尾一模一样 +8 布布和一二 2026-08-10 11/550 2026-08-14 14:58 by Equinoxhua
[基金申请] 应该是93bebmhtak前后十一个字符比较关键 +23 Lanmanbaby 2026-08-09 37/1850 2026-08-14 13:40 by Equinoxhua
[硕博家园] 读博的好处 +4 lnee 2026-08-11 4/200 2026-08-14 10:20 by ahsoarli
[基金申请] FileCode能看出啥? +10 要乐观耀哥 2026-08-10 32/1600 2026-08-14 09:37 by 要乐观耀哥
[基金申请] 静等基金结果 +8 gjjjzhong 2026-08-10 21/1050 2026-08-13 17:56 by 且听虎啸
[基金申请] 不应该看fileCode +7 且听虎啸 2026-08-12 9/450 2026-08-13 14:27 by flydreamws
[基金申请] 结合人工智能,周易传统文化,filecode打分制来了,3分以上希望很大。 +3 Tide man 2026-08-12 4/200 2026-08-13 08:35 by ZJTJZ
[基金申请] 帮忙看看fileCode +7 wwncly 2026-08-10 13/650 2026-08-11 19:36 by 冰心玉壶晴
[基金申请] 什么时候出结果,有咨询渠道??? +3 Tide man 2026-08-11 3/150 2026-08-11 17:54 by kudofaye
[基金申请] 确定了,国自然21号放榜 +6 布布和一二 2026-08-10 7/350 2026-08-10 19:15 by 2000zf36392
[基金申请] 国自然结果 +4 Vierhys 2026-08-10 8/400 2026-08-10 15:06 by Vierhys
[基金申请] 据悉今年马上要出结果了 +7 瞬息宇宙 2026-08-10 8/400 2026-08-10 12:42 by Vivilian
信息提示
请填处理意见