0% found this document useful (0 votes)
19 views2 pages

2Y DSA2 Tutorial1 2

This document provides an introduction to exercises on data structures and algorithms focusing on proofs by induction, contradiction, and recursion. The exercises cover topics such as: proving mathematical formulas using different proof types; evaluating sums using induction; proving properties of Fibonacci numbers and binary representations; and writing recursive functions to solve problems like flipping digits, calculating change, and finding string permutations. The objectives are to practice different proof techniques and applying recursion to solve algorithmic problems.

Uploaded by

xboxmoulay2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

2Y DSA2 Tutorial1 2

This document provides an introduction to exercises on data structures and algorithms focusing on proofs by induction, contradiction, and recursion. The exercises cover topics such as: proving mathematical formulas using different proof types; evaluating sums using induction; proving properties of Fibonacci numbers and binary representations; and writing recursive functions to solve problems like flipping digits, calculating change, and finding string permutations. The objectives are to practice different proof techniques and applying recursion to solve algorithmic problems.

Uploaded by

xboxmoulay2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

2nd Year /Semester3 (2023-2024)

Data Structures & Algorithms 2


Tutorial 1
Introduction
OBJECTIVES
 Proof by Induction vs. Counter-example vs. Contradiction
 Recursion
Exercise 1
Prove the following formulas:
a). log(AB) = B log A
b). log X < X for all X > 0

Exercise 2
Using Induction, prove the following formulas:
a) ∑ ( )
b) ∑ (∑ )
( )
You can make use the formula: ∑

Exercise 3
Proof by Contradiction that For all integers n, if n3+5 is odd then n is even.
Exercise 4
Let Fi be the Fibonacci numbers defined as Fk+1=Fk+Fk-1 such that F0=1and F1=1

Prove the following:

● ∑
● such that ( √ ) ( is known as the Golden Ratio )

Exercise 5
Evaluate the following sums:

 ∑
 ∑

 ∑

1/2
 ∑ (Home)

Exercise 6
Write a recursive algorithm that returns the number of ones in the binary
representation of N. Use the fact that this is equal to the number of 1 in the
representation of N/2 when N is even. If N is odd, there is an additional 1.
● What is the number of zeros for a given binary number?

Exercise 7
Given a decimal number (For instance: 34892), write a recursive function to flip
the number from right to left ( → 29843 ) ( Please, don’t use String functions).

Exercise 8 (Home)
Write a function for computing the Fibonacci number using both paradigms:
iterative and recursive.

Exercise 9 (Home)
For a vending machine to return the change to the customer, it must return a
minimal number of coins. Write a recursive function to determine the number
of each type of coin to give back to the customer as part of the change.
(For example: 290 → 1x200DA + 1x50DA + 2x20DA)

Exercise 10 (Home)
For a given string (Example, “ABC”), write a recursive function to print to the
console all possible permutations of the given string.
( → ABC ACB BAC BCA CBA CAB )

2/2

You might also like