C Queue, Duplicating elements in sorted order -
so
if have queue
a --> b --> null;
and when utilize function
void duplicate(queuenodeptr phead, queuenodeptr *ptail)
it give
a --> --> b --> b --> null
i can't around head sorting reference of tail.
all
a --> b --> --> b --> null
how approach this?
basic code fine need hint,
thanks!
if can find out number of elements in queue (n), can following:
for = 1 n e = remove(queue) insert(queue, e) insert(queue, e)
you each element duplicated using queue operations.
if want manipulate info directly, it's no longer queue - it's (linked) list.
c queue
No comments:
Post a Comment