RUVIDEO
Поделитесь видео 🙏

java 3 test 2 solve stack & queue question (Arabic) смотреть онлайн

Q9. A linked stack is a:
(A) Single linked list in which the front of the linked list is the top of the stack.
(B) Single linked list in which the last node of the linked list is the top of the stack.
(C) Doubly linked list in which the front of the linked list is the top of the stack.
(D) Doubly linked list in which the last node of the linked list is the top of the stack.


Answer: B


Q10. What would be the output of the following program:
public class StackTest
{
public static void main(String[] args)
{
ArrayStack st = new ArrayStack(); for(int i = 3; i smaller 10; i += 2)
st.push( i + 1);
ArrayStack st1 = new ArrayStack(); while(! st.isEmpty())
st1.push(st.pop() + 2); while(! st1.isEmpty())
System.out.print(st1.pop() + “ ”);
}
}


(A) 6 8 10 12


(B) 12 10 8 6
(C) 10 12 8 6
(D) 12 10 6 8
Answer: A
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Write a method called rearrangeStack in a class called StackExt that receives two parameters st of type ArrayStack and item of type int. The method rearranges the elements of the stack st in such a way that all the elements of the stack st which are below item are moved to the top portion of the stack and all remaining items are moved to the bottom portion of the array.
Use common stack operations only such as push, pop, peek,isEmpty, constructor and copy constructor. You can create local objects of type ArrayStack in your method.
Example:
Before method call: item = 10
top
st: 20 15 5 25 3 7 12 After method call:
top
st: 5 3 7 20 15 25 12

public class StackExt
{
public void rearrangeStack(ArrayStack st, int item)
{

////////////////////////////////////////////////////////////////////////////////////////////////////
(A) [10 Marks] Write a method called mergeQueues to be included in class QueueEx that merges two queues q1 and q2 of type ArrayQueue into a third queue q3 as follows. Queue q3 is obtained by adding an element from q1 followed by adding an element from q2. If no more elements are available in one of the queues, then the remaining elements of the other queue are added into q3. Queues q1 and q2 should remain unchanged at the end of the method.
Example:
q1: 10 30 5 20 40
q2: 7 15 25
q3: 10 7 30 15 5 25 20 40

Assume that class ArrayQueue is available for use. Use common queue operations such as offer, poll, peek, isEmpty, constructor and copy constructor. You can use iterator to access elements of queues q1 and q2.

public class QueueEx
{
public void mergeQueues(ArrayQueue q1, ArrayQueue q2,
ArrayQueue q3)
{

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «java 3 test 2 solve stack & queue question (Arabic)» бесплатно и без регистрации, вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.