Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedBased 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Xxviii Special Issue On Database And Expert Systems Applications Lncs 9940

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Qimin Chen

1st Edition

3662534541, 978-3662534540

More Books

Students also viewed these Databases questions