It's UWAweek 47

help2200

This forum is provided to promote discussion amongst students enrolled in CITS2200 Data Structures and Algorithms.

Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.

How do I ask a good question?
Displaying selected article
Showing 1 of 176 articles.
Currently 14 other people reading this forum.


 UWA week 22 (1st semester, study break) ↓
SVG not supported

Login to reply

👍?
helpful
2:24pm Sun 2nd Jun, ANONYMOUS

merge() is O(n) and mergesort() is O(n*log(n)). mergesort() repeatedly divides the array into subarrays until each subarray is size 1. This halving takes O(log(n)) steps and forms a complete binary tree with depth log(n). And for each level of division/depth in the binary tree, a merge() operation is called which merges the two halved arrays in sorted order. Since each element in the two subarrays are compared and placed at most once, there can be at most 2(n/2) = n operations for halves of size n, hence O(n). Thus, there are log(n) recursion levels, and for each level, a merge() operation of O(n) is called, which means overall is O(n*log(n)) operations.

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  8:08AM Aug 25 2024
Privacy policy