Section A Question 1 Stacks are a particular way of storing and editing data in memory, explain the rationale behind the use of stack pointers. Draw a flow chat to demonstrate how data would be pushed onto stack Write a pseudo code to push data into a stack Using your code in “c” write a program using c++ programming language to data into the stack   Question 2 Assuming you are to add three numbers. Write an algorithm to perform additions   Such a specification creates difficulty, while actually implementing it (difficulty in converting into source code). Hence many programmers prefer to have specification of algorithm by means of pseudo-code. Another way of representing the algorithm is by flow chart. Flow chart is a graphical   Convert your algorithm in “a” above into a c++ program   Critically explain how your algorithm in “a” would be modified to sum n numbers Determine the space complexity of your algorithm in “b” above   Question 3 Arrays and linked list are a way of storing data in computers. Critically explain why you will choose one over the other if you are to insert and delete data. If int [7] is used to store data in a standard computer, determine the size of memory that will be needed to store the data and explain how you got that answer Assuming 4 of the memory reserved in the declaration in “b” above was used, determine in bytes, the memory used and explain why A bi-dimensional array float call[3][2]={4,1,0,3} is used to store information arriving at a call center. If call[2][1] is to be analyzed, determine the information stored there and explain how you got your answer..     Section B Question 1 The electoral petition of 2021 was aimed at determining the winner of the 2020 election. The rule is that the winner of an election in Ghana must obtain at least 50% + 1 of the valid votes cast. Draw a flow chat for the scenario described above Using your flow chat in “a” above, write an algorithm that could be implemented using any programming language. Your algorithm should be able to declare a winner if he/she meets the condition of 50% + 1. Critically explain how you will store data for the presidential candidates and the valid votes cast for them. If two variables are stored as integers and manipulated such that one divides the other and the results stored. Explain how you would prevent the loss of fractional parts after the division     Question 2 If data in a warehouse are stored in a stack architecture and it has been agreed by management that data has to be removed from the stack, discuss giving reasons the first action you will take in removing the data Draw a flow chat to demonstrate how data will be removed from stack. Write a pseudo code for the process in “b” above. Using your code in “c” above, write a program using either C or C++ programming language to remove data from the stack.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 3PE
icon
Related questions
Question

Section A

Question 1

  1. Stacks are a particular way of storing and editing data in memory, explain the rationale behind the use of stack pointers.
  2. Draw a flow chat to demonstrate how data would be pushed onto stack
  3. Write a pseudo code to push data into a stack
  4. Using your code in “c” write a program using c++ programming language to data into the stack

 

Question 2

Assuming you are to add three numbers.

  1. Write an algorithm to perform additions

 

Such a specification creates difficulty, while actually implementing it (difficulty in converting into source code). Hence many programmers prefer to have specification of algorithm by means of pseudo-code. Another way of representing the algorithm is by flow chart. Flow chart is a graphical

 

  1. Convert your algorithm in “a” above into a c++ program

 

  1. Critically explain how your algorithm in “a” would be modified to sum n numbers
  2. Determine the space complexity of your algorithm in “b” above

 

Question 3

  1. Arrays and linked list are a way of storing data in computers. Critically explain why you will choose one over the other if you are to insert and delete data.
  2. If int [7] is used to store data in a standard computer, determine the size of memory that will be needed to store the data and explain how you got that answer
  3. Assuming 4 of the memory reserved in the declaration in “b” above was used, determine in bytes, the memory used and explain why
  4. A bi-dimensional array float call[3][2]={4,1,0,3} is used to store information arriving at a call center. If call[2][1] is to be analyzed, determine the information stored there and explain how you got your answer..

 

 

Section B

Question 1

The electoral petition of 2021 was aimed at determining the winner of the 2020 election. The rule is that the winner of an election in Ghana must obtain at least 50% + 1 of the valid votes cast.

  1. Draw a flow chat for the scenario described above
  2. Using your flow chat in “a” above, write an algorithm that could be implemented using any programming language. Your algorithm should be able to declare a winner if he/she meets the condition of 50% + 1.
  3. Critically explain how you will store data for the presidential candidates and the valid votes cast for them.
  4. If two variables are stored as integers and manipulated such that one divides the other and the results stored. Explain how you would prevent the loss of fractional parts after the division

 

 

Question 2

  1. If data in a warehouse are stored in a stack architecture and it has been agreed by management that data has to be removed from the stack, discuss giving reasons the first action you will take in removing the data
  2. Draw a flow chat to demonstrate how data will be removed from stack.
  3. Write a pseudo code for the process in “b” above.
  4. Using your code in “c” above, write a program using either C or C++ programming language to remove data from the stack.

 

 

 

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Stack
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning