# Assignment 2 with Answers - Qatar University College of...

This preview shows pages 1–2. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Qatar University College of Engineering Department of Computer Science and Engineering Course: CMPS 323 Design and Analysis of Algorithms Instructor: Dr. Khaled Bashir Shaban Assignment #2 (with Answers) Due date Saturday, March 26 th , 2011 (12:00 midnight). 1. What is the recurrence relation for the following algorithm and what is its solution: float unknown(int n) { if (n<= 1) return (1); else return(unknown(n-1) + unknown(n-2)); } ………………………………………………………………………………………………………… The recurrence relation is: T(n) = T(n-1) + T(n-2) + 1 T(1) = 0 Then you should solve it using an appropriate method… …………………………………………………………………………………………………………... 2. Analyze the following algorithm that reverses a linked list recursively: node * reverse (node * n) { node * m ; if (! (n && n -> next)) return n ; m = reverse (n -> next) ; n -> next -> next = n ;...
View Full Document

{[ snackBarMessage ]}

### Page1 / 3

Assignment 2 with Answers - Qatar University College of...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online