BEST代写-线上编程学术专家

Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

Python代写|Comp9123 Assignment 1

Python代写|Comp9123 Assignment 1

这是一篇来自澳洲的关于解决一些算法运算问题的Python代写

 

This assignment isdue on March17 and should be submitted on Gradescope.All submitted work must bedone individuallywithout consulting someone else’s so-lutions in accordance with the University’s “Academic Dishonesty and Plagiarism”policies.

As a first step go to the last page and read the section: Advice on how to do theassignment.

Problem1.(10points)

UsingO-notation, upperbound the running time of the following algorithm, whereAis an array containingnintegers. You can assume that mod is a basic mathemat-ical operation that takesO(1) time.

1:functionalgorithm(A)

2:btrue

3:fori0; 2i<n;i++do

4:ifA[2i]mod 26=0then

5:bf alse

6:fori0; 2i<n1;i++do

7:ifA[2i+1]mod 26=1then

8:bf alse

9:returnb

Problem2.(25points)

We want to build a stack for integer elements that in addition to the operations wesaw during the lecture (push(e),pop(),top(),size(), andisEmpty()), also supportsagetMinimum() operation that returns the minimum value of all elements storedin the stack. All operations should run inO(1)time. Your data structure shouldtakeO(n)space, wherenis the number of elements currently stored in the datastructure.

Example execution:

push(23[23]

push(4[23,4]

getMinimum()  returns[23,4]

pop()  returns[23]

getMinimum()  returns23  [23]

Your task is to:

a)Design a data structure that supports the required operations in the requiredtime and space.

b)Briefly argue the correctness of your data structure and operations.

c)Analyse the running time of your operations and space of your data structure.

bestdaixie

评论已关闭。