Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
19 views
Stack
Uploaded by
ashigupta725
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save stack For Later
Download
Save
Save stack For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
19 views
Stack
Uploaded by
ashigupta725
AI-enhanced title
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save stack For Later
Carousel Previous
Carousel Next
Save
Save stack For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 5
Search
Fullscreen
Mr. Rajeshwar has created a stack whose size is fixed for 10 elements and wants to perform some ‘operations on it. He wants to push certain elements and pop some elements from it. He is confused about the operations and how the clements will behave on pushing and popping? Chevrolet Suaiki Honda Mercedes RolaBoyce Help him to find the answers ofthe following questions. {) How many elements ean he push more to the stack? ws 3 4 wr (@) How many elements he needs to take out before “RolsRoyee” will come out? 2 ws wa (@t (ji) 1F3 elements are popped out and 2 pushed in what will be the strength of the stack? 2 4 oo @r (jv) IF"Tata" and “Datsun” are pushed to the stack respectively , which element will be popped ‘out as a result of a pop operation now? (a) Chevrolet (b) Datsun (e) Tata (€) RolsRoyce () 1f2 elements are popped out and 4 pushed into the Initial stack, how many times a loop needs to iterate to traverse the stack? ws (3 7 (oa Ans. (i) (b) Though the capacity of the stack i 10, so he ean push a maximum of elements i) (© Though there are elements above “RolsRoyee”, 10 4clemonts need to be taken ont (Gi) (6) Popping 3 clements means 2 remain, Now, pushing? elements means strength becomes 4 (ie) (b) Since “Datsun is pushed atthe end, twill be popped ont ist. (o) Since, there are 5 elements in stack and we ‘popped out 2 elements from i, then 3 elements remain, Now, we push 4 elements into stack, then total elements wre 7. Henee, a loop need to iterate to traverse the stack is 7 times. ial wData Structure Data Structure is a way to enable users to manage, organize and store collections of data and perform operations on them accordingly. iia ¥ = tied snp BCCI has created a dictionary containing top players and their runs as key value pairs of cricket team. Write a program, with separate user defined functions to perform the following operations ‘© Push the keys (name of the players) of the dictionary into a stack, where the corresponding value (runs) is greater than 49 ‘* Pop and display the content of the stack. For example: Ifthe sample content of the dictionary is as follow: 'KAPIL":40, "SACHIN’:55, "SAURAV":80, "RAHUL":35, "YUVRAJ ‘The output from the program should be: SACHIN SAURAV YUVRAJ 10,} Sef PUsH(s,R) S. append (R) cet POR(s Lf Stet) eeturn §.pop() else: eturn none st=t1 SCORE=("KAPIL":40, "SACHIN":55, "SAURAV":80, "RAHUL":35, "YUVRAI":110, d for k Ln SCORE: AF SCORE [K]>4 DUSH(ST,k) while Tr Ae sTtst) print (POP(ST) ,end=" ") #pop and display breakVileram has a list containing 10 integers. You need to help him create a program with separate user defined functions to perform the following operations based on this lst * Traverse the content ofthe list and push the ODD numbers into a stack, ‘* Pop and display the content of the stack. For Example: If the sample Content of the list is as follows: N=[12, 13,34, 56, 21, 79, 98, 22, 35, 38] Sample Output of the code should be: 13,21,89,35 det PUSH (S/N): 8 .append (N) def POP(s): ie St=t): return $.pop() sett) 12, 13, 34, 56, 21, 79, 98, 22,35, 38] PUSH (ST, k) is sti=t) print (POP (ST) ,ende! " break YASH MOTORS have a dictionary of top performer EMPLOYEES and their SALES of as key value pairs of COMPANY. Write a program, with separate user defined functions to perform. the following operations: ‘* Push the keys (name of the EMPLOYEE) of the dictionary into a stack, where the corresponding value (SALES) is greater than 500000. # Pop and display the content of the stack. For example: ary is as follows: 400000, "RAJEEV":350000, "MAYANK”: 50000, "RAHUL":1000000, } ‘The output from the program should be: SUNIL MAYANK RAHUL lee PUSH(STE,S): STK. append (S) et PoP (STR) 45 STK!= (1: eturn STK. popt) SALES={ *SUNT1" : 700000, "ROMIT" :400000, "RAJEEY":350000, °MAYANK" :750000, "RAHUL" :1000000, ) st=0 n SALES: ‘SALES [k]>500000: PUSE (ST, k) while True: ertety: print (POP(ST) ,end=Saroj have a list of 10 numbers . You need to help him create a program with separate user defined functions to perform the following operations based on this list. ¢ Traverse the content of the list and push the numbers into a stack which are divisible by 5 Pop and display the content of the stack. For Example: Ifthe sample Content of the list is as follows N=[2,5,10,13,20,23,45,56,60,78) Sample Output of the code should be: 5,10,20,45,60 def push(st,num) : ST. append (nun) return ST.popQ N= (2,5,10,13,20,23,45,56,60,78] sT=(] for 4 in N: © 1e5e=0: push (ST, 1) print (pop(ST) ,end=' °) breakA company having dictionary of various Departments and Number of computers (PC) available as key value pairs. Write a program, with separate user defined functions to perform the following operations: Push the keys (name of the Department) of the corresponding value (Number of PC) is 25 or more. Pop and display the content of the stack. For example: Ifthe sample content ofthe dictionary is as follows SETUP=("HR":10, "QUALITY":25, "SUPPORT":50, "PRODUCTION":20, "SUPPLY":25, } ‘The output from the program should be: QUALITY SUPPORT SUPPLY cef PUSH(ST,S) = ST.appena(s) jonary into a stack, where the det POP(ST) if 81 ST.pop() SETUP=("HR":10, "QUALITY" :25, "SUPPORT":50, "PRODUCTION" :20, SUPPLY" :25, ) st=0) for k in STUD: © SETUP[k] >=25: PUSH (ST, k) while true: af sTIst]: print (PoP(ST)) break A programmer wants to prepare a stack from given list of integer elements only for the numbers which are divisible by 3. Help him create a program with a user defined functions to perform the following operations based on this list. © Traverse the content of the list and push the numbers into a stack which are divisible by 3. ‘© Pop and display the content of the stack. For Example: Ifthe sample Content of the list is as follows: 5,10,13,21,23,45,56,60,78] Sample Output of the code should be: 3.21.45.60 ‘TRY OUT..
You might also like
Most Expected 2 Marks Most Expected Questions Stack Computer Science Class 12
PDF
100% (1)
Most Expected 2 Marks Most Expected Questions Stack Computer Science Class 12
28 pages
PROGRAM 1-1
PDF
No ratings yet
PROGRAM 1-1
12 pages
Stack Qa Edited
PDF
No ratings yet
Stack Qa Edited
5 pages
Chapter 9 Important Questions
PDF
No ratings yet
Chapter 9 Important Questions
14 pages
Pyqs of Data Structure - Stack For More Such Type of Questions and Detailed Video Explanation, Visit The Link
PDF
100% (1)
Pyqs of Data Structure - Stack For More Such Type of Questions and Detailed Video Explanation, Visit The Link
6 pages
Stack Practice Programs
PDF
No ratings yet
Stack Practice Programs
19 pages
Stack Programs
PDF
No ratings yet
Stack Programs
7 pages
Stack Avg
PDF
No ratings yet
Stack Avg
7 pages
stack Q&A
PDF
No ratings yet
stack Q&A
9 pages
Programs On Stack
PDF
No ratings yet
Programs On Stack
9 pages
Stack Program
PDF
No ratings yet
Stack Program
17 pages
Stack
PDF
No ratings yet
Stack
14 pages
Data Structures
PDF
No ratings yet
Data Structures
5 pages
XII STACK
PDF
No ratings yet
XII STACK
4 pages
Chapter 5 Programs
PDF
No ratings yet
Chapter 5 Programs
12 pages
Stack Worksheet
PDF
No ratings yet
Stack Worksheet
9 pages
Stack Practice Programs
PDF
No ratings yet
Stack Practice Programs
6 pages
Chapter 9 Important Questions-1
PDF
No ratings yet
Chapter 9 Important Questions-1
11 pages
Stack Top
PDF
No ratings yet
Stack Top
6 pages
Data Structure Stack
PDF
No ratings yet
Data Structure Stack
24 pages
Adobe Scan 24 Jan 2025
PDF
No ratings yet
Adobe Scan 24 Jan 2025
6 pages
Stack
PDF
No ratings yet
Stack
9 pages
NOTES DataStructure Stacks 2022 23
PDF
No ratings yet
NOTES DataStructure Stacks 2022 23
8 pages
4. Data Structure - Worksheet 1 - 3 Marks
PDF
No ratings yet
4. Data Structure - Worksheet 1 - 3 Marks
8 pages
Stack Answers 1710499434
PDF
No ratings yet
Stack Answers 1710499434
5 pages
STACK WORKSHEET
PDF
No ratings yet
STACK WORKSHEET
3 pages
stackQuestionBanksolution
PDF
No ratings yet
stackQuestionBanksolution
10 pages
For Video Explanation of This Topic, Please Click On The Following Link
PDF
No ratings yet
For Video Explanation of This Topic, Please Click On The Following Link
7 pages
File - 2102217671 - 1686193757 - D.S Part 5
PDF
No ratings yet
File - 2102217671 - 1686193757 - D.S Part 5
4 pages
Stacks
PDF
No ratings yet
Stacks
5 pages
Stacks HW
PDF
No ratings yet
Stacks HW
3 pages
5 6320997802969138292
PDF
No ratings yet
5 6320997802969138292
104 pages
Stacks Worksheet 1
PDF
No ratings yet
Stacks Worksheet 1
2 pages
Stack Practice Questions
PDF
No ratings yet
Stack Practice Questions
6 pages
Copy of Stacks
PDF
No ratings yet
Copy of Stacks
2 pages
Data Structure
PDF
No ratings yet
Data Structure
5 pages
Data Structure
PDF
No ratings yet
Data Structure
10 pages
STACK PROGRAMS
PDF
No ratings yet
STACK PROGRAMS
3 pages
stack questions
PDF
No ratings yet
stack questions
23 pages
Stacks Notes With Programs
PDF
No ratings yet
Stacks Notes With Programs
2 pages
Chapter End Test - Xii - Stack
PDF
No ratings yet
Chapter End Test - Xii - Stack
2 pages
Stack
PDF
No ratings yet
Stack
10 pages
Program-1: Given A Stack Named Book - Details That Contains Book - No, Book - Name and
PDF
100% (4)
Program-1: Given A Stack Named Book - Details That Contains Book - No, Book - Name and
3 pages
STACK WORKSHEET 24-25
PDF
No ratings yet
STACK WORKSHEET 24-25
9 pages
Stack Notes Programs
PDF
No ratings yet
Stack Notes Programs
14 pages
Stack Questions and Answers for Practical Exam
PDF
No ratings yet
Stack Questions and Answers for Practical Exam
10 pages
CSC KV CHN - Stack With Worksheet
PDF
No ratings yet
CSC KV CHN - Stack With Worksheet
10 pages
DATA STRUCTURE
PDF
No ratings yet
DATA STRUCTURE
10 pages
1
PDF
No ratings yet
1
8 pages
Stack 3 Marks
PDF
No ratings yet
Stack 3 Marks
16 pages
Practical File- 20 codes
PDF
No ratings yet
Practical File- 20 codes
16 pages
Stacks
PDF
No ratings yet
Stacks
2 pages
Stack Importan Questions and Answers
PDF
No ratings yet
Stack Importan Questions and Answers
4 pages
MT - 3 revision
PDF
No ratings yet
MT - 3 revision
3 pages
Stack Class XII
PDF
No ratings yet
Stack Class XII
16 pages
DataStructure Stack
PDF
No ratings yet
DataStructure Stack
41 pages
Data Structure
PDF
No ratings yet
Data Structure
24 pages
SM - Data Structure - 2324
PDF
No ratings yet
SM - Data Structure - 2324
15 pages
Stacks (FINAL)
PDF
No ratings yet
Stacks (FINAL)
14 pages
Related titles
Click to expand Related Titles
Carousel Previous
Carousel Next
Most Expected 2 Marks Most Expected Questions Stack Computer Science Class 12
PDF
Most Expected 2 Marks Most Expected Questions Stack Computer Science Class 12
PROGRAM 1-1
PDF
PROGRAM 1-1
Stack Qa Edited
PDF
Stack Qa Edited
Chapter 9 Important Questions
PDF
Chapter 9 Important Questions
Pyqs of Data Structure - Stack For More Such Type of Questions and Detailed Video Explanation, Visit The Link
PDF
Pyqs of Data Structure - Stack For More Such Type of Questions and Detailed Video Explanation, Visit The Link
Stack Practice Programs
PDF
Stack Practice Programs
Stack Programs
PDF
Stack Programs
Stack Avg
PDF
Stack Avg
stack Q&A
PDF
stack Q&A
Programs On Stack
PDF
Programs On Stack
Stack Program
PDF
Stack Program
Stack
PDF
Stack
Data Structures
PDF
Data Structures
XII STACK
PDF
XII STACK
Chapter 5 Programs
PDF
Chapter 5 Programs
Stack Worksheet
PDF
Stack Worksheet
Stack Practice Programs
PDF
Stack Practice Programs
Chapter 9 Important Questions-1
PDF
Chapter 9 Important Questions-1
Stack Top
PDF
Stack Top
Data Structure Stack
PDF
Data Structure Stack
Adobe Scan 24 Jan 2025
PDF
Adobe Scan 24 Jan 2025
Stack
PDF
Stack
NOTES DataStructure Stacks 2022 23
PDF
NOTES DataStructure Stacks 2022 23
4. Data Structure - Worksheet 1 - 3 Marks
PDF
4. Data Structure - Worksheet 1 - 3 Marks
Stack Answers 1710499434
PDF
Stack Answers 1710499434
STACK WORKSHEET
PDF
STACK WORKSHEET
stackQuestionBanksolution
PDF
stackQuestionBanksolution
For Video Explanation of This Topic, Please Click On The Following Link
PDF
For Video Explanation of This Topic, Please Click On The Following Link
File - 2102217671 - 1686193757 - D.S Part 5
PDF
File - 2102217671 - 1686193757 - D.S Part 5
Stacks
PDF
Stacks
Stacks HW
PDF
Stacks HW
5 6320997802969138292
PDF
5 6320997802969138292
Stacks Worksheet 1
PDF
Stacks Worksheet 1
Stack Practice Questions
PDF
Stack Practice Questions
Copy of Stacks
PDF
Copy of Stacks
Data Structure
PDF
Data Structure
Data Structure
PDF
Data Structure
STACK PROGRAMS
PDF
STACK PROGRAMS
stack questions
PDF
stack questions
Stacks Notes With Programs
PDF
Stacks Notes With Programs
Chapter End Test - Xii - Stack
PDF
Chapter End Test - Xii - Stack
Stack
PDF
Stack
Program-1: Given A Stack Named Book - Details That Contains Book - No, Book - Name and
PDF
Program-1: Given A Stack Named Book - Details That Contains Book - No, Book - Name and
STACK WORKSHEET 24-25
PDF
STACK WORKSHEET 24-25
Stack Notes Programs
PDF
Stack Notes Programs
Stack Questions and Answers for Practical Exam
PDF
Stack Questions and Answers for Practical Exam
CSC KV CHN - Stack With Worksheet
PDF
CSC KV CHN - Stack With Worksheet
DATA STRUCTURE
PDF
DATA STRUCTURE
1
PDF
1
Stack 3 Marks
PDF
Stack 3 Marks
Practical File- 20 codes
PDF
Practical File- 20 codes
Stacks
PDF
Stacks
Stack Importan Questions and Answers
PDF
Stack Importan Questions and Answers
MT - 3 revision
PDF
MT - 3 revision
Stack Class XII
PDF
Stack Class XII
DataStructure Stack
PDF
DataStructure Stack
Data Structure
PDF
Data Structure
SM - Data Structure - 2324
PDF
SM - Data Structure - 2324
Stacks (FINAL)
PDF
Stacks (FINAL)