Algorithms & Data Structures

Given a undirected tree with N nodes and N – 1 edges rooted at node 1.We are given Q queries of type :uv, where we need to find the maximum node value among nodes present in the simple path between node u and v.ExampleIf N = 5, edge = {(1,2),(1,5),(1,4),(3,5)], Q = 2.• If query 1 is 13. Then simple path between node 1 and 3 is 1-5 -3. Maximum value node on simple path is 5.• If query 2 is 12. Then simple path between node 1 and 2 is 1-2. Maximum value node on simple path is 2.Function DescriptionComplete the maxNode function provided in the editor. This function takes the following 4 parameters and returns an array denoting answer forqueriesN: Represents the number of nodes in tree.• edge : Represents the edges present in tree.• Q: Represents the number of queries in tree.query : Represents the queries in form of 2 space separated integers.Input :1. First line contain integer N, denoting number of nodes in tree.2. Next N – 1 lines contain two space separated integers u v, denoting an edge between node u and v.3. Next line contain integer Q, denoting number of queries.4. Next Q lines contain two space separated integers u,v denoting queryConstraints : 2 <= N <= 10000 1 <= Q <= 100000Output : For each query, print the maximum value node on a simple path between two nodes.

Don't use plagiarized sources. Get Your Custom Essay on
Algorithms & Data Structures
Just from $13/Page
Order Essay
Academic Heros
Calculate your paper price
Pages (550 words)
Approximate price: -

Why Work with Us

Top Quality and Well-Researched Papers

Our writers are encouraged to read and research widely to have rich information before writing clients’ papers. Therefore, be it high school or PhD level paper, it will always be a well-researched work handled by experts.

Professional and Experienced Academic Writers

For one to become part of our team, thorough interview and vetting is undertaken to make sure their academic level and experience are beyond reproach, hence enabling us give our clients top quality work.

Free Unlimited Revisions

Once you have received your paper and feel that some issues have been missed, just request for revision and it will be done. In addition, you can present your work to the tutor and he/she asks for improvement/changes, we are always ready to assist.

Prompt Delivery and 100% Money-Back-Guarantee

All our papers are sent to the clients before the deadline to allow them time to review the work before presenting to the tutor. If for some reason we feel our writers cannot meet the deadline, we will contact you to ask for more time. If this is not possible, then the paid amount will be refunded.

Original & Confidential

Our writers have been trained to ensure work produced is free of plagiarism. Software to check originality are also applied. Our clients’ information is highly guarded from third parties to ensure confidentiality is maintained.

24/7 Customer Support

Our support team is available 24 hours, 7 days a week. You can reach the team via live chat, email or phone call. You can always get in touch whenever you need any assistance.

Try it now!

Calculate the price of your order

Total price:

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

You have had a hectic day, and still need to complete your assignment, yet it is late at night. No need to panic. Place your order with us, retire to bed, and once you wake up, the paper will be ready.


Essay Writing Service

It does not matter the urgency of your paper, or the academic level, our team is ready to help you 24/7. Just contact us and all your academic needs will be sorted.


Admission Essays & Business Writing Help

A student is often required to write an admission letter requesting to be admitted in a certain institution. For you to be gain that admission in your dream institution, you must write a convincing letter. You can depend on our team for the best admission letters.


Editing Support

Academic writing is not just about getting information and throwing it all over. Our team will ensure you have a polished paper that is coherent and has a good flow of information. We also ensure the paper follows the correct formatting styles like APA, Harvard, MLA, Chicago/Turabian.


Revision Support

If our writers write a paper but you are not satisfied in one way or another, you can always ask for revision. This is totally free. Our writers and editors will revise your paper untill you are be totally satisfied. We as well offer revision for papers not done by our writers at a small fee.