i need to use Kotlin for a technical interview, ar...
# getting-started
o
i need to use Kotlin for a technical interview, are the basic datastructures like graph and queue easily usable?
s
it sounds like you shouldn’t use kotlin for this interview
😂 5
👆 2
@Ray Eldath did you paste that into the right thread?
o
i should probably ask them
😂 1
r
sorry for that.
👍 1
s
@oday you can build your own graph and queue structures in Kotlin just like in any other language
o
yea that’s what i was afraid of
versus python’s
graph = {}
graph['key'] = { items}
s
what?
🤣 1
r
hhhhhh
1
s
that’s a
dict
in python
otherwise known as a map
the utility function to quickly build maps is
mapOf()
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/map-of.html
but it sounds like you need more of a refresher on the basics rather than the stdlib
fwiw on JVM you do have access to the Java
LinkedList
for queues
o
yea i guess youre right
s
similarly, there’s also
setOf()
(https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/set-of.html) if you wanna use that for adjacency lists
though you might want a
mutableSetOf()
depending on how you’re building your graph
is what he says about the graph, the way to implement a graph?
s
sure. that is indeed one way of building a graph
it is conceptually the same as building a graph in python
o
b
It highly depend on the kind of graph you want to make
kind meaning: type (as in does your graph always contain the same type), size, (un)directed , (a)cyclic
and it will also depend on what you want to do with the graph
you can make simple graphs with just (data) classes
data class Node(val name: String) ; data class Edge(val from: Node, val to: Node, val properties: Map<String,String>)
and you have a property graph
now if you have a 10 billion nodes graph, this is probably a really bad idea 😉