| | |
time complexity problem
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2008
Posts: 5
Reputation:
Solved Threads: 0
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.
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.
•
•
Join Date: Mar 2008
Posts: 5
Reputation:
Solved Threads: 0
•
•
•
•
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.
![]() |
Similar Threads
- about time complexity (IT Professionals' Lounge)
- Complexity problem (Java)
- Question: Linear Time Sorting Problem (Computer Science)
- Time Complexity Problem -Urgent (Computer Science)
- Help On Time Complexity Algorithm (Computer Science)
- Directed Graph Problem (Computer Science)
- I hit a brick wall-- time complexity problem (Computer Science)
Other Threads in the C++ Forum
- Previous Thread: Unknown syntax error in C++ class
- Next Thread: Read hexadecimal value from a file..
| Thread Tools | Search this Thread |
api application array arrays based beginner binary bitmap bmp c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator getline givemetehcodez graph homeworkhelp iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg simple sorting string strings template text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






