Tree Depth-Theory of Complexity and Algorithms-Assignment, Exercises of Advanced Algorithms

This assignment was given by Manju Nripendra at West Bengal State University for Theory of Complexity and Algorithms course. It includes: Depth, Big, Swap, Maximum, Internal, Node, Variable, Children

Typology: Exercises

2011/2012

Uploaded on 07/17/2012

padmaghira
padmaghira 🇮🇳

3.2

(5)

53 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
A Question of Some Depth
Let Tbe a k-ary tree, i.e. each internal node of Thas at most kchildren.
Suppose that the depth of Tis d(the maximum depth of any node of Tis
d). What is the maximum number of external nodes (leaves) that Tcan have?
What is the maximum total number of nodes that Tcan have?
The Big Swap
Suppose that xand yare two integer variables. How can I swap the values
of xand ywithout using a third temporary variable?
(The usual way to do this swap is to do something like
temp x
xy
ytemp.
Here we want to avoid using this extra variable. What can we do instead to
achieve this swap?)
1
docsity.com

Partial preview of the text

Download Tree Depth-Theory of Complexity and Algorithms-Assignment and more Exercises Advanced Algorithms in PDF only on Docsity!

A Question of Some Depth

Let T be a k-ary tree, i.e. each internal node of T has at most k children. Suppose that the depth of T is d (the maximum depth of any node of T is d). What is the maximum number of external nodes (leaves) that T can have? What is the maximum total number of nodes that T can have?

The Big Swap

Suppose that x and y are two integer variables. How can I swap the values of x and y without using a third temporary variable? (The usual way to do this swap is to do something like

temp ← x x ← y y ← temp.

Here we want to avoid using this extra variable. What can we do instead to achieve this swap?)

docsity.com