2. Write an algorithm for the following operation: (a) checking the stack before inserting the new data. [1 MARK] Answer

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

2. Write an algorithm for the following operation: (a) checking the stack before inserting the new data. [1 MARK] Answer

Post by answerhappygod »

2.
Write an algorithm for the following operation:
(a)
checking the stack before inserting the new data.
[1 MARK]
Answer:
(b)
checking the queue before deleting the existing data.
[1 MARK]
Answer:
(c)
getting last element in stack without remove it.
[1 MARK]
Answer:
(d)
removing element from queue.
[1 MARK]
Answer:
(e)
storing element into the stack
[1 MARK]
Answer:
Page Break
3.
(a)
Using a diagram, differentiate between singly circularlinked-list, doubly circular linked-list and doublylinked-list.
[3 MARKS]
Answer:
(b)
State ONE (1) example of stack and ONE (1) example of queue inreal-world.
[2 MARKS]
Answer:
4.
Assume the max location size for the static queue is 15 withstarting index is [0].
Referring to the following operations:
Initial static queue with W, E, S, T, L and I.
ENQUEUE F and E.
DEQUEUE three numbers.
DEQUEUE two numbers.
ENQUEUE L, S and E.
Determine the index of FRONT and REAR after eachoperation.
[5 MARKS]
Answer:
Question
(a)
(b)
(c)
(d)
(e)
FRONT
REAR
5.
Illustrate the sequences of the dynamic stack AFTER everyoperation.
(a)
Initial dynamic stack including number 51, 52 and 53.
[2 MARKS]
Answer:
(b)
PUSH number 54 and 55.
[2 MARKS]
Answer:
(c)
POP three numbers.
[2 MARKS]
Answer:
(d)
PUSH number 56, 57 and 58.
[2 MARKS]
Answer:
(e)
POP four numbers.
[2 MARKS]
Answer:
6.
Illustrate the following array operations.
(a)
Create ONE (1) array named FRUIT with initial items includeBanana, Papaya, Pineapple and Watermelon. Max size for the array is10.
[2 MARKS]
Answer:
(b)
Add item Mango, Rambutan and Durian in FRUIT.
[2 MARKS]
Answer:
(c)
Delete item in FRUIT [0], FRUIT [4] and FRUIT [6].
[2 MARKS]
Answer:
(d)
Delete Rambutan from FRUIT.
[2 MARKS]
Answer:
(e)
Add item Jackfruit, Mangosteen and Lime in FRUIT.
[2 MARKS]
Answer:
7.
Draw a sequence of linked-list diagram for each of the followingoperations, and beginning with empty list.
(a)
Add symbol @, #, $, % into the list.
[2 MARKS]
Answer:
(b)
Add symbol & in front of symbol $.
[2 MARKS]
Answer:
(c)
Add symbol * in between symbol @ and #.
[2 MARKS]
Answer:
(d)
Remove symbol $, % and *.
[2 MARKS]
Answer:
(e)
Remove symbol @ and &.
[2 MARKS]
Answer:
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply