Answer:
Hi
In the first scenario we have
S = []
then:
S=[1],
S=[2,1]
S=[3,2,1]
S=[2,1]
S=[4,2,1]
S=[2,1]
S=[1]
So when it's call the method peek to S, X will be assigned 1
Explanation:
Stack is a linear data structure which follows a particular order in which the operations are performed. The order may be LIFO(Last In First Out). There are many real-life examples of a stack. Consider an example of plates stacked over one another in the canteen. (Taken from wikipedia)
- The method <em>push</em> is to put the element on the top of the stack
- The method <em>pop</em> is take out the top element of the stack
- The method <em>peek</em> is to see what is the top element of the stack
Answer:
use destination theme and embed workbook
Explanation:
When dealing with Excel spreadsheets in the Microsoft Office Software Suite, the paste option labeled use destination theme and embed workbook is used if you want the pasted chart not to be linked to the source document but at the same time this updates the chart formatting to match the destination formatting, making it exactly the same as the destination from which you copied it.
Answer:
1. #include <stdio.h>
2. int main()
3. {
4. int k;
5. int j;
6. int i;
7. int array[7];
8. array[0] = 1;
9. for (i = 1; i < 9; ++i)
10. {
11. array[i] = array[i-1]*2;
12. for (j=0; j < i; ++j)
13. {
14. printf("%d ",array[j]);
15. }
16. for (k=i-2; k > -1; --k)
17. {
18. printf("%d ", array[k]);
19. }
20. printf("\n");
21. }
22. return 0;
23. }
Explanation:
- From line 1 to 3 we start the main function
- From line 4 to 7 we declare the variables that we are going to be using throughout the program including an array of 7 positions
- On line 8 we initialize the array with one to match the sequence
- From line 9 to 10 we create a for loop to create the 9 sequences of numbers
- On line 11 we assign values to the array by taking the previous value and multiplying it by 2, this way we can create the sequence 1,2,4,8,32...
- From line 12 to 15 we print the ordered array
- From line 16 to 19 we print the inverse array minus one
- On line 20 we print an enter