0% found this document useful (0 votes)
19 views4 pages

Stack Questions

Mm

Uploaded by

manishactr07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
19 views4 pages

Stack Questions

Mm

Uploaded by

manishactr07
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 4
[1] What is Stack? Write any one application of Stack? Ans.: Stack is a linear data strcuture that allows to add or remove an element from top. It follows LIFO (Last In First Out) principle. The applications of stack are as follows: 1, Pile of clothes in almirah 2. Multiple chairs in a verticale pile 3. Bangles on girl's wrist 4. Phone call logs 5. Web browsing history 6, Undo & Redo commands in text editors 7. Tubewell boring machine [2] List out any two real-life examples of Stack. Ans.: 1. Pile of dinner plates 2. Pile of chairs 3. Tennis balls in their container 4. CD and DVD holder 5. The forward and backword button in media player [3] Define stack. What is the significance of TOP in stack? Ans.: The definition of stack is given in question 1. The TOP is the pointer in stack which allows to add and remove element from one side. [4] Give any two characteristics of stacks. Ans.: 1. Stack is a linear data structure. 2. The tasks performed on stack are : push, pop, peep, and change 3. The insertion and deletion performed on stack from one end only i.e top 4. Stack is implemented in python through lists 5. It follows LIFO principle 6. When the stack is having limited elements and all elements are filled this conidtion is known as stack overflow 7. When there is no element or elments are removed gradually and the stack becomes empty is Known as stack underflow. [5] What do you mean by push and pop operations on stack? " * Ans 1. Push operation refers to inserting element in the stack. 2. Pop operation refers to deleting element from the stack. [6] What is LIFO data structure? Give any two applications of a stack? " . Ans.: LIFO stands for Last In First Out. It is a principle of data structure where the way of insertion and deletion is defined by orrucence of each element. Rofor Question 1 for applications of a stack. [7] Name any two linear Data Structures? What do you understand by the term LIFo? “Hide_Answer’ Ans.: Linear data structure refers toa data structure in which elements are organised in a sequence. The term LIFO is explained in the above question. [8] Name four basic operations performed on stack. a . Ans.: Some basic operations perform on stack are: 1. push: Inserting element in stack 2. pop: Deleting element from stack 3. peep: Accessing the top element 4. change: Changing the value of top element [9] Why stack is called LIFO data structure? “Hide_Answer’ Ans. Stack is called LIFO structure because it allows to insert and delete an element from top where the last element is always on top. While removing this top element is removed first. [10] What do you mean by underflow in the context of stack? “Hide_Answer" Ans. Underflow refers to condition in data structure operations while deleting elements. While deleting elements gradually elements are deleted and the list becomes emply. This situation is know as underflow. [11] Consider STACK=[23,45,67,89,51]. Write the STACK content after each operations: STACK.pop() . STACK.append(99) ; STACK.append(87) STACK.pop() sons 2. STACK 123, ASS 07, 89,99] 3, STACK = [23,45,67,89,99,87] [12] Differentiate between list and stack. "Hide_Answer" Ans. Stack: 1. A stack is a data structure. 2. Stacks uses LIFO principle 3. In stack element only be inserted or deleted from top potision 4. Stack has dynamic size 5. It allows to use only linear search List: 1. A list is a collection of items or data values 2. List uses index position 3. In lists elements can be inserted or deleted any indexes 4. List has fixed size 5. List allows linear and binary search [13] Differentiate between push and pop in stacks. Answer" Ans. Push: 1. Inserting an element into the stack is known as Push. 2. Stack is dynamic in size but when fixed size stack are used, overflow condition will occur 3. The top pointer increases when element is pushed Pop: 1. Deleting an element into the stack is known as Pop 2. Underflow condition will occur when stack becomes empty while elements 3. The top pointer decreases when element is popped [14] Write an algorithm for pop operation in stack. "Hide_Answer” Ans.: Step 1: Start Step 2: If top=-1 go to step 3 else go to step 4 Step 3: Print “Stack is underflow” and go to step 7 Step 4: Delete item = Stack[top] Step 5: Decrement top by 1 Step 6: Print “Item Popped” Step 7: Stop [15] Write an algorithm for push operation in stack. "Hide A a Ans. Step 1: Start Step 2: top=-1 Step 3: Input new element Step 4: Increment top by 1 Step 5: stack[top] = new element Step 6: Print “Item Pushed” Step 7: Stop

You might also like