Answer the following questions true (T) or false (F)

1. Insertion into a vector runtime is O(1) at any position in the vector. Explain what ‘runtime is O(1)’ means.

2. Insertion into an STL list takes O(1) time at any position in the list. What does ‘ takes O(1) time’ mean?


1. False
Explanation: Runtime is O(1) means there is an upper bound for the runtime that is independent of the size of the problem, which is the size of the vector in this case. Vector insertion is O(n) at any position in the vector except the back. Insertion is O(1) only for insertion at the back of the vector. For example, use of the push_back() member is O(1). There are other ways to insert most of which we do have not treated in the text, all of which are O(1) at the back.
2. True
Explanation: An STL list is a linked structure. Insertion at any position involves only a half-dozen or so assignments and a free store allocation. This is O(1), which means there is a fixed upper bound for the insertion time that is independent of the size of the list.

Computer Science & Information Technology

You might also like to view...

The ____________________ of the drag as you create a path line determines how much influence the anchor point will have over the curve.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

To display an ampersand character on a control, type _________ in its Text property.

a) &_ b) & c) && d) _&

Computer Science & Information Technology

Critical Thinking QuestionsCase 3-2Your new volunteer position is to work with middle school youth in the computer lab. The Volunteer Coordinator has asked if you would be available to answer student questions during today's lab session. Steve, Becky's lab neighbor, overhears your spelling-checking tip and complains that he always mistypes a common word causing PowerPoint to mark it as misspelled. He asks if there is any way to avoid dealing with this constantly mistyped word. You suggest that the next time he spell-checks a presentation containing the common word, he clicks the _____ button in the Spelling dialog box to have PowerPoint automatically correct the word as he types it. a. AutoCorrectc. Ignore Allb. Ignored. Add

What will be an ideal response?

Computer Science & Information Technology

Which kind of video technology do most laptop incorporate?

a. TFT Active Matrix b. Passive Matrix c. OLED d. TFT Passive Matrix

Computer Science & Information Technology