Questions from Test 1 and 2 for COSC

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/36

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

37 Terms

1
New cards

The contents of a queue can wrap around, while those in a stack cannot

Which of the following statements is true?

2
New cards

23

Suppose you push the values 12, 23, 45, 61, and 13 onto the stack in that order. Then you pop three items, and peek at the stack. What value do you see

3
New cards

False

True or False: A stack or a queue often serves as the underlying mechanism on which an array data type is based

4
New cards

A B / C D * -

What would A / B - C * D be when converted to postfix.

5
New cards

False

True or false: If there are N items, the bubble sort makes exactly NxN comparisons

6
New cards

a minimum key is repeatedly discovered

What happens in the selection sort?

7
New cards

Shift operations

Shifting a group of items left or right requires repeated _____

8
New cards

O(1)

Given the following segment of code what would the big O value be for running the segment?

Def avePos(a,b):

N = 0

total = 0

if(a > 0):

total += a

N += 1

if( b > 0):

total += B

N += 1

return N, total

9
New cards

24

What is the result of the following postfix: 2 4 + 8 2 / *

10
New cards

O(log (n))

Inserting an item into a priority queue takes what Big O time on average?

11
New cards

The lowest priority items are deleted first

The term priority in priority queue means that?

12
New cards

last in first out

What does LIFO mean?

13
New cards

Quicker to search

Ordered arrays, compared with unordered arrays are

14
New cards

O(N^4), O(N^2), O(N Log(N)), O(N), O(log(N)), O(1)

Slowest to fastest growth rates: O(N^2), O(N Log(N)), O(N), O(N^4), O(1), O(log(N))

15
New cards

9

What is the maximum number of items that must be examined to complete a binary search of an array of 300 elements?

16
New cards

False

True or false: Pushing and popping items for a stack and inserting and removing items from a queue all take O(N) time

17
New cards

O(N^2)

What is the big O for an algorithm who's running time is given by the function: T(N) = 35N + 4.5(N-1)+ 2N*N

18
New cards

True

True or False: When you delete an item from an unordered array, in most cases you shift other items to fill in the gap.

19
New cards

False

True or False: The bubble sort always ends up comparing every possible pair of items in the initial array

20
New cards

O(N^3)

Given the following segment of code what would the big O value be for running in the segment?

for i in range (N):

for j in range(N):

for k in range(N):

print(i + j + k)

21
New cards

constant

O(1) means that a process operates in _____________ time.

22
New cards

O(log(N))

Insertion and deletion in a binary search tree require what Big O time?

23
New cards

(3, 6, 12, 17)

Draw the binary search tree that is created from the sequence of keys:

10, 5, 15, 22, 3, 12, 17, 9, 6 for leaf notes

24
New cards

(10)

Draw the binary search tree that is created from the sequence of keys:

10, 5, 15, 22, 3, 12, 17, 9, 6 for root notes

25
New cards

(5, 9, 10, 15, 22, 5, 9, 15, 22)

Draw the binary search tree that is created from the sequence of keys:

10, 5, 15, 22, 3, 12, 17, 9, 6 for all internal nodes

26
New cards

not having to copy data when inserting or deleting items.

When compared with storing data in an array, the main benefit of storing it in a binary search tree is

27
New cards

defines the kinds of data that are represented and the operations that can be performed on them.

An abstract data type

28
New cards

first

Access to the links in a linked list is usually though the ___________ link.

29
New cards

Largest value - +

Smallest value - *

Blank #1 What node key has the largest value?

Blank #2 What node key has the smallest value?

<p>Blank #1 What node key has the largest value?</p><p>Blank #2 What node key has the smallest value?</p>
30
New cards

*%#$@=!+

What is the "in-order" traversal of this tree?

<p>What is the "in-order" traversal of this tree?</p>
31
New cards

=%*$#@+!

What is the "pre-order" traversal of this tree?

<p>What is the "pre-order" traversal of this tree?</p>
32
New cards

*#@$%!+=

What is the "post-order" traversal of this tree?

<p>What is the "post-order" traversal of this tree?</p>
33
New cards

can be implemented using recursive functions or generators.

Traversing tree data structures

34
New cards

fewer nodes than the main tree.

A subtree of a binary tree always has

35
New cards

every left child has a key less than its parent and every right child has a key greater than or equal to its parent.

A binary tree is a search tree if

36
New cards

to get the Nth item in a list, a program must follow N links, whereas in an array, the program can compute the position of the item from N.

Lists differ from arrays in that:

37
New cards

2

How many references must be set or changed to insert a link in the middle of a singly linked list?