unknownusers25
Addict
Paano po ba i-implement ang change function sa Stack at Queue? Wala po akong mahanap na info about sa operation na change sa Queue at Stack. Salamat sa sasagot.
Di ko din po alam, but I'll clarify nalang po sa prof ko. This was the problem Act2 would be the Queue DS with peak() and change() functions and Act3 would be the Stack DS with peak() and change() functions.i change ang alin?
// STACK
let exampleStack[size]
let sp = 0; // stack pointer
doStack(let push, let value)
if (push)
exampleStack[sp++] = value;
else
return exampleStack[--sp];
// Queue
let exQueue[size]
let qt = 0; // queue tracking
doQueue(let add, let value)
if (add)
qMoveValueByOne(1) // right
exQueue[0] = value
else
let tmp = exQueue[0]
qMoveValueByOne(0) // left
return tmp
Same po na kung ano ang gamit ng peak() operation, di ko lang magets yung sinabi na change() operation. By the way salamat po <3Stack - Last in First Out
change by push, or pop, stack pointer (SP) points to previous stack
Queue - First In First Out
literal na pila, serve who comes first unlike stack na serve whats on the current SP then inc/decrement pointer
sa change... idk?
Code:// STACK let exampleStack[size] let sp = 0; // stack pointer doStack(let push, let value) if (push) exampleStack[sp++] = value; else return exampleStack[--sp]; // Queue let exQueue[size] let qt = 0; // queue tracking doQueue(let add, let value) if (add) qMoveValueByOne(1) // right exQueue[0] = value else let tmp = exQueue[0] qMoveValueByOne(0) // left return tmp
baka mali ito, or iba tinutukoy sa class ninyo
elaborate sir ano po ba ginagawa ng peak() function? para mas maging malinaw baka alam natin heheSame po na kung ano ang gamit ng peak() operation, di ko lang magets yung sinabi na change() operation. By the way salamat po <3