Question: Code Analysis ( 2 0 pts ) Analyze the time complexity ( TC ) and space complexity ( SC ) for the WORST case for
Code Analysis pts
Analyze the time complexity TC and space complexity SC for the WORST case for your code listed below.
Hint: be careful when analyzing string functions.
The answers must be typed, not handwritten. Handwritten answers on paper or on digital will have a small penalty.
Use variable names:
W number of words in paragraph
number of words in search list
length of largest word
paragraph length
Even though constant maximum lengths are provided, your analysis should use the variables, P and L to show how the
program scales for longer words and paragraphs.
Copypaste YOUR code in the TC document and write next to each line its time complexity. For lines that are headers of
loops, mark the TC of each small component eg for init, condition and update for a forloop
Indirect insertion sort worst casepts
Your code:
Your tables:
Space Complexity:
Final TC worst case
Binary searching in indirectly sorted data one word and all words worst case pts
You code:
Your tables
Binary search one word: SC:
Final TC worst case
Binary search all words: SC:
Final TC worst case
Penalties:
pts penalty for answers handwritten instead of typed in the answers document including the tables
pts penalty for not including code in this document.
pts penalty if lines of code are not annotated with their TC in this document.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
