Quiz 3

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

106. The efficiency of the Linked-List based remove function to remove at the end of the list is big-O of:

- 1

107. The efficiency of the Linked-List based remove function to remove from the beginning of the list is big-O of:

- 1

108. The efficiency of the Linked-List based Stack pop function is big-O of:

- 1

109. The efficiency of the Linked-List based Stack push function is big-O of:

- 1

110. The efficiency of the Linked-List based Stack top function is big-O of:

- 1

112. The efficiency of the Linked-List based view function to view at the beginning of the list is big-O of:

- 1

113. The efficiency of the Linked-List based view function to view at the end of the list is big-O of:

- 1

16. How many NULL pointers are there in a singly linked list with three elements?

- 1

99. The efficiency of the HashTable to insert in an empty or nearly empty table is big-O of:

- 1

24. In a linked list, how many Nodes are needed to store an item in the list?

- 1 item

31. In inserting 10 items into the list of hw5 through driver2, how many different pointers to MyRec elements are passed to List's insert method?

- 1 or 0, 1 pointer over and over so 0 different pointers (JUST NOT 10)

146. "Which is a better test case to test your calc of hw4: A. 1+2 B. 1+1 C. Neither one is better"

- 1+2

30. In inserting 10 items into the list of hw5 through driver1, how many different pointers to MyRec elements are passed to List's insert method?

- 10

15. How many NULL pointers are there in a doubly linked list with three elements?

- 2

18. If inserting into a Bully hash table, if Aldo is in the same location that Hasan wants, who gets the space?

- Hasan

19. If inserting into a Bully hash table, if Hasan is in the same location that Aldo wants, who gets the space?

- Hasan

125. What is the hashing term for the sum of the ASCII codes for the name of an object to insert in the table?

- Hash code

32. In our linked list of hw5, in what section of memory are all List objects allocated?

- Heap

45. "In your hw6 C++ Locate code, assuming ""element"" is the Base pointer parameter, write the code check if table[index] holds a matching item: if (________________________________________)"

- If(*element == *(table[index]))

51. Not considering validity checks or other error checking, write the one line of linked list based Stack code to implement Push assuming Pop removes from the END of the List.

- Insert(this_List, END)

52. Not considering validity checks or other error checking, write the one line of linked list based Stack code to implement Push assuming Pop removes from the FRONT of the List.

- Insert(this_list, FRONT)

38. In the algorithm discussed in class for inserting a Node after the parameter Node in insert_Node of hw5, the first two lines of code attached the Node to the List. What did the next two lines of code do?

- Integrate the node into the list

134. What is the word in English to describe the field of an object that is known regardless of whether the operation is lookup or insert?

- Key field

144. When using polymorphic generic containers, an object ___________ when inserted into a container.

- Loses its identity

100. The efficiency of the HashTable to lookup in a nearly full table is big-O of:

- N

102. The efficiency of the Linked-List based insert function to insert at a selected position in the list is big-O of:

- N

105. The efficiency of the Linked-List based remove function to remove at a selected position in the list is big-O of:

- N

111. The efficiency of the Linked-List based view function to view at a selected position in the list is big-O of:

- N

98. The efficiency of the HashTable to insert in a nearly full table is big-O of:

- N

48. Name of method of MyRec in hw5 that was not a constraint method?

- New_MyRec bc not called in List code

130. What is the one method of MyRec from hw5 that is not called polymorphically?

- New_myrec

53. Not considering validity checks or other error checking, write the one line of linked list based Stack code to implement Top assuming Push inserts at the END of the List.

- View(this_List, END)

54. Not considering validity checks or other error checking, write the one line of linked list based Stack code to implement Top assuming Push inserts at the FRONT of the List.

- View(this_List, FRONT)

36. In our linked list of hw5, the data is stored using _________.

- Void *

13. "For the void pointer parameter of MyRec methods of hw5, when will a MyRec pointer be passed to a MyRec method using that parameter: A. Always B. Never C. Sometimes"

- always

26. In a linked list, which direction does the pre pointer point?

- backward

123. What is the best word to describe the algorithm used by each method of the linked-list based Stack of hw5?

- delegate

126. What is the name of the design pattern used in hw5 when the linked-list based Stack was implemented via one line methods calling List methods to perform the underlying implementation?

- facade

25. In a linked list, which direction does the next pointer point?

- forward

135. When inserting a MyRec into the list of hw5 through driver1, where is that MyRec object in memory?

- heap

33. In our linked list of hw5, in what section of memory are all Nodes allocated?

- heap

34. In our linked list of hw5, in what section of memory are all objects stored in the list allocated?

- heap

28. In a typical database, which is the more common operation, insert or lookup?

- lookup

138. When the list of hw5 is working correctly, what differences does the user see when running driver1 and driver2?

- none

141. When using a non-circular doubly linked list, what is the value of the next pointer in the Node at the end of the list?

- null

142. When using a non-circular doubly linked list, what is the value of the pre pointer in the Node at the front of the list?

- null

143. When using a non-circular singly linked list, what is the value of the next pointer in the Node at the end of the list?

- null

131. What is the one word to best describe the number that represents the size of a HashTable?

- prime

122. What is the best one word to describe a list where all insertions occur at the end of the list and removals occur at the front of the list?

- queue

120. What is the best one word to describe a list where all insertions and removals occur at the end of the list?

- stack

121. What is the best one word to describe a list where all insertions and removals occur at the front of the list?

- stack

4. Considering a tiered or layered design, Node methods called _______ methods, and Node methods were called by _______ methods.

○ MyRec, List

3. Considering a tiered or layered design, List methods called _______ methods, and List methods were called by _______ methods.

○ NODE, Stack

10. Considering the main idea of a hash table, where is an item inserted?

○ Where it belongs

9. Considering the main idea of a hash table, where do you search for an item?

○ Where you expect to find it

42. In your HashTable of hw6, what is the formula for determining the increment step for an item?

- (Sum of ASCII % (table size - 1)) +1

44. In your HashTable of hw6, what is the formula for determining the next location for an item?

- (current loc + increment) % table size

46. "In your hw6 Locate code in C++, assuming ""element"" is the Base pointer parameter, write the code to determine the hash value: long hashValue = _________________;"

- (long) *element;

43. In your HashTable of hw6, what is the formula for determining the index of the first location for an item?

- (sum of ASCII % table size)

14. How many NULL pointers are there in a circular doubly linked list with three elements?

- 0

101. The efficiency of the HashTable to lookup in an empty or nearly empty table is big-O of:

- 1

103. The efficiency of the Linked-List based insert function to insert at the beginning of the list is big-O of:

- 1

104. The efficiency of the Linked-List based insert function to insert at the end of the list is big-O of:

- 1

128. What is the name of the first parameter to most Node methods of hw5?

- This node

129. What is the name of the first parameter to most Stack methods of hw5?

- This stack

133. What is the purpose of the MyRec object in hw5?

- To test the list

39. In the algorithm discussed in class for inserting a Node before the parameter Node in insert_Node of hw5, what did the first two lines of code do? The next two lines of code integrated the Node into the List?

- Attached the Node to the list

23. If searching for Gary in a Bully table, Hasan is in the location searched. From only that comparison, can you determine that Gary is in the table? A. Gary not there. B. Gary there. C. Can't determine.

- C

21. If searching for Gary in a Bully hash table, Julia is in the location searched. From only that comparison, can you determine that Gary is in the table? A. Gary not there. B. Gary there. C. Can't determine.

- Can't determine

118. What are the four specific manipulations possible on the items stored in our hw5 list?

- Copy, deallocate, isgreaterthan, write

117. What are the four constraint methods of MyRec in hw5?

- Copy, delete, write, isgreaterthan

41. In what three areas in the code for hw5 are the constraint methods determined?

- Copy_MyRec, delete_MyRec, write_MyRec DOUBLE CHECK THIS LATER

147. Which of the constraint methods of MyRec in hw5 was not found in both driver1 and driver2?

- Copy_func

119. What are the two ways that delete_Node can be called such that the data it holds won't be deleted?

- Data ptr null or try to delete data that's null

47. List the 5 layers of code for hw5 in order from outermost to innermost.

- Driver, stack, list, node, MyRec

29. In hw5, which of driver1 or driver2 uses a reusable MyRec object allocated on the Run-Time Stack?

- Driver2 (2 items: OG and reusable)

116. To implement a Stack container using the linked-list of hw5, items are inserted at the ______ of the list and are removed at the ______.

- End, end

59. T or F: Any object can be inserted in a polymorphic generic container without any restrictions placed on that object.

- F

63. T or F: If calling delete_Node from delete_List, the caller wants to delete the data but not the Node.

- F

64. T or F: If calling delete_Node from delete_List, the caller wants to delete the Node but not the data.

- F

68. T or F: Since the parameter to delete_MyRec is a void pointer, it will only deallocate the data but won't set the originating pointer to NULL.

- F

70. T or F: The calculator of hw4 is an example of a polymorphic generic container.

- F

72. T or F: The Bully algorithm is not an example of Ordered Hashing

- F

76. T or F: The MyRec of hw5 is an example of a polymorphic generic container.

- F

78. T or F: The UCSDStudent of hw6 is an example of a polymorphic generic container.

- F

79. T or F: The Variable of hw6 is an example of a polymorphic generic container.

- F

80. T or F: When called from the driver1 or driver 2 code in hw5, when a constraint method is called, it is called polymorphically.

- F

82. T or F: When delete_Node is called from remove_Node, it should delete both the Node and the data it holds.

- F

83. T or F: When delete_Node is called from remove_Node, it should delete only the data it holds, but not the Node.

- F

86. T or F: When drawing linked lists, an arrow that points to the bottom of the Node really points to the data field of that Node.

- F

87. T or F: When drawing linked lists, an arrow that points to the side of the Node really points to the middle field of that Node.

- F

91. T or F: When inserting into a doubly linked circular list, the code to insert at the front, end or anywhere in the list is achieved with three distinct sets of lines of code.

- F

92. T or F: When removing from a doubly linked circular list, the code to remove from the front, end or anywhere in the list is achieved through three distinct sets of lines of code.

- F

94. T or F: When using a polymorphic generic container, the container can manipulate objects only when knowing the types of those objects.

- F

96. T or F: When using the Bully hashing algorithm, an unsuccessful search ends either at an empty space or at an item later alphabetically than the current item.

- F

69. T or F: The array based Stack of hw3 is an example of a polymorphic generic container.

- F (Stack of longs)

55. T or F. The MyRec methods of hw5 have void pointer parameters so these methods can be called passing in objects of different types.

- False (conform to parameters expected, only ever pass in * MyRec)

27. In a test case of inserting 1 to 5 at the front and 6-10 at the end of the list, what is the best word to describe seeing the list displayed?

- Familiar (you can look at it and see if its 123.... vs 234872486592374), recognizeable

137. When Node's insert's Node pointer parameter is NULL, what does that imply about the item being inserted into the list in hw5?

- First one/only

115. To implement a Queue container using the linked-list of hw5, items are inserted at the ______ of the list and are removed at the ______.

- Front, end

37. In our linked list of hw5, the manipulations are achieved through ______.

- Function ptrs

20. If searching for Gary in a Bully hash table, Bora is in the location searched. From only that comparison, can you determine that Gary is in the table? A. Gary not there. B. Gary there. C. Can't determine.

- Gary isn't there, Gary > Bora so would have bumped Bora

22. If searching for Gary in a Bully hash table, null is in the location searched. From only that comparison, can you determine that Gary is in the table? A. Gary not there. B. Gary there. C. Can't determine.

- Not there

35. In our linked list of hw5, list the two conditions either one of which indicates that the list is empty.

- Occupancy = 0 or end ptr = null

139. When using a circular doubly linked list, what is the value of the next pointer in the Node at the end of the list?

- Point to beginning

124. What is the hashing term for the list of array indices used to search for a location for an item?

- Probe sequence

140. When using a circular doubly linked list, what is the value of the pre pointer in the Node at the front of the list?

- Pt to the end

136. When inserting a MyRec into the list of hw5 through driver2, where is that MyRec object in memory?

- RTS

145. When using polymorphic generic containers, an object ___________ when removed from the container.

- Regains it identity

49. Not considering validity checks or other error checking, write the one line of linked list based Stack code to implement Pop assuming Push inserts at the END of the List.

- Remove_List(this_List, END);

50. Not considering validity checks or other error checking, write the one line of linked list based Stack code to implement Pop assuming Push inserts at the FRONT of the List.

- Remove_List(this_list, FRONT)

114. The MyRec object structure definition of hw5 was created with what two design ideals mentioned in class?

- Simple and representative

17. If a user runs driver2, inserts 5 items, and when displayed, the last item inserted is displayed 5 times, what is the likely cause?

- Stored reusable obj as if it was a diff ptr every time (all ptrs to same reusable space even though have been changing the value stored in there), you stored the OG instead of a copy

56. T or F: A linked list is a container object made up of 0 or more Nodes.

- T

57. T or F: a struct in C defines an object containing only data fields and is similar to a class without methods in Java or C++.

- T

58. T or F: Any object can be inserted in a polymorphic generic container only when the object satisfies certain constraints.

- T

60. T or F: Hash Tables are often array based.

- T

61. T or F: Hash Tables sizes are often prime so that each space is reachable.

- T

62. T or F: If calling delete_Node from delete_List, the caller wants to delete both the Node and the data.

- T

65. T or F: In our linked list of hw5, the Node objects are all nameless allocated at locations in memory accessible only by starting with a named pointer.

- T

66. T or F: In your hash table code for hw6, the probe sequence is not stored but is instead the values of "index" as hashing loop executes.

- T

67. T or F: One arrow in the drawing of a linked list is achieved through one line of code in your program.

- T

73. T or F: The HashTable of hw6 is an example of a polymorphic generic container.

- T

74. T or F: The linked-list based Stack of hw5 is an example of a polymorphic generic container.

- T

75. T or F: The List of hw5 is an example of a polymorphic generic container.

- T

81. T or F: When called from the List or Node code in hw5, when a constraint method is called, it is called polymorphically.

- T

84. T or F: When delete_Node is called from remove_Node, it should delete the Node but not the data it holds.

- T

88. T or F: When drawing linked lists, an arrow that points to the top of the Node really points to the upper left corner of that Node.

- T

89. T or F: When inserting into a doubly linked circular list at the front or at the end of the list, insertion is done between the same two nodes.

- T

93. T or F: When removing from a doubly linked circular list, the code to remove from the front, end or anywhere in the list is achieved with the same lines of code.

- T

95. T or F: When using a polymorphic generic container, the container can manipulate objects without knowing the types of those objects.

- T

97. T or F: When using the Bully hashing algorithm, an unsuccessful search ends either at an empty space or at an item earlier alphabetically than the current item.

- T

77. T or F: The SymTab of hw6 is an example of a polymorphic generic container.

- T (derived class of HashTable, what calc uses)

90. T or F: When inserting into a doubly linked circular list, the code to insert at the front, end or anywhere in the list is achieved with the same lines of code.

- T (ideally)

71. T or F: The Bully algorithm is an example of Ordered Hashing

- T (there's some ordering to items that takes account when implement hashing)

85. T or F: When drawing linked lists, all arrows that point to any part of the same Node really point to the upper left corner of that Node.

- T (where drawing begins, address is the beginning of the allocation)

132. What is the purpose of the MyRec methods in hw5?

- Test the list, conform to the list

40. In using a polymorphic generic container, the container changes its behavior based on ___________

- The item it holds

127. What is the name of the first parameter to most List methods of hw5?

- This list

2. Assume a hash table size of 5, what is the probe sequence for an item with an original location of 3 and an increment of 3?

○ 3 and 3: sequence of 3 (+3 %5) 1 4 2 0

7. "Considering the line of code: this_node->data=(copy_func) ? (*copy_func) (element) : element; What was needed to store the item allocated by main?"

○ Copy func needs to be 0, just stores OG item

6. "Considering the line of code: this_node->data=(copy_func) ? (*copy_func) (element) : element; What was needed to store an item allocated by the List/Node?"

○ Copy func needs to be non 0

11. Describe the first lines of code in all constraint methods in hw5.

○ Declare ptr of real type then initialize to param sent in cast to real type

12. For the case of duplicate insertion in a hash table, how should the programmer decide how duplicates should be processed?

○ General case: look to the application to see what's appropriate; Our specific case: replace, usually means updated a variable but it depends on the program

8. "Considering the line of code: if (delete_func && (*npp)->data) (*delete_func) (&((*npp)->data)); List one condition that results in the data not being deleted."

○ If delete func = 0 or if data ptr is 0; need to know how to delete and where data is

1. Assume a hash table size of 5, what is the probe sequence for an item with an ASCII sum of 122?

○ Initial location: 122 % 5 = 5 2, inc (122 % 4) + 1 = 3 so sequence is 2 0 3 1 4

5. Considering a tiered or layered design, Stack methods called _______ methods, and Stack methods were called by _______ methods.

○ List, Driver


Set pelajaran terkait

Astronomy Ch. 7B: The Earth and Terrestrial Planets

View Set

Life And Health Insurance State Exam

View Set

bipedalism and traits of early hominins

View Set

Commercial Underwriting Principles Final Exam

View Set

Macroeconomics Chapter 12 questions/review #2

View Set