24小时热门版块排行榜    

Znn3bq.jpeg
查看: 76  |  回复: 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个字符以上)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 材料085601调剂 +29 何润采123 2026-04-10 31/1550 2026-04-13 09:19 by asdsyh1111
[考研] 一志愿中南大学 0855 机械 286 求调剂 +10 不会吃肉 2026-04-12 10/500 2026-04-12 22:51 by 零零二
[考研] 电子信息270求调剂 +18 terminal469 2026-04-07 18/900 2026-04-12 16:23 by ajpv风雷
[考研] 295分求调剂 +13 ?要上岸? 2026-04-10 13/650 2026-04-12 15:37 by laoshidan
[考研] 一志愿华中农微生物,288分,三年实验经历 +11 代fish 2026-04-09 11/550 2026-04-12 10:21 by Hayaay
[考研] 调剂 +10 月@163.com 2026-04-11 10/500 2026-04-12 09:14 by zhouyuwinner
[考研] 305求调剂 +7 玛卡巴卡boom 2026-04-11 7/350 2026-04-12 07:35 by zhouxiaoyu
[考研] 299求调剂 +8 ZVVZ13 2026-04-08 8/400 2026-04-12 00:40 by 蓝云思雨
[考研] 调剂 +6 青灯不负 2026-04-09 6/300 2026-04-11 20:35 by dongdian1
[考研] 269求调剂 +11 啊啊我我 2026-04-07 11/550 2026-04-11 16:45 by vgtyfty
[考研] 22408调剂求助 +7 毂12 2026-04-09 9/450 2026-04-11 09:23 by 哦哦123
[考研] 调剂 化学 307 +21 73372112 2026-04-09 23/1150 2026-04-10 23:53 by wj165256
[考研] 材料专业344求调剂 +16 hualkop 2026-04-10 21/1050 2026-04-10 17:28 by laoshidan
[考研] 301求调剂 +5 149. 2026-04-10 5/250 2026-04-10 15:45 by 柴小白
[考研] 一志愿西交机械专硕求调剂 +8 求上岸的小王 2026-04-10 8/400 2026-04-10 15:09 by hemengdong
[考研] 调剂 +19 2261744733 2026-04-08 19/950 2026-04-09 19:11 by vgtyfty
[考研] 求调剂材料科学与工程一志愿985初试365分 +5 材化李可 2026-04-08 5/250 2026-04-09 17:00 by Lilly_Li
[考研] 277、学硕,求调剂 数一104, +11 瓶子PZ 2026-04-07 12/600 2026-04-07 23:30 by 一只好果子?
[考研] 325 调剂 +6 QQ小虾 2026-04-07 6/300 2026-04-07 15:17 by Ccclqqq
[考研] 材料调剂 +11 一样YWY 2026-04-07 11/550 2026-04-07 15:13 by shdgaomin
信息提示
请填处理意见