Homework1_Solutions
.pdf
keyboard_arrow_up
School
University of Texas *
*We aren’t endorsed by this school
Course
360C
Subject
Computer Science
Date
Dec 6, 2023
Type
Pages
7
Uploaded by ConstableGiraffeMaster829
ECE360C: Algorithms
Homework Assignment #1
University of Texas at Austin
Due: September 1, 2023 (11:59pm)
Homework Assignment #1
– Solutions
Solutions are for individual use only by students registered for ECE 360C in Spring
2023 semester. They should not be otherwise shared or posted.
Problem 1: Remember [20 points]
Answer the following true/false questions about the Gale-Shapley algorithm.
(We are using the
version of Gale-Shapley described in class where
n
positions are offered to
n
applicants.
The
positions do the offering, and applicants simply accept the best offer they are made.)
True
False
⊠
□
Every execution of the Gale-Shapley algorithm results in a stable matching
of positions to applicants.
□
⊠
In any execution of the Gale-Shapley algorithm, every applicant will end up
with their least favored position.
⊠
□
During the execution of the Gale-Shapley algorithm, once an applicant has
been offered a position, they will always have
some
position.
□
⊠
During the execution of the Gale-Shapley algorithm, once a position has
been offered to at least one applicant, the position will always be matched
to
some
applicant.
□
⊠
Depending on the preference lists and the order in which offers are made, it
is possible for some position to end up without a matched applicant.
⊠
□
If an applicant and a position rank each other first, they are guaranteed to
be matched by Gale-Shapley at the end of the algorithm.
□
⊠
In some cases, even when the inputs to the algorithm are properly formed,
the Gale-Shapley algorithm could get into an infinite loop of applicants and
positions matching, then breaking the match, then matching again.
⊠
□
The sequence of offers an applicant accepts is always improving (that is, an
applicant never has to give up a good position for one the applicant ranks
lower).
⊠
□
If a position
x
makes an offer to applicant
b
after having made an offer to
applicant
a
earlier in the algorithm, it must be true that
x
ranks
a
higher
than
b
.
□
⊠
The number of unfilled positions decreases by one for every iteration of the
Gale-Shapley
while
loop.
Homework Assignment #1: September 1, 2023 (11:59pm)
2
Problem 2: Understand [20 points]
In our discussion of the Gale-Shapley algorithm, we used the number of offers as a measure of
progress
and showed that each iteration of the
while
loop makes one new offer of a position to an
applicant. Since there are
n
applicants and
n
positions, and an applicant can never be offered a
position more than once, the
while
loop can be executed at most
n
2
times.
Consider a simple instance of Gale-Shapley, where
n
= 3 (there are 3 open positions,
A
,
B
, and
C
and 3 applicants
X
,
Y
, and
Z
). Provide an example execution of Gale-Shapley that results in
the maximum possible number of offers made (i.e., executions of the
while
loop). You will need
to provide the complete preference list of all three positions and all three applicants as well as the
order in which positions are offered to applicants. Also state whether your free list is a LIFO queue
or a FIFO queue (that is, is a position that becomes open because an applicant took a better offer
immediately offered their next favored applicant or do they go to the back of the line?).
Finally, summarize at least three generic observations this exercise helps you make about the
Gale-Shapley algorithm’s execution. We’ve done the first one for you.
Positions’ Preference Lists
A:
X
Y
Z
(given)
B:
Y
X
Z
C:
X
Y
Z
Applicants’ Preference Lists
X:
B
C
A
Y:
C
A
B
Z:
A
B
C
Type of Queue
FIFO
Initial Queue Order
(include A, B, and C)
A, B, C
How many offers are made, in total?
7
Three Generic Observations
(don’t refer to
n
= 3 or to specific applicants or positions)
1.
It is not possible for all
n
positions to be offered to all
n
applicants.
2.
There will always be at least one applicant who only receives one offer.
3.
Regardless of the order in which offers are made, for a given set of preferences lists, the
same offers are always made.
Homework Assignment #1: September 1, 2023 (11:59pm)
3
Problem 3: Apply [20 points]
Read about this real world application of a Gale-Shapley-like algorithm:
https://nyti.ms/3EevfRv
Identify three similarities and three differences between the classic Gale-Shapley algorithm and the
version described in the article.
Two Similarities
1.
The goal is the same – match two types of parties with the other based on preferences.
2.
Both parties rank the other, and each individual has the option to rank based on their own
preferences.
Two Differences
1.
There aren’t necessarily the same number of students and slots available. At least it doesn’t
appear to be explicitly the case.
2.
The applicants (and positions) don’t have to rank all of the other party
Based on your knowledge of Gale-Shapley and your reading of this article, do you have any concerns
or questions about how the matching algorithm works in this context? If so, write them here. If
not, write “No concerns or questions.” (Finish this part of the question before moving on. It will
be more interesting for you and for us.)
My Questions and Concerns
Lots of things are fine here.
Now read these two additional articles about the process (note the dates on all three articles):
https://nyti.ms/3KTO14w
https://bit.ly/NYCPart3
If you have any trouble accessing these articles, please let us know ASAP.
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
Q 01: (Each containing 2*3=6) What is the Critical section problem? Write and explain Peterson solution for it.
arrow_forward
Solve these questions
arrow_forward
Hill cipher decryption:
I must find the encryption key in order to decrypt a specific message. All i know is that the encryption key is 3x3 matrix and the specific message begins with the phrase "CONFIDENT".
I must do this in python. I understand how to decrypt stuff once I have the key matrix. But I am confused as to how to find the key matrix in the first place with the information given.
arrow_forward
APAI1001 Assignment 1 (Due: Oct 18 (Friday), 23:59pm)
Q1
Breath first search
(Path Searching) Franklin Philips, a professor of the University of Los Santos (B5), is going to
drive to Vice City (E3) to attend a conference today. The map of this region with district division
is showed as follows. However, Prof. Philips woke up late in the morning and he must arrive at
Vice City as soon as possible. Answer the following questions to help Prof. Philips finding the
shortest path. (Adjacent districts are interconnected if and only if they are divided by dotted line).
5
4
3
2
1
A
Los Santos
B
Vice City
E
Consider using breath first search (under the graph search framework) to find the shortest path.
Note that each district on the map has at most 4 successors, and most locations have less than
4 successors due to road blocks and map boundaries. We consider a default left-bottom-right-
top order of the successors (when adding them to the frontier).
(a) [CiC] Write down the adjacency lists of…
arrow_forward
Course Title: Data Structures and Algorithms
Please Correct Solve The Question
Question :
Part (a) Design an adjacency Matrix of the alphabets of your name is "MOEAD REHAN". In accordance with the following conditions:
If your name has repeated characters (e.g. character E, 2 times) then you will consider only 1 time.
If your Name contains both G and S, then there will be an edge between them and one additional edge from W to each if W is also in your name.
If N is the alphabet in your name, it will have an edge to A and S if it available in your name.
If P is available then it will have an edge with L if it is available.
If there is a blank space in full Name then it will be represented by “_”, and it must have an edge with all alphabets.
(Note: Place on in 1 for Edge and 0 for No Edge)
Part (b) Sketch an undirected graph of the above designed adjacency matrix.
arrow_forward
Horizontal sequence :VIRL
Vertical sequence:MKF
Scoring rules: g/o = -3, g/e = -1, match or mismatch - from PAM250 substitution matrix below.
NW algorithm.
1. Complete the scoring matrix.
Scoring matrix with PAM250 scores:
V
I
R
L
M
K
F
2. Set up, initialize and complete the NW matrix.
3. Retrace, align and score alignment(s).
Use the arrows and circles for the matrix and path(s).
V
I
R
L
M
K
F
Align and score all optimal alignments here.
PLZ the arrows and circles for the matrix and path(s) AND SHOW ALL possible Alignment
arrow_forward
Horizontal sequence :VIRL
Vertical sequence:MKF
Scoring rules: g/o = -3, g/e = -1, match or mismatch - from PAM250 substitution matrix below.
NW algorithm.
1. Complete the scoring matrix.
Scoring matrix with PAM250 scores:
V
I
R
L
M
K
F
2. Set up, initialize and complete the NW matrix.
3. Retrace, align and score alignment(s).
Use the arrows and circles for the matrix and path(s).
V
I
R
L
M
K
F
Align and score all optimal alignments here.
arrow_forward
Solve using integer programming
arrow_forward
Subject - Design & Anal algorithms
Please complete all the questions together.
Use python code. Thank you in Advance.
You are given two sorted arrays, array A of size n and array B of size m. Write pseudo-code for the Merge procedure that merges arrays A and B into a new sorted array C. You can assume C has been preallocated to have the right size
arrow_forward
Self Grouping Program
arrow_forward
Required 2nd answer
arrow_forward
link to MINST code: https://www.dropbox.com/s/i21pedejv0sknnq/MINST.pdf?dl=0
1) Add a confusion matrix to the MNIST code example from the link provided. Set the epochs parameter to 5. Explain which entry of the matrix yields the number of ones (the number 1) that are falsely recognized as eights (the number 8). (If you use indices in your explanation, use the Python index notation, i.e., start at zero.) Run your code a few times. Is the confusion matrix always the same? Briefly explain.
arrow_forward
Python Answer Required:
A Rajesh teaches a cooking class. The course is attended by NN students, numbered 11 to NN.
The cook must participate in the presence before each class, i.e. call out the names of the
students one by one and indicate which students are present. Each student has a first and last
name. To save time, Rajesh only wants to call up students' first names. However, if there are
multiple students with the same first name, the Rajesh must call out the full names (first and last
names) of all those students. For any student who does not share a first name with any other
student, the cook can still only call that student's first name.
Help the Rajesh decide for each student whether to call that student's full name or just their first
name.
Input
1
1
hasan jaddouh
Output
hasan
arrow_forward
[(2A)] The given table below (in the first photo) shows the 5 different places that you would like to visit on a particular day. The table below shows the estimated distance (in kilometers per hour) it takes you to travel from one place to another. If you will visit each of these places exactly once, determine the shortest time possible it would take you to do using the Greedy Algorithm. Example (second photo) already provided in the photos below..
arrow_forward
Python question
Analysis: Computational Complexity (Q14-15)
In this section, you are asked to analyse the worst-case computational time complexity of Python functions. Always identify the order of growth in the tightest and simplest possible form using big-O notation, e.g., write O(n) instead of O(2n+n/2).
Question 14 (Complexity 1)
State the overall worst-case time complexity of the below function and provide a short explanation of your answer. The function accepts an integer n as input.
def mystery(n): num = 1 count = 0 while num < n: num = num*2 count += 1 return count
Question 15 (Complexity 2)
State the overall worst-case time complexity of the below function and provide a short explanation of your answer. The function is supposed to return a list, res, containing the duplicated elements in the given list , lst, of size n. Analyse the function in terms of the length of the list, n.
def duplicate_values(lst): res = [] for i in range(len(lst)):…
arrow_forward
Answer questions 2 only
arrow_forward
Below is the exercise for Advanced Sorts.
To start, create your own set of 10 numbers in an array that are not sorted. Using your array, do the following exercises:
Show how the Mergesort algorithm sorts your array by:
1) Showing which sub parts of the array are being examined with each recursive call to Mergesort
2) Showing the results of the array each time the Merge function is used
Your demonstration should be similar to slides 19-33 in the Mergesort presentation. You do not have to show the details of the function calls in the stack (unless it helps you), but do explain what is happening at each step to show understanding of the algorithm.
arrow_forward
Q3: Interplanetary Spaceflight
Milan Tusk is the richest person in the universe. After devoting decades of his life to further our space exploration technologies, he’s finally ready to retire. Being a space enthusiast, the first thing he wants to do is visit n planets p1, p2, …, pn, in this order. He’s currently on planet p0.
Milan knows that the distance between planets pi and pi + 1 (for 0 ≤ i < n) is d[i]light years. His spaceship uses 1 tonne of fossil fuels per light year. He starts with a full tank and can fill up his tank at any of the n planets (but he must not run out in between two planets). There’s a huge cost to set up the spaceship for refuelling. Due to financial constraints (he’s not THAT rich), he can fill up his tank at most ktimes.
In order to save money and make his spaceship lighter, Milan is looking for the smallest possible fuel tank that enables him to complete his space travel and reach planet pn. What is the smallest tank capacity that enables him to do so?…
arrow_forward
Only 2nd quesstion
arrow_forward
solve with python language please
arrow_forward
Question no 01: Mr. Patrick is fond of reading books he is looking for a computerized way to keep record of hisbook collection, you have been given the responsibility to meet up his following requirements.(Use appropriate data structure to accomplish your task), develop following methods:1. Add(): adds a new book to the list ( A book contains name of the book, author name)NOTE: every new book will have access to its neighboring books (previous and next)2. Remove():in case any book is removed from the pile update your list 3. countBooks(): displays the total number of books 4. search(): returns true if the given book is present in the list else returns false 5. display(): shows the book collection
arrow_forward
Bus timetables specify to the second the exact arrival and departure time of each bus on each stop. You need to pay for the full fare of every bus you ride and different bus lines charge different fees , but they are flat fees (independent of distance travelled on the line)
A travel plan is a sequence of stop-time pairs where stop is a location of a bus stop and time is when we arrive at that stop. The plan is feasible if for any two consecutive pairs (a, t) and (b, t′) in the plan there exists a bus that departs after t and arrives at b at exactly t′. That is, a travel plan does not allow us to walk between stops. Assuming that no two buses arrive at the same time at the same stop, a feasible plan uniquely identifies the bus lines that we need to take to realize the plan. The cost of the plan is the sum of the fares we need to pay. Your task is to design an efficient algorithm that given a departure time t, an arrival time t′, an origin stop a and a destination stop b, finds the…
arrow_forward
Exercise # 2: Map search
For the location map search example explained in the Greedy best first search and A* algorithm, change the search algorithm to follow the uniform cost algorithm (UCS). Run the new code and compare the results of UCS versus Greedy & A*, in terms of the levels required and the number of nodes expanded.
IT HAS TO BE IN PYTHON LANGUAGE
arrow_forward
# Exercise 1. Implement the algorithm covered in lectures that determines if an integer n is prime. Your function should return True, if n is prime, and False otherwise. Your algorithm has to be effective for n ~ 1,000,000,000,000.def isPrime(n):
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
- Q 01: (Each containing 2*3=6) What is the Critical section problem? Write and explain Peterson solution for it.arrow_forwardSolve these questionsarrow_forwardHill cipher decryption: I must find the encryption key in order to decrypt a specific message. All i know is that the encryption key is 3x3 matrix and the specific message begins with the phrase "CONFIDENT". I must do this in python. I understand how to decrypt stuff once I have the key matrix. But I am confused as to how to find the key matrix in the first place with the information given.arrow_forward
- APAI1001 Assignment 1 (Due: Oct 18 (Friday), 23:59pm) Q1 Breath first search (Path Searching) Franklin Philips, a professor of the University of Los Santos (B5), is going to drive to Vice City (E3) to attend a conference today. The map of this region with district division is showed as follows. However, Prof. Philips woke up late in the morning and he must arrive at Vice City as soon as possible. Answer the following questions to help Prof. Philips finding the shortest path. (Adjacent districts are interconnected if and only if they are divided by dotted line). 5 4 3 2 1 A Los Santos B Vice City E Consider using breath first search (under the graph search framework) to find the shortest path. Note that each district on the map has at most 4 successors, and most locations have less than 4 successors due to road blocks and map boundaries. We consider a default left-bottom-right- top order of the successors (when adding them to the frontier). (a) [CiC] Write down the adjacency lists of…arrow_forwardCourse Title: Data Structures and Algorithms Please Correct Solve The Question Question : Part (a) Design an adjacency Matrix of the alphabets of your name is "MOEAD REHAN". In accordance with the following conditions: If your name has repeated characters (e.g. character E, 2 times) then you will consider only 1 time. If your Name contains both G and S, then there will be an edge between them and one additional edge from W to each if W is also in your name. If N is the alphabet in your name, it will have an edge to A and S if it available in your name. If P is available then it will have an edge with L if it is available. If there is a blank space in full Name then it will be represented by “_”, and it must have an edge with all alphabets. (Note: Place on in 1 for Edge and 0 for No Edge) Part (b) Sketch an undirected graph of the above designed adjacency matrix.arrow_forwardHorizontal sequence :VIRL Vertical sequence:MKF Scoring rules: g/o = -3, g/e = -1, match or mismatch - from PAM250 substitution matrix below. NW algorithm. 1. Complete the scoring matrix. Scoring matrix with PAM250 scores: V I R L M K F 2. Set up, initialize and complete the NW matrix. 3. Retrace, align and score alignment(s). Use the arrows and circles for the matrix and path(s). V I R L M K F Align and score all optimal alignments here. PLZ the arrows and circles for the matrix and path(s) AND SHOW ALL possible Alignmentarrow_forward
- Horizontal sequence :VIRL Vertical sequence:MKF Scoring rules: g/o = -3, g/e = -1, match or mismatch - from PAM250 substitution matrix below. NW algorithm. 1. Complete the scoring matrix. Scoring matrix with PAM250 scores: V I R L M K F 2. Set up, initialize and complete the NW matrix. 3. Retrace, align and score alignment(s). Use the arrows and circles for the matrix and path(s). V I R L M K F Align and score all optimal alignments here.arrow_forwardSolve using integer programmingarrow_forwardSubject - Design & Anal algorithms Please complete all the questions together. Use python code. Thank you in Advance. You are given two sorted arrays, array A of size n and array B of size m. Write pseudo-code for the Merge procedure that merges arrays A and B into a new sorted array C. You can assume C has been preallocated to have the right sizearrow_forward
- Self Grouping Programarrow_forwardRequired 2nd answerarrow_forwardlink to MINST code: https://www.dropbox.com/s/i21pedejv0sknnq/MINST.pdf?dl=0 1) Add a confusion matrix to the MNIST code example from the link provided. Set the epochs parameter to 5. Explain which entry of the matrix yields the number of ones (the number 1) that are falsely recognized as eights (the number 8). (If you use indices in your explanation, use the Python index notation, i.e., start at zero.) Run your code a few times. Is the confusion matrix always the same? Briefly explain.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