# CS代考：Final Exam FIT1008代考

## CS代写下单流程

Livia：北京大学硕士在读，从事机器学习和计算机视觉工作5年发表sci、ei论文3篇方向为机器学习、计算图形学、机器学习参与过诸多项目的开发熟悉c++、python、pytorch、opencv、SQL等，曾获”国科大杯”创新创业大赛分决赛三等奖。

Zera：香港大学电子电气工程学硕士毕业，熟悉汇编语言(C语言、C++、JAVA 等)和各种开发仿真软件（Matlab、Visual Studio、Sublime Text、Simulink 等），可以独立开发小型项目。

Noelle：清华大学数据科学硕士，目前已获得剑桥大学、加州大学洛杉矶分校、约翰霍普金斯大学等博士offer，申请经验丰富。发表顶级期刊、会议论文5篇，曾获清华大学校级一等奖学金。

Melody：获得香港大学(HKU)和新加坡南洋理工大学(NTU)全额奖学金博士录取；英语基础扎实，掌握R，python和SAS等多种统计分析语言，有pytorch环境下使用Linux处理大型数据集的经验。

Coloie：麻省理工毕业，掌握 Python, Java, C++, Rstudio, Stata 及Linux的基本操作，能独立开发小型项目。

## CS  Final Exam 代考案例

Q1 – Python to MIPS translation

func:

# save the \$fp and \$ra into the stack

addi \$sp, \$sp -8 ​ # make space in the stack for the two registers

sw \$ra, 4(\$sp) ​ # save \$ra onto stack

sw \$fp, 0(\$sp) ​ # save \$fp onto stack

addi \$fp, \$sp, 0 ​ # copy \$sp into \$fp

addi \$sp, \$sp, -4​ # make space for local var (result)

# if n< = 0

lw \$t0, 8(\$fp) ​ # load argument n

slt \$t0, \$0, \$t0 ​ # if 0 < n then \$t0 = 1

bne \$t0, \$0, else ​ # if \$t0 = 1 (i.e., n > 0) go to else

sw \$0, -4(\$fp)​ # result = 0

j endif # jump over else branch

else:

# compute n-1 and store it in \$t0

lw \$t0, 8(\$fp)

addi \$t0, \$t0, -1

# save the argument (n-1) in the stack

addi \$sp, \$sp, -4

sw \$t0, 0(\$sp)

jal func​ # call func with n-1 as argument

addi \$sp, \$sp, 4​ # remove argument

# result = 4*n + func(n-1)

lw \$t0, 8(\$fp) # load n into \$t0

sll \$t0, \$t0, 2 # 4*n shifting by 2

addi \$t0, \$t0, \$v0, ​ # 4*n + func(n-1)

sw \$t0, -4(\$fp) # store it in result

endif:

lw \$v0, -4(\$fp) # put result in \$v0

addi \$sp, \$sp, 4 ​ # remove local

lw \$fp, 0(\$sp) ​ # restore \$fp and \$ra

lw \$ra 4(\$sp)

addi \$sp, \$sp, 8

jr \$ra ​ #go back to the callee

Part 1.f

The iterative version will require exactly the same number of bytes (N) as the recursive

version, since the number of dynamic objects created during their executions (which are the

only ones stored by functions in the Heap) will not change.

For the MIPS code provided, N is 0, as nothing is created in the Heap.

Note that, in practice, Python would create objects for integers and will indeed use the Heap.

Part 1.h

The Stack for the iterative version of ​ func(n)​ will contain the argument ​ n​ (4 bytes), the saved

\$ra​ and ​ \$fp​ (4+4 bytes), and the local variable ​ result​ (4 bytes). This means a total of N = 16

bytes for the iterative version.

In the recursive version, the callee will call ​ func(n)​ which will then call itself n} times. And

each time it will take N (16 as we shown above) bytes. That means a total of (​n+1)​*N bytes.

Q2 – CS saves the world

Write the output of the function mystery for the input values:

1

1

2

3

1

4

What does the function mystery compute?

It computes the sum of the digits of x in base 2.

What is the time complexity of mystery, using the O() notation? Prove

O(log x). See solutions of Exercise 2 of tute 5.

Write the output of the function enigma for the input …

1

1

3

6

1

5

The subquestions below this line have been removed the exam (11 out of 20 marks). It was of the same difficulty of the digital root question (Exercise 6 of tute 5), which is a non-starred exercise. This was hard but doable, as the histogram shows. However, since there were other hard questions, this one was removed.

What does the function enigma compute?

It computes mystery(x) + mystery(mystery(x)) + …

What is the time complexity of enigma, using the O() …

The output of mystery(x) has size log(x).

Since enigma computes mystery(x) + mystery(mystery(x)) + …, it requires T(x) = log(x) +

log( log(x)) + … operations.

Since log(x) <=x/2, we have \log\log(x) <= log (x/2)<= x/4\$.

Hence T(x) <= x/2 + x/4 + … = x.

Computing enigma(x) is thus in O(x).

See solutions of Exercise 6 of tute 5.

What does enigma(4095) return? Justify your answer.

Observe that 4095 = 4096 – 1 = 2^{12} -1 = 2^{11} + 2^{10} + … + 2^0, hence mystery(4095)

returns 12.

Therefore enigma(4095) returns 12 + enigma(12).

mystery(12) returns 2, and mystery(2) returns 1.

Hence enigma(4095) returns 15

## Recent Case

### 盘点留学生常用5 种最佳笔记方法，哪一种适合您

SCI期刊论文的发表过程是一项复杂而细致的工作，涉

### 轻松掌握万能Essay模板，撰写一篇合格的英文论文

Python可谓是当下最火的编程语言，同时，Pyt