Bhargavi_Kadiyala_CSE511_Project2_HotSpotAnalysisReport
.pdf
keyboard_arrow_up
School
Arizona State University *
*We aren’t endorsed by this school
Course
511
Subject
Computer Science
Date
Jan 9, 2024
Type
Pages
6
Uploaded by MateLemur3897
Reflection for HotZoneAnalysis Function and HotCellAnalysis Function HotZoneAnalysis Function: The HotZoneAnalysis function is a key component of this project, focusing on the calculation of hotspots within rectangles concerning New York taxi trip pick-up points. Rectangles are defined by the longitude and latitude of opposing corners, while points represent taxi pick-up locations. The function utilizes the ST_Contains(rec_string, point_string) function to determine if a point is within a given rectangle. The input format is ("2.3, 5.1, 6.8, 8.9", "5.5, 5,5"). To correctly implement this function, we identify the minimum and maximum corners of the rectangle using "math. min" and "math. max" for latitude and longitude. A user-
defined function (ST_contains) is created and registered for use in a SQL query to join the rectangle and point datasets using the ST_contains UDF in a WHERE clause. The final step involves returning each rectangle's coordinates and the count of points inside it from the joinResult view using the SQL query: "SELECT rectangle, COUNT(point) AS count FROM joinResult GROUP BY rectangle ORDER BY rectangle." HotCellAnalysis Function: The HotCellAnalysis function calculates the hotness of a given cell, defined by latitude, longitude, and DateTime. The objective is to compute the Getis-Ord statistic, indicating hotness based on the number of pickups for a specific location on a particular day. Analysis/Lessons Learned: 1.
Setup and Utilization of Apache Spark: Gained familiarity with setting up Apache Spark, creating User Defined Functions (UDF), and working with DataFrames. 2.
Execution of SQL Queries on Spark: Learned the process of executing SQL queries on Spark. 3.
Proficiency in Structuring Scala Projects: Developed proficiency in structuring and composing a Scala project, including SBT commands for compilation, cleaning, and packaging. 4.
Scala Code Construction: Acquired experience in constructing a Scala project, manipulating SBT commands, and working with Scala code. 5.
Handling Geospatial Data: Gained hands-on exposure to geospatial data, including determining if a point falls within a zone and retrieving zone boundaries.
6.
Local Testing Procedures: Enhanced proficiency in local testing procedures, encompassing the creation of input files and the specification of the test output directory. Demonstrated expertise in configuring and executing tests, ensuring the seamless validation of code logic and functionality in a local environment. 7.
Optimization Techniques: Mastered optimization techniques, notably employing strategies like coalesce(1) to effectively minimize the number of partitions in a Data Frame. Particularly valuable when generating multiple CSV outputs, these techniques contribute to the streamlined processing and enhanced performance of data operations. Analysis/Lessons Learned:
1.
Familiarity was gained in setting up Apache Spark, creating and utilizing User Defined Functions (UDF), and working with DataFrames. 2.
The process of executing SQL queries on Spark was learned. 3.
Proficiency was developed in structuring and composing a Scala project. This involved aspects like initiating a Scala project, utilizing SBT commands, compiling, cleaning, and packaging. 4.
A novel experience with Scala code encompassed learning how to construct a simple project and manipulate SBT commands for various project tasks. 5.
Hands-on exposure to geospatial data involved understanding how to ascertain if a point falls within a zone, retrieving zone boundaries, and handling longitude and latitude. 6.
Successfully acquired skills in local testing procedures, encompassing tasks such as the creation of input files and the establishment of the test output directory. Demonstrated competence in executing comprehensive tests to ensure code functionality in a local testing environment.Techniques such as using coalesce(1) to reduce the number of partitions in a Data Frame, especially when generating multiple CSV outputs, were acquired. 7.
Developed expertise in optimization techniques, including the utilization of coalesce(1) to minimize the number of partitions in a Data Frame. Particularly beneficial when generating multiple CSV outputs, these techniques contribute to efficient data processing and improved overall performance. 8.
Implementation: a.
Overview of Hot Zone Analysis: b.
Overview of Hot Cell Analysis. Overview of Hot Zone Analysis(def ST_Contains(queryRectangle: String, pointString: String )
The HotzoneAnalysis is written in Scala using Apache Spark. The purpose of the code is to perform a Hot Zone Analysis on spatial data, specifically, it seems to be dealing with points and rectangles. ST_Contains function: spark.udf.register("ST_Contains",(queryRectangle:String,pointString:String)=>(HotzoneUtils.ST_Contains
(queryRectangle, pointString))) This line registers a User Defined Function (UDF) named ST_Contains in Spark. A UDF is a feature in Spark that allows you to define your own functions and use them in SQL expressions. The ST_Contains UDF takes two parameters: •
queryRectangle
: A string representing a rectangle. •
pointString
: A string representing a point. The UDF delegates the actual implementation to HotzoneUtils.ST_Contains(queryRectangle, pointString). This implies that there is a companion object or class named HotzoneUtils where the ST_Contains method is defined. In spatial databases and GIS (Geographic Information Systems), ST_Contains is a common spatial predicate that checks whether one geometry (in this case, a rectangle) contains another geometry (in this case, a point). If the point is inside the rectangle, ST_Contains returns true; otherwise, it returns false. The details of the HotzoneUtils.ST_Contains method would be in the HotzoneUtils class or object, which is not provided in the code snippet you shared. You would need to look into the HotzoneUtils code to understand the specifics of how the containment check is implemented. In summary, the HotzoneAnalysis code reads point and rectangle data, registers a UDF for spatial containment check (ST_Contains), performs a join between points and rectangles based on the containment condition, and finally calculates and returns the count of points within each rectangle as a result of the Hot Zone Analysis. Overview of Hot Cell Analysis.(write the multiple steps required before calculating the z-score.) Here are the multiple steps required before calculating the Z-score in the runHotcellAnalysis function: 1) Load Data: Load the original data from the specified data source (CSV file in this case) using Spark, and create a temporary view named "nyctaxitrips." var pickupInfo = spark.read.format("com.databricks.spark.csv") .option("delimiter", ";") .option("header", "false") .load(pointPath)
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
get_total_cases() takes the a 2D-list (similar to database) and an integer x from this set {0, 1, 2} as input parameters. Here, 0 represents Case_Reported_Date, 1 represents Age_Group and 2 represents Client_Gender (these are the fields on the header row, the integer value represents the index of each of these fields on that row). This function computes the total number of reported cases for each instance of x in the text file, and it stores this information in a dictionary in this form {an_instance_of_x : total_case}. Finally, it returns the dictionary and the total number of all reported cases saved in this dictionary.
arrow_forward
Common Time Zones
Function Name: commonTimeZones()
Parameters: code1( str ), code2( str)
Returns: list of common time zones ( list )
Description: You and your friend live in different countries, but you figure there's a chance that
both of you might be in the same time zone. Thus, you want to find out the list of possible time
zones that you and your friend could both be in. Given two country codes, write a function that
returns a list of the time zones the two countries have in common. Be sure not to include any
duplicate time zones. If the two country codes do not have any common time zones, return the
string 'No Common Time Zones' instead.
Note: You can assume that the codes will always be valid.
example test cases:
>>> commonTimeZones('can', 'usa')
[UTC-08:00', 'UTC-07:00', 'UTC-06:00', 'UTC-05:00', 'UTC-04:00]
>>> commonTimeZones('rus', 'chn')
[UTC+08:00]
For this assignment, use the REST countries API
(https://restcountries.com/#api-endpoints-v2).
For all of your requests, make…
arrow_forward
Common Time Zones
Function Name: commonTimeZones()
Parameters: code1( str ) , code2( str )
Returns: list of common time zones ( list )
Description: You and your friend live in different countries, but you figure there's a chance that
both of you might be in the same time zone. Thus, you want to find out the list of possible time
zones that you and your friend could both be in. Given two country codes, write a function that returns a list of the time zones the two countries have in common. Be sure not to include any duplicate time zones. If the two country codes do not have any common time zones, return the string 'No Common Time Zones' instead.
Note: You can assume that the codes will always be valid.
example test cases:
>>> commonTimeZones('can', 'usa')
['UTC-08:00', 'UTC-07:00', 'UTC-06:00', 'UTC-05:00', 'UTC-04:00']
>>> commonTimeZones('rus', 'chn')
['UTC+08:00']
For this assignment, use the REST countries API…
arrow_forward
By python
arrow_forward
Brussel's choice def brussels_choice_step(n, mink, maxk):
This problem is adapted from another jovial video "The Brussel's Choice" of Numberphile (a site so British that you just know there has to be a Trevor and a Colin somewhere in there) whose first five minutes you should watch to get an idea of what is going on. This function should compute and return the list of all numbers that the positive integer n can be converted to by treating it as a string and replacing some substring m of its digits with the new substring of either 2*m or m/2, the latter substitution allowed only when m is even so that dividing it by two produces an integer.
This function should return the list of numbers that can be produced from n in a single step. To keep the results more manageable, we also impose an additional constraint that the number of digits in the chosen substring m must be between mink and maxk, inclusive. The returned list must contain the numbers in ascending sorted order.
arrow_forward
A c++ code that performs a search for a specific employee and returns the employee ID if found and 0 if not:
int findEmployeeById(Employee list[], int size, int myId)
arrow_forward
A deque data structure implements the following functions:
insertFront(int); //Insert at the front
insertBack(int);//Insert at the back
removeFront();//Remove and print front element
eraseBack();//Remove and print last element
first();//print first element
last();//print last element
Write the output of the following sequence of operations:
insertFront(3), insertBack(8), insertBack(9),
insertFront(5), removeFront(), eraseBack(),
first(), insertBack(7), removeFront(), last(), eraseBack().
arrow_forward
A deque data structure implements the following functions:
insertFront(int); //Insert at the front
insertBack(int);//Insert at the back
removeFront();//Remove and print front element
eraseBack();//Remove and print last element
first();//print first element
last();//print last element
Write the output of the following sequence of operations:
insertFront(3), insertBack(8), insertBack(9),
insertFront(5), removeFront(), eraseBack(),
first(), insertBack(7), removeFront(), last(), eraseBack().
Write the sequence of numbers without space or comma.
arrow_forward
PYTHON CODING
This function takes a list of points and then returns a new list of points, which starts with the first point that was given in the list, and then followed by points closest to the start point.
Here is the function that needs to be created:
def solution_path(points) : # insert code here return path
Please use any of the following function to develop the solution_path function
Distance function - calculates the distance between two points
def distance(p1, p2) : distance = sqrt (((p1 [0] - p2 [0]) **2) + ((p1 [1] - p2 [1]) **2)) return (distance)
Find_closest function - calculates the closest point to the starting point
def find_closest(start_point, remaining_points): closest_distance = 99999 for coordinate in remaining_points: dist = distance(start_point, coordinate) if(dist < closest_distance): closest_distance = dist closest_point = coordinate return closest_point
Path_distance function -…
arrow_forward
Dec2Hex function :
def decimal_to_hex(number): hex_map = {0: '0', 1: '1', 2: '2', 3: '3', 4: '4', 5: '5', 6: '6', 7: '7', 8: '8', 9: '9', 10: 'A', 11: 'B', 12: 'C', 13: 'D', 14: 'E', 15: 'F'} hex_digits = [] while number > 0: hex_digits.append(hex_map[number % 16]) number //= 16 # Reverse the order of the hex digits and join them to form the final hex string hex_string = ''.join(reversed(hex_digits)) return f'0x{hex_string}' if hex_string else '0x0'
Perform a Profile of your Dec2Hex function.
Write a function that takes a timedate object as a parameter andcalculates the number of years from NOW to the time in the timedateobject.
Add unit-testing code to your Dec2Hex exercise, and then perform aUnit test of the updated Dec2Hex code.
arrow_forward
Sum of two squares def sum_of_two_squares(n):
Some positive integers can be expressed as a sum of two squares of some positive integers greater than zero. For example, 74 = 49 + 25 = 72 + 52. This function should find and return a tuple of two positive integers whose squares together add up to n, or return None if the parameter n cannot be broken into a sum of two squares.
To facilitate the automated testing, the returned tuple must present the larger of its two numbers first. Furthermore, if some integer can be broken down to a sum of squares in several ways, return the breakdown that maximizes the larger number. For example, the number 85 allows two such representations 72 + 62 and 92 + 22 , of which this function must return (9, 2).
The technique of two approaching indices that start from the beginning and end of a sequence, respectively, and approach each other until they meet somewhere, used in the function two_summers in one of our class examples, is directly applicable to this…
arrow_forward
Sum of two squares def sum_of_two_squares(n): Some positive integers can be expressed as a sum of two squares of some positive integers greater than zero. For example, 74 = 49 + 25 = 72 + 52. This function should find and return a tuple of two positive integers whose squares together add up to n, or return None if the parameter n cannot be broken into a sum of two squares.To facilitate the automated testing, the returned tuple must present the larger of its two numbers first. Furthermore, if some integer can be broken down to a sum of squares in several ways, return the breakdown that maximizes the larger number. For example, the number 85 allows two such representations 72 + 62 and 92 + 22 , of which this function must return (9, 2).The technique of two approaching indices that start from the beginning and end of a sequence, respectively, and approach each other until they meet somewhere, used in the function two_summers in one of our class examples, is directly applicable to this…
arrow_forward
ArcGis Program Geographic Systems
You have been assigned to create a map using a
number of feature classes. Each feature class is
projected in a different coordinate system. The
accurate position of all the features is very
important for this assignment. Therefore, you
select a feature class and use it's coordinate
system for the data frame. Then you should
perform a(n)
for
each of the remaining feature classes.
arrow_forward
A prime number is an integer value that is only divisible by 1 and itself. 2, 3, 5, 7, and 11 are examples of prime numbers. You have been provided with
two function definitions:
The is_prime () function takes an integer parameter number, and returns True if number is prime and False otherwise. The
get_next_prime () function also takes a single integer parameter number, and returns the first prime number larger than it. You must not
change the implementation of these 2 functions.
Complete the get_primes_list() function that takes a single list of integers called numbers as parameter. You can assume that the integer
items in this list will be non-negative. The function must update this list so that items that are not prime numbers are updated to the first prime number
larger than them. To implement this function you must call both the is_prime () and get_next_prime () functions. Some examples of the
function being called are shown below.
Note: the get_primes_list() function does not…
arrow_forward
Part B - reading CSV files
You will need a Python repl to solve part B.
Define a Python function named cheapest_rent_per_state that has one parameter. The parameter is a string representing the name of a CSV file. The CSV file will be portion of a dataset published by the US
government showing the median (middle) rent in every county in the US. Each row in the CSV file has the same format
Area Name, Efficiency, 1-Bedroom, 2-Bedroom, 3-Bedroom, 4-Bedroom, State Code
The data in the Area Name and State Code columns are text. The data in all of the other columns are decimal numbers.
Your function will need to use the accumulator pattern to return a dictionary. The keys of that dictionary will be the state codes read in from the file (state codes are at index 6). For each key in the dictionary, it's
value should be the smallest median rent for an efficiency in that state (median rents for an efficiency are at index 1).
Important Hints:
* You will really, really want to use the built-in csv…
arrow_forward
Function 1: draw_subregion
Complete the implementation of draw_subregion. This function has the following parameters:
my_turtle: A turtle object (which will do the drawing)
polygon_points: A list of (x, y) points (i.e. a list of tuples) that defines the points of a polygon.
This function should make the turtle draw the polygon given by the points. Make sure that you lift your pen before heading to the first point. You should also make sure you return to the very first point at the end (i.e. you will go to the first point in the list two times: once at the beginning, and once at the end).
Language Python
arrow_forward
Unique Values
This function will receive a single map parameter known as a_map. a_map will contain a single letter as a string and numbers as values. This function is supposed to search a_map to find all values that appear only once in a_map. The function will create another map named to_ret. For all values that appear once in a_map the function will add the value as a key in to_ret and set the value of the key to the key of the value in a_map (swap the key-value pairs, since a_map contains letters to numbers, to_ret will contain Numbers to Letters). Finally, the function should return to_ret.
Signature:
public static HashMap<String, Integer> uniqueValues(HashMap<Integer, String> a_map)
Example:
INPUT: {0=M, 2=M, 3=M, 5=M, 6=n, 7=M, 9=M}OUTPUT: {n=6}
INPUT: {0=A, 1=c, 2=c, 4=c, 5=a, 8=Q, 9=c}OUTPUT: {A=0, a=5, Q=8}
arrow_forward
Complete Assignment attached using Codeskulptor3.com
arrow_forward
Gamex, an online game website launches a game for kids where the kids have to pick up balls from a pool and drag them to the ribbon beneath the pool. The pool contains red, blue and green colored
balls. Tester function of the game checks whether the kid have placed the picked balls according to the following constraints:
The kid should have picked atleast one red, one blue and two green colored balls.
The kid should place the balls in the following order. Red balls followed by green followed by blue balls.
The number of red balls should be equal to blue balls.
iv.
i.
ii.
ii.
The number of green balls should be twice as of red balls.
Design pushdown automata to simulate the function of tester. Justify your answer.
arrow_forward
function removeErrMsgs() {
var errMessages = document.getElementsByClassName('msg');for (let msg of errMessages) {msg.innerHTML = "";}}function validateValues() {var toBeReturned = true;removeErrMsgs();var fname = document.getElementById("fname").value;if (fname.length > 30) {document.getElementsByClassName('msg')[0].innerHTML = "First name can not be longer than 30 characters";toBeReturned = false;}
var lname = document.getElementById("lname").value;if (lname.length > 30) {document.getElementsByClassName('msg')[1].innerHTML = "Last name can not be longer than 30 characters";toBeReturned = false;}
var phone = document.getElementById('num').value;if (phone.length > 8) {document.getElementsByClassName('msg')[2].innerHTML = "Phone number can not be greater than 8 numbers";toBeReturned = false;}
var items = document.getElementById('items').value;if (items > 4 || items < 2) {document.getElementsByClassName('msg')[3].innerHTML = "Item numbers should be between 1 and…
arrow_forward
Variables are well-suited to the processing of data lists. True or False
arrow_forward
Sum of two squares
def sum_of_two_squares(n):
Some positive integers can be expressed as a sum of two squares of some positive integers greater than zero. For example, 74 = 49 + 25 = 7^2 + 5^2. This function should find and return a tuple of two positive integers whose squares together add up to n, or return None if the parameter n cannot be broken into a sum of two squares.To facilitate the automated testing, the returned tuple must present the larger of its two numbers first. Furthermore, if some integer can be broken down to a sum of squares in several ways, return the breakdown that maximizes the larger number. For example, the number 85 allows two such representations 7^2 + 6^2 and 9^2 + 2^2 , of which this function must return (9, 2).The technique of two approaching indices that start from the beginning and end of a sequence, respectively, and approach each other until they meet somewhere is directly applicable to this problem. In this problem, these indices crawl towards each…
arrow_forward
C++
arrow_forward
in phython language
Create a module file named mystatistics.py. This module should define two functions: mean() and median().
Both functions takes a list as a parameter.
mean() function calculates the average of all elements in the parameter list and returns it.
median() function sorts the list first. If the number of elements in the list is odd, it returns the middle element. If it is even then it averages the two middle elements and then returns the value.
Python has its own statistics library which has mean and median functions. Use them to test your functions and place a testing code in your module.
arrow_forward
Part C - advanced file reading
You will need a Python repl to solve part C.
Define a Python function named expensive_counties that has two parameters. The first parameter is a string representing the name of a text file. Each line of this text file will be a state code. The second
parameter is a string representing the name of a CSV file. The CSV file will be portion of the US government's dataset documenting median rents in each US county. Each row in the CSV file has the format:
Area Name, Efficiency, 1-Bedroom, 2-Bedroom, 3-Bedroom, 4-Bedroom, State Code
Your function will need to use the accumulator pattern to return a new list. You will need to add to this list the Area Name from every row that meets 2 criteria:
(1) The state code (the column at index 6) was a line in the text file named in the first parameter; AND
(2) The median rent on a 1-bedroom apartment (the column at index 2) is over 1000.
Important Hints:
* You will really, really want to use the built-in csv library…
arrow_forward
program
arrow_forward
A "generic" data structure cannot use a primitive type as its generic type.
O True
False
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Related Questions
- get_total_cases() takes the a 2D-list (similar to database) and an integer x from this set {0, 1, 2} as input parameters. Here, 0 represents Case_Reported_Date, 1 represents Age_Group and 2 represents Client_Gender (these are the fields on the header row, the integer value represents the index of each of these fields on that row). This function computes the total number of reported cases for each instance of x in the text file, and it stores this information in a dictionary in this form {an_instance_of_x : total_case}. Finally, it returns the dictionary and the total number of all reported cases saved in this dictionary.arrow_forwardCommon Time Zones Function Name: commonTimeZones() Parameters: code1( str ), code2( str) Returns: list of common time zones ( list ) Description: You and your friend live in different countries, but you figure there's a chance that both of you might be in the same time zone. Thus, you want to find out the list of possible time zones that you and your friend could both be in. Given two country codes, write a function that returns a list of the time zones the two countries have in common. Be sure not to include any duplicate time zones. If the two country codes do not have any common time zones, return the string 'No Common Time Zones' instead. Note: You can assume that the codes will always be valid. example test cases: >>> commonTimeZones('can', 'usa') [UTC-08:00', 'UTC-07:00', 'UTC-06:00', 'UTC-05:00', 'UTC-04:00] >>> commonTimeZones('rus', 'chn') [UTC+08:00] For this assignment, use the REST countries API (https://restcountries.com/#api-endpoints-v2). For all of your requests, make…arrow_forwardCommon Time Zones Function Name: commonTimeZones() Parameters: code1( str ) , code2( str ) Returns: list of common time zones ( list ) Description: You and your friend live in different countries, but you figure there's a chance that both of you might be in the same time zone. Thus, you want to find out the list of possible time zones that you and your friend could both be in. Given two country codes, write a function that returns a list of the time zones the two countries have in common. Be sure not to include any duplicate time zones. If the two country codes do not have any common time zones, return the string 'No Common Time Zones' instead. Note: You can assume that the codes will always be valid. example test cases: >>> commonTimeZones('can', 'usa') ['UTC-08:00', 'UTC-07:00', 'UTC-06:00', 'UTC-05:00', 'UTC-04:00'] >>> commonTimeZones('rus', 'chn') ['UTC+08:00'] For this assignment, use the REST countries API…arrow_forward
- By pythonarrow_forwardBrussel's choice def brussels_choice_step(n, mink, maxk): This problem is adapted from another jovial video "The Brussel's Choice" of Numberphile (a site so British that you just know there has to be a Trevor and a Colin somewhere in there) whose first five minutes you should watch to get an idea of what is going on. This function should compute and return the list of all numbers that the positive integer n can be converted to by treating it as a string and replacing some substring m of its digits with the new substring of either 2*m or m/2, the latter substitution allowed only when m is even so that dividing it by two produces an integer. This function should return the list of numbers that can be produced from n in a single step. To keep the results more manageable, we also impose an additional constraint that the number of digits in the chosen substring m must be between mink and maxk, inclusive. The returned list must contain the numbers in ascending sorted order.arrow_forwardA c++ code that performs a search for a specific employee and returns the employee ID if found and 0 if not: int findEmployeeById(Employee list[], int size, int myId)arrow_forward
- A deque data structure implements the following functions: insertFront(int); //Insert at the front insertBack(int);//Insert at the back removeFront();//Remove and print front element eraseBack();//Remove and print last element first();//print first element last();//print last element Write the output of the following sequence of operations: insertFront(3), insertBack(8), insertBack(9), insertFront(5), removeFront(), eraseBack(), first(), insertBack(7), removeFront(), last(), eraseBack().arrow_forwardA deque data structure implements the following functions: insertFront(int); //Insert at the front insertBack(int);//Insert at the back removeFront();//Remove and print front element eraseBack();//Remove and print last element first();//print first element last();//print last element Write the output of the following sequence of operations: insertFront(3), insertBack(8), insertBack(9), insertFront(5), removeFront(), eraseBack(), first(), insertBack(7), removeFront(), last(), eraseBack(). Write the sequence of numbers without space or comma.arrow_forwardPYTHON CODING This function takes a list of points and then returns a new list of points, which starts with the first point that was given in the list, and then followed by points closest to the start point. Here is the function that needs to be created: def solution_path(points) : # insert code here return path Please use any of the following function to develop the solution_path function Distance function - calculates the distance between two points def distance(p1, p2) : distance = sqrt (((p1 [0] - p2 [0]) **2) + ((p1 [1] - p2 [1]) **2)) return (distance) Find_closest function - calculates the closest point to the starting point def find_closest(start_point, remaining_points): closest_distance = 99999 for coordinate in remaining_points: dist = distance(start_point, coordinate) if(dist < closest_distance): closest_distance = dist closest_point = coordinate return closest_point Path_distance function -…arrow_forward
- Dec2Hex function : def decimal_to_hex(number): hex_map = {0: '0', 1: '1', 2: '2', 3: '3', 4: '4', 5: '5', 6: '6', 7: '7', 8: '8', 9: '9', 10: 'A', 11: 'B', 12: 'C', 13: 'D', 14: 'E', 15: 'F'} hex_digits = [] while number > 0: hex_digits.append(hex_map[number % 16]) number //= 16 # Reverse the order of the hex digits and join them to form the final hex string hex_string = ''.join(reversed(hex_digits)) return f'0x{hex_string}' if hex_string else '0x0' Perform a Profile of your Dec2Hex function. Write a function that takes a timedate object as a parameter andcalculates the number of years from NOW to the time in the timedateobject. Add unit-testing code to your Dec2Hex exercise, and then perform aUnit test of the updated Dec2Hex code.arrow_forwardSum of two squares def sum_of_two_squares(n): Some positive integers can be expressed as a sum of two squares of some positive integers greater than zero. For example, 74 = 49 + 25 = 72 + 52. This function should find and return a tuple of two positive integers whose squares together add up to n, or return None if the parameter n cannot be broken into a sum of two squares. To facilitate the automated testing, the returned tuple must present the larger of its two numbers first. Furthermore, if some integer can be broken down to a sum of squares in several ways, return the breakdown that maximizes the larger number. For example, the number 85 allows two such representations 72 + 62 and 92 + 22 , of which this function must return (9, 2). The technique of two approaching indices that start from the beginning and end of a sequence, respectively, and approach each other until they meet somewhere, used in the function two_summers in one of our class examples, is directly applicable to this…arrow_forwardSum of two squares def sum_of_two_squares(n): Some positive integers can be expressed as a sum of two squares of some positive integers greater than zero. For example, 74 = 49 + 25 = 72 + 52. This function should find and return a tuple of two positive integers whose squares together add up to n, or return None if the parameter n cannot be broken into a sum of two squares.To facilitate the automated testing, the returned tuple must present the larger of its two numbers first. Furthermore, if some integer can be broken down to a sum of squares in several ways, return the breakdown that maximizes the larger number. For example, the number 85 allows two such representations 72 + 62 and 92 + 22 , of which this function must return (9, 2).The technique of two approaching indices that start from the beginning and end of a sequence, respectively, and approach each other until they meet somewhere, used in the function two_summers in one of our class examples, is directly applicable to this…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education