i) find the minimum value in the data structure
ii) delete this value from the data structure
iii) insert some other value into the data structure
Consider each of the following data structures as a candidate for the above task. For each data structure, state the overall BIG-OH for myTask in terms of the average case and the worst case as a function of n, where n is the number of elements in the data structure. Do NOT guess: +2 points for correct answer, -2 points for incorrect answer, 0 points for no answer.
| myTask: Big-Oh | ||
| Average Case | Worst Case | |
| Unsorted Linked List | ||
| Sorted Linked List | ||
| Minheap (Priority Queue) | ||
| Binary Search Tree | ||
| Hash Table | ||
Semaphore A = 0; // initialization of semaphore
Semaphore B = 0;
Semaphore C = 0;
P0: P1:
while (true) { while (true) {
wait(C); signal(C);
signal(B); wait(B);
wait(A); signal(A);
} }
a) Use First-Come First-Serve (FCFS) scheduling.
|
|
|||||||||||
|
|
|
|||||||||||
|
int i = 2;
int f(int j){
return(i*j);
}
int g( int h(int) ){
int i = 3;
return h(i);
}
main(){
int j = g(f);
print(j);
}
a) Assuming static scoping, show the runtime stack when at its highest point. Include all important information. Also, what is the output of the program?
b) Assuming dynamic scoping, show the output of the program (do NOT show the runtime stack).
You may choose 3A or 3B, but not both.