Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Questions During the entry of vector data elements by the user, a ______ sty

ID: 3860533 • Letter: C

Question

C++ Questions

During the entry of vector data elements by the user, a ______ style loop is often used (since we don't yet know how many items there are). Once data is entered and we are processing the elements we know are there, the loop used is typically a ______ style loop. Given a vector which holds n data items, it should take at most (log_2 n/n/2/n^2) operations to place the data in order. Once the data is sorted, we should be able to search through the data in (log_2 n/n/2/n^2) average time. (Searching of sorted data is normally done with (linear/binary) search, after all.) If I had not sorted the data first, I would have had to search with (linear/binary) search, which would take (log_2 n/n/2/n^2) operations (on average).

Explanation / Answer

5. During the entry of vector data elements by the user, a while style loop is often used. Once data is entered and we are processing the elements we know are there, the loop used is typically a for style loop.

6. Given a vector which holds n data items, it should take atmost n^2 operations to place the data in order. Once the data is sorted, we should be able to search through the data in log2(n) average time. (Searching of sorted data is normally done with binary search). If I had not sorted the data first, I would have had to search with linear search, which would take n/2 operations (on average).

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote