Asymptotic Time Complexity
- From: s_valmont@xxxxxxxxx
- Date: 26 Jan 2007 18:31:15 -0800
Just wondering if my time complexity analyis of the algorithm below is
accurate as I am new to this! The algorithm involves storing data
using an array and afterward printing it sorted.
<algorithm>
For each line of data we receive
If the record count plus one is larger than the array size
Create a new, bigger array
Copy the contents of the old array into the new one
If the record already exists
Update the record
Else
Create a new record and add it to the array
Increase the record count
Sort the array
For each record in the array
Print the record
</algorithm>
All steps are constant or linear time complexity except for one
sequence - when we need to resize our array.
However the large amount of time required by the resizing operation is
amortized constant time due to the fact that it is averaged over the
relatively large number of cycles that do not require a resize. Thus
with this "factored out", what we have is linear or O(n) asymptotic
time complexity.
Does this make any sense?
Thanks a lot!
.
- Follow-Ups:
- Re: Asymptotic Time Complexity
- From: Arthur J. O'Dwyer
- Re: Asymptotic Time Complexity
- Prev by Date: Other than php/perl/lisp/c/c++/java, anybody have a favorite computer-programming language?
- Next by Date: Re: what type of sort is this?
- Previous by thread: Other than php/perl/lisp/c/c++/java, anybody have a favorite computer-programming language?
- Next by thread: Re: Asymptotic Time Complexity
- Index(es):
Relevant Pages
|