Topmask拥有来自海外常青藤大学,清华,北大,中科院等计算机专业硕博士生,也有用在互联网深耕多年的程序猿大佬,随时方便提供帮助,尽可能为你解答专业领域的问题,包括CS作业代写,CS代考,作业讲解,代码调试,课程辅导等。
100%硕博原创
全球Top100名校+国内985/211毕业硕博生组成的1000+师资团队,拥有扎实的专业基础和丰富的项目经验,各类cs作业、cs考试难题皆能迎刃而解。
100%高分保障
TopMask的cs代写保证85+高分通过,代码能在本地正常运行,优质代码保障,无代码重复冗余等问题,让您的作业和考试高分顺利Pass!
24/7快速响应
微信客服与专业助教24/7无休在线,cs代写过程中的任何问题,随时反馈,及时解决;诚信服务,质量优先,代写结束后14天内均享受免费售后服务,未达到约定成绩100%原路退款。
1v1视频沟通学霸
我们支持与老师直接沟通cs代写需求,在周期较长的项目中,根据需求定期组织辅导与沟通,让您随时了解进度,反馈问题,保障任务顺利进行。
Programming COMP2521 90分代考案例
Question 1
An algorithm solves a problem of size nn recursively by breaking it down into two subproblems of size n/2n/2 with the same structure, until the size of a subproblem is one or zero. It takes O(1)O(1) time to solve a (sub)problem of size one or zero. It takes O(n)O(n) time to convert a problem of size nn into two subproblems and it takes O(n)O(n) time to combine the results of these subproblems into the result of the problem of size nn. What is the time complexity of this algorithm? Justify your answer.
Write your answer in q1.txt.
Submission
Submit via the give command
give cs2521 sample_exam_q1 q1.txt
Question 2
Consider the following algorithm, which converts a positive integer nn to its binary representation.
BinaryConversion:
Input positive integer n
Output binary representation of n on a stack
create empty stack S
while n > 0 do
push (n mod 2) onto S
n = floor(n / 2)
end while
return S
What is the time complexity of the algorithm? Assume that creating a stack and pushing an element onto a stack are both O(1)O(1) operations (i.e., constant). Justify your answer.
Write your answer in q2.txt.
Submission
Submit via the give command
give cs2521 sample_exam_q2 q2.txt
Question 3
Consider the the following 2-3-4 tree :
(a) What value(s) would be stored in the root node of the above 2-3-4 tree after the insertion of the value 8? What value(s) would be stored in the node that now contains 8? Note: if you need to promote a value, you must promote the smaller of the two middle values. Justify your answer.
(b) What value(s) would be stored in the root node of the above 2-3-4 tree after the insertion of the value 50? What value(s) would be stored in the node that now contains 50? Note: if you need to promote a value, you must promote the smaller of the two middle values. Justify your answer.
Write your answers in q3.txt.
Submission
Submit via the give command
give cs2521 sample_exam_q3 q3.txt
Question 4
Consider the following trie. Finishing nodes are shown in red.
a) How many words are stored in this trie?
(b) Which nodes would be visited in searching for “deeds”?
(c) What new nodes would be created if the word “bogus” was added to the trie? Justify your answer.
(d) What new nodes would be created if the word “do” was added to the trie? Justify your answer.
Write your answers in q4.txt.
Submission
Submit via the give command
give cs2521 sample_exam_q4 q4.txt
Question 5
(a) What is the difference between an Euler path and a Hamilton path?
(b) Does the graph below have any Euler paths? If so, give one of them. If not, explain why.
(c) Does the graph below have any Hamilton paths? If so, give one of them. If not, explain why.
Write your answers in q5.txt.
Submission
Submit via the give command
give cs2521 sample_exam_q5 q5.txt
Question 6
This question is about the array-based implementation of a max heap.
(a) Suppose the original state of the heap is:
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9]
— Q N H D K E — — —
Show the state of the heap after performing each of the following operations:
join(pq, S)
join(pq, P)
Note that the “join(pq, P)” operation should be performed on the state of the heap obtained after performing the “join(pq, S)” operation.
(b) Suppose the original state of the heap is:
[0] [1] [2] [3] [4] [5] [6] [7] [8] [9]
— Q N H D K E — — —
Show the state of the heap after performing each of the following operations. What are the values of it1 and it2?
it1 = leave(pq)
it2 = leave(pq)
Note that the “it2 = leave(pq)” operation should be performed on the state of the heap obtained after performing the “it1 = leave(pq)” operation.
Write your answers in q6.txt.
Submission
Submit via the give command
give cs2521 sample_exam_q6 q6.txt
Question 7
Consider a hash table of integer keys with 11 slots and a primary hash function of h(k)=k % 11h(k)=k % 11.
Consider the following sequence of values:
10, 12, 28, 35, 25, 32, 20, 17, 24, 39
(a) Suppose the hash table described above uses linear probing for collision resolution. Show the final contents of the hash table after the values above have been inserted into an initially empty table in the order given. Give the cost, in terms of the number of keys examined, when searching for the key value 6 in the resulting table.
(b) Suppose the hash table described above uses double hashing for collision resolution, with a secondary hash function of h2(k)=1+(k % 5)h2(k)=1+(k % 5). Show the final contents of the hash table after the values above have been inserted into an initially empty table in the order given. Give the cost, in terms of the number of keys examined, when searching for the key value 6 in the resulting table.
Write your answers in q7.txt.
Submission
Submit via the give commandgive cs2521 sample_exam_q7 q7.txt