problem statement, tree is an undirected associated diagram where there are no cycles. This issue is about non-established trees. A leaf of a tree is a vertex that is associated with all things considered one vertex. The landscaper Vitaly grew a tree from n vertices. He chose to manage the tree. To do this, he plays out a number of tasks. In

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

Please c++ only. Correct answer will upvoted else downvoted.

 

In this problem statement, tree is an undirected associated diagram where there are no cycles. This issue is about non-established trees. A leaf of a tree is a vertex that is associated with all things considered one vertex. The landscaper Vitaly grew a tree from n vertices. He chose to manage the tree. To do this, he plays out a number of tasks. In one activity, he eliminates all leaves of the tree. Note the uncommon instances of the activity: applying an activity to an unfilled tree (of 0 vertices) doesn't transform it.

applying an activity to a tree of one vertex eliminates this vertex this vertex is treated as a leaf. applying an activity to a tree of two vertices eliminates both vertices (both vertices are treated as leaves). Vitaly applied k tasks successively to the tree. What number of vertices remain? 

Input :The main line contains one integer t (1≤t≤104) — the number of experiments. Then, at that point, t experiments follow. Each experiment is gone before by an unfilled line. 

Each experiment comprises of a few lines. The main line of the experiment contains two integers n and k (1≤n≤4⋅105, 1≤k≤2⋅105) — the number of vertices in the tree and the number of activities, separately. Then, at that point, n−1 lines follow, every one of them contains two integers u and v (1≤u,v≤n, u≠v) which depict a couple of vertices associated by an edge. It is ensured that the given chart is a tree and has no circles or numerous edges. It is ensured that the amount of n from all experiments doesn't surpass 4⋅105. 

Output :For each experiment output on a different line a solitary integer — the number of vertices that stay in the tree subsequent to applying k activities.

Expert Solution
steps

Step by step

Solved in 4 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