"John is very interested in history and all the generations of his family. He does a lot of research and realizes that he is descended from the great Mayan dynasty. After a lot of searching through ancient records and the latest records of the society, he is able to find out all the parent-child relationships in his family all the way from the great emperor Ming of the dynasty to himself

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

"John is very interested in history and all the generations of his family. He does a lot of research and realizes that he is descended from the great Mayan dynasty. After a lot of searching through ancient records and the latest records of the society, he is able to find out all the parent-child relationships in his family all the way from the great emperor Ming of the dynasty to himself

 

These relationships are given in the form of a linear array where the emperor is at the first position and his children are at pos (2i + 1) and (2i + 2)

 

Subject: Java Programming

This is the pattern followed throughout.

 

Henry wants to figure out all the siblings of the person X from the data.

 

Return the sorted list of all of john's siblings.

 

If no sibling return {-1}

 

input 1: N, the length of the array
input2: An array representing the ancestral tree
input 3: X, the person whose siblings are sought.

 

output - return the array of all siblings in increasingly sorted order.

 

Examples :

 

input 1 : 5
input 2 : {1,2,3,4,5}
input 3 : 1

 

out put : {-1}

 

Explanation: x is the root of the tree and has no siblings

 

 

input 1 : 6
input 2 : {1,2,3,4,5,6}
input 3 : 5

 

output : {4,6}

 

Explanation : {2,3 } are the children of {1}.
{4,5,6 } are the children of {2,3}, thus the siblings of x= 5 are {4,6}

 

Can't seem to solve it by using Java. Please help. It started out with this

public int[] findSiblings(int input1, int[] input2, int input3)

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY