24小时热门版块排行榜    

查看: 87  |  回复: 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个字符以上)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 售SCI一区T0P文章,我:8.O55.1.O.54,科目全,可十急 +3 ttH3f1oA6ace 2026-11-04 8/400 2026-11-05 13:44 by My20PsvIExYO
[考研] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +3 ttH3f1oA6ace 2026-11-04 9/450 2026-11-05 13:33 by My20PsvIExYO
[考博] 售SCI一区T0P文章,我:8.O.55.1.O54,科目全,可伽急 +3 kvewwGtKktqB 2026-11-04 6/300 2026-11-05 13:22 by My20PsvIExYO
[公派出国] 售SCI一区T0P文章,我:8.O.55.1.O54,科目全,可伽急 +4 kvewwGtKktqB 2026-11-04 9/450 2026-11-05 13:22 by My20PsvIExYO
[硕博家园] 售SCI一区T0P文章,我:8O.55.1.O.5.4,科目齐全,可+急 +4 kvewwGtKktqB 2026-11-04 11/550 2026-11-05 13:13 by My20PsvIExYO
[公派出国] 售SCI一区T0P文章,我:8O.55.1.O.5.4,科目齐全,可+急 +4 ncTVBM6AOJHF 2026-11-04 9/450 2026-11-05 13:11 by My20PsvIExYO
[考研] 售一区SCI文章T0P,我:8O.551.O54,科目全,可十急 +4 ncTVBM6AOJHF 2026-11-04 9/450 2026-11-05 13:11 by My20PsvIExYO
[考博] 售SCI一区T0P文章,我:8.O55.1.O.54,科目全,可十急 +5 ncTVBM6AOJHF 2026-11-04 12/600 2026-11-05 13:11 by My20PsvIExYO
[硕博家园] 售SCI一区文章,我:8O5.5.1.O5.4,科目全,可伽急 +3 ncTVBM6AOJHF 2026-11-04 7/350 2026-11-05 13:00 by My20PsvIExYO
[公派出国] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +5 ncTVBM6AOJHF 2026-11-04 8/400 2026-11-05 13:00 by My20PsvIExYO
[公派出国] 售SCI文章,我:8O5.5.1.O.54,科目齐全,可+急 +6 ncTVBM6AOJHF 2026-11-04 17/850 2026-11-05 12:51 by My20PsvIExYO
[公派出国] 售SCI-T0P文章,我:8O.5.5.1.O.54,科目齐全,可+急 +3 ELBZ6WwEaRj6 2026-11-04 6/300 2026-11-05 12:16 by My20PsvIExYO
[考博] 售SCI一区T0P文章,我:8.O.55.1.O.5.4,科目全,可+急 +4 ncTVBM6AOJHF 2026-11-04 7/350 2026-11-05 11:12 by PYZmcHr5kSaq
[教师之家] 售SCI一区T0P文章,我:8O.55.1.O.54,科目全,可伽急 +4 ncTVBM6AOJHF 2026-11-04 12/600 2026-11-05 11:10 by PYZmcHr5kSaq
[考研] 售SCI一区T0P文章,我:8O.55.1.O.5.4,科目齐全,可+急 +4 ncTVBM6AOJHF 2026-11-04 8/400 2026-11-05 11:01 by PYZmcHr5kSaq
[硕博家园] 售SCI一区文章,我:8.O.551.O.5.4,科目全,可伽急 +3 ncTVBM6AOJHF 2026-11-04 8/400 2026-11-05 10:59 by PYZmcHr5kSaq
[考博] 售SCI一区文章,我:8.O.55.1.O.54,科目齐全,可伽急 +5 ncTVBM6AOJHF 2026-11-04 14/700 2026-11-05 10:48 by PYZmcHr5kSaq
[考研] 售一区SCI文章T0P,我:8O.551.O54,科目全,可十急 +3 ncTVBM6AOJHF 2026-11-04 12/600 2026-11-05 10:48 by PYZmcHr5kSaq
[硕博家园] 售SCI一区T0P文章,我:8O.55.1.O.54,科目全,可伽急 +4 ncTVBM6AOJHF 2026-11-04 10/500 2026-11-05 10:39 by PYZmcHr5kSaq
[基金申请] 各位基础老师们,看完中央《从严治党》的决定后,对学术界更加有信心了吧 +5 iaeyuan 2026-11-01 5/250 2026-11-04 14:43 by jinchengzi
信息提示
请填处理意见