amortized analysis time complexity problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chits12345
    New Member
    • Mar 2008
    • 1

    #1

    amortized analysis time complexity problem

    Hi all

    Is there anybody who can solve this problem? This is not a easy problem.


    Problem:

    Assume that George(S,X) is a function that returns a Boolean value, where S is a stack, and that the time complexity of George is O( log |S| ) , where |S| is the current size of the stack.

    Consider the following block of pseudo code.

    S <- - empty stack
    For i from 1 to n do
    Read (Xi)
    While (S! = Ø) and George(S, Xi) do
    Pop (S)
    End while
    Push Xi onto S
    End for
    Assume that reading popping and pushing take O (1) time.


    Use Amortized analysis to prove that the block of code runs in O (n logn) time.


    Please describe your answer in detail if you know the solution.

    Any help is appreciated.
  • Laharl
    Recognized Expert Contributor
    • Sep 2007
    • 849

    #2
    We won't do your homework for you. Have you started or do you have any ideas of where to begin?

    Comment

    Working...