EBK DATA STRUCTURES AND ALGORITHMS IN C
EBK DATA STRUCTURES AND ALGORITHMS IN C
4th Edition
ISBN: 9781285415017
Author: DROZDEK
Publisher: YUZU
bartleby

Concept explainers

Question
Book Icon
Chapter 4, Problem 4PA
Program Plan Intro

Implementation of the addingLargeNumbers() algorithm

Program Plan:

  • In “addingLargeNumbers()” function
    • It reads digits of first number from user one by one and pushes it into stack “Numm1_stack”.
    • It reads digits of second number from user one by one and pushes it into stack “Numm2_stack”.
    • Initialize “carryy” as “0”.
    • Till “Numm1_stack” or “Numm2_stack” becomes empty,
      • Add stack tops of both stacks with “carryy” and pop it from stacks.
      • Push last digit of result into stack “Resultt_stack” and store carry in “carryy”.
    • If “Numm1_stack” is not empty, till it becomes empty,
      • Add stack top of stack “Numm1_stack” with “carryy” and pop it from stack.
      • Push last digit of result into stack “Resultt_stack” ans store carry in “carryy”.
    • If “Numm2_stack” is not empty, till it becomes empty,
      • Add stack top of stack “Numm2_stack” with “carryy” and pop it from stack.
      • Push last digit of result into stack “Resultt_stack” ans store carry in “carryy”.
    • If “carryy” is not “0” push it into “Resultt_stack”.
    • Till “Resultt_stack” becomes empty,
      • Print stack top and pop it from stack.
  • In “main()” function
    • Call function “addingLargeNumbers()”.

Blurred answer
Students have asked these similar questions
Implement this algorithm: Implement a function cross_out_multiples that takes as arguments a list of boolean values (true/false) called is_prime and a number n. The function sets the boolean values at all multiples of n (2*n, 3*n, 4*n ...) that are in the list to false. Implement a function sieve(n) which gives back a list of all primes below n.
Write a Java program that uses ArrayList and Iterator. It should input from user the names and ages of your few friends in a loop and add into ArrayList. Finally, it should use an Iterator to display the data in a proper format.     ( Sample run of the program:-) List of my Friends   Enter name and age [friend# 0] Khalid Al-shamri 22.5   Do you want to add another friend (y/n)? y   Enter name and age [friend# 1] Rahsed Al-anazi 21.1   Do you want to add another friend (y/n)? y   Enter name and age [friend# 2] Salem Al-mutairi 23.7     Do you want to add another friend (y/n)? n   Here is the data you entered:   0.  Khalid Al-shamri,      22.5 1.  Rahsed Al-anazi,         21.1 2.  Salem Al-mutairi,       23.7
Implement a recursive function void deleteMax() on the IntList class (provided). The function will delete from the IntList the IntNode containing the largest value. If there are multiple nodes containing this largest value, only delete the 1st one. Be careful not to cause any memory leaks or dangling pointers. You may NOT use any kind of loop (must use recursion). You may NOT use global or static variables. You may NOT use any standard library functions.   Ex: list: 5->7->1->16->4->16->3 list.deleteMax(); list: 5->7->1->4->16->3   IntList.h #ifndef __INTLIST_H__#define __INTLIST_H__ #include <ostream> using namespace std; struct IntNode {int value;IntNode *next;IntNode(int value) : value(value), next(nullptr) {}}; class IntList { private:IntNode *head; public: /* Initializes an empty list.*/IntList() : head(nullptr) {} /* Inserts a data value to the front of the list.*/void push_front(int val) {if (!head) {head = new IntNode(val);} else {IntNode…
Knowledge Booster
Background pattern image
Computer Science
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
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education