Modify this pop() function, so that it uses recursion.

Assignment Help C/C++ Programming
Reference no: EM13937016

1. Modify this pop() function, so that it uses recursion.

int Stack::pop()
{
if (isEmpty())
{
cerr << "Attempting to Pop from an Empty stack!!" << endl;
return -1;
}
else
{
int temp = nodes[curTop];
curTop--;
return temp;
}

}

2. Rewrite the following power() function so that it uses recursion. Provide a function main to test the implementation.

power.cpp

#include <iostream>

using namespace std;

int power(int number, int exponent)
{
int retval = 1;
for (int i=0; i < exponent; i++)
{
retval = retval * number;
}
return retval;
}

int main(int argc, char **argv)
{
cout << power(2, 3) << endl;
cout << power(3, 6) << endl;
cout << power(4, 9) << endl;

return 0;
}

Reference no: EM13937016

Questions Cloud

Most effective websites that reflect : Write extended paragraphs to answer each question below. Answer ALL PARTS of the question. Your answers may consist of 3 or 4 paragraphs for each question.
Conduct a marketing audit for an organisation : Conduct a marketing audit for an organisation of your choice and propose EITHER a new product/service (or new variant) for inclusion in the organisation's portfolio OR a new communication plan for an existing product/service
What viruses were very deadly and were eliminated : The rapid rate of reproduction combined with the many different mutations has had a limiting effect on the effectiveness of HIV therapy using antibiotics. Without the mutations the virus would fall victim to antibiotics.Are there other viruses whi..
What is the importance of chain of custody : Explain and describe the best practices for collection, preservation, transportation, and storage of electronic evidence. What is the importance of chain of custody as it relates to computer crime
Modify this pop() function, so that it uses recursion. : Rewrite the following power() function so that it uses recursion. Provide a function main to test the implementation.
Integrated marketing communications plan report : Development of a comprehensive, detailed Integrated Marketing Communications plan report and presentation - 1400 - 1500 words.
Network according to a business specification : Networks are fundamental to every aspect of our society. Designing a network that is both adequate to current and future needs is important. In this assignment, you are asked to design a network according to a business specification. Business Str..
Is evolution a proven fact or a theory : Is "evolution" a proven fact or a theory? What other ideas compete with evolution to explain changes in populations? What are the differences between these competing ideas?
What type of nic is installed in your comptuter : What type of NIC is installed in your comptuter - an expansion card, a wireless card or an embedded NIC?  Use the status of your Local Area Connection object to determine the speed of your network adapter

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd