Davencode

Untitled

Jul 4th, 2021 (edited)
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. ALGO_IT(A,p,r,k)
  2. STQ=STR=LAST=NIL;
  3. CP=P; CR=R;
  4. While(CP<=CR || STR != NILL) do
  5. if(CP < CR) then
  6. ret = false
  7. if (CP = CR) then
  8. ret = (k==A[CP])
  9. LAST=CP
  10. CP=CR+1
  11. else
  12. Q=CP+CR/2
  13. STQ=PUSH(STQ,Q)
  14. STR=PUSH(STR,CR)
  15. CR=Q-1
  16. else
  17. Q=TOP(STQ); CR=TOP(STR);
  18. if(LAST != CR)then
  19. ret = (k==A[q] || val)
  20. if (ret=(k==A[q]) then
  21. LAST=CP
  22. CP=CR+1
  23. STP=STQ=POP();
  24. else if(ret=false)then
  25. CP=Q+1
  26. else
  27. LAST=CP
  28. CP=CR+1
  29. STP=STQ=POP();
  30. else
  31. ret=val
  32. LAST=CP
  33. CP=CR+1
  34. STP=STQ=POP();
  35. return ret;
Add Comment
Please, Sign In to add comment