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
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(n1) + unknown(n2)); } ………………………………………………………………………………………………………… The recurrence relation is: T(n) = T(n1) + T(n2) + 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
This note was uploaded on 05/14/2011 for the course CMPS 323 taught by Professor Shaban during the Spring '11 term at Qatar University.
 Spring '11
 Shaban

Click to edit the document details