Question: Based on python Edited: there is no specific type of triangle 4. [total: 12] In this problem, we will deal with the notion of pseudo-similar

Based on python Edited: there is no specific type of triangle 4.Based on python

Edited: there is no specific type of triangle

4. [total: 12] In this problem, we will deal with the notion of pseudo-similar triangles. Each triangle is represented by a 3-tuple of positive numbers, specifying the sides of the triangle. We say that two triangles t1 and t2 are pseudo-similar if triangle t2 can be obtained by rotating and reflecting triangle ti. For example, t1 = (6, 9, 12) is pseudo-similar to t2 = (6, 12, 9) since t2 can be obtained by rotating and reflecting t1. (6, 9, 12) rotate, (9, 12, 6) reflect, (6, 12, 9) However, t1 = (6, 9, 6) is not pseudo-similar to t2 = (6, 9, 9). We say that two triangles are the same kind if they are pseudo-similar. In Python, a triangle will be represented as a 3-tuple of positive integers. Your task is to write the function num_triangle_kinds, which determines the number of different kinds of triangles in the list. (8 points) Requirements: Your code must be written in Python 3, and the filename must be triangle.py. . We will grade only the num_triangle_kinds function; please do not change its signature in the starter code. include as many helper functions as you wish. You are not allowed to use the built-in Python dictionary or set. To get full marks, your algorithm must have average-case runtime O(n). You can assume Simple Uniform Random Hashing. Write-up (4 points): in your ps2.pdf/ps2.tex files, include the following: an explanation of how your code works, justification of correctness, and justification of desired O(n) average- case runtime. 4. [total: 12] In this problem, we will deal with the notion of pseudo-similar triangles. Each triangle is represented by a 3-tuple of positive numbers, specifying the sides of the triangle. We say that two triangles t1 and t2 are pseudo-similar if triangle t2 can be obtained by rotating and reflecting triangle ti. For example, t1 = (6, 9, 12) is pseudo-similar to t2 = (6, 12, 9) since t2 can be obtained by rotating and reflecting t1. (6, 9, 12) rotate, (9, 12, 6) reflect, (6, 12, 9) However, t1 = (6, 9, 6) is not pseudo-similar to t2 = (6, 9, 9). We say that two triangles are the same kind if they are pseudo-similar. In Python, a triangle will be represented as a 3-tuple of positive integers. Your task is to write the function num_triangle_kinds, which determines the number of different kinds of triangles in the list. (8 points) Requirements: Your code must be written in Python 3, and the filename must be triangle.py. . We will grade only the num_triangle_kinds function; please do not change its signature in the starter code. include as many helper functions as you wish. You are not allowed to use the built-in Python dictionary or set. To get full marks, your algorithm must have average-case runtime O(n). You can assume Simple Uniform Random Hashing. Write-up (4 points): in your ps2.pdf/ps2.tex files, include the following: an explanation of how your code works, justification of correctness, and justification of desired O(n) average- case runtime

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!