Test
Data Structures
Crea una cuenta gratis para terminar este test
Guarda tu progreso y consulta tu resultado final.
¿Ya tienes cuenta? Inicia sesión
Preguntas del test (40)
1How do referenced types differ from primitive types?
- APrimitive types are integers.
- BReferenced types are strings.
- CPrimitive types use memory addresses.
- DReferenced types use pointers to addresses.
2Why do programmers use data structures rather than individual values?
- Afor reduced storage
- Bfor multiple data types
- Cfor ease of access
3Which data type only uses one bit per instance?
- AShort
- Bchar
- Cdouble
- Dboolean
4Which data type uses the most storage per value?
- Ashort
- Bint
- Clong
- Dfloat
5What is the output of the following JavaScript code?
var Salutations = [["Dear", "Hello", "Howdy"], ["Friend", "Judy", "Concerned", "Good Old Pal"]]
console.log(Salutations[1][1])- ADear
- BJudy
- CFriend
- DHello
6How many elements are there in a two-dimensional array with length (4,7)?
- A21
- B4
- C7
- D28
7What is the output of the following Swift code?
var noKeys = [5,4,7,8,10,22]
var noChains=noKeys.count
print(noChains)- A4
- B7
- C22
- D6
8Why is a linear search slow?
- AIt uses conditional statements.
- BIt tests every element.
- CIt copies the array.
9Why should you exercise restraint and care in the use of mutable arrays?
- AThe syntax for their use is extremely tedious and sensitive.
- BTheir use can slow down performance dramatically.
- CThe code may become difficult to translate to other languages.
10What is the output of the following C# code?
using System;
class Program
{
static void Main() {
int[ ][ ] jagged = new int[3][];
jagged[0]=new int[4];
jagged[1] = new int[2];
jagged[2]=new int[7];
Console.WriteLine(jagged[1][1]);
}}- A3
- B2
- C0
- D7
11What is the defining characteristic of a jagged, two-dimensional array?
- AThe length in the second dimension is variable.
- BThe elements consist of strings.
- CThe elements are of different data types.
- DThe size of the array is not fixed.
12What is the time complexity for a linear search if the value is not present?
- AO(ln(n))
- BO(n)
- CO(1)
- DO(n ln(n))
13How are data elements referenced in an array?
- Aby value
- Bwith an index or key
- Cwith a size or type
- Dby name
14What is returned by MyList.contains("Buy glue") if you are using java.util.LinkedList?
- Aa Boolean
- Ba string
- Can integer
15Where does the following Java code add a new element to a linked list?
Node nodeToAdd = new Node(data);
nodeToAdd.next = this.head;
this.head = nodeToAdd;- Aat the end of the list
- Bat the head of the list
- Cin the middle of the list
16What is the time complexity for insertion into a linked list?
- AO(ln(n))
- BO(1)
- CO(n)
17How does Python implement linked lists?
- Aas doubly linked lists
- Bas arrays
- Cas strings
18What is required to change a singly linked list to a doubly linked list?
- Aa two-dimensional array
- Bpointers to adjacent nodes
- Ca second head node and reverse pointers
- Da tail node and pointers to previous nodes
19You have just added a new element at the end of an existing linked list. What is in the pointer of that new element?
- Athe address of the first element in the list
- Ba null value
- Cthe address of the last element in the list
20What is contained in a node of a linked list?
- Aa value and an index
- Ba string and an integer
- Cdata and a pointer
- Dan array and a size
21How do queues differ from stacks?
- AQueues use FIFO and stacks use LIFO.
- BQueues use LIFO and stacks use FIFO.
- CQueues add and remove from the end of the list rather than from the beginning.
- DStacks add and remove from different ends of the list rather than from the same end.
22What is wrong with the following Java code?
import java.util.Stack;
public class MyClass {
public static void main(String args[]) {
Stack myStack = new Stack();
myStack.push("test");
myStack.pop();
myStack.pop();- AThere is a missing ;.
- BIt attempts to push to an empty stack.
- CThere is an extra {.
- DIt attempts to pop from an empty stack.
23The following Swift code uses the push and pop functions as in the example. What is the value of SecondPop?
var deck:Stack=Stack()
deck.push(item: "Queen: Spades")
deck.push(item "10: Diamonds")
deck.push(item: "4: Hearts")
deck.push(item: "2: Hearts")
var FirstPop = deck.pop()
var SecondPop= deck.pop()- A10: Diamonds
- BQueen: Spades
- C4: Hearts
- D2: Hearts
24In the Swift code func pop()-> String?, what does the question mark mean?
- AThe function may sometimes fail.
- BThe length of the string is unknown.
- CThe value returned is either a string or nil.
- DThe argument of the function is unknown.
25Which data structure is most useful for reversing an ordered state or list?
- Aa queue
- Ba stack
- Ca string
- Dan array
26What does LIFO stand for?
- Aleast important for order
- Blimit in free order
- Cleast in first on
- Dlast in first out
27How are items with the same priority dequeued from priority queues?
- Aby FIFO
- Bby LIFO
- Cby value
- Dby size
28The following Swift code uses the Queue class as in the example. What does the print() function output?
var yourQueue = Queue()
yourQueue.enqueue(item: "10")
yourQueue.enqueue(item: "5")
yourQueue.enqueue(item: "8")
var OutZero yourQueue.dequeue()
var OutOne = yourQueue.dequeue()
print(yourQueue.peek()!)- A10
- B8
- Cnil
- D5
29What does a peek() return from a queue?
- Athe first item
- Ban arbitrary item
- Cthe last item
- Dthe middle item
30Which language has the least support for hash functions and tables?
- APython
- BSwift
- CJavascript
- DJava
31Which line in the following Python 3 code produces a Key Error?
- ACapitalsToStates["Austin"] = "Texas"
- Bprint(CapitalsToStates["New York"])
- CCapitalsToStates = {}
- Dprint(CapitalsToStates["Austin"])
32Why would you use separate chaining?
- Ato increase access speed
- Bto resolve a collision
- Cto calculate a remainder
- Dto generate a small index
33When do hash tables suffer in performance?
- Awhen the keys are excessively long
- Bwhen there are collisions
- Cwhen the table is very large
34How does hashing differ from encrypting?
- AEncrypting is reversible, but hashing is not.
- BEncrypting produces plain text, but hashing produces integers.
- CHashing uses ASCII, and encrypting does not.
- DHashing produces unique values, but encrypting does not.
35Which statement is true for associative arrays?
- AValues must be ordered.
- BKeys must be unique.
- CValues must be unique.
- DKeys must be ordered.
36Which statement is true for a tree data structure?
- AA parent can have only two children.
- BLeaves can have many children.
- CThe root does not have a parent.
- DA node cannot be both a parent and a child.
37What does the following Python 3 code output?
pocketContents=set(["keys","coins","knife"])
pocketContents.add("receipt")
pocketContents.add("string")
print(pocketContents)- A{'receipt', 'coins', 'keys', 'string'}
- B{'receipt', 'coins', 'keys', 'string', 'knife'}
- C{'string', 'knife'}
- D{'receipt', 'coins', 'keys', 'knife'}
38Which list constitutes a valid set containing four elements?
- A{0, 5, 12, 0}
- B{"four", "twelve", 6, "four"}
- C{"dog", "cat", "dog", "car"}
- D{0, "dog", "car", 7}
39What characterizes a min heap?
- AThe children have values less than those of their parents.
- BThe value of the right child is less than that of the left.
- CThe root contains the largest value.
- DThe root contains the lowest value.
40Why are binary search trees organized with the left child less than the parent and the right child greater than the parent?
- Ato have more layers or branches
- Bto reduce storage requirements
- Cto use fewer pointers
- Dto make them easy to search
Información
- Descripción
- Software Development Computer Science Test sobre Data Structures, creado por Dustin White el 15/12/2021.
- Autor
- Dustin White
- Idioma
- English
- Visitas
- 21
- Etiquetas
- Valoración
- Aún sin valoraciones Valora este test