24小时热门版块排行榜    

查看: 75  |  回复: 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个字符以上)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 277材料科学与工程080500求调剂 +4 自由煎饼果子 2026-03-16 4/200 2026-03-21 16:15 by lature00
[考研] 初试 317 +3 半拉月丙 2026-03-20 3/150 2026-03-21 13:25 by zhukairuo
[考研] 085601调剂 358分 +3 zzzzggh 2026-03-20 4/200 2026-03-21 10:21 by luoyongfeng
[考研] 求调剂 +6 Mqqqqqq 2026-03-19 6/300 2026-03-21 08:04 by JourneyLucky
[考研] 机械专硕299求调剂至材料 +3 kkcoco25 2026-03-16 4/200 2026-03-21 03:52 by JourneyLucky
[考研] 一志愿天津大学化学工艺专业(081702)315分求调剂 +12 yangfz 2026-03-17 12/600 2026-03-21 03:30 by JourneyLucky
[考研] 一志愿重庆大学085700资源与环境专硕,总分308求调剂 +3 墨墨漠 2026-03-18 3/150 2026-03-21 00:39 by JourneyLucky
[考研] 308求调剂 +3 阿姐阿姐家啊 2026-03-18 3/150 2026-03-20 23:24 by JourneyLucky
[考研] 295材料求调剂,一志愿武汉理工085601专硕 +5 Charlieyq 2026-03-19 5/250 2026-03-20 20:35 by JourneyLucky
[考研] 0703化学调剂 ,六级已过,有科研经历 +13 曦熙兮 2026-03-15 13/650 2026-03-20 19:35 by Dream007008
[考研] 0856调剂,是学校就去 +8 sllhht 2026-03-19 9/450 2026-03-20 14:25 by 无懈可击111
[论文投稿] 申请回稿延期一个月,编辑同意了。但系统上的时间没变,给编辑又写邮件了,没回复 10+3 wangf9518 2026-03-17 4/200 2026-03-19 23:55 by babero
[考博] 申博26年 +3 八6八68 2026-03-19 3/150 2026-03-19 19:43 by nxgogo
[考研] 288求调剂,一志愿华南理工大学071005 +5 ioodiiij 2026-03-17 5/250 2026-03-19 18:22 by zcl123
[考研] 收复试调剂生 +4 雨后秋荷 2026-03-18 4/200 2026-03-18 14:16 by elevennnne
[考研] 0854,计算机类招收调剂 +3 胡辣汤放糖 2026-03-15 6/300 2026-03-18 12:09 by 上岸上岸……..
[考研] 283求调剂 +3 听风就是雨; 2026-03-16 3/150 2026-03-17 07:41 by 热情沙漠
[考研] 333求调剂 +3 文思客 2026-03-16 7/350 2026-03-16 18:21 by 文思客
[考研] 321求调剂 +5 大米饭! 2026-03-15 5/250 2026-03-16 16:33 by houyaoxu
[考研] 070305求调剂 +3 mlpqaz03 2026-03-14 4/200 2026-03-15 11:04 by peike
信息提示
请填处理意见