Class XII Computer Science 083 Important Data Structure stack Question and answer | Class 12 Term 2 important questions

Class XII Computer Science 083 Important Data Structure stack Question and answer | Class 12 Term 2 important questions 

Data Structure stack Question

Push (Adding the element to Stack) 

Write a function to push an element into the stack.

def push(stk,e):

    stk.append(e)

    top = len(stk)-1

POP (Removing the element from the Stack) 

Write a python function to delete an element from the stack.

def pop_stack(stk):

    if stk==[]:

        return "UnderFlow"

    else:

        e = stk.pop()

        if len(stk)==0:

            top = None

        else:

            top = len(stk)-1

        return e

Display  (Display the element from the Stack) 

Write a function to display the stack elements.

def display(stk):

    if stk==[]:

        print("Stack is Empty")

    else:

        top = len(stk)-1

        print(stk[top],"-Top")

        for i in range(top-1,-1,-1):

            print(stk[i])

Inspection (Inspect the element of the Stack) 

Write a function to inspect an element from the stack.

def peek(stk):

    if stk==[]:

        return "UnderFlow"

    else:

        top = len(stk)-1

        return stk[top]

Related searches

sample paper 2021 class 12 computer science python term 2

computer science class 12 sample paper 2021 with solutions

class 12 computer science sample paper 2021-22 term 2

class 12 computer science term 2 sample paper solution

cs sample paper term 2 class 12

computer science sample paper class 12 2022 term 2

computer science (class 12 term 2 syllabus)

computer science sample papers class 12 solved pdf

If you any doubts, Please let me know

Previous Post Next Post

Contact Form