For my assignment, I'm not sure how to start making a stack implemented via linked list of arrays. I'm stuck on how to approach the very first steps (Stack class members and constructor.) I'm familiar with allocating memory, arrays, and linked lists, but putting them together has me lost. How should I create a Stack with a dynamic linked list of arrays?
Stack name (number of elements); Creates a stack of strings with name “name.” Internally, each unit of memory allocation is “number of elements” elements. Users should be smart enough to choose a number of elements that matches their expected usage patterns.
void push(string) Adds an element containing string to the top of the stack.
bool top(string &) Retrieves the string in the top element. If the stack it empty, returns false.
bool pop(string &) Retrieves and removes the top element. If the stack is empty, returns false.
destroy() Releases any memory used by the stack.
Implementation details:
Stack class members :
- int array size (specified by user when instantiating)
-linked list definition // ex.( list < string* > something; )
- int topElement (element number of the current top element of the stack)
The element number is logically a “pointer” to the top element. It always points to the place in the current array where the next element would go. Again, assume that the array size is 10. If the element number is 5, then a new element goes into array [5]. When the list is empty, the element number is zero. When the element number is 10, the array is full.
constructor:
allocate an array of the specified size
create a linked list entry containing a pointer to the array
set topElement to 0, indicating that the top of the stack is element 0 of the current array
push:
if the current array is full (topElement = array size)
{
create a new array
add a pointer node for this array to the linked list
move the data to element 0 of the new array
set topElement to 1
}
else
{
add data to the array at position {topElement]
topElement ++
}
pop:
if the current array is empty (topElement = 0)
{
if there is only one array allocated
{
return false
}
else
{
delete current array
remove linked list entry for array
set topElement = array size - 1
retrieve data from current array [topElement]
return true
}
}
else
{
topElement - -
retrieve data from current array [topElement]
return true
}
destroy:
delete array
remove linked list node for array
set topElement = array size
Use a header file for your Stack class, a .cpp for its member functions, and a second .cpp for the main routine.
The main is included and KEEP MAIN AS IS
int main() {
Stack s(5);
string st;
bool b;
s.push("aaaaa");
s.push("bbbbb");
s.push("ccccc");
s.push("ddddd");
s.push("eeeee");
cout << "main: start of part 1" <<
endl;
b = s.top(st);
cout << "main: top of stack " << st
<< endl;
b = s.pop(st);
cout << "main: just popped this ->" <<
st << endl;
b = s.top(st);
cout << "main: new top of stack after pop "
<< st << endl;
b = s.pop(st);
cout << "main: just popped this ->" <<
st << endl;
b = s.pop(st);
cout << "main: just popped this ->" <<
st << endl;
b = s.pop(st);
cout << "main: just popped this ->" <<
st << endl;
b = s.pop(st);
cout << "main: just popped this ->" <<
st << " stack should now be empty" << endl;
b = s.top(st);
if (b)
{
cout << "main: stack
non-empty when it should be empty" << endl;
return 4;
}
else
{
cout << "main: stack empty
when it's empty" << endl;
}
cout << endl << "main: start of part 2"
<< endl;
s.push("aaaaa"); // 1st element 1st
array
s.push("bbbbb");
s.push("ccccc");
s.push("ddddd");
s.push("eeeee");
s.push("fffff"); // 1st element 2nd
array
s.push("ggggg");
s.push("hhhhh");
s.push("iiiii");
s.push("jjjjj");
s.push("kkkkk"); // 1st element 3rd
array
b = s.top(st);
cout << "main: top of stack " << st
<< endl;
cout << "main: before while loop " << st
<< endl;
b = s.pop(st);
while (b)
{
cout << "main: element of
stack " << st << endl;
b=s.pop(st);
}
cout <<"main: before destroy"<<
endl;
s.destroy();
cout <<"main: after destroy"<< endl;
s.push("zzzzz");
b=s.top(st);
cout << "main: new top of stack " << st
<< endl;
s.destroy();
return 0;
}
In: Computer Science
The biggest challenges I saw for this position were the same ones NAO was facing: reducing vehicle development time and structural costs, increasing market share, achieving world class levels of customer enthusiasm, and integrating the various functional departments of NAO. We expected to know we had been successful when 99% of the projects were delivered on time, on budget, and with expected benefits, and when the people in NAO took great pride in this organization. Of course, we are all also working to increase profitability and market share. That was to be done by working with the process information officers, the sector information officers, and with the regional information officers. Our virtual teams had to be flexible to really understand the needs of our internal customers and to help them figure out ways to meet those needs.
One of the Business Unit Information Officers was Maryann Goebel, CIO of the Truck Group. She had over 24 years of experience in information systems, gained from working in 10 different large companies first as a programmer/analyst, and later as an IT executive or in a functional area as an IT specialist. She came to GM in April, 1997 from Bell Atlantic/NYNEX Mobile, where she helped a relationship with an outsourcer turn around. She described her GM job.
The challenge was to make GM number one again. Management believed in the right value set, and consistently delivered the right message. Ralph was the perfect leader for the challenge because there was a lot of history between EDS and GM. In the Truck Group, I found a team who had embraced the GM 5 core values that worked for me: continuous improvement, customer enthusiasm, teamwork, integrity, and innovation. As the CIO of the Truck Group, I reported to two people, Dan McNicholl, the CIO of NAO and Tom Davis, the head of the Truck Group. This business had 45,000 people on the payroll, and I had about 16 employees and 17 contractors reporting to me. There were some other people in the sector that look like IT people, and we often worked with them. We bought services from EDS, and they supplied whatever individuals were needed to meet the service levels we agreed to.
The job of CIO of this sector was a new position. No one focused on this job before me. The reception was very positive, in fact some managers welcomed me with open arms. Most of the managers were interested in my views as an outsider and helped me get to know their organization. I knew I was getting the right message across when several individuals who were initially afraid, I was there to "steal their resources" called me up to ask for my involvement in their IT projects. They finally trusted me.
Some of the tasks I was initially asked to do were to evaluate a proposal for services from EDS where the Truck Group manager wanted to know if this was a realistic reasonable cost for the services offered. I had to really evaluate what was in the numbers in the proposal. Another service I offered was to bring an outside perspective to the Truck Group. I was not afraid to ask a lot of questions, and since I was new to GM, I didn't take for granted many of the things more experienced managers do. I was also a participant in decisions on how the business should be run. I believed that unless you were participating, you were only an order taker. But there is much to do to be a participant. I read briefings, networked with knowledgeable individuals and asked lots of questions to get up to speed.
The biggest challenge I saw in August 1997 was achieving globalization of the IT functions that supported the Truck Group. The structure had the US and Canadian organizations reporting up through the truck team. But other international operations didn't report in the same way. The challenge was to help management of this group understand the global picture, which meant figuring out how to collect, process, and disseminate the management information. I'll know I will have been successful through metrics on customer satisfaction, not on internal efficiency. Establishing the metrics was another challenge.
Cherri Musser joined IS&S as the IO of Business Services which included human resources, finance, legal and purchasing. Musser spent 23 years working in information systems at Texas Instruments, then came to GM in November 1996. When she left TI, she was the VP for research and development for the Texas Instruments Software Business. She joined the new GM IS&S team because,
Ralph wanted to keep information systems efforts focused on the customer and business value. The opportunity to address the IT needs of a company the size of GM—and to build a new IT team to do it— was too good to pass up.
I saw my job as working with the functional areas such as human resources, finance, purchasing, legal, facilities management, etc. to look for synergies across the company. I was looking for ways to drive common systems. We already had a purchasing systems project underway. We were thinking about how to transition to supply chain. For every plant that GM brought up, the plant manager had selected his or her own administrative system.
We worked on convergence. This was done by convening a strategy board for each functional area. For example, the strategy board for finance consisted of the corporate CFO, the CFOs for NAO, GMAC and Delphi, and the corporate comptroller. We met once per month to discuss the process we were using to reach common systems. A similar board was set up in human resources, and that one included the president of GM University and the top human resources individuals in each business unit. Another board was set up for procurement and materials management.
Describe in detail how General Motors leveraged IS to enable global collaboration. What were the challenges encountered at General Motors by enabling global collaboration, and how would you suggest to resolves these challenges?
In: Computer Science
An Antique dealer needs to store records of the items in the inventory into a stack (the dealer believes that keeping items longer will be beneficial; nonetheless, the business logic here is not important!). Besides the usual push() and pop(); the dealer needs to always know what is the most expensive item in the inventory/stack. You are hired to implement a new method, called max(), which returns the current maximum value for any item in the stack. Notice that the stack grows and shrinks dynamically as elements are added or removed from the stack (i.e. the contents of the stack are not fixed).
a. Write the pseudocode of the max() method.
b. What is the Big-O complexity of your solution? Explain clearly how you obtained such complexity.
c. Is it possible to have all three methods (push(), pop() and max()) be designed to have a complexity of O(1)? If no; explain why this is impossible. If yes; provide the pseudocode of the algorithm that would allow O(1) for all three methods
In: Computer Science
Securing Information Systems
Chapter eight in the Laudon text is filled with many examples of how computer systems are vulnerable due to failure, destruction, errors, and abuse. And the never ending onslaught of security breaches continues to escalate despite the lessons learned. It is evident that maintaining good information systems security is a full time endeavor.
By doing a search of the Internet or by other research methods,
find an example of an organization that faced an information
systems security issue or crisis.
Ponder these questions:
1) How did the organization identify that there was a security problem?
2) What, if any, security infrastructure and policies were in place when the problem occurred?
3) What initial actions were taken to deal with the situation?
4) From a management perspective, what, if any, new organizational policies and procedures did they institute?
5) Were any new security tools and technologies eventually implemented to further safeguard their systems?
6) What was the business impact? How did they recover? Were there any legal ramifications, loss of customers, or damage of reputation?
7) Generally speaking, how can a business determine the value of investing in security and control?
In: Computer Science
It is required that this program be written in ARM Assembly using raspberry pi. Submit an ARM assembly program that does the following:
1. Prompt for the user to enter a number (integer).
2. If the entered number is <100 print: "The input number is less than 100."
3. If the entered number is >=100 print: "The input number is greater than or equal to 100."
4. Prompt for the user to enter a single character.
5. If the entered character is lower case (a..z) print: "Lower case letter entered."
6. If the entered character is upper case (A..Z) print: "Upper case letter entered."
7. Otherwise print: "Special character entered." 8. Return control to the operating system.
I SEE THIS QUESTION HAS BEEN POSTED IN THE PAST AND NEVER RECEIVED A CORRECT ANSWER. THIS PROGRAM MUST BE WRITTEN IN ARM ASSEMBLY USING THE ARM PROCESSOR FOUND ON A RASPBERRY PI. IT CAN ALSO BE WRITTEN USING THE RASPBERRY PI EMULATOR THAT CAN BE FOUND ONLINE FOR FREE. PLEASE DO NOT POST THE ANSWER IN A DIFFERENT PROGRAMMING LANGUAGE. THANK YOU!
In: Computer Science
Suggest ideas for an interface, which uses the properties of sound effectively.
In: Computer Science
"This C Programming "
Write a program that accepts four (4) lines of input:
• The first line contains a float value in 4.2f format
• The second line contains a char value
• The third line contains a 4-digit int value
• The fourth line contains a char value
and then displays all of the input on a single line
Write a program that accepts a phone number of the form +1(xxx)-xxx-xxxx
where x is a digit, and displays the sum of all digits in the phone number.
In: Computer Science
n this exercise, you create a program for the sales manager at Computer Haven, a small business that offers motivational seminars to local companies. Figure 7-53 shows the charge for attending a seminar. Notice that the charge per person depends on the number of people the company registers. For example, the cost for four registrants is $400; the cost for two registrants is $300. The program should allow the sales manager to enter the number of registrants for as many companies as needed. When the sales manager has finished entering the data, the program should calculate and display the total number of people registered, the total charge for those registrants, and the average charge per registrant. For example, if one company registers four people and another company registers two people, the total number of people registered is six, the total charge is $700, and the average charge per registrant is $116.67. Number of people a company registers . Charge per person ($)
1 – 3 150
4 – 9 100
10 or more 90
fig 7-53
a.Create an IPO chart for the problem, and then desk-check the algorithm appropriately.b.List the input, processing, and output items, as well as the algorithm, in a chart similar to the one shown earlier in Figure 7-42. Then code the algorithm into a program.c.Desk-check the program using the same data used to desk-check the algorithm.d.If necessary, create a new project named Advanced25 Project, and save it in the Cpp8\Chap07 folder. Enter your C++ instructions into a source file named Advanced25.cpp. Also enter appropriate comments and any additional instructions required by the compiler. Display the average charge with two decimal places
In: Computer Science
Assume that the monthly profits of a company are given in an
array, each entry representing
the profits for the corresponding month. Propose an algorithm to
find a group of consecutive
months where the profit was the highest.
For example, the profits, in millions, for a year Jan-Dec is given
by
A=[2 -5 3 4 0 -1 5 8 -9 1 -2 0];
The highest profit was from the period March-August and the value
is 19 million. Assume
that the array can be very large{not just 12 months. Submit a well
comment c++ pseudocode
along
with an example of the algorithm
Solve for algorithms with complexity O(n)
In: Computer Science
I don't know which one is wrong. Can you please check.
Thank you
QUESTION 1
In the following code, how many and which functions have been defined/declared?
def powerNum(power):
pNum = n ** power
return pNum
n = int(input("Enter a number whose power you want to calculate: "))
def main():
p = int(input("Enter the power number: "))
print ("Power of the number you entered is", powerNum (p))
main()
|
1 function: powerNum |
||
|
1 function: powerNum |
||
|
3 functions: powerNum, and main is defined/declared twice. |
||
|
2 functions: powerNum and main |
QUESTION 2
In the following code, which of the variable(s) is (are) considered as global variable(s):
def powerNum(power):
pNum = n ** power
return pNum
n = int(input("Enter a number whose power you want to calculate: "))
def main():
p = int(input("Enter the power number: "))
print ("Power of the number you entered is", powerNum (p))
main()
|
p and power |
||
|
pNum |
||
|
p |
||
|
power |
||
|
n |
QUESTION 3
In the following code, which line of code is returning the value for function powerNum?
def powerNum(power):
pNum = n ** power
return pNum
n = int(input("Enter a number whose power you want to calculate: "))
def main():
p = int(input("Enter the power number: "))
print ("Power of the number you entered is", powerNum (p))
main()
|
def powerNum(power): |
||
|
print ("Power of the number you entered is", powerNum (p)) |
||
|
return pNum |
||
|
pNum = n ** power |
QUESTION 4
In the following code, which of the variable(s) is (are) considered as parameter variable(s):
def powerNum(power):
pNum = n ** power
return pNum
n = int(input("Enter a number whose power you want to calculate: "))
def main():
p = int(input("Enter the power number: "))
print ("Power of the number you entered is", powerNum (p))
main()
|
n |
||
|
pNum |
||
|
p and power |
||
|
p |
||
|
power |
QUESTION 5
After learning about the issues with global variables, Amita took the old code with global variables in cell A and re-wrote without global variables. Based on the partial code done in the cell below, what changes, if any, need to be made to the code in cell-B below?
| cell-A: Old code with global variables | cell-B: Partial new code without global variables |
|
def powerNum(power): pNum = n ** power return pNum n = int(input("Enter a number whose power you want to calculate: ")) def main(): p = int(input("Enter the power number: ")) print ("Power of the number you entered is", powerNum (p)) main() |
def powerNum(power): pNum = n ** power return pNum def main(): n = int(input("Enter a number whose power you want to calculate: ")) p = int(input("Enter the power number: ")) print ("Power of the number you entered is", powerNum (p)) main() |
|
We need to just change powerNum function to accept two parameters: one for power value and one for the number as below def powerNum(power, n): |
||
|
No changes need to be made to main or powerNum functions |
||
|
Yes, powerNum should now be defined with two parameters: one for power value and one for the number as below def powerNum(power, n): Also we will need to change how the function is called in main function as below: powerNum(p,n) |
||
|
We need to just pass the additional argument when the powerNum function is called in main function as below: powerNum(p,n) |
QUESTION 6
In the following code, which line of code is calling or invoking function powerNum?
def powerNum(power):
pNum = n ** power
return pNum
n = int(input("Enter a number whose power you want to calculate: "))
def main():
p = int(input("Enter the power number: "))
print ("Power of the number you entered is", powerNum (p))
main()
|
return pNum |
||
|
def powerNum(power): |
||
|
pNum = n ** power |
||
|
print ("Power of the number you entered is", powerNum (p)) |
QUESTION 7
In the following code, which line of code is defining or declaring function powerNum?
def powerNum(power):
pNum = n ** power
return pNum
n = int(input("Enter a number whose power you want to calculate: "))
def main():
p = int(input("Enter the power number: "))
print ("Power of the number you entered is", powerNum (p))
main()
|
def powerNum(power): |
||
|
return pNum |
||
|
pNum = n ** power |
||
|
print ("Power of the number you entered is", powerNum (p)) |
QUESTION 8
In the following code, which of the variable(s) is(are) considered as argument(s):
def powerNum(power):
pNum = n ** power
return pNum
n = int(input("Enter a number whose power you want to calculate: "))
def main():
p = int(input("Enter the power number: "))
print ("Power of the number you entered is", powerNum (p))
main()
|
p and power |
||
|
n |
||
|
power |
||
|
p |
||
|
pNum |
QUESTION 9
In python, how can you pass arguments to a function?
|
by keyword arguments only and can be in any order |
||
|
default is by position but you can also pass by keyword arguments as in the case below: show_interest (rate=0.01, periods=10, principal=10000.0) |
||
|
by position only and they must be passed in the same order in which they are defined in the function header |
||
|
by position only and they can be passed in any order irrespective of how are they are defined |
QUESTION 10
In the following code, in which order do the lines of code get executed?
def powerNum(power):
pNum = n ** power
return pNum
n = int(input("Enter a number whose power you want to calculate: "))
def main():
p = int(input("Enter the power number: "))
print ("Power of the number you entered is", powerNum (p))
main()
|
getting input n from the user >> calling main function >> calling powerNum function >> ending in powerNum function |
||
|
calling powerNum function >> getting input n from the user >> calling main function |
||
|
getting input n from the user >> calling main function >> calling powerNum function >> returning back to main function from powerNum function |
In: Computer Science
C Programming Please write a single function and not the whole program
Can you please provide comments and explanations for all questions. Thank you
Write a single function for the following:
void split_date(int day_of_year, int
year, int *month, int *day);
day_of_year is an integer between 1 and 366, specifying a particular day within the year
designated by the parameter year.
Month and day point to variables in which the function
will store the equivalent month (1 – 12) and day within the month
(1 – 31)
The question is trying to ask you to write a single function in C that takes a day of the year (1-366) and calculates which month and which day of the month corresponds to that day of in the month. So a day of the year of let's 15 would return 1 (for the month - January) and 15 for the day of the month. The second parameter (year) is needed because leap years have 366 days and non-leap years have 365 days.
In: Computer Science
SQL is our language for relational databases - do you think it's an adequate "language" for database creation and manipulation?
In: Computer Science
Discuss the use of artificial intelligence in automation of tasks in accounting giving 3
pertinent examples. Need to be 520 word
In: Computer Science
A sequence of integers x1,x2,...,xn is unimodal if for some 1 ≤ i ≤ n we have x1 < x2 < ... < xi and xi > xi+1 > ... > xn. Find the maximum element in a unimodal sequence of integers x1, x2, . . . , xn. The running time should be O(log n). Show that your algorithm meets the bound.
In: Computer Science
Consider the following scenario and design a C++ program using an output stream file: A person invests $1,000 on a savings account yielding 5% interest. Assuming that all the interest is left on deposit, calculate and print the amount of money in the account at the end of each year for 10 years. Use the following formula to determine the amounts: a = p (1 + r)n where p is the original amount invested (i.e., the principal) r is the annual interest rate (e.g., use 0.05 for 5%)f n is the number of years a is the amount on deposit at the end of the nth year. Your program must have an output file to display your results.
In: Computer Science