Data Structure Questions

  1.  Find the intersection point of two linked list, find C1-

Array List and Linked List

Let's talk about Java Array List and Linked List here.

Array List:

Features-
  • ArrayList class implements List interface (and a couple more) and extends AbstractList class.
  • ArrayList is a re-sizable array implementation which means it can automatically grow its size if required.
  • ArrayList is internally backed by an Array.
  • Duplicates are allowed.
  • Not thread safe.
How it works:
  • When we instantiate an ArrayList, it actually creates an Array of default capacity of 10 using no argument constructor. 
  • When we add elements to the list, it stores the elements inside that array. Once this array gets full, it automatically creates a new array of larger capacity than the previous array (typically 1.5 time larger) and copies all the elements from old array to the new larger array.
  • However it does not shrink its size if we keep deleting the elements from it.

Linked List:

Features-
  • Doubly Linked List implementation of Linked List (Abstract Data Type) provided by Java.
  • LinkedList class implements following interface:
    • List
    • Deque
    • Clonable
    • Serializable
    • Iterable
    • Collection
    • Queue
  • It extends AbstractSequentialList class.
  • Duplicates are allowed.
  • Uses Nodes to store elements.
  • Dynamic memory allocation i.e. nodes will be created when required.
  • Not thread safe.

Practice online - Competitive Coding and Practice websites


Here are some useful websites to practice and compete in online programming challenges. Just register using your email and get going.

REST WebService Questions

REST Services : REpresentational State Transfer.


  1. What is SOA? Service Oriented Architecture?
  2. What is REST?
  3. On which protocol REST is based?
  4. How many HTTP methods supported by REST and what are they?
  5. What are the JAX-RS annotations?
  6. How to define the response Type in REST?
  7. What is difference between PathParam and QueryParam?
  8. How to create client to invoke the REST Services?
  9. What JSON means?
  10. Difference between REST based and SOAP based service.

Puzzles



  1.  You have 5 litre and 3 litre buckets and unlimited water supply. You need to measure 4 litres of water using only the two given buckets. There is no measuring mark on any of the buckets.

  2. 25 horses are there and you need to find the 3 fastest horses among them. Only 5 horses can run in one race. Find the minimum number of races required to get top 3 fastest horses.

  3. You are given two candles of equal size and a lighter, which can burn 1 hour each. You have to measure 90, 45 and 30 minutes with these candles.

  4. There are 3 switches outside of a room and 3 bulb inside the room. You need to figure out which switch operate which bulb by going into the room only once. 

      5. Measure 9 minutes from the two hour glasses-

 


    6. Prisoners and Hat problem-

    7. How many squares are there on a chess board?

    8. A person has 3000 bananas and a horse. The person wants to transport maximum number of bananas to a place which is 1000 KMs away, using only the horse as a mode of transportation. The horse cannot carry more than 1000 bananas at a time and eats a banana every km it travels. What is the maximum number of bananas that can be transferred to the destination using only horse (no other mode of transportation is allowed).

9. Pay a worker using 7 units of  gold from a gold bar.




10. There are 8 batteries, but only 4 of them work. You have to use them for a flashlight which needs only 2 working batteries. To guarantee that the flashlight is turned on, what is the minimum number of battery pairs you need to test?