c++ - Merge Sort and Queue -
im working on review sheet pretty got except not sure these two. please?
q benefit of using queue merge sort? q suppose in mergesort replace queue stack (i.e. push instead of enqueue, pop in place of dequeue). explain effect replacement have.
with queues things automatically added end of list; thus, when lowest level of mergesort's recursion (individual elements), sorted array can enqueue largest of these elements new list. using stack should reverse list since elements added put @ front, you'd have search smallest element instead of largest.
Comments
Post a Comment