Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
1.0k views
in Computer by (15.9k points)

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: 

a) In recursive function 

b) When function is called.

c) Expression conversion such as – Infix to Postfix, Infix to Prefix, Postfix to Infix, Prefix to Infix. 

In Stack, insertion operation is known as Push whereas deletion operation is known as Pop. 

Code – 1

def push(Country,N): 

Country._________(len(Country),N)) #Statement 1 

#Function Calling 

Country=[ ] 

C=['Indian', 'USA', 'UK', 'Canada', 'Sri Lanka'] 

for i in range(0,len(C),________): #Statement 

2 push(Country,C[i]) 

print(Country)

Required Output: 

['Indian', 'UK', 'Sri Lanka'] 

Code - 2

def pop(Country): 

if __________: #Statement 3 

 return "Under flow" else: return Country.________() #Statement 4 #

Function Calling 

for i in range(len(Country)+1): print(_______) #Statement 5 

Required Output: 

Sri Lanka 

UK 

India 

Under flow

Fill the above statement based on given questions: 

i. Identify the suitable code for the blank of statement 1. 

a. .append() 

b. .insert() 

c. .extend() 

d. .append(len(Country),N) 

ii. Fill the statement 2, to insert the alternate element from Country list. 

a. 3 

b. 0 

c. -1 

d. 2

iii. Fill the statement 3, to check the stack is empty. 

a. Country=[] 

b. Country.isEmpty() 

c. len(country)==0 d. No of the above

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)

v. Fill the statement 5, to call the pop function. 

a. pop(C) 

b. pop(Country) 

c. call pop(Country)

d. def pop(Country)

Please log in or register to answer this question.

1 Answer

+1 vote
by (15.3k points)

1. Correct Answer : b. .insert()

2. Correct Answer : d. 2

3. Correct Answer : c. len(country)==0

4. Correct Answer: b. pop()

5. Correct Answer: b. pop(Country)

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...