PDA

Click to See Complete Forum and Search --> : what's this mean?


nabeels786
May 9th, 2002, 05:45 PM
"Addition and deletion are both O(logn) operations"

about heapsort

i have two weeks to learn hashing, heapsort, and "operations on dynamic data structures" (transversals, insertion, deleteion, memory management"

any tips/resources?

thanks :)

(its for a comp sci ap test, they dont have the course here, so im just taking the test)

CornedBee
May 13th, 2002, 07:44 AM
I think it's about the speed of the operation. It tells you how long an operation takes. For example: bubble sort takes at worst n^2. This means the number of loop iterations (where the loop body does the work) is at worst the square of the number of elements. This is very bad.
Quicksort on the other hand takes at worst log n. This is a LOT less.
At best both algorithms need nearly no time (if the array is already sorted).
Finding an element in a linked list takes at worst n. At best 1. (depending on where the element is).

I don't know what the O means, but I think it means "worst case". There may be other letters that mean things like "constant time" or "always".
"constant time" means an operation takes the same time no matter how many elements there are (e.g. deleting an element from a double linked list at a known position).
"always" means an operation takes the same time relative to the element count no matter where in the array the manipulated data is, can't think of an example.

Keda may know more.