time complexity problem

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2008
Posts: 5
Reputation: chts12345 is an unknown quantity at this point 
Solved Threads: 0
chts12345 chts12345 is offline Offline
Newbie Poster

time complexity problem

 
0
  #1
Mar 17th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 1,661
Reputation: jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of 
Solved Threads: 123
jephthah's Avatar
jephthah jephthah is offline Offline
Posting Virtuoso

Re: time complexity problem

 
1
  #2
Mar 17th, 2008
If a train leaves the station @ 8:30 p.m. full of clowns named bob and larry and one named steve and it takes 1 hour to get there, the number of licks it will take to get to the center of a tootsie roll tootsie pop

= 42.



QED.
Last edited by jephthah; Mar 17th, 2008 at 8:32 pm.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 5
Reputation: chts12345 is an unknown quantity at this point 
Solved Threads: 0
chts12345 chts12345 is offline Offline
Newbie Poster

Re: time complexity problem

 
0
  #3
Mar 17th, 2008
Originally Posted by jephthah View Post
If a train leaves the station @ 8:30 p.m. full of clowns named bob and larry and one named steve and it takes 1 hour to get there, the number of licks it will take to get to the center of a tootsie roll tootsie pop

= 42.



QED.

Hi

I didn't get you. This is not the answer of my problem.Please be clear.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,502
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1479
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: time complexity problem

 
0
  #4
Mar 17th, 2008
Originally Posted by chts12345 View Post
Hi

I didn't get you. This is not the answer of my problem.Please be clear.
I think it was meant as a joke
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 1,661
Reputation: jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of 
Solved Threads: 123
jephthah's Avatar
jephthah jephthah is offline Offline
Posting Virtuoso

Re: time complexity problem

 
0
  #5
Mar 18th, 2008
I didn't get you. This is not the answer of my problem.Please be clear.
okay... how about, "You need to quit relying on others to do your work, and do it yourself. When you have put forth some effort, and then get stuck, come back with a sensible question."

is that clear?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC