coding interview preparation coursera week 2 quiz answers
Knowledge check: Basic data structures
1. What does it mean to say a Data Structure is a first-class object?
- This means that a data structure can be passed to a function, returned as a result and generally treated like any other variable.
- They are not memory intensive.
- It is very quick at retrieving and storing data.
2. What does it mean to parse a string?
- To pass it to the compiler to execute instructions.
- To remove symbols and uppercases from a string of text.
- To remove items from a string not based on a given format.
3. How many bytes does it normally take to represent a standard int?
- 16
- 4
- 8
4. A Boolean answer is one that will be either true or false?
- True
- False
5. Is it possible to copy an array?
- No.
- Yes, but only through making a deep-copy.
- Yes, but only through making a shallow-copy.
Knowledge check: Collection data structures
6. You wish to store a list of grades for a class. Given the choice between a set and a list, which is the more appropriate data structure?
- List
- Set
- Either would do
7. In relation to data structures what does mutability mean?
- It means that it can be changed after it has been created.
- It means that once an object is created it cannot be changed.
- It relates to dynamic programming languages, and it can be passed as a variable to a function.
8. LIFO and FILO mean the same thing?
- True
- False
9. Creating a class through the use of a capital T as below: Stack, is an example of what?
- Generics
- Immutability
- Encapsulation
10. On what type of data structure would one do a depth first search?
- Stacks
- Lists
- Trees
Knowledge check: Advanced data structures
11. Given an array of 12 numbers -> 1,45,5,34,23,5,82,12,35,21,8,9
And a hashing function modulus 6. How many collisions would you expect to have in your table?
- 7
- 6
- 4
- 5
12. What data structure would be most suitable for mimicking the actions of a hashtable?
- Queue
- Dictionaries
- Stack
13. What value is stored at the root of a min_heap?
- The last inserted value
- The lowest value
- The highest value
14. Why is the travelling salesman used in graphs?
- Because the analogy of travelling can be related to the number of connected nodes.
- Because the distance between two nodes reflects distance in real life.
- Because graphs store information in a fixed way so that every node is the exact same distance apart. Allowing us apply travel times to it.
15. In relation to computer science what is a clique?
- It is a social group that one actively engages with.
- It is a subset of a graph that has found to have strong internal connections and weak external ones.
- It is a memory feature that allows for quick lookup of one’s social circle.
Module quiz: Introduction to data structures
16. What do TSV files use to separate their data?
- Tabs
- Types
- Topic
17. Arrays are always stored on the stack?
- Yes, but only through making a shallow-copy.
- Yes, but only through making a deep-copy.
- No
18. What happens when you try to retrieve a value using a number greater than the index size?
- It would return a warning and a message indicating the issue.
- It would throw an error.
- Nothing. There would be nothing to retrieve so it would return null.
19. In relation to computer science, what is a class?
- It is the thing from which arrays are build.
- It is a blueprint for an object.
- An object that has functionality.
20. In relation to objects, what are instance variables?
- Attributes that can take on many forms.
- Characteristics of the class.
- An attribute that has an immediate impact when compiled.
21. How many children can a node in a binary tree have?
- 4
- 2
- 1
22. Which of the following uses a FIFO approach.
- Queues
- Stacks
- Lists
23. In relation to data structures what does synchronization mean?
- Relates to a measured way of increasing the size of an object.
- It is something to do with swimming.
- Making a class thread safe.
24. Why do you need to implement a comparator when storing objects on a tree?
- As a means of comparing objects so the tree knows which node to store an object on.
- So that the compiler can know to keep the tree balanced by comparing a number of nodes.
- To ensure that values don’t clash when being added to a tree.
25. Why are heaps called heaps?
- The organization of their data is done in a very loose way, so it is said that the elements are heaped together.
- The order of importance is determined by where in the data structure the information is found.
- Because they store a selection of different data types.