Sort without duplicates (2) X65597


Statement
 

pdf   zip

thehtml

Write a function sort_no_dup that receives a list of integers, possibly including repeated entries, and returns a sorted list with the same integers without any repetition. The solution must use compulsorily a binary search tree (BST).

Input The function receives a list of integers as a parameter.

Output The function returns as a result a list of integers sorted and without duplicate elements.

Observation Besides integers, only a total of three data structures are to appear in your solution: the parameter list, the returned resulting sorted list, and one BST to be implemented by you.

Sample session
>>> sort_no_dup([5, 1, 5, 2, 4, 1, 4, 8, 2, 1])
[1, 2, 4, 5, 8]
>>> sort_no_dup([])
[]
>>> sort_no_dup([33, 33, 33, 33, 33, 33])
[33]
>>> sort_no_dup([7, 6, 7, 6, 7, 6])
[6, 7]
>>> sort_no_dup([258, 256, 254, 252, 250])
[250, 252, 254, 256, 258]
Information
Author
Language
English
Official solutions
Python
User solutions
Python