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

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
if(node.value>node.next.value)
Background image of page 3

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

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

Page1 / 4

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

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

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