EGR227 final practice cards

5.0(1)
Studied by 81 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/108

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 3:33 AM on 4/9/24
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

109 Terms

1
New cards

1) Which collision resolution technique places the item in another empty bucket?

a. Chaining

b. Open hashing

c. Open addressing

d. Closed addressing

c
2
New cards

2) A hash function uses an item's ___ to compute the item's bucket index.

a. bucket

b. key

c. function

d. location

b
3
New cards

3) What operation is used to compute a bucket index in the range 0 to 16 from a key?

a. key * 17

b. key - 17

c. key / 17

d. key % 17

d
4
New cards

4) Consider a hash table with items 10, 31, 23, 54, 66, 88, and 9, and a hash function of key % 10. Which of the following items will result in a collision if the numbers are inserted in order? 55, 46, 77, 99, 93, 92, 97

a. 55, 77, 99, 92

b. 55, 77, 92, 97

c. 46, 99, 93, 97

d. 46, 77, 99, 93

c

5
New cards

5) A 5-bucket hash table has the items 45, 56, and 67. The hash table's items will be positive integers. Which of the following is the correct way of representing the hash table?

a. 0, 45, 56, 67, 0

b. 45, 56, 67, 0, 0

c. -1, 45, 56, 67, 1

d. 45, 56, 67, -1, -1

d

6
New cards

6) Consider a hash table using chaining with 10 buckets and a hash function of key % 10. What would bucket 3โ€™s list be after the following operations? HashInsert(hashTable, item 12)

HashInsert(hashTable, item 23) HashInsert(hashTable, item 34) HashInsert(hashTable, item 45) HashInsert(hashTable, item 33) HashInsert(hashTable, item 31) HashInsert(hashTable, item 30)

a. 23, 33

b. 23, 30, 31, 33

c. 34, 33

d. 24, 33, 31, 30

a

7
New cards
<p>7) Consider the following hash table, and a hash function of key % 5. What would bucket 3โ€™s list be after the following operations? </p><p>HashRemove(hashTable, 25) HashRemove(hashTable, 48) HashInsert(hashTable, item 53)</p><p>a. 33, 53</p><p>b. 68, 33, 53</p><p>c. 68, 33, 48</p><p>d. 68, 33, 48, 53</p>

7) Consider the following hash table, and a hash function of key % 5. What would bucket 3โ€™s list be after the following operations?

HashRemove(hashTable, 25) HashRemove(hashTable, 48) HashInsert(hashTable, item 53)

a. 33, 53

b. 68, 33, 53

c. 68, 33, 48

d. 68, 33, 48, 53

b

8
New cards
<p>8) Consider the following hash table, and a hash function of key % 10. How many list items will be compared for the search operations? </p><p>HashInsert(newTable, item 25) HashInsert(newTable, item 54) HashRemove(newTable, 27) HashInsert(newTable, item 84) HashInsert(newTable, item 83) HashSearch(newTable, 72) HashSearch(newTable, 77) HashSearch(newTable, 63)</p><p>a. 2; 0; 2</p><p>b. 2; 0; 3</p><p>c. 1; 0; 3</p><p>d. 2; 0; 1</p>

8) Consider the following hash table, and a hash function of key % 10. How many list items will be compared for the search operations?

HashInsert(newTable, item 25) HashInsert(newTable, item 54) HashRemove(newTable, 27) HashInsert(newTable, item 84) HashInsert(newTable, item 83) HashSearch(newTable, 72) HashSearch(newTable, 77) HashSearch(newTable, 63)

a. 2; 0; 2

b. 2; 0; 3

c. 1; 0; 3

d. 2; 0; 1

d

9
New cards
<p>9) Given the following hash table, how many items are compared when searching for item 45 using the following search algorithm?</p><p> PICTURE NEEDED</p><p>a. 3 items: 25, 45 and 65</p><p>b. 4 items: 47, 28, 25, and 45</p><p>c. 2 items: 25 and 45</p><p>d. 1 item: only 45</p>

9) Given the following hash table, how many items are compared when searching for item 45 using the following search algorithm?

PICTURE NEEDED

a. 3 items: 25, 45 and 65

b. 4 items: 47, 28, 25, and 45

c. 2 items: 25 and 45

d. 1 item: only 45

c

10
New cards

10) Consider a hash table named marksTable that uses linear probing and a hash function of key % 5. What would be the location of the item 46?

HashInsert(marksTable, item 49) HashInsert(marksTable, item 41) HashInsert(marksTable, item 42) HashInsert(marksTable, item 44) HashInsert(marksTable, item 46)

a. Bucket 0

b. Bucket 1

c. Bucket 2

d. Bucket 3

d

11
New cards

11) Consider a hash table named numTable that uses linear probing and a hash function of key % 5. What is the status of bucket 4 after the following operations?

HashInsert(numTable, item 24) HashInsert(numTable, item 33) HashInsert(numTable, item 51) HashInsert(numTable, item 44) HashInsert(numTable, item 52) HashRemove(numTable, 44) HashInsert(numTable, item 50)

a. empty-since-start

b. empty-after-removal

c. occupied

d. removed from table

c

12
New cards

12) Consider a hash table named idTable that uses linear probing and a hash function of key % 10. What is printed after the following operations?

HashInsert(idTable, item 45) HashInsert(idTable, item 67) HashInsert(idTable, item 76) HashInsert(idTable, item 78) HashInsert(idTable, item 79) HashInsert(idTable, item 92) HashInsert(idTable, item 87)

Print HashSearch(idTable, 67) Print HashSearch(idTable, 77) Print HashSearch(idTable, 87)

a. 67, 87

b. 67, null, 87

c. 67, false, 87

d. true, false, true

b
13
New cards
<p>13) Which XXX completes the following algorithm?  PICTURE NEEDED</p><p>a. return hashTable[key]</p><p>b. return hashTable[bucket]</p><p>c. return bucket</p><p>d. return key</p>

13) Which XXX completes the following algorithm? PICTURE NEEDED

a. return hashTable[key]

b. return hashTable[bucket]

c. return bucket

d. return key

b

14
New cards

15) A hash table named numTable uses a hash function of key % 10 and quadratic probing with c1 = 1 and c2 = 2. Into which bucket is item 44 inserted?

HashInsert(numTable, item 1) HashInsert(numTable, item 12) HashInsert(numTable, item 23) HashInsert(numTable, item 34) HashInsert(numTable, item 44)

a. 5

b. 6

c. 7

d. 8

c
15
New cards

16) If (๐ป + ๐‘1 โˆ— ๐‘– + ๐‘2 โˆ— ๐‘– ! )\bmod(๐‘ก๐‘Ž๐‘๐‘™๐‘’๐‘ ๐‘–๐‘ง๐‘’) maps to an occupied bucket, then the itemโ€™s index (i) is incremented by _____.

a. 5

b. 1

c. 10

d. 2

b
16
New cards

17) Consider a hash table, a hash function of key % 10. Which of the following programmer-defined constants for quadratic probing cannot be used in a quadratic probing equation?

a. c1 = 1 and c2 = 0

b. c1 = 5 and c2 = 1

c. c1 = 1 and c2 = 5

d. c1 = 10 and c2 = 10

d
17
New cards
<p>18) Given the following table, where a hash function returns key % 11 and quadratic probing is used with c1 = 1 and c2 = 1, which values can be inserted sequentially without collision?  PICTURE NEEDED</p><p>a. 22, 33, 44</p><p>b. 23, 34, 45</p><p>c. 23, 35, 47</p><p>d. 22, 34, 45</p>

18) Given the following table, where a hash function returns key % 11 and quadratic probing is used with c1 = 1 and c2 = 1, which values can be inserted sequentially without collision? PICTURE NEEDED

a. 22, 33, 44

b. 23, 34, 45

c. 23, 35, 47

d. 22, 34, 45

c

18
New cards
<p>19) Which XXX completes the quadratic probing search function?</p><p> PICTURE NEEDED</p><p>a. bucket = (Hash(key) + c1 * c2 + i * i * i) / N</p><p>b. bucket = (Hash(key) + c1 + i + c2 / i * i) / N</p><p>c. bucket = (Hash(key) + c1 / i + c2 / i * i) % N</p><p>d. bucket = (Hash(key) + c1 * i + c2 * i * i) % N</p>

19) Which XXX completes the quadratic probing search function?

PICTURE NEEDED

a. bucket = (Hash(key) + c1 * c2 + i * i * i) / N

b. bucket = (Hash(key) + c1 + i + c2 / i * i) / N

c. bucket = (Hash(key) + c1 / i + c2 / i * i) % N

d. bucket = (Hash(key) + c1 * i + c2 * i * i) % N

d

19
New cards
<p>20) How many vertices are there in the graph? PICTURE NEEDED</p><p>a. 6 </p><p>b. 7 </p><p>c. 11 </p><p>d. 12</p>

20) How many vertices are there in the graph? PICTURE NEEDED

a. 6

b. 7

c. 11

d. 12

b

20
New cards
<p>21) How many edges are there in the graph? PICTURE NEEDED</p><p>a. 5 </p><p>b. 7 </p><p>c. 8 </p><p>d. 10</p>

21) How many edges are there in the graph? PICTURE NEEDED

a. 5

b. 7

c. 8

d. 10

b

21
New cards
<p>22) Identify the shortest path between vertices B and D. PICTURE NEEDED</p><p>a. x6, x3, x7 </p><p>b. x1, x5 </p><p>c. x2, x3, x4 </p><p>d. x7, x4</p>

22) Identify the shortest path between vertices B and D. PICTURE NEEDED

a. x6, x3, x7

b. x1, x5

c. x2, x3, x4

d. x7, x4

b

22
New cards
<p>23) Identify the adjacent pair of vertices.  PICTURE NEEDED</p><p>a. A and E</p><p>b. B and E</p><p>c. A and C</p><p>d. B and D</p>

23) Identify the adjacent pair of vertices. PICTURE NEEDED

a. A and E

b. B and E

c. A and C

d. B and D

b

23
New cards
<p>24) Which is a valid path between D and E?  PICTURE NEEDED</p><p>a. x11, x12, x9</p><p>b. x6, x7, x12</p><p>c. x5, x1, x3</p><p>d. x9, x12, x10</p>

24) Which is a valid path between D and E? PICTURE NEEDED

a. x11, x12, x9

b. x6, x7, x12

c. x5, x1, x3

d. x9, x12, x10

d

24
New cards
<p>25) In the following graph, which city is not directly connected to City 1?  PICTURE NEEDED</p><p>a. City 5</p><p>b. City 2</p><p>c. City 7</p><p>d. City 6</p>

25) In the following graph, which city is not directly connected to City 1? PICTURE NEEDED

a. City 5

b. City 2

c. City 7

d. City 6

c

25
New cards
<p>26) What is the shortest time taken to travel between A and G?  PICTURE NEEDED</p><p>a. 17 min</p><p>b. 14 min</p><p>c. 15 min</p><p>d. 16 min</p>

26) What is the shortest time taken to travel between A and G? PICTURE NEEDED

a. 17 min

b. 14 min

c. 15 min

d. 16 min

b

26
New cards
<p>27) Which cities are connected to City 6 directly?  PICTURE NEEDED</p><p>a. City 4, City 7, and City 1</p><p>b. City 4, City 3, and City 2</p><p>c. City 5, City 7, and City 1</p><p>d. City 4, City 7, and City 2</p>

27) Which cities are connected to City 6 directly? PICTURE NEEDED

a. City 4, City 7, and City 1

b. City 4, City 3, and City 2

c. City 5, City 7, and City 1

d. City 4, City 7, and City 2

a

27
New cards
<p>28) How many different paths from A to F take 15 minutes?  PICTURE NEEDED</p><p>a. 1</p><p>b. 2</p><p>c. 3</p><p>d. 4</p>

28) How many different paths from A to F take 15 minutes? PICTURE NEEDED

a. 1

b. 2

c. 3

d. 4

c

28
New cards
<p>29) Identify the vertices adjacent to C.  PICTURE NEEDED</p><p>a. B and E</p><p>b. D</p><p>c. B, D, and E</p><p>d. A, B, and E</p>

29) Identify the vertices adjacent to C. PICTURE NEEDED

a. B and E

b. D

c. B, D, and E

d. A, B, and E

c

29
New cards
<p>30) Which of the following best represents a sparse graph? PICTURE NEEDED</p>

30) Which of the following best represents a sparse graph? PICTURE NEEDED

b

30
New cards
<p>31) The following adjacency list represents the friendship between people. Identify the correct statement. PICTURE NEEDED</p><p>a. Harry is directly friends with Rody </p><p>b. Bob is directly friends with Hank </p><p>c. Hank can introduce Tim to Bob </p><p>d. Rita can introduce Bella to Tina</p>

31) The following adjacency list represents the friendship between people. Identify the correct statement. PICTURE NEEDED

a. Harry is directly friends with Rody

b. Bob is directly friends with Hank

c. Hank can introduce Tim to Bob

d. Rita can introduce Bella to Tina

a

31
New cards

32) Which of the following is the size of an adjacency list graph representation? V refers to the number of vertices, E the number of edges.

a. O(V + E)

b. O(V - E)

c. O(V * E)

d. O(V * 2E)

a
32
New cards
<p></p>

a

33
New cards
<p>34) Identify the vertices adjacent to C. PICTURE NEEDED</p><p>a. A and D </p><p>b. B and D </p><p>c. D and E </p><p>d. A and E</p>

34) Identify the vertices adjacent to C. PICTURE NEEDED

a. A and D

b. B and D

c. D and E

d. A and E

d

34
New cards
<p></p>

c

35
New cards
<p>36) Identify the graph for the given adjacency matrix. PICTURE NEEDED</p>

36) Identify the graph for the given adjacency matrix. PICTURE NEEDED

d

36
New cards
<p>37) Identify the breadth-first search traversal from vertex C.</p>

37) Identify the breadth-first search traversal from vertex C.

b

37
New cards
<p>38) In which order might vertices be visited when doing a breadth-first search that starts at D? PICTURE NEEDED</p><p>a. B, F, G, H </p><p>b. B, H, G, F </p><p>c. B, H, F, G</p><p>d. F, B, H, G</p>

38) In which order might vertices be visited when doing a breadth-first search that starts at D? PICTURE NEEDED

a. B, F, G, H

b. B, H, G, F

c. B, H, F, G

d. F, B, H, G

b

38
New cards
<p>39) If a breadth-first search starts at vertex E, the last vertex to be visited will be vertex _____. PICTURE NEEDED</p><p>a. A </p><p>b. B </p><p>c. C </p><p>d. D</p>

39) If a breadth-first search starts at vertex E, the last vertex to be visited will be vertex _____. PICTURE NEEDED

a. A

b. B

c. C

d. D

d

39
New cards
<p>40) Assuming that a breadth-first search starts at E, which vertices are in the frontierQueue after vertices E, G, and D have been visited? PICTURE NEEDED </p><p>a. E, G </p><p>b. A, C </p><p>c. A, C, G </p><p>d. A, C, E, G</p>

40) Assuming that a breadth-first search starts at E, which vertices are in the frontierQueue after vertices E, G, and D have been visited? PICTURE NEEDED

a. E, G

b. A, C

c. A, C, G

d. A, C, E, G

b

40
New cards
<p>41) Identify the DFS traversal of the graph if the starting vertex is B. PICTURE NEEDED</p><p>a. B, E, A, C, D </p><p>b. B, C, E, A, D </p><p>c. B, A, D, E, C </p><p>d. B, D, C, E, A</p>

41) Identify the DFS traversal of the graph if the starting vertex is B. PICTURE NEEDED

a. B, E, A, C, D

b. B, C, E, A, D

c. B, A, D, E, C

d. B, D, C, E, A

c

41
New cards
<p>42) A DFS traversal starting from vertex C will visit _____ last. PICTURE NEEDED</p><p>a. vertex A </p><p>b. vertex C </p><p>c. either vertex A or vertex D </p><p>d. either vertexA, vertex B, or vertex E</p>

42) A DFS traversal starting from vertex C will visit _____ last. PICTURE NEEDED

a. vertex A

b. vertex C

c. either vertex A or vertex D

d. either vertexA, vertex B, or vertex E

d

42
New cards
<p>43) Which statement would replace XXX in the given depth-first search traversal algorithm?</p><p>PICTURE NEEDED</p><p>a. Push adjV to stack</p><p>b. currentV = adjV</p><p>c. Pop adjV</p><p>d. Push adjV to visitedSet</p>

43) Which statement would replace XXX in the given depth-first search traversal algorithm?

PICTURE NEEDED

a. Push adjV to stack

b. currentV = adjV

c. Pop adjV

d. Push adjV to visitedSet

a

43
New cards
<p>44) Assuming A is the starting vertex for DFS and B is at the top of the stack after the first iteration of the while loop, which vertices are in the stack after the second iteration of the while loop? PICTURE NEEDED</p><p>a. A, E, C </p><p>b. A, C, D </p><p>c. A, C, E </p><p>d. A, D, E</p>

44) Assuming A is the starting vertex for DFS and B is at the top of the stack after the first iteration of the while loop, which vertices are in the stack after the second iteration of the while loop? PICTURE NEEDED

a. A, E, C

b. A, C, D

c. A, C, E

d. A, D, E

b

44
New cards
<p>45) Recursive DFS is run on the following graph. Assuming E is the starting vertex, which of the following is the call to the function? PICTURE NEEDED</p><p>a. RecursiveDFS(C) </p><p>b. RecursiveDFS(E) </p><p>c. RecursiveDFS(A) </p><p>d. RecursiveDFS(A, E)</p>

45) Recursive DFS is run on the following graph. Assuming E is the starting vertex, which of the following is the call to the function? PICTURE NEEDED

a. RecursiveDFS(C)

b. RecursiveDFS(E)

c. RecursiveDFS(A)

d. RecursiveDFS(A, E)

b

45
New cards
<p>46) Which array stores the following heap? PICTURE NEEDED</p><p>a. 9 6 7 5 4 3 1</p><p>b. 9 6 5 4 7 3 1</p><p>c. 1 3 4 5 6 7 9</p><p>d. 4 5 6 9 7 3 1</p>

46) Which array stores the following heap? PICTURE NEEDED

a. 9 6 7 5 4 3 1

b. 9 6 5 4 7 3 1

c. 1 3 4 5 6 7 9

d. 4 5 6 9 7 3 1

a

46
New cards
<p>47) What are the parent and child indices for node 7 in the following max-heap? PICTURE NEEDED</p><p>a. Parent index: 1; child indices: 6, 7 </p><p>b. Parent index: 0; child indices: 2, 3 </p><p>c. Parent index: 0; child indices: 5, 6 </p><p>d. Parent index: 0; child indices: 3, 4</p>

47) What are the parent and child indices for node 7 in the following max-heap? PICTURE NEEDED

a. Parent index: 1; child indices: 6, 7

b. Parent index: 0; child indices: 2, 3

c. Parent index: 0; child indices: 5, 6

d. Parent index: 0; child indices: 3, 4

c

47
New cards

48) Identify the correct definition of the MaxHeapPercolateUp() function.

a. MaxHeapPercolateUp(node, heapArray)

b. MaxHeapPercolateUp(node, Array)

c. MaxHeapPercolateUp(nodeIndex, heapArray)

d. MaxHeapPercolateUp(parentIndex, heapArray)

c
48
New cards
<p>49) Which XXX would replace the missing statement in the given MaxHeapPrecolateDown() function? </p><p>PICTURE NEEDED</p><p>a. for (i = 0; i &lt; 2 &amp;&amp; i + childIndex &gt; arraySize; i++) </p><p>b. for (i = 0; i &lt; 2 &amp;&amp; i + childIndex &lt; arraySize; i++) </p><p>c. for (i = 0; i &lt; 2 &amp;&amp; i + childIndex &gt; arraySize; i--) </p><p>d. for (i = 3; i &gt; 2 &amp;&amp; i + childIndex &lt; arraySize; i--)</p>

49) Which XXX would replace the missing statement in the given MaxHeapPrecolateDown() function?

PICTURE NEEDED

a. for (i = 0; i < 2 && i + childIndex > arraySize; i++)

b. for (i = 0; i < 2 && i + childIndex < arraySize; i++)

c. for (i = 0; i < 2 && i + childIndex > arraySize; i--)

d. for (i = 3; i > 2 && i + childIndex < arraySize; i--)

b

49
New cards

50) For a heap node with an index of 3 and a parent index of 1, identify the child node indices.

a. 1, 2

b. 0, 1

c. 5, 6

d. 7, 8

d
50
New cards
<p>51) Identify the binary tree that satisfies the max-heap property.  PICTURE NEEDED</p>

51) Identify the binary tree that satisfies the max-heap property. PICTURE NEEDED

c

51
New cards
<p>52) Identify the binary tree that satisfies the min-heap property.  PICTURE NEEDED</p>

52) Identify the binary tree that satisfies the min-heap property. PICTURE NEEDED

b

52
New cards
<p>53) Identify the binary tree that satisfies the max-heap property.  PICTURE NEEDED</p>

53) Identify the binary tree that satisfies the max-heap property. PICTURE NEEDED

a

53
New cards
<p>54) Identify the new binary max-heap after inserting 60 in the following max-heap.  PICTURE NEEDED</p>

54) Identify the new binary max-heap after inserting 60 in the following max-heap. PICTURE NEEDED

b

54
New cards

55) Identify the new priority queue after enqueueing 40.

26 36 42 54

a. 29 36 42 54 40

b. 40 29 36 42 54

c. 29 36 40 42 54

d. 29 36 42 40 54

c

55
New cards

56) Identify the number returned by the dequeue operation on the following priority queue.

21 36 45 54 60 73 90

a. 21

ย b.ย  36

ย c.ย  54

ย d.ย  90

a

56
New cards

57) Identify the number returned by the peek operation on the following priority queue.

1 3 4 5 6 7 9
a.ย  9

b.ย  5

c.ย  7

d. 1

d

57
New cards

58) What is the worst-case runtime complexity of a peek operation on a priority queue?

a. ๐‘‚(๐‘™๐‘œ๐‘”๐‘)

b. ๐‘‚(1)

c. ๐‘‚(๐‘)

d. ๐‘‚(๐‘๐‘™๐‘œ๐‘”๐‘)

b

58
New cards
<p>60) Is this an AVL tree? Justify your answer.  PICTURE NEEDED</p><p>a. Yes, as the tree is a binary search tree (BST) </p><p>b. Yes, as both the left and right subtrees have height 0 </p><p>c. No, as the tree is not a binary search tree (BST) </p><p>d. No, as both the left and right subtrees have height 0</p>

60) Is this an AVL tree? Justify your answer. PICTURE NEEDED

a. Yes, as the tree is a binary search tree (BST)

b. Yes, as both the left and right subtrees have height 0

c. No, as the tree is not a binary search tree (BST)

d. No, as both the left and right subtrees have height 0

c

59
New cards
<p>61) Identify the AVL tree.  PICTURE NEEDED</p>

61) Identify the AVL tree. PICTURE NEEDED

a

60
New cards

62) What is the minimum possible height of an AVL tree with the following nodes in order? 320, 470, 500, 540, 700, 650, 870

a. 1

b. 2

c. 3

d. 4

b

61
New cards

63) Identify the equation to calculate the balance factor, B, of an AVL tree node N.

a. ๐ต = ๐‘š๐‘–๐‘›(๐ป๐‘’๐‘–๐‘”โ„Ž๐‘ก(๐‘…๐‘–๐‘”โ„Ž๐‘ก๐‘†๐‘ข๐‘๐‘‡๐‘Ÿ๐‘’๐‘’(๐‘)), ๐ป๐‘’๐‘–๐‘”โ„Ž๐‘ก(๐ฟ๐‘’๐‘“๐‘ก๐‘†๐‘ข๐‘๐‘‡๐‘Ÿ๐‘’๐‘’(๐‘)))

b. ๐ต = ๐‘š๐‘Ž๐‘ฅ(๐ป๐‘’๐‘–๐‘”โ„Ž๐‘ก(๐‘…๐‘–๐‘”โ„Ž๐‘ก๐‘†๐‘ข๐‘๐‘‡๐‘Ÿ๐‘’๐‘’(๐‘)), ๐ป๐‘’๐‘–๐‘”โ„Ž๐‘ก(๐ฟ๐‘’๐‘“๐‘ก๐‘†๐‘ข๐‘๐‘‡๐‘Ÿ๐‘’๐‘’(๐‘)))

c. ๐ต = ๐ป๐‘’๐‘–๐‘”โ„Ž๐‘ก(๐ฟ๐‘’๐‘“๐‘ก๐‘†๐‘ข๐‘๐‘‡๐‘Ÿ๐‘’๐‘’(๐‘)) + ๐ป๐‘’๐‘–๐‘”โ„Ž๐‘ก(๐‘…๐‘–๐‘”โ„Ž๐‘ก๐‘†๐‘ข๐‘๐‘‡๐‘Ÿ๐‘’๐‘’(๐‘))

d. ๐ต = ๐ป๐‘’๐‘–๐‘”โ„Ž๐‘ก(๐ฟ๐‘’๐‘“๐‘ก๐‘†๐‘ข๐‘๐‘‡๐‘Ÿ๐‘’๐‘’(๐‘)) โˆ’ ๐ป๐‘’๐‘–๐‘”โ„Ž๐‘ก(๐‘…๐‘–๐‘”โ„Ž๐‘ก๐‘†๐‘ข๐‘๐‘‡๐‘Ÿ๐‘’๐‘’(๐‘))

d
62
New cards

64) Which is the worst-case height of AVL?

a. Less than or equal to 1.5 times compared to minimum binary tree height

b. Greater than or equal to 1.5 times compared to minimum binary tree height

c. Less than or equal to 1.5 times compared to maximum binary tree height

d. Greater than or equal to 1.5 times compared to maximum binary tree height

a

63
New cards
<p>65) Which is not a valid AVL tree due to being unbalanced?  PICTURE NEEDED</p>

65) Which is not a valid AVL tree due to being unbalanced? PICTURE NEEDED

a

64
New cards
<p>66) Identify the correct rotation to maintain the height balance of the AVL tree.  PICTURE NEEDED</p>

66) Identify the correct rotation to maintain the height balance of the AVL tree. PICTURE NEEDED

c

65
New cards
<p>67) Identify the correct rotation to maintain the height balance of the AVL tree.  PICTURE NEEDED</p>

67) Identify the correct rotation to maintain the height balance of the AVL tree. PICTURE NEEDED

a

66
New cards
<p>68) Which XXX would replace the missing statement in the following algorithm for updating the height of an AVL tree?  PICTURE NEEDED</p><p> a. nodeโ‡ขheight = max(leftHeight, rightHeight) + 2 </p><p>b. nodeโ‡ขheight = max(leftHeight, rightHeight) + 1 </p><p>c. nodeโ‡ขheight = max(leftHeight, rightHeight) </p><p>d. nodeโ‡ขheight = max(leftHeight, rightHeight) โ€“ 1</p>

68) Which XXX would replace the missing statement in the following algorithm for updating the height of an AVL tree? PICTURE NEEDED

a. nodeโ‡ขheight = max(leftHeight, rightHeight) + 2

b. nodeโ‡ขheight = max(leftHeight, rightHeight) + 1

c. nodeโ‡ขheight = max(leftHeight, rightHeight)

d. nodeโ‡ขheight = max(leftHeight, rightHeight) โ€“ 1

b

67
New cards
<p>69) Which XXX will complete the following partial algorithm for the right rotation of an AVL tree.  PICTURE NEEDED</p><p>a. AVLTreeSetChild(nodeโ‡ขright, "right", node) AVLTreeSetChild(node, "right", leftRightChild) </p><p>b. AVLTreeSetChild(nodeโ‡ขleft, "left", node) AVLTreeSetChild(node, "right", leftRightChild) </p><p>c. AVLTreeSetChild(nodeโ‡ขroot, "right", node) AVLTreeSetChild(nodeโ‡ขright, "right", leftRightChild) </p><p>d. AVLTreeSetChild(nodeโ‡ขleft, "right", node) AVLTreeSetChild(node, "left", leftRightChild)</p>

69) Which XXX will complete the following partial algorithm for the right rotation of an AVL tree. PICTURE NEEDED

a. AVLTreeSetChild(nodeโ‡ขright, "right", node) AVLTreeSetChild(node, "right", leftRightChild)

b. AVLTreeSetChild(nodeโ‡ขleft, "left", node) AVLTreeSetChild(node, "right", leftRightChild)

c. AVLTreeSetChild(nodeโ‡ขroot, "right", node) AVLTreeSetChild(nodeโ‡ขright, "right", leftRightChild)

d. AVLTreeSetChild(nodeโ‡ขleft, "right", node) AVLTreeSetChild(node, "left", leftRightChild)

d

68
New cards
<p>70) Identify the correct rotation to rebalance the given tree after the new node is inserted.  PICTURE NEEDED</p>

70) Identify the correct rotation to rebalance the given tree after the new node is inserted. PICTURE NEEDED

a

69
New cards
<p>71) Identify the balanced tree when 5, 7, 9, 11 are inserted in sequence to the given tree. PICTURE NEEDED</p>

71) Identify the balanced tree when 5, 7, 9, 11 are inserted in sequence to the given tree. PICTURE NEEDED

c

70
New cards
<p>73) Which XXX would replace the missing statement in the algorithm for inserting a new node in an empty AVL tree? </p><p> PICTURE NEEDED</p><p>a. if (nodeโ‡ขleft == null) </p><p>b. if (treeโ‡ขroot == null) </p><p>c. if (nodeโ‡ขleft != null) </p><p>d. if (treeโ‡ขroot != null)</p>

73) Which XXX would replace the missing statement in the algorithm for inserting a new node in an empty AVL tree?

PICTURE NEEDED

a. if (nodeโ‡ขleft == null)

b. if (treeโ‡ขroot == null)

c. if (nodeโ‡ขleft != null)

d. if (treeโ‡ขroot != null)

b

71
New cards

74) Which statement is true about the insertion of a new node in an AVL tree?

a. AVLTreeInsert updates heights on all child nodes before inserting the node

b. AVLTreeInsert updates heights on all child nodes after inserting the node

c. AVLTreeInsert updates heights on all ancestors before inserting the node

d. AVLTreeInsert updates heights on all ancestors after inserting the node

d
72
New cards
<p>75) Identify the rebalanced AVL tree after removing 60.  PICTURE NEEDED</p>

75) Identify the rebalanced AVL tree after removing 60. PICTURE NEEDED

d

73
New cards
<p>77) Identify the rebalanced AVL tree after the following operations: AVLTreeRemoveKey(tree, 20) AVLTreeRemoveKey(tree, 41) AVLTreeRemoveKey(tree, 67)  </p><p>PICTURE NEEDED</p>

77) Identify the rebalanced AVL tree after the following operations: AVLTreeRemoveKey(tree, 20) AVLTreeRemoveKey(tree, 41) AVLTreeRemoveKey(tree, 67)

PICTURE NEEDED

a

74
New cards
<p>79) In the AVLTreeRemoveNode algorithm, identify the correct statements that check and remove the root node with 1 or 0 children.  PICTURE NEEDED</p>

79) In the AVLTreeRemoveNode algorithm, identify the correct statements that check and remove the root node with 1 or 0 children. PICTURE NEEDED

d

75
New cards
<p>80) Identify which nodes are printed first and last. PICTURE NEEDED</p><p>a. F and D</p><p>b. F and C</p><p>c. F and A</p><p>d. F and S</p>

80) Identify which nodes are printed first and last. PICTURE NEEDED

a. F and D

b. F and C

c. F and A

d. F and S

a

76
New cards
<p>81) Which XXX completes the BST in order traversal algorithm? </p><p>a. BSTPrintInorder(node)</p><p>b. BSTPrintInorder(nodeโ‡ขleft)</p><p>c. BSTPrintInorder(nodeโ‡ขright)</p><p>d. BSTPrintInorder(null)</p>

81) Which XXX completes the BST in order traversal algorithm?

a. BSTPrintInorder(node)

b. BSTPrintInorder(nodeโ‡ขleft)

c. BSTPrintInorder(nodeโ‡ขright)

d. BSTPrintInorder(null)

b

77
New cards

83) What happens when a leaf node is removed?

a. The root node becomes null

b. The parent node becomes null

c. The parentโ€™s left or right child node becomes null

d. The internal node becomes null

c
78
New cards
<p>84) What is the tree when node 4 is removed?  PICTURE NEEDED</p>

84) What is the tree when node 4 is removed? PICTURE NEEDED

b

79
New cards
<p>85) What is the tree when node 300 is removed?  PICTURE NEEDED</p>

85) What is the tree when node 300 is removed? PICTURE NEEDED

c

80
New cards
<p>87) Where will a new node with key 5 be inserted into the following BST? </p><p>a. As 2's right child </p><p>b. As 4โ€™s left child </p><p>c. As 4's right child </p><p>d. As 7โ€™s left child</p>

87) Where will a new node with key 5 be inserted into the following BST?

a. As 2's right child

b. As 4โ€™s left child

c. As 4's right child

d. As 7โ€™s left child

c

81
New cards
<p>88) If a new node with key 50 is inserted into the following BST, what sequence of nodes is visited and where is the new node inserted? </p><p>a. 40, as 40's right child </p><p>b. 40 โ‡ข 80 โ‡ข 70, as 70โ€™s right child </p><p>c. 40 โ‡ข 80 โ‡ข 70 โ‡ข 60, as 60โ€™s left child </p><p>d. 40 โ‡ข 80 โ‡ข 70 โ‡ข 60, as 60โ€™s right child</p>

88) If a new node with key 50 is inserted into the following BST, what sequence of nodes is visited and where is the new node inserted?

a. 40, as 40's right child

b. 40 โ‡ข 80 โ‡ข 70, as 70โ€™s right child

c. 40 โ‡ข 80 โ‡ข 70 โ‡ข 60, as 60โ€™s left child

d. 40 โ‡ข 80 โ‡ข 70 โ‡ข 60, as 60โ€™s right child

c

82
New cards

89) The space complexity of a BST insertion algorithm is _____.

a. ๐‘‚(๐‘)

b. ๐‘‚(log ๐‘)

c. ๐‘‚(log ! ๐‘)

d. ๐‘‚(1)

d
83
New cards
<p>90) Which XXX completes the BST search algorithm?  PICTURE NEEDED</p><p>a. if (key &lt; curโ‡ขkey) </p><p>b. if (key &gt; curโ‡ขkey) </p><p>c. if (key &lt; curโ‡ขleftโ‡ขkey) </p><p>d. if (key &gt; curโ‡ขrightโ‡ขkey)</p>

90) Which XXX completes the BST search algorithm? PICTURE NEEDED

a. if (key < curโ‡ขkey)

b. if (key > curโ‡ขkey)

c. if (key < curโ‡ขleftโ‡ขkey)

d. if (key > curโ‡ขrightโ‡ขkey)

a

84
New cards
<p>91) What is the second node that is visited when searching for 7?  PICTURE NEEDED</p><p>a. 5 </p><p>b. 7 </p><p>c. 10 </p><p>d. 15</p>

91) What is the second node that is visited when searching for 7? PICTURE NEEDED

a. 5

b. 7

c. 10

d. 15

a

85
New cards
<p>93) If search key = 60, identify the sequence of nodes that are visited and the outcome. </p><p>a. 100 โ‡ข 70 โ‡ข 60 โ‡ข 60 </p><p>b. 100 โ‡ข 70 โ‡ข 60 </p><p>c. 100 โ‡ข 70 โ‡ข 60โ‡ข 60โ‡ข null </p><p>d. 100 โ‡ข 70 โ‡ข null</p>

93) If search key = 60, identify the sequence of nodes that are visited and the outcome.

a. 100 โ‡ข 70 โ‡ข 60 โ‡ข 60

b. 100 โ‡ข 70 โ‡ข 60

c. 100 โ‡ข 70 โ‡ข 60โ‡ข 60โ‡ข null

d. 100 โ‡ข 70 โ‡ข null

b

86
New cards
<p>94) What is the maximum number of loop iterations when searching for โ€œSโ€ in the BST below?  PICTURE NEEDED</p><p>a. 6 </p><p>b. 5 </p><p>c. 4 </p><p>d. 3</p>

94) What is the maximum number of loop iterations when searching for โ€œSโ€ in the BST below? PICTURE NEEDED

a. 6

b. 5

c. 4

d. 3

c

87
New cards
<p>95) Which of the following is a valid binary search tree? </p><p>PICTURE NEEDED</p>

95) Which of the following is a valid binary search tree?

PICTURE NEEDED

a

88
New cards
<p>97) Identify the sequence of nodes that are visited to search for 150.</p><p> PICTURE NEEDED </p><p>a. 250, 200, 190 </p><p>b. 250, 200, 190, 210 </p><p>c. 200, 190 </p><p>d. 190, 210, 290, 310</p>

97) Identify the sequence of nodes that are visited to search for 150.

PICTURE NEEDED

a. 250, 200, 190

b. 250, 200, 190, 210

c. 200, 190

d. 190, 210, 290, 310

a

89
New cards
<p>98) What is the largest number of comparisons for searching the following BST?  PICTURE NEEDED</p><p>a. 5 </p><p>b. 4 </p><p>c. 3</p><p>d. 1</p>

98) What is the largest number of comparisons for searching the following BST? PICTURE NEEDED

a. 5

b. 4

c. 3

d. 1

b

90
New cards
<p>99) What is the sequence of ordering for the nodes of the following BST?   PICTURE NEEDED</p><p>a. 190 โ‡ข 210 โ‡ข 200 โ‡ข 250 โ‡ข 300 โ‡ข 290 โ‡ข 310 </p><p>b. 190 โ‡ข 210 โ‡ข 290 โ‡ข 310 โ‡ข 200 โ‡ข 300 โ‡ข 250 </p><p>c. 250 โ‡ข 200 โ‡ข 300 โ‡ข 190 โ‡ข 210 โ‡ข 290 โ‡ข 310 </p><p>d. 190 โ‡ข 200 โ‡ข 210 โ‡ข 250 โ‡ข 290 โ‡ข 300 โ‡ข310</p>

99) What is the sequence of ordering for the nodes of the following BST? PICTURE NEEDED

a. 190 โ‡ข 210 โ‡ข 200 โ‡ข 250 โ‡ข 300 โ‡ข 290 โ‡ข 310

b. 190 โ‡ข 210 โ‡ข 290 โ‡ข 310 โ‡ข 200 โ‡ข 300 โ‡ข 250

c. 250 โ‡ข 200 โ‡ข 300 โ‡ข 190 โ‡ข 210 โ‡ข 290 โ‡ข 310

d. 190 โ‡ข 200 โ‡ข 210 โ‡ข 250 โ‡ข 290 โ‡ข 300 โ‡ข310

d

91
New cards
<p>100) What is the parent of the โ€œTheory.docโ€ node?  PICTURE NEEDED</p><p>a. Science </p><p>b. Mark </p><p>c. Students </p><p>d. Tom</p>

100) What is the parent of the โ€œTheory.docโ€ node? PICTURE NEEDED

a. Science

b. Mark

c. Students

d. Tom

a

92
New cards
<p>101) What is the depth of the โ€œPractical.jpgโ€ node?  PICTURE NEEDED</p><p>a. 1 </p><p>b. 2 </p><p>c. 3 </p><p>d. 4</p>

101) What is the depth of the โ€œPractical.jpgโ€ node? PICTURE NEEDED

a. 1

b. 2

c. 3

d. 4

c

93
New cards
<p>102) What type of node is โ€œEnglishโ€?  PICTURE NEEDED</p><p>a. Root </p><p>b. Parent </p><p>c. Internal node </p><p>d. Leaf</p>

102) What type of node is โ€œEnglishโ€? PICTURE NEEDED

a. Root

b. Parent

c. Internal node

d. Leaf

d

94
New cards

103) In a tree representing a file system, _____.

a. leaf nodes represent only empty directories

b. leaf nodes represent only non-empty directories

c. leaf nodes represent either files or empty directories

d. leaf nodes represent only files

c

95
New cards

104) Identify the correct statement about binary space partitioning.

a. Regions are always split down the middle either horizontal or vertical.

b. Half the objects are eliminated each level while traversing down a BSP tree.

c. BSP tree can be used to store all objects in a two-dimensional world.

d. In animation only one region is analyzed at a time.

c

96
New cards
<p>105) Which is an internal node?  PICTURE NEEDED</p><p>a. X </p><p>b. Y </p><p>c. P </p><p>d. Q</p>

105) Which is an internal node? PICTURE NEEDED

a. X

b. Y

c. P

d. Q

a

97
New cards
<p>106) Identify the ancestor(s) of node P. PICTURE NEEDED</p><p> a. X </p><p>b. X, A </p><p>c. X, Y </p><p>d. X, Y, A</p>

106) Identify the ancestor(s) of node P. PICTURE NEEDED

a. X

b. X, A

c. X, Y

d. X, Y, A

b

98
New cards
<p>107) Identify the depth of node Q.  PICTURE NEEDED</p><p>a. 0 </p><p>b. 1 </p><p>c. 2 </p><p>d. 3</p>

107) Identify the depth of node Q. PICTURE NEEDED

a. 0

b. 1

c. 2

d. 3

c

99
New cards
<p>108) Identify the type of the following binary tree.   PICTURE NEEDED</p><p>a. Not full, complete, not perfect </p><p>b. Full, not complete, not perfect </p><p>c. Full, complete, not perfect </p><p>d. Full, complete, perfect</p>

108) Identify the type of the following binary tree. PICTURE NEEDED

a. Not full, complete, not perfect

b. Full, not complete, not perfect

c. Full, complete, not perfect

d. Full, complete, perfect

b

100
New cards
<p>109) Identify the type of the following binary tree.  PICTURE NEEDED</p><p>a. Not full, complete, not perfect </p><p>b. Full, not complete, not perfect </p><p>c. Full, complete, not perfect </p><p>d. Full, complete, perfect</p>

109) Identify the type of the following binary tree. PICTURE NEEDED

a. Not full, complete, not perfect

b. Full, not complete, not perfect

c. Full, complete, not perfect

d. Full, complete, perfect

d