It's UWAweek 17 (1st semester, week 8)

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 91 articles.
Currently no other people reading this forum.


 UWA week 16 (1st semester, week 7) ↓
SVG not supported

Login to reply

👍?
helpful
2:23pm Tue 16th Apr, William R.

Is O(1) achievable? The add_child function asks for a target of O(1), a tree data structure wouldn't be able to achieve this, finding from root the parent to link the child would be O(n). A set would meet O(1) but would have trouble with get_primogeniture_order which asks for O(n) and going through the set several times to find the eldest child of the eldest child of the... and so on would be O(n^2) because if it was held in n + n-1 + n-2 ... +1 that solves to O(n^2). So far I have opted for a hashmap, which under most circumstances is O(1) under the very rare occurrence that everything hashes to the same key, then it would have worst case O(n). Am I missing a data structure that could achieve all target time complexities or does target time complexity allow for hashtables that would be just off? Kind Regards Bill

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  5:07AM Sep 06 2023
Privacy policy