keren

שאלה 3 - עמ' 24 / מיקודית

May 8th, 2012
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. public static Stack<Item> AppearencesOtef (BinTreeNode <Integer> T, Stack<Integer> S)
  2. {
  3.     Stack <Integer> helper = copyStack(S);
  4.     Stack <Integer> btn= copyBinTreeIntoStack(T);
  5.  
  6. return (Appearences(helper,btn))
  7.  
  8. }
  9.  
  10. public static Stack<Item> Appearences(Stack<Integer> helper,Stack <Integer> btn)
  11. {
  12.     Stack<Item> Sitm= null;
  13. while (!helper.isEmpty() )
  14. {
  15.     int x=helper.top();
  16.     int Scount=CountAppeirence(x,helper);
  17.     int BTNcount=CountAppeirence(x,btn);
  18.     Item itm = new Item (helper.pop(),Scount,BTNcount);
  19.     DeleteX(x,helper);
  20.     DeleteX(x,btn);
  21.     Sitm.push(itm);
  22. }
  23. while (!btn.isEmpty() )
  24. {
  25.     int x=btn.top();
  26.     int BTNcount=CountAppeirence(x,btn);
  27.     Item itm = new Item (btn.pop(),0, BTNcount);
  28.     Sitm.push(itm);
  29. }
  30.  
  31. return Sitm;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment