# HW1 - Darshana Umakanth CS 251 Homework 1 False(assuming n...

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

Darshana Umakanth CS 251 Homework 1. False (assuming n is the current size of the array, not the number of push operations) 2. False 3. False 4. True 5. True 6. False 7. True 8. True 9. True 10. True 11. False 12. False Short Answer 1. The code reverses the queue ‘q’ 2. 2 b T 3. N 3 /6 a. For N=1000, it will take approximately 500,000 seconds 4. For a list of numbers in descending order, insertion sort will take worst-case time, as the number of inversions in the list is maximized when the list is ordered backwards. For a list of N numbers, the number of inversions is 2N and the number of compares is at least N 2 . Therefore, the insertion sort runs in approximately N 2 time. 5. H O M E W O R K O H M E W O R K O H E M W O R K O H E M O W R K O H E M O W K R E H M O O W K R E H M O O K R W E H K M O O R W

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

View Full Document
6. Programming Questions 1. public int max(Node node) { int tempVal=0; int tempKey=0; int count=0; if(first==null) return 0; if(node.next==null) return node.value; 13 18 15 12 15 20 7 6 5 4 1 2 9 3
if(node.value>node.next.value)

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.

## This note was uploaded on 09/29/2011 for the course CS 251 taught by Professor Staff during the Spring '08 term at Purdue.

### Page1 / 4

HW1 - Darshana Umakanth CS 251 Homework 1 False(assuming n...

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

View Full Document
Ask a homework question - tutors are online