{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Assignment4

# Assignment4 - adding each vote(or title to a list At the...

This preview shows page 1. Sign up to view the full content.

Assignment #4 – CS3913 Due date: Thursday March 11, 2010, before class time (1:00pm). Note: each question is worth 25% Q1 – Do Exercise #6 in Chapter 5 Q2 – Provide a formal algorithm (pseudocode) for a modified mergesort in which you split the input into three instead of splitting it into two. Analyze the time complexity of your algorithm, and compare it with the normal mergesort which uses “splitting input into two”. Q3 – Let’s assume you get a sorted array T[1. .n], containing all distinct integers (negative or positive). Give a O(log n) divide-and-conquer algorithm to find i where T[i] = i if such i exists. Q4 – A web site is used for compiling votes on which book should be named “best of the year”. Here, a vote is casted by typing the title of the book, which is assumed to be unique (i.e., it is not a vote from a given list). The results are compiled by just
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: adding each vote (or title) to a list. At the end, your first job is to detect whether there is one book that got the majority of the votes (i.e., it appears more than n/2 times in the list). Give a divide-and-conquer algorithm for finding such book if one exists, and provide its time complexity. Your algorithm should be faster than the O(n 2 ) brute-force solution of counting the number of titles (by going through list) for each of the elements of the list. Also, you algorithm should not use a significant amount of extra memory (i.e., you can’t just create an array of counters, with one entry per title, and then iterate through the list, updating the counters appropriately). Finally, you should use only equality testing of the titles (i.e., you are not allowed to sort the array)....
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online