Question
Two trains 200 metres and 100 metres in length are
running towards each other on parallel tracks, one at the rate 50 km/hr and another at 40 km/hr. In how many seconds will they be clear of each other from the moment they meet?Solution
Required time = Sum of the lengths of trains / Relative speed Relative speed = 50 + 40 = 90 kmph = (90 × 5)/18 = 25 m/sec Required time = (200 + 100)/25 = 300/25 = 12 seconds
Recursive problems are implemented by
In Data Communication, what protocol is used to ensure reliable transmission of data over a network?
Which data structure is most suitable for implementing recursion?
Worst case is the worst case time complexity of Prim’s algorithm if adjacency matrix is used?
Which algorithm guarantees the shortest path in a graph with negative weights but no negative cycles?
Which graph traversal technique is commonly used for topological sorting?
The recurrence relation T(n) = 2T(n/2) + O(n) corresponds to which algorithm’s time complexity?
Output of below code
public class Prg {
public static void main(String args[]){
System.out.print("A" + "B" + 'A');
}
...The time complexity of the best case for QuickSort is:
Which sorting algorithm has an average-case time complexity of O(n log n) and is known for its efficiency, often using a divide-and-conquer approach?