Data Structures

Beschreibung

Software Development Computer Science Quiz am Data Structures, erstellt von Dustin White am 15/12/2021.
Dustin White
Quiz von Dustin White, aktualisiert more than 1 year ago
Dustin White
Erstellt von Dustin White vor mehr als 2 Jahre
10
0

Zusammenfassung der Ressource

Frage 1

Frage
How do referenced types differ from primitive types?
Antworten
  • Primitive types are integers.
  • Referenced types are strings.
  • Primitive types use memory addresses.
  • Referenced types use pointers to addresses.

Frage 2

Frage
Why do programmers use data structures rather than individual values?
Antworten
  • for reduced storage
  • for multiple data types
  • for ease of access

Frage 3

Frage
Which data type only uses one bit per instance?
Antworten
  • Short
  • char
  • double
  • boolean

Frage 4

Frage
Which data type uses the most storage per value?
Antworten
  • short
  • int
  • long
  • float

Frage 5

Frage
What is the output of the following JavaScript code? var Salutations = [["Dear", "Hello", "Howdy"], ["Friend", "Judy", "Concerned", "Good Old Pal"]] console.log(Salutations[1][1])
Antworten
  • Dear
  • Judy
  • Friend
  • Hello

Frage 6

Frage
How many elements are there in a two-dimensional array with length (4,7)?
Antworten
  • 21
  • 4
  • 7
  • 28

Frage 7

Frage
What is the output of the following Swift code? var noKeys = [5,4,7,8,10,22] var noChains=noKeys.count print(noChains)
Antworten
  • 4
  • 7
  • 22
  • 6

Frage 8

Frage
Why is a linear search slow?
Antworten
  • It uses conditional statements.
  • It tests every element.
  • It copies the array.

Frage 9

Frage
Why should you exercise restraint and care in the use of mutable arrays?
Antworten
  • The syntax for their use is extremely tedious and sensitive.
  • Their use can slow down performance dramatically.
  • The code may become difficult to translate to other languages.

Frage 10

Frage
What 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]); }}
Antworten
  • 3
  • 2
  • 0
  • 7

Frage 11

Frage
What is the defining characteristic of a jagged, two-dimensional array?
Antworten
  • The length in the second dimension is variable.
  • The elements consist of strings.
  • The elements are of different data types.
  • The size of the array is not fixed.

Frage 12

Frage
What is the time complexity for a linear search if the value is not present?
Antworten
  • O(ln(n))
  • O(n)
  • O(1)
  • O(n ln(n))

Frage 13

Frage
How are data elements referenced in an array?
Antworten
  • by value
  • with an index or key
  • with a size or type
  • by name

Frage 14

Frage
What is returned by MyList.contains("Buy glue") if you are using java.util.LinkedList?
Antworten
  • a Boolean
  • a string
  • an integer

Frage 15

Frage
Where 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;
Antworten
  • at the end of the list
  • at the head of the list
  • in the middle of the list

Frage 16

Frage
What is the time complexity for insertion into a linked list?
Antworten
  • O(ln(n))
  • O(1)
  • O(n)

Frage 17

Frage
How does Python implement linked lists?
Antworten
  • as doubly linked lists
  • as arrays
  • as strings

Frage 18

Frage
What is required to change a singly linked list to a doubly linked list?
Antworten
  • a two-dimensional array
  • pointers to adjacent nodes
  • a second head node and reverse pointers
  • a tail node and pointers to previous nodes

Frage 19

Frage
You have just added a new element at the end of an existing linked list. What is in the pointer of that new element?
Antworten
  • the address of the first element in the list
  • a null value
  • the address of the last element in the list

Frage 20

Frage
What is contained in a node of a linked list?
Antworten
  • a value and an index
  • a string and an integer
  • data and a pointer
  • an array and a size

Frage 21

Frage
How do queues differ from stacks?
Antworten
  • Queues use FIFO and stacks use LIFO.
  • Queues use LIFO and stacks use FIFO.
  • Queues add and remove from the end of the list rather than from the beginning.
  • Stacks add and remove from different ends of the list rather than from the same end.

Frage 22

Frage
What 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();
Antworten
  • There is a missing ;.
  • It attempts to push to an empty stack.
  • There is an extra {.
  • It attempts to pop from an empty stack.

Frage 23

Frage
The 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()
Antworten
  • 10: Diamonds
  • Queen: Spades
  • 4: Hearts
  • 2: Hearts

Frage 24

Frage
In the Swift code func pop()-> String?, what does the question mark mean?
Antworten
  • The function may sometimes fail.
  • The length of the string is unknown.
  • The value returned is either a string or nil.
  • The argument of the function is unknown.

Frage 25

Frage
Which data structure is most useful for reversing an ordered state or list?
Antworten
  • a queue
  • a stack
  • a string
  • an array

Frage 26

Frage
What does LIFO stand for?
Antworten
  • least important for order
  • limit in free order
  • least in first on
  • last in first out

Frage 27

Frage
How are items with the same priority dequeued from priority queues?
Antworten
  • by FIFO
  • by LIFO
  • by value
  • by size

Frage 28

Frage
The 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()!)
Antworten
  • 10
  • 8
  • nil
  • 5

Frage 29

Frage
What does a peek() return from a queue?
Antworten
  • the first item
  • an arbitrary item
  • the last item
  • the middle item

Frage 30

Frage
Which language has the least support for hash functions and tables?
Antworten
  • Python
  • Swift
  • Javascript
  • Java

Frage 31

Frage
Which line in the following Python 3 code produces a Key Error?
Antworten
  • CapitalsToStates["Austin"] = "Texas"
  • print(CapitalsToStates["New York"])
  • CapitalsToStates = {}
  • print(CapitalsToStates["Austin"])

Frage 32

Frage
Why would you use separate chaining?
Antworten
  • to increase access speed
  • to resolve a collision
  • to calculate a remainder
  • to generate a small index

Frage 33

Frage
When do hash tables suffer in performance?
Antworten
  • when the keys are excessively long
  • when there are collisions
  • when the table is very large

Frage 34

Frage
How does hashing differ from encrypting?
Antworten
  • Encrypting is reversible, but hashing is not.
  • Encrypting produces plain text, but hashing produces integers.
  • Hashing uses ASCII, and encrypting does not.
  • Hashing produces unique values, but encrypting does not.

Frage 35

Frage
Which statement is true for associative arrays?
Antworten
  • Values must be ordered.
  • Keys must be unique.
  • Values must be unique.
  • Keys must be ordered.

Frage 36

Frage
Which statement is true for a tree data structure?
Antworten
  • A parent can have only two children.
  • Leaves can have many children.
  • The root does not have a parent.
  • A node cannot be both a parent and a child.

Frage 37

Frage
What does the following Python 3 code output? pocketContents=set(["keys","coins","knife"]) pocketContents.add("receipt") pocketContents.add("string") print(pocketContents)
Antworten
  • {'receipt', 'coins', 'keys', 'string'}
  • {'receipt', 'coins', 'keys', 'string', 'knife'}
  • {'string', 'knife'}
  • {'receipt', 'coins', 'keys', 'knife'}

Frage 38

Frage
Which list constitutes a valid set containing four elements?
Antworten
  • {0, 5, 12, 0}
  • {"four", "twelve", 6, "four"}
  • {"dog", "cat", "dog", "car"}
  • {0, "dog", "car", 7}

Frage 39

Frage
What characterizes a min heap?
Antworten
  • The children have values less than those of their parents.
  • The value of the right child is less than that of the left.
  • The root contains the largest value.
  • The root contains the lowest value.

Frage 40

Frage
Why are binary search trees organized with the left child less than the parent and the right child greater than the parent?
Antworten
  • to have more layers or branches
  • to reduce storage requirements
  • to use fewer pointers
  • to make them easy to search
Zusammenfassung anzeigen Zusammenfassung ausblenden

ähnlicher Inhalt

Computing Hardware - CPU and Memory
ollietablet123
SFDC App Builder 2
Parker Webb-Mitchell
Data Types
Jacob Sedore
Intake7 BIM L1
Stanley Chia
Software Processes
Nurul Aiman Abdu
Design Patterns
Erica Solum
CCNA Answers – CCNA Exam
Abdul Demir
Abstraction
Shannon Anderson-Rush
Spyware
Sam2
HTTPS explained with Carrier Pigeons
Shannon Anderson-Rush
Data Analytics
anelvr