Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q 2 2 . 3 . 1 ) [ 2 points ] Consider the following C + + implementation to answer the next subquestions: void

Q22.3.1)[2 points] Consider the following C++ implementation to answer the next subquestions:
void insertElement (int new_element, int list_length, vector &vect){ int indx =0;
bool flag;
bool flag = false;
while ((indx list_length) && ! flag){
if (new element > vect [indx]){
indx++; }
else {
flag = true; }}
for (int i=list_length; i>indx; i--){
vect [i]
=
vect[i-1]; }
vect [indx]= new_element; }
}
Q22.1.- What does this function do?[1 point]
Q22.2.- What is the running time of the best case scenario in terms of big-O?[0.5 point]
Q22.3.- What is the running time of the worst case scenario in terms of big-O?[0.5 point]
Q22.4.- How can we improve the running time of this function in the worst case scenario? [1 bonus point]void insertElement(int new_element, int list_length, vector=0bar(+)++=
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Systems A 360-degree Approach

Authors: Jawwad ShamsiMuhammad Khojaye

1st Edition

0429531575, 9780429531576

More Books

Students also viewed these Databases questions