Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q17: Person A proudly shows off an implementation of a stack class with member functions size, empty, push, pop and top. Person B comments that

image text in transcribed
Q17: Person A proudly shows off an implementation of a stack class with member functions size, empty, push, pop and top. Person B comments that structure would greatly benefit from the addition of an iterator. A's best response suggestion is which? this is a nice start, but that the stack to 's (a) Disagree with B pointing out that an iterator would render the stack class pointless (b) Agree with B because more functionality is always better. Q18. What does the following code fragment compute for a given List mylst of integers? Assume that the list is not empty and elements are stored in ascending order of their values List#iterator Listcintsiiterator while (erue) - ayst.beg in ( ); -mylst.endo l 12 e if (il12) breaka 12) break if (?l-- i2) return il else return il2)/2: (a) The middle element of the vector. (b) The median value of the vector. (c) The average between the smallest and largest value in the vector. (d) This won't work Q19: When implementing an algorithm that necessitates frequent insertion and deletion of values into a data structure which is meant to maintain the sortedness of its values, which data structure will be the preferred choice in light of computational costs? (a) Plain array. (b) Vector data structure. (c) Linked list data structure. (d) Any of the above will do. Q20: The following statements are made about binary search for a target value in a vector data structure: (1) The cost of finding the target is Oflog N) on average, but it can be as high as o(w) (2) The number of elements in a vector must be odd for binary search to work. (3) Binary search needs the vector elements stored in sorted order. (4) Binary search works equally well on all types of linear data structures. True statements are (c) (3) and (4) (d) 3 only (b) (1), (3) and (4)

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

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

When measuring shelves, 7 inches (is, are) significant.

Answered: 1 week ago

Question

What is the median debt-to-income ratio?

Answered: 1 week ago

Question

What is the median loan amount?

Answered: 1 week ago