Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

‫جامعة تبوك‬

‫عمادة التعلم اإللكتروني والتعليم عن بعد‬

Week 13 – Lecture 2 (Practical)


Problem Solving in Computing
(Stacks and Queues)
1- Assume that we want to find the sum of all elements in a stack of length 10.
Write and algorithm to find that sum?
2- Assume that we have a stack of length 10. The stack contains integer numbers.
Write an algorithm to count the frequency of the value 3 in this stack.
3- Covert algorithm in question 2 into a program using C++ or Java.
4- A queue of length 20 contains 20 even and odd numbers. Write an algorithm to
find the sum of those even numbers in that queue.

You might also like