More General Flashcards
1
Q
What is a closure (Python)
A
Occur when there is a nested funciton present, the nested function references a value in the enclosing scope only, the outer function returns the nested function. Allows avoidance of global variables and hides data def make_multiplier_of(n): def multiplier(x): return x * n return multiplier
2
Q
Check for balanced parenthesis using Stack, Queue
A
https://www.geeksforgeeks.org/check-for-balanced-parentheses-in-python/
3
Q
Convert list to string in python
A
list1 = ['1', '2', '3'] str1 = ''.join(list1)
list1 = [1, 2, 3] str1 = ''.join(str(e) for e in list1)
4
Q
How much time does it take to retrieve an element in a Hashmap, Binary Tree, and a LinkedList
A
HashMap: O(1), Binary Tree: O(logn), LinkedList: O(n)
5
Q
What is the difference between Overridding and Overloading?
A
Overriding is resolved at runtime and Overloading at compile time
6
Q
What is the difference between forking a process and spawning a thread?
A
When forking a process the code is duplicated and run in
7
Q
What is polymorphism
A
Using the same interface for objects of different forms, data, functions, classes