title-img


Java Sort

You are given a list of student information: ID, FirstName, and CGPA. Your task is to rearrange them according to their CGPA in decreasing order. If two student have the same CGPA, then arrange them according to their first name in alphabetical order. If those two students also have the same first name, then order them according to their ID. No two students have the same ID. Hint: You can use comparators to sort a list of objects. See the oracle docs to learn about comparators. Input Forma

View Solution →

Java Dequeue

In computer science, a double-ended queue (dequeue, often abbreviated to deque, pronounced deck) is an abstract data type that generalizes a queue, for which elements can be added to or removed from either the front (head) or back (tail). Deque interfaces can be implemented using various types of collections such as LinkedList or ArrayDeque classes. For example, deque can be declared as: Deque deque = new LinkedList<>(); or Deque deque = new ArrayDeque<>(); You can find mo

View Solution →

Java BitSet

Java's BitSet class implements a vector of bit values (i.e.: false (0) or true (1)) that grows as needed, allowing us to easily manipulate bits while optimizing space (when compared to other collections). Any element having a bit value of 1 is called a set bit. Given 2 BitSets, B1 and B2, of size N where all bits in both BitSets are initialized to 0, perform a series of M operations. After each operation, print the number of set bits in the respective BitSets as two space-separated integers on

View Solution →

Java Priority Queue

In computer science, a priority queue is an abstract data type which is like a regular queue, but where additionally each element has a "priority" associated with it. In a priority queue, an element with high priority is served before an element with low priority. - Wikipedia In this problem we will test your knowledge on Java Priority Queue. There are a number of students in a school who wait to be served. Two types of events, ENTER and SERVED, can take place which are described below.

View Solution →

Java Inheritance I

Using inheritance, one class can acquire the properties of others. Consider the following Animal class: class Animal{ void walk(){ System.out.println("I am walking"); } } This class has only one method, walk. Next, we want to create a Bird class that also has a fly method. We do this using extends keyword: class Bird extends Animal { void fly() { System.out.println("I am flying"); } } Finally, we can create a Bird object that can both fly and walk.

View Solution →