Test
Database Algorithm midterm
Este test tiene tipos de pregunta que se abren en el reproductor de siempre.
Preguntas del test (36)
1Data Encapsulation:
The separation of the representation of data from the applications that use the data at a logical level- AVerdadero
- BFalso
2Abstract data type (ADT)
A data type whose properties (domain and operations) are specified independently of any particular implementation- AVerdadero
- BFalso
3Data structure
A collection of data elements whose organization is characterized by accessing operations that are used to store and retrieve the individual data elements- AVerdadero
- BFalso
4[blank_start]ADT[blank_end] is a high-level description: the logical picture of the data and the operations that manipulate them.
[blank_start]Data Structure[blank_end] is concrete: a collection of data elements and the operations that store and retrieve individual elements.
ADT is implementation [blank_start]independent[blank_end], whereas a data structure is implementation [blank_start]dependent[blank_end].
A data structure is how we implement the data in an ADT whose values have component parts. The operations on an ADT are translated into algorithms on the data structure.- AADT
- BData Structure
- Cindependent
- Ddependent
5Composite data type
A data type that allows a collection of values to be associated with an object of that type
Composite data types come in two forms:
unstructured
structured.
An unstructured composite type is a collection of components that are not organized with respect to one another.
A structured data type is an organized collection of components in which the organization determines the method used to access individual data components.- AVerdadero
- BFalso
6[blank_start]Encapsulation[blank_end] This is the practice of keeping fields within a class private, then providing access to them via public methods
[blank_start]Inheritance[blank_end] It lets programmers create new classes that share some of the attributes of existing classes
[blank_start]Polymorphism[blank_end] This Java OOP concept lets programmers use the same word to mean different things in different contexts
[blank_start]method overriding[blank_end] when the different meanings are implied by the values of the supplied variables- AEncapsulation
- BInheritance
- CPolymorphism
- Dmethod overriding
7Stack
Visualize stack as a deck of cards. The current top card represents the current scope of the program, usually the function that is currently being execute
Last in First out- AVerdadero
- BFalso
8Heap/Queue
The heap is an area of memory that is completely independent of the current function or stack frame
The heap is less structured than the stack. You can think of it as just a pile of bits. Your program can add new bits to the pile at any time or modify bits that are already in the pi
First in First out- AVerdadero
- BFalso
9C++ allows you to mark a class as final, which means trying to inherit from it will result in a compiler error. A class can be marked as final with the final keyword right behind the name of the class
- AVerdadero
- BFalso
10AlgorithmarrayMax(A, n) # operations
currentMax←A[0] [blank_start]2[blank_end]
for i ← 1 to n − 1 do [blank_start]1 +n[blank_end]
if A[i] > currentMax then [blank_start]2(n−1)[blank_end]
currentMax ← A[i] 2(n−1)
{ increment counter i} 2(n−1)
return currentMax [blank_start]1[blank_end]
Total [blank_start]7n−2[blank_end]
Running time: [blank_start]O(n)[blank_end]- A2
- B1 + n
- C2(n−1)
- D1
- E7n−2
- FO(n)
11Linear ≈ n
Quadratic ≈ n^2
Cubic ≈ n^3- AVerdadero
- BFalso
123 n^3+ 20 n^2+ 5
3 n^3+ 20 n^2+ 5 is O(n^3)
need c > 0 and n 0 ≥ 1 such that 3 n^3 + 20 n^2 + 5 ≤ c• n^3 for n ≥ n 0
this is true for c = 4 and n0 = 21
*simple add 1 to constant factors- AVerdadero
- BFalso
13Algorithm prefixAverages1(X, n)
Input array X of n integers
Output array A of prefix averages of X
A ← new array of n integers
for i ← 0 to n−1 do
s ← X[0]
for j ← 1 to i do [blank_start]1 + 2 + ...+(n−1)[blank_end]
s ← s + X[j]
A[i] ← s / (i+1)
return A
Running Time: [blank_start]O(n^2)[blank_end]- AO(n^2)
- BO(n)
- CO(n^3)
- D1 + 2 + ...+(n−1)
14[blank_start]push(object)[blank_end]: inserts an element
[blank_start]object pop()[blank_end]: removes and returns the last inserted element
[blank_start]object top()[blank_end]: returns the last inserted element without removing it- Apush(object)
- Bobject pop()
- Cobject top()
15Review this lecture for stack using array implementation:
https://slate.sheridancollege.ca/d2l/le/content/563008/viewContent/7718650/View- AVerdadero
- BFalso
16[blank_start]enqueue(object)[blank_end]: inserts an element at the end of the queue
[blank_start]dequeue()[blank_end]: removes and returns the element at the front of the queue
[blank_start]object front()[blank_end]: returns the element at the front without removing it- Aenqueue(object)
- Bdequeue()
- Cobject front()
17The Vector ADT (similar to Queue ADT) extends the notion of array by storing a sequence of arbitrary objects
An element can be accessed, inserted or removed by specifying its index- AVerdadero
- BFalso
18Review Queue using array based implementation:
https://slate.sheridancollege.ca/d2l/le/content/563008/viewContent/7737114/View- AVerdadero
- BFalso
19A singly linked list is a concrete data structure consisting of a sequence of nodes
Usually made as a struct
Each node stores:
element
link to the next node
struct node {
int value
node* next
}- AVerdadero
- BFalso
20The List ADT models a sequence of positions storing arbitrary objects
It establishes a before/after relation between positions- AVerdadero
- BFalso
21A doubly linked list provides a natural implementation of the List ADT
Nodes implement Position and store:
element
link to the previous node
link to the next node
created as a struct- AVerdadero
- BFalso
22A tree consists of nodes with a parent-child relation
[blank_start]Root[blank_end]: node without parent (A)
[blank_start]Internal[blank_end] node: node with at least one child
[blank_start]External[blank_end] node: node without children
[blank_start]Depth of a node[blank_end]: number of parents
[blank_start]Height of a tree[blank_end]: maximum depth of any node- ARoot
- BInternal
- CExternal
- DDepth of a node
- EHeight of a tree
23Traversal of tree
visits the nodes of a tree in a systematic manner
a node is visited before its descendants
What order type is this:
- Apreorder
24a node is visited after its descendants
what order type is this:
- Apostorder
25 A node is visited after its left subtree and before its right subtree
what order type is this?
- Ainorder
26A priority queue stores a collection of items
An item is a pair(key, element)
[blank_start]insertItem(k, o)[blank_end] inserts an item with key k and element o
[blank_start]removeMin()[blank_end] removes the item with smallest key and returns its element
[blank_start]minKey()[blank_end] returns, but does not remove, the smallest key of an item
[blank_start]minElement()[blank_end] returns, but does not remove, the element of an item with smallest key- AinsertItem(k, o)
- BremoveMin()
- CminKey()
- DminElement()
27review lecture on different priority queue sorting:
https://slate.sheridancollege.ca/d2l/le/content/563008/viewContent/7772392/View- AVerdadero
- BFalso
28Method insertItem of the priority queue ADT corresponds to the insertion of a key k to the heap
The insertion algorithm consists of three steps:
Find the insertion node z (the new last node)
Store k at z and expand z into an internal node
Restore the heap-order property- AVerdadero
- BFalso
29Upheap: (done after an insert node)
restores the heap-order property by swapping k along an upward path from the insertion node
terminates when the key k reaches the root or a node whose parent has a key smaller than or equal to k- AVerdadero
- BFalso
30remove from a heap:
removeMin of the priority queue ADT corresponds to the removal of the root key from the heap
The removal algorithm consists of three steps:
Replace the root key with the key of the last node w
Compress wand its children into a leaf
Restore the heap-order property- AVerdadero
- BFalso
31Downheap (done after removing a node or replacing the root key):
restores the heap-order property by swapping key k along a downward path from the root
terminates when key k reaches a leaf or a node whose children have keys greater than or equal to k- AVerdadero
- BFalso
32The dictionary ADT models a searchable collection of key-element items
The main operations of a dictionary are searching, inserting, and deleting items
Multiple items with the same key are allowed- AVerdadero
- BFalso
33In hash tables:
Collisions occur when different elements are mapped to the same cell
can be fixed by increasing prime number- AVerdadero
- BFalso
34review lecture on hash tables and practice allocating keys based on prime number given:
https://slate.sheridancollege.ca/d2l/le/content/563008/viewContent/7784971/View- AVerdadero
- BFalso
35Binary search performs operation findElement(k) on a dictionary implemented by means of an array-based sequence, sorted by key
similar to the high-low game
at each step, the number of candidate items is halved
terminates after O(log n) steps- AVerdadero
- BFalso
36review this lecture on binary tree searching/deleting/inserting:
https://slate.sheridancollege.ca/d2l/le/content/563008/viewContent/7789913/View- AVerdadero
- BFalso
Información
- Descripción
- Computer Science Test sobre Database Algorithm midterm, creado por Duncan Levings el 19/02/2019.
- Autor
- Duncan Levings
- Idioma
- English
- Visitas
- 2
- Etiquetas
- Valoración
- Aún sin valoraciones Valora este test