Millions of computer science students have taken a course on algorithms and data structures, typically the second course after the initial one introducing programming. One of the basic data structures in such a course is the stack. The stack has a special place in the emergence of computing as a science, as argued by Michael Mahoney, the pioneer of the history of the theory of computing. The Stack can be used in many computer applications, few are given below:
Identify the suitable code for the blank of Statement 1.
(A) .append()
(B) .insert()
(C) .extend()
(D) .append(Len(Country), N)
Answer:
(A) .append()
(B) .insert()
(C) .extend()
(D) .append(Len(Country), N)
Question 2 (ii)
Fill the Statement 2, to insert the alternate element from Country list.
(A) 3
(B) 0
(C) –1
(D) 2
Answer:
Checking the options
- (A) 3
(B) 0
(C) –1
(D) 2
So, the correct answer is (D)
Question 2 (iii)
Fill the statement 3, to check the stack is empty.
(A) Country=[]
(B) Country. is Empty()
(C) Len(Country)==0
(D) No of the above
Answer:
Checking the options
- (A) Country=[]
(B) Country. is Empty()
(C) len(Country)==0
(D) No of the above
So, the correct answer is (C)
Question 2 (iv)
Fill the statement 4, to delete an element from the stack.
(A) pop(1)
(B) pop()
(C) del country[1]
(D) Country. delete(1)
Answer:
Checking the options
- (A) pop(1)
(B) pop()
(C) del country[1]
(D) Country. delete(1)
So, the correct answer is (B)
Question 2 (v)
Fill the statement 5, to call the pop function.
(A) pop(C)
(B) pop(Country)
(C) call pop(Country)
(D) def pop(Country)
Answer:
Checking the options
- (A) pop(C)
(B) pop(Country)
(C) call pop(Country)
(D) def pop(Country)
So, the correct answer is (B)