midterm1 - CS 573 Midterm 1 Questions Fall 2010 This exam...

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

View Full Document Right Arrow Icon
CS 573 Midterm 1 Questions Fall 2010 This exam lasts 90 minutes. Write your answers in the separate answer booklet. Please return this question sheet with your answers. 1. (a) Suppose A [ 1.. n ] is an array of n distinct integers, sorted so that A [ 1 ] < A [ 2 ] < ··· < A [ n ] . Each integer A [ i ] could be positive, negative, or zero. Describe and analyze an efficient algorithm that either computes an index i such that A [ i ] = i or correctly reports that no such index exists. (b) Now suppose A [ 1.. n ] is a sorted array of n distinct positive integers. Describe and analyze an even faster algorithm that either computes an index i such that A [ i ] = i or correctly reports that no such index exists. 2. A double-Hamiltonian circuit a closed walk in a graph that visits every vertex exactly twice . Prove that it is NP-hard to determine whether a given graph contains a double-Hamiltonian circuit. b d c f g a e This graph contains the double-Hamiltonian circuit a ± b ± d ± g ± e ± b ± d ± c ± f ± a ± c ± f ± g ± e ± a . 3. A palindrome is any string that is exactly the same as its reversal, like I , or DEED , or HANNAH , or AMANAPLANACATACANALPANAMA . Describe and analyze an algorithm to find the length of the longest subsequence of a given string that is also a palindrome. For example, the longest palindrome subsequence of
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

midterm1 - CS 573 Midterm 1 Questions Fall 2010 This exam...

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online