We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,477 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Mergesort Analysis

Assume that we have a mergesort algorithm which takes 2 series as an input and returns 1 after the merge each time. So that if we want to count say memory blocks we would need 2 blocks for the input and 1 for the output accordingly, total size of 3 blocks (3B). My question is whether this algorithm could run if the memory size is 2B + O(1)?

2
Contributors
3
Replies
4 Days
Discussion Span
1 Year Ago
Last Updated
4
Views
jim_underpants
Newbie Poster
4 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Uh, what? What is a "block"? Also the output of mergesort is as big as the input, it's not half as big the way you say.

Rashakil Fol
Super Senior Demiposter
Team Colleague
2,732 posts since Jun 2005
Reputation Points: 1,153
Solved Threads: 182
Skill Endorsements: 25

A block is a set of data that i retract from the hard drive. A block could have 2 or more sorted elements, lets say numbers. So a block could be something like: [2 5 8] or [3 9 10 12]. Before we start the merging every block has the same size. You are right the algorithm is not mergesort itself, but a version of mergesort that combines the 2 series from the input to 1 at the output, as I described above. It follows the same rules as mergesort though, that's why I said mergesort, because I thought that we need to take its recursive definitions and recurrence relations to solve the problem.

jim_underpants
Newbie Poster
4 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Okay but what I meant was the the output of merging is as big as the input. So if you measure the output as being 1B you're going to have a nonsensical measurement.

Rashakil Fol
Super Senior Demiposter
Team Colleague
2,732 posts since Jun 2005
Reputation Points: 1,153
Solved Threads: 182
Skill Endorsements: 25

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.0782 seconds using 2.68MB