Questions

5 Marks Each

🎯

Test yourself on this topic

2 questions · timed · auto-graded

Question 15 Marks
The following is the code related to the data structure QUEUE

Now answer the following based on the code given:

(a) What is the purpose of EnQueue function

(# Statement-1) defined above:

(i) It is a user defined function to scan / access QUEUE elements

(ii) It is a pre defined function to scan / access QUEUE elements

(iii) It is a user defined function working on double ended queue

(iv) It is a user defined function working on circular queue

(b) What is the line QUEUE.append(VALUE)

(# Statement-2) doing

(i) This will add the element at the end of the QUEUE

(ii) This will remove the element from the end of the QUEUE

(iii) This will add the element at the beginning of the QUEUE

(iv) This will remove the element from the beginning of the QUEUE

(c) Conceptually if the QUEUE is already full , what will happen

(i) PEEK() function will be executed

(ii) OVERFLOW occurs

(iii) UNDERFLOW occurs

(iv) We may still add more elements in it.

(d) What is the use of the variable VALUE used in argument (# Statement-1)

(i) This is the position of FRONT

(ii) This is the position of REAR

(iii) This is an element added in a QUEUE

(iv) This is the name of the list

(e) When the else part (# Statement-3) of the above code will be executed

(i) When the length of the QUEUE is zero

(ii) When the length of the QUEUE is one

(iii) When the length of the QUEUE is more than one

(iv) This part of the code will always executed

Answer
(a) (i) It is a user defined function to scan / access QUEUE elements

(b) (iii) This will add the element at the beginning of the QUEUE

(c) (ii) OVERFLOW occurs

(d) (iii) This is an element added in a QUEUE

(e) (iii) When the length of the QUEUE is more than one

View full question & answer
Question 25 Marks
Read the following code carefully which is implementing the concept of STACK:

Now answer the following based on the code given:

(a) How are the above two functions interrelated?

(i) The function isEmpty(STACK) will be called when pop(STACK) is called

(ii) The function pop(STACK) will be called when is Empty(STACK) is called

(iii) Both functions are implementing recursion

(iv) These functions are not related to each other.

(b) What is the difference in between STACK.pop() and pop(STACK)

(i) Both are pre-defined functions

(ii) Both are user-defined functions

(iii) STACK.pop() is pre defined and pop(STACK) is user defined

(iv) STACK.pop() is user defined and pop(STACK) is pre defined

(c) What is the return type of the function defisEmpty (STACK)

(i) None (ii) void

(iii) int (iv) Boolean

(d) What will the pop(STACK) function return if the stack already consist of [‘A’,’B’] at the position 0 and 1 respectively

(i) A (ii) B (iii) Both A and B (iv) None

(e) if len(STACK) == 0: What is the purpose of this line in the above code:

(i) It checks if the stack is already full

(ii) It checks if the stack can add more value in it or not

(iii) It checks if the stack is already empty

(iv) It checks if the stack exist or not

Answer
(a) (i) The function isEmpty(STACK) will be called when pop(STACK) is called

(b) (iii) STACK.pop() is pre defined and pop(STACK) is user defined

(c) (iv) Boolean

(d) (ii) B

(e) (iii) It checks if the stack is already empty.

View full question & answer
5 Marks Each - Computer Science STD 12 Humanities Questions - Vidyadip