1. Drag and drop a function name to the appropriate algorithm below (in blank) :
ID: 3864610 • Letter: 1
Question
1. Drag and drop a function name to the appropriate algorithm below (in blank) :
Algorithm blank :
for j = n -1, n - 2, ..., i do
A[ j + 1 ] A[ j ]
A[ i ] e
n n + 1
Algorithm blank :
for j = i+1, i+2, ..., n-1 do
A[ j - 1 ] A[ j ]
n n - 1
A. insert(i, e) B. insert(i, e)
2. Drag and drop appropriate Big Oh to each operation of a vector with n elements realized by an array(blank), and its storage usage:
Space usage: blank
Operation Time
size() blank
empty() blank
at(i) blank
set(i,e) blank
insert(i,e) blank
erase(i,e) blank
A. O(1) B. O(n)
3.Drag and drop the corresponding step under each picture below(blank) in order to show the 3 steps to grow an extendable array.
blank:
blank
blank:
A. Copy elements from A to B
B. Reassign A to refer to the new array and delete the old array
C. Create a new array B
Explanation / Answer
for 1st questoin both A and B are same option. There is some problem i guess.
Algorithm blank :
for j = i+1, i+2, ..., n-1 do
A[ j - 1 ] A[ j ]
A[ i ] e
n n - 1
The above is correct code for inserting e at the ith position
2)
Space usage: blank
Operation Time
size() O(1)
empty() O(1)
at(i) O(1)
set(i,e) O(1)
insert(i,e) O(n)
erase(i,e) O(n)
3) for this question image is not visible
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.