Starting Out With C++, Early Objects (Looseleaf)
Starting Out With C++, Early Objects (Looseleaf)
8th Edition
ISBN: 9780133427622
Author: GADDIS
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 14, Problem 11PC
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.

Blurred answer
Students have asked these similar questions
C programming I need help writing a code that uses a struct pointer into a binary tree and using the same pointer into an array
i) Create a Node class that will hold three fields i.e an integer element and a reference to the next Node along with a reference to the previous Node. ii) Create a Dummy Headed Doubly Circular Linked list Abstract Data Type (ADT)named DoublyList.The elements in the list are Nodes consisting of an integer type key (all keys are unique) and a reference to the next node and a reference to the previous Node. Use Python. Do not use Numpy
C++ Coding Assignment: Redo the 8 queens 1-dimensional array program with backtracking by REMOVING ALL GOTO's, but implementing the same algorithm. GIVEN C++ CODE - WITH GOTO's: #include <iostream>using namespace std; int main() {   int q[8], c=0;  q[0] = 0; // place a queen in row 0 of column 0  int counter = 0; // to count solutions                              // c: column as q[c]: row in column c   next_col:  ++c; // or c++;           // next column  if(c==8) goto print;  q[c]=-1; // 0   next_row:  ++q[c]; // or q[c]++;                // next row  if(q[c]==8) goto backtrack;  for(int i=0; i<c; ++i)    if(q[i]==q[c] || (c-i)== abs(q[c]-q[i])) // || = row test OR diagonal tests      goto next_row;    goto next_col;   backtrack:    --c; // or c--    if(c==-1) // once we backtrack to column -1, we have all the solutions.      return 0; // ends the program    goto next_row;   print:    counter++; // new solutions    cout << counter << ":" << endl;    for(int…
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