2. Consider the following lists a-["the", "system", "only", "dreams", "in", "total", "darkness"] b-[40, 111, 55, 200, 91, 63, 500] 16:35 · a. Convert these lists into a dictionary with 7 key/value pairs such that lists a and b indicate key and value for each pair, respectively. b. Sort the dictionary with respect to keys in descending order by utilizing methods and'or built-in Python functions. . Implement Merge Sort & Insertion Sort algorithms in Python as presented in the lecture. a. Modify these algorithms to sort any given list in descending order. Verify your code by executing modified algorithms for a-[3,7,6,1,9,2,4,5,8].

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Can u solve it using functions and please solve part 2 and 3 also, not only part 1.
1. Consider the following algorithm:
Input: list a consisting N elements
for i from 0 to len(a)
gencrate a random number x
if a[i]<x
display a[i] is greater than x
else
for j from 1 to 10
display j*100
a. Convert the pseudocode into a Python program that can work with any list. Try with a list
consisting of 20 elements.
Determine the time complexity of dhis algorithun via
b. calculating T(N) and converting into big O notation,
c. direct calculation with big O notation.
2. Consider the following lists
a=["the", "system", "only", “dreams", "in", “total", “darkness"]
b=[40, 111, 55, 200, 91, 63, 500]
16:35
a. Convert these lists into a dictionary with 7 key/value pairs such that lists a and b indicate
key and value for each pair, respectively.
b. Sort the dictionary with respect to keys in descending order by utilizing methods and/or
built-in Python functions.
3. Implement Merge Sort & Insertion Sort algorithms in Python as presented in the lecture.
a. Modify these algorithms to sort any given list in descending order. Verify your code by
executing modified algorithms for a=[3,7,6,1,9,2,4,5,8].
b. Generate a random list b consisting of 100000 numbers in which each number from 1 to
100000 occurs exactly once. For this list, calculate execution time for both sorting
algorithms developed in part a.
c. Extend part b such that the same algorithm is repeated 10 times with different random
lists of the same size. It should also calculate the average solution time for each sorting
algorithm over 10 executions.
d. Calculate execution time for both modified algorithms considering the following list
c=[1,2,3, ... , 99999, 100000]. Briefly comment on the difference between the results of
part b and part c for respective algorithms.
Note: Comment out every "print" in the code except the one that displays execution fime.
Transcribed Image Text:1. Consider the following algorithm: Input: list a consisting N elements for i from 0 to len(a) gencrate a random number x if a[i]<x display a[i] is greater than x else for j from 1 to 10 display j*100 a. Convert the pseudocode into a Python program that can work with any list. Try with a list consisting of 20 elements. Determine the time complexity of dhis algorithun via b. calculating T(N) and converting into big O notation, c. direct calculation with big O notation. 2. Consider the following lists a=["the", "system", "only", “dreams", "in", “total", “darkness"] b=[40, 111, 55, 200, 91, 63, 500] 16:35 a. Convert these lists into a dictionary with 7 key/value pairs such that lists a and b indicate key and value for each pair, respectively. b. Sort the dictionary with respect to keys in descending order by utilizing methods and/or built-in Python functions. 3. Implement Merge Sort & Insertion Sort algorithms in Python as presented in the lecture. a. Modify these algorithms to sort any given list in descending order. Verify your code by executing modified algorithms for a=[3,7,6,1,9,2,4,5,8]. b. Generate a random list b consisting of 100000 numbers in which each number from 1 to 100000 occurs exactly once. For this list, calculate execution time for both sorting algorithms developed in part a. c. Extend part b such that the same algorithm is repeated 10 times with different random lists of the same size. It should also calculate the average solution time for each sorting algorithm over 10 executions. d. Calculate execution time for both modified algorithms considering the following list c=[1,2,3, ... , 99999, 100000]. Briefly comment on the difference between the results of part b and part c for respective algorithms. Note: Comment out every "print" in the code except the one that displays execution fime.
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY