Language Specific Flashcards

Concepts and facts specific to a languages - Java & C#

1
Q

Stack Methods

A

Stack (Java)

  • push(E item)
  • pop()
  • empty()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Queue Methods

A

Queue (Interface) (Java)

In order to instantiate an object use a concrete class like ArrayDequeue/ LinkedList

offer(e) : Add an element , returns true else false
poll() : remove the head of the queue
clone() : perform a shallow copy of the entire queue

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Pair class in Java

A

the format is Pair

String toString() : This method will return the String representation of the Pair.
K getKey() : It returns key for the pair.
V getValue() : It returns value for the pair.
int hashCode() : Generate a hash code for the Pair.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Data structure to identify the min entry in a list. For eg. in the meeting room problem, when we have to identify the meeting room that is available, in other words, the meeting end time is the least

A

Priority Queue or Min Heap [Java]
SortedList [C#]

For Meeting room problem - if the room we extracted from the top of the min heap isn’t free, then no other room is. So, we can save time here and simply allocate a new room.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly