How to Add a many2many Relational Field in Odoo 17
Stacks
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11. Implementing a Stack Using an Array (Contd.) 10 top = – 1 Stack 2 1 0 4 3 PUSH an element 3
12. Implementing a Stack Using an Array (Contd.) 10 top = 0 Stack 2 1 0 4 3 top = 0 PUSH an element 3
13. Implementing a Stack Using an Array (Contd.) 10 top = 0 10 Stack 2 1 0 4 3 3 Item pushed PUSH an element 3
14. Implementing a Stack Using an Array (Contd.) 10 top = 0 10 Stack 2 1 0 4 3 3 PUSH an element 8
15. Implementing a Stack Using an Array (Contd.) 10 top = 0 10 Stack 2 1 0 4 3 3 top = 1 PUSH an element 8
16. Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 top = 1 8 Item pushed PUSH an element 8
17. Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 top = 1 8 PUSH an element 5
18. Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 top = 1 8 top = 2 PUSH an element 5
19. Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 top = 2 5 Item pushed PUSH an element 5
20. Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 top = 2 5 PUSH an element 1
21. Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 top = 2 5 top = 3 PUSH an element 1
22. Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 5 top = 3 1 Item pushed PUSH an element 1
23. Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 5 top = 3 1 PUSH an element 9
24. Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 5 top = 3 1 top = 4 PUSH an element 9
25. Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 5 1 top = 4 9 Item pushed PUSH an element 9
26. Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 5 1 top = 4 9 PUSH an element 2
27. Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 5 1 top = 4 9 top = 5 PUSH an element 2
28. Implementing a Stack Using an Array (Contd.) 10 10 Stack 2 1 0 4 3 3 8 5 1 9 top = 5 Stack overflow PUSH an element 2
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
Editor's Notes
To start the session, you need to get a set of playing cards in the class. Follow the instructions as given below to begin the game of Rummy. 1. The game begins by dealing a fixed number of cards to all players. The remaining cards are placed face down to form a “stock” pile. 2. There is also a face-up pile called the “discard” pile. 3. Initially, the discard pile contains only one card which is obtained by picking the topmost card from the stock pile. 4. Each player can draw either the topmost card of the stock pile or the topmost card on the discard pile to make a valid sequence in his/her hand. 5. After this, the player must discard one card on top of the discard pile. 6. The next player, can then draw either the topmost card of the draw pile or the topmost card of the discard pile. 7. Therefore, if a player has to draw a card from the discard pile, he/she can draw only the topmost card of the discard pile. 8. Similarly, when a player has to discard a card, he/she must discard it on the top of the discard pile. 9. The discard pile can therefore be considered a Last-In-First-Out list. 10. The last card placed on top of the discard pile is the first one to be drawn. 11. To represent and manipulate this kind of a discard pile in a computer program, you would like to use a list that: a. Contains the details of all the cards in the discard pile. b. Implements insertion and deletion of card details in such a way that the last inserted card is the first one to be removed. This kind of a list can be implemented by using a stack. Ask students to define a stack? Ask them to refer to the game and come up with some characteristics of a stack. Then come to next slide and give them the definition of stacks.
You can give some more explanation of stacks by with the help of the following example. 1. A stack is like an empty box containing books, which is just wide enough to hold the books in one pile. 2. The books can be placed as well as removed only from the top of the box. 3. The book most recently put in the box is the first one to be taken out. 4. The book at the bottom is the first one to be put inside the box and the last one to be taken out.
In this slide you need to show the calculation to determine the sum of an arithmetic progression for bubble sort algorithm. Refer to student guide.
In this slide you need to show the calculation to determine the sum of an arithmetic progression for bubble sort algorithm. Refer to student guide.
Tell students that stacks can be implemented using both arrays and Linked List. The slides to explain the implementation of stacks using an array are given.
Make this session an interactive one by asking students to write an algorithm to implement POP operation using an array. Let students first try to write the algorithm. Then you can explain the algorithm given in the student guide. In addition, also explain the exception conditions that is encountered while popping an element from the stack, using an array.
In this slide you need to show the calculation to determine the sum of an arithmetic progression for bubble sort algorithm. Refer to student guide.
In this section, you need to discuss the applications of Stacks. In addition, to the given applications, you can discuss some real life applications also. For example, ask students to notice the operations in their Mobile phones. When you go to the Menu log Recent calls Missed calls. On the missed call page, you will be able to view all the missed call number. To back to the main page, you need to press the back option and it will take you page, you last visited.
In this section, you need to discuss the applications of Stacks. In addition, to the given applications, you can discuss some real life applications also. For example, ask students to notice the operations in their Mobile phones. When you go to the Menu log Recent calls Missed calls. On the missed call page, you will be able to view all the missed call number. To back to the main page, you need to press the back option and it will take you page, you last visited.
Explain this concept to students by further telling them that the changes are internally stored in the stack data structure inside the computer. The last change made is the first one to be reverted.
In this slide, ask students to relate to the example they have learnt in the beginning of the session.
This is one of the applications where stack is used. You need to run through the slides and then ask students to write an algorithm to check the correctness of the nested parenthesis. The algorithm will be: Scan the expression. Push the opening bracket into the stack. If a closing bracket is encountered, check if the closing bracket is same as the opening bracket. If this condition holds true, POP the corresponding opening bracket from the stack. If the condition is false, the expression is not a valid expression.
In this slide, ask students to relate to the example they have learnt in the beginning of the session.