24СʱÈÈÃŰæ¿éÅÅÐаñ    

Znn3bq.jpeg
²é¿´: 77  |  »Ø¸´: 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¸ö×Ö·ûÒÔÉÏ)
×î¾ßÈËÆøÈÈÌûÍÆ¼ö [²é¿´È«²¿] ×÷Õß »Ø/¿´ ×îºó·¢±í
[¿¼ÑÐ] »¯¹¤Ñ§Ë¶294·Ö£¬Çóµ¼Ê¦ÊÕÁô +33 yzyzx 2026-04-12 37/1850 2026-04-17 23:00 by wunaiy88
[¿¼ÑÐ] 271Çóµ÷¼Á +37 2261744733 2026-04-11 39/1950 2026-04-17 10:11 by ºÚ¿Æ¼¼¿óÒµ
[¿¼ÑÐ] 291Çóµ÷¼Á +9 ¹ØÒä±±. 2026-04-14 9/450 2026-04-16 22:49 by cfdbai
[¿¼ÑÐ] ²ÄÁÏÏà¹Ø×¨Òµ344Çóµ÷¼ÁË«·Ç¹¤¿ÆÑ§Ð£»ò¿ÎÌâ×é +23 hualkop 2026-04-12 25/1250 2026-04-16 22:12 by SUSE_CL
[¿¼ÑÐ] Ò»Ö¾Ô¸»¦9£¬ÉúÎïѧ326Çóµ÷¼Á +9 Áõīī 2026-04-15 9/450 2026-04-16 17:14 by ´Þ´Þ´Þcccc
[¿¼ÑÐ] 291Çóµ÷¼Á +11 ¹ØÒä±±. 2026-04-14 11/550 2026-04-16 15:18 by jiahl2024
[¿¼ÑÐ] 290µ÷¼ÁÉúÎï0860 +38 ÍÛ¹þ¹þ£¬¡£ 2026-04-11 44/2200 2026-04-16 09:52 by cuisz
[¿¼ÑÐ] 279ѧ˶ʳƷרҵÇóµ÷¼ÁԺУ 20+7 ¹Â¶ÀµÄÀǰ®³ÔÑò 2026-04-12 29/1450 2026-04-16 09:00 by screening
[¿¼ÑÐ] 085801µçÆø×¨Ë¶272Çóµ÷¼Á +19 µçÆøÀî 2026-04-13 21/1050 2026-04-15 13:37 by ºÚ¿Æ¼¼¿óÒµ
[¿¼ÑÐ] 310Çóµ÷¼Á +16 666ÕæºÃ 2026-04-11 18/900 2026-04-15 13:28 by ºÚ¿Æ¼¼¿óÒµ
[½Ìʦ֮¼Ò] ת³¤Æ¸ÁË +7 ¼òµ¥»¯xn 2026-04-13 7/350 2026-04-14 14:50 by xindong
[¿¼ÑÐ] ¿¼Ñе÷¼Á +13 ³¤¹­°Á 2026-04-13 14/700 2026-04-14 14:44 by zs92450
[¿¼ÑÐ] 105500ҩѧÇóµ÷¼Á +4 x_skys 2026-04-12 4/200 2026-04-14 13:37 by rndfc
[¿¼ÑÐ] 085600²ÄÁÏÓ뻯¹¤329·ÖÇóµ÷¼Á +24 Ò¶zilin 2026-04-13 25/1250 2026-04-14 09:20 by ÊÔ¹ÜÆÆÁÑ
[¿¼ÑÐ] 085600²ÄÁÏÓ뻯¹¤349·ÖÇóµ÷¼Á +16 Àîľ×Ó°¡¹þ¹þ 2026-04-12 17/850 2026-04-14 09:11 by fenglj492
[¿¼ÑÐ] 300·ÖÇóµ÷¼Á £¨085501»úеר˶£¬±¾¿ÆÑï´ó£© +9 xu@841019 2026-04-11 10/500 2026-04-14 08:48 by ľľmumu¡«
[¿¼ÑÐ] Çóµ÷¼Á +3 ÎÒ°®¸ßÊý¸ßÊý°®Î 2026-04-12 3/150 2026-04-14 01:00 by Íõ¬Bè±
[¿¼ÑÐ] Çóµ÷¼Á£¬985²ÄÁÏÓ뻯¹¤348·Ö +9 º­ÖñÁõ 2026-04-11 14/700 2026-04-13 22:26 by º­ÖñÁõ
[¿¼ÑÐ] 0831Ò»ÂÖµ÷¼Áʧ°ÜÇóÖú +10 СÐÜî£î£_s 2026-04-11 10/500 2026-04-12 22:43 by ³¤¹­°Á
[¿¼ÑÐ] 352 Çóµ÷¼Á +6 yzion 2026-04-11 8/400 2026-04-11 16:24 by Ã÷Ô´ËʱÓÐ
ÐÅÏ¢Ìáʾ
ÇëÌî´¦ÀíÒâ¼û