Starting Out with C++: Early Objects (9th Edition)
9th Edition
ISBN: 9780134400242
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 14, Problem 12PC
Program Plan Intro
Ancestral Trees
Program Plan:
- Include required header files.
- Declare and initialize string arrays “people []”, “mother []”, and “father []”.
- Declare and initialize positions for the integer arrays “mom []”, and “pop []”.
- Give function prototype “ancestors ()”.
- Given function definition for “ancestors ()”.
- Print the name of the person.
- Check if mom’s position is not equal to -1.
- Call the function ““ancestors ()”.
- Check if pop’s position is not equal to -1.
- Call the function ““ancestors ()”.
- Define the function “main ()”. Inside this function,
- Print the ancestors of the person containing index “0” from “people []” array by calling the function “ancestors ()” by passing “0” as the argument.
- Print the ancestors of the person containing index “6” from “people []” array by calling the function “ancestors ()” by passing “6” as the argument.
- Return the statement.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
C programming I need a code that asks the user for how many times it'll run and run that many time and ask the user for a number and it puts that number into a binary search tree and an array using diffrent functions
Course: Data Structure and Algorithims
Language: Java
Kindly make the program in 2 hours.
Task is well explained.
You have to make the proogram properly in Java:
Restriction: Prototype cannot be change you have to make program by using given prototype.
TAsk:
Create a class Node having two data members
int data;
Node next;
Write the parametrized constructor of the class Node which contain one parameter int value assign this value to data and assign next to null
Create class LinkList having one data members of type Node.
Node head
Write the following function in the LinkList class
publicvoidinsertAtLast(int data);//this function add node at the end of the list
publicvoid insertAthead(int data);//this function add node at the head of the list
publicvoid deleteNode(int key);//this function find a node containing "key" and delete it
publicvoid printLinkList();//this function print all the values in the Linklist
public LinkListmergeList(LinkList l1,LinkList l2);// this function…
C++ Binary Search Tree program
Create a class "Person" with three member variables
string first name, string last name, int age. The primary key will be the last name. User will be prompted with a menu with two options: 1, "Enter person", where they will enter the persons first name, last name and age, or 2, "View person list" where the person may view the information previously added.
Chapter 14 Solutions
Starting Out with C++: Early Objects (9th Edition)
Ch. 14.1 - What is a recursive functions base case?Ch. 14.1 - What happens if a recursive function does not...Ch. 14.1 - Prob. 14.3CPCh. 14.1 - What is the difference between direct and indirect...Ch. 14 - What type of recursive function do you think would...Ch. 14 - Which repetition approach is less efficient; a...Ch. 14 - When should you choose a recursive algorithm over...Ch. 14 - Prob. 4RQECh. 14 - Prob. 5RQECh. 14 - Prob. 6RQE
Ch. 14 - Predict the Output 7. What is the output of the...Ch. 14 - Soft Skills 8. Programming is communication; the...Ch. 14 - Prob. 1PCCh. 14 - Recursive Conversion Convert the following...Ch. 14 - Prob. 3PCCh. 14 - Recursive Array Sum Write a function that accepts...Ch. 14 - Prob. 5PCCh. 14 - Recursive Member Test Write a recursive Boolean...Ch. 14 - Prob. 7PCCh. 14 - Prob. 8PCCh. 14 - Ackermanns Function Ackermanns function is a...Ch. 14 - Prefix to Postfix Write a program that reads...Ch. 14 - Prob. 11PCCh. 14 - Prob. 12PC
Knowledge Booster
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
- Subject-Object oriented programing Write a program which:• creates a new Array List• adds 5 decimal numbers to it• prints the list to the screen In the same program, remove the element at the last index of the Array List. Print the resulting list tothe screen.arrow_forwardint main() //default function for call { int a[100],n,i,j; for (int i = 0; i < n; i++) //Loop for ascending ordering { for (int j = 0; j < n; j++) //Loop for comparing other values { if (a[j] > a[i]) //Comparing other array elements { int tmp = a[i]; //Using temporary variable for storing last value a[i] = a[j]; //replacing value a[j] = tmp; //storing last value } } } printf("\n\nAscending : "); //Printing message for (int i = 0; i < n; i++) //Loop for printing array data after sorting { printf(" %d ", a[i]); } } Need to transform this C code to MIPS Assembly Language Code simple stepsarrow_forwardQ: Convert this to sorted array #include<iostream> #include"Student.cpp" class StudentList { private: struct ListNode { Student astudent; ListNode *next; }; ListNode *head; public: StudentList(); ~StudentList(); int IsEmpty(); void Add(Student newstudent); void Remove(); void DisplayList(); }; StudentList::StudentList() { head=NULL; }; StudentList::~StudentList() { cout <<"\nDestructing the objects..\n"; while(IsEmpty()!=0) Remove(); if(IsEmpty()==0) cout <<"All students have been deleted from a list\n"; }; int StudentList::IsEmpty() { if(head==NULL) return 0; else return 1; }; void StudentList::Add(Student newstudent) { ListNode *newPtr=new ListNode; if(newPtr==NULL) cout <<"Cannot allocate memory"; else { newPtr->astudent=newstudent; newPtr->next=head; head=newPtr; } }; void StudentList::Remove() { if(IsEmpty()==0) cout <<"List empty on remove"; else { ListNode *temp=head;…arrow_forward
- Your colleague wrote some code that works on their local environment Debug.cpp ) but is now trying to integrate it into the main source code DataLogger.cpp ). They are getting an error and have asked you to help them fix it. COMPILE AND RUN Submit your code by pressing the button below. Write a note to your colleague about why their code does not work. Include at least two ways fix bug. Which way would/did you fix the bug? Why?arrow_forward1. Stack Implementation Write a method called insert for the class Stack. The method shall be implemented using an array-based structure. You can assume that String[] stack is defined in the class, which is responsible to store the elements and responsible to enforce the order of first-in last-out, a.k.a., FIFO. Additionally, you can assume there is a pointer called top, that indicates the position of the top of the stack, pointing to the next available position to insert. The method shall: • take a String s as a parameter, and shall add it at the top of the stack. shall return true if the element s was added successfully at the top of the stack, false otherwise. . . The method must check boundaries of capacity and limitation of the Stack. In case the method is invoked to insert an element of the top of the stack that exceeds its current capacity, the method shall handle the situation properly. Do not provide the entire Stack implementation, only the code solution of the method.arrow_forwardC Program / C Language Make a C program for the rank order from highest to lowest of the array.arrow_forward
- Write a recursive function that returns True if the numerical array passed as input is palindrome, and False otherwise. An array is palidrome if its elements, when flipped, produce an array that is identical to the original one. For example: [1,2,3,2,1] is palindrome [1,2,3,4,3] is not palindrome Fill in the following code skeleton. It is composed of four parts: three base cases and the recursive call. Write code for all the parts. Assume that the input arrays can have any size, and that the elements are always positive integers.arrow_forwardRooks on a rampage def safe_squares_rooks(n, rooks): A generalized n-by-n chessboard has been invaded by a parliament of rooks, each rook represented as a two-tuple (row, column) of the row and the column of the square that the rook is in. Since we are again computer programmers instead of chess players and other normal folks, our rows and columns are numbered from 0 to n - 1. A chess rook covers all squares that are in the same row or in the same column. Given the board size n and the list of rooks on that board, count the number of empty squares that are safe, that is, are not covered by any rook. To achieve this in reasonable time and memory, you should count separately how many rows and columns on the board are safe from any rook. Because permuting the rows and columns does not change the answer to this question, you can imagine all these safe rows and columns to have been permuted to form an empty rectangle at the top left corner of the board. The area of that safe rectangle is…arrow_forwardC languagearrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage