Skip to main content

STACK ASSIGNMENT | 15TH OCT

 

STACK ASSIGNMENT

QUE 1:

[1] A ____________ is a way to store, organize, or manage data in efficient and productive manner.

[2] A stack is one of the following types of data structure?

a) Linear b) Dynamic c) Circular d) All of these

[3] Stack data structure is following ____________ principle.

[4] In stack data can be inserted or deleted from ____________ only.

[5] The insert operation in the stack is known as pop. (True/False)

[6] You can replace any element position in the stack. (True/False)

[7] The peek operation refers to accessing/inspecting the top element in the stack. (True/False)

[8] A condition raise due to the stack is full is known as ___________.

a) Underflow b) Overflow c) List is full d) Completely Filled

[9] While popping the element from the stack, a condition will be raised, this condition is known as ____________.

a) Underflow b) Overflow c) List is Empty d) Blank List

[10] Stack overflow condition is raised in ____________ operation where as Stack underflow condition is raised in _____________ operations.

Push, Pop

QUE 2:

1.     1. What do you mean by data structure? Explain your answer with a suitable example.

2.     2. Write a function to display the stack elements.

3.     3. Write a python function named is_underflow() to check a stack is an underflow.

4.     4. Write functions AddPlayer(player) and DeletePlayer(player) in python to add and remove a player by considering them as push and pop operations in a stack.

Comments

Popular posts from this blog

PYTHON - MYSQL CONNECTIVITY CODE

  #INSERTION OF DATA import mysql.connector mydb = mysql.connector.connect( host="localhost", user="root", passwd="root", database="school" ) print("Successfully Connected") #print(mydb) mycursor=mydb.cursor()   v1=int(input("enter ID:")) v2=input("enter name:") v3=input("enter Gender:") v4=int(input("enter age:")) sql='insert into TEACH values("%d","%s","%s","%s")'%(v1,v2,v3,v4) print(sql) mycursor.execute(sql) mydb.commit() print("record added") #MYSQL Connection code – Deletion on database SOURCE CODE: s=int(input("enter id of TEACHER to be deleted:")) r=(s,) v="delete from TEACH where id=%s" mycursor.execute(v,r) mydb.commit() print("record deleted") MYSQL Connection code – Updation on database SOURCE CODE: import mysql.connector mydb = mysql.connector.c...

REVISION IF CONSTRUCT | CLASS TEST

                                                                                     CLASS TEST 1. Write a Python program that asks the user for their age, gender, and current fitness level (beginner, intermediate, or advanced). Based on this information, suggest a suitable fitness plan using if-else statements. Requirements: Inputs : Age (integer) Gender (male/female) Fitness level (beginner/intermediate/advanced) Outputs : Recommend a fitness plan that includes: Suggested workout duration. Type of exercises (e.g., cardio, strength, flexibility). Rest days. Logic : Use if-else to determine the plan based on conditions such as: Age group (e.g., <18, 18–40, >40). Fitness leve...