Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Answers to these please urgent!! I sent 1 8 questions i dont even know which is answered please help - - 1 - 4 Short
Answers to these please urgent!! I sent questions i dont even know which is answered please help Short Answer: Data Abstraction points
If you are given an interface for an ADT, but not an actual source le how well can you program
against itHint: there is a type of methods that cannot be specied in an interface. points
When it comes to performance not functionality is it important to know how an ADT is internally
implemented? points
Would it be safer more securereliable to expose an mutable or immutable type to an unknown rd
party library? Explain. points
Short Answer: Bags, Stacks and Queues points
Trace a stack called S through the following operations:
Stack S new Stack ;
S push new I n t e g e r ;
S push new I n t e g e r ;
I n t e g e r X S pop ;
S push new I n t e g e r ;
S push new I n t e g e r ;
I n t e g e r X S pop ;
I n t e g e r Y S peek ;
S push new I n t e g e r ;
I n t e g e r Z S pop ;
a Give the contents of the stack after this code has been executed. Indicate the elements in order
and label the top. points
b Give the contents of the stack after this code has been executed. Indicate the elements in order
and label the top. points
Trace a queue called Q through the following operations:
Queue Q new Queue ;
Q enqueue new I n t e g e r ;
I n t e g e r X Q dequeue ;
Q enqueue new I n t e g e r ;
Q enqueue new I n t e g e r ;
Q enqueue new I n t e g e r ;
I n t e g e r Y Q f i r s t ;
Q enqueue new I n t e g e r ;
I n t e g e r Z Q dequeue ;
a What is the value of Y after it has been assigned? points
b Give the contents of the queue after the code has been executed. Indicate the elements in order
and label the front. points
Short Answer: Analysis of Algorithms points
What are the BigOh orders of the following growth functions? You should provide a relatively tight
upper bound. points
fnlognnn
fn nlogn nlogn
Show that the upper bound you give for f above does indeed hold. points
Assume you have two algorithms A and B A is On and B is On Will the algorithm A always
run faster than algorithm B on realworld inputs? Explain. points
What is the BigOh order of the following code fragment? The fragment is parametrized on the variable
n Assume that you are measuring the number of println calls. points
f o r int i ; i Math pow n ; i
f o r int j ; j n ; j
System out p r i n t l n Nested l o o p s ;
Consider the following algorithm that implements selection sort:
public s t a t i c void s e l e c t i o n S o r t Comparable a
int N a l e n g t h ;
f o r int i ; i N; i
int min i ;
f o r int j i ; j N; j
i f l e s s a j a min min j ;
exch a i min ;
If you were choosing a cost metric ie what operation should be counted in order to determine this
algorithm's BigOh order, what operation would be the best choice? Explain. points
Short Answer: Elementary Sorts, Mergesort points
Embedded hardware with solid state storage eg EEPROM, ash has a limit number of writes during
its life cycle. Hence, one sorting algorithm design goal is to minimize the number of writes that are
made. Of the sorting algorithms discussed, which achieves that goal even in worse case? points
In terms of sorting quickly, would we ever want to use insertion sort On instead of mergesort
Onlogn points
Consider the following array: Show a trace of execution for topdown mergesort.
Illustrate how the array is broken down, and then merged into an ordered state. points
In the lower bound proof for sorting, why does a sorted input require fewer comparisons than an
unsorted one? Hint: think about how much you 'learn' from each comparison in both of those
cases. points
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started