Thursday, December 17, 2015

SQLite

- Open Source database
- supports relational database features like SQL syntax, transactions
- requires limited memory (approx. 250 KByte) which makes it a light weight database to embed in to each process
- supports the data types TEXT, INTEGER and REAL

Features:
- SQLite library and thus becomes an integral part of the application program.
- Due to the server-less design, SQLite applications require less configuration than client-server databases.
 SQLite is called zero-conf.
- The SQLite file format is cross-platform. A database file written on one machine can be copied to and used
 on a different machine with a different architecture.
- Adding new tables or new columns to existing tables is so easy.
- Content can be accessed and updated using powerful SQL queries.
- SQLite read operations can be multitasked, though writes can only be performed sequentially.


Design Tips:
1. First, Second and Third normal forms in Database (Students record)
1st - Remove duplicate data and break data in granular level
2nd - All column data should depend on full primar key and not part
3rd - No column should depend on other column

( ref : https://www.youtube.com/watch?v=wp0N1tYjEWc&feature=youtu.be&hd=1)

Thursday, November 26, 2015

Food habit for improved brain function

  i. Morning breakfast very important for that day
- Consider grains, vegetables, milk, fruits.
- Dry fruits
- Carrot

  ii. Avoid heavy food in the morning, because digestion takes more blood ciculation.
- Non-Veg, Potato are heavy foods.

  iii. Proper sleep
  iv. Regular excercise ( increases oxygen in the body)
  v. Deep breathing habit (Meditation helps in deep breathing habit)
 
 
  Sources of Fati Acid
- dry ground nuts
- pumkin seeds
- salmon fish / sadins (mathi in kannada)
- fresh coconut
- Apple

  Sources of Amino acid
- Eggs/ milk product (protein & Calcium are high in curd) / crabohytrate enrich foods/ spinach

  Increase iron take
- Almond/ Red Meat (lamb & beef)
 
  Sources of Vitamin - A
- Carrot/ pumkin seeds/ Papayas/

  Other practices
- Reading story/ Listening story
- Drawing/ Painting
- Singing
- Puzzle solving
- Activity to improve the creativity
- Questioning to understand the things completely

Monday, November 9, 2015

String Algorithms

Sorting
i. Key indexed counting
ii. LSD (Least-significant-digit-first) string sorting
- Sorts equal length strings.
- uses key index counting method
iii. MSD (Most-significant-digit-first) string sorting
- Recurvise sort
- Sorst any length strings
iv. 3-way radix sort

String Search
1. R-way Tries

Sub String Searching
i. Knuth–Morris–Pratt
ii. Boyer–Moore
iii. Rabin–Karp

Thursday, October 29, 2015

Java ExecutorSerivce Example


public class Problem1 {
 
    private static final int CPU_COUNT = Runtime.getRuntime().availableProcessors();
    private static final int CORE_POOL_SIZE = CPU_COUNT + 1;
    
    private static final ThreadFactory sThreadFactory = new ThreadFactory() {
        private final AtomicInteger mCount = new AtomicInteger(1);

        public Thread newThread(Runnable r) {
            return new Thread(r, "Task #" + mCount.getAndIncrement());
        }
    };
 
 public static void main(String[] args) {
  System.out.println("CORE_POOL_SIZE : "+CORE_POOL_SIZE);
  
  ExecutorService service = Executors.newFixedThreadPool(CORE_POOL_SIZE, sThreadFactory);
  
  service.execute(new Task());
  service.execute(new Task());
  service.execute(new Task());
  service.execute(new Task());
  
  Future<Integer> res1 = service.submit(new Task1());
  Future<Integer> res2 = service.submit(new Task1());
  Future<Integer> res3 = service.submit(new Task1());
  Future<Integer> res4 = service.submit(new Task1());
  try {
   System.out.println("result from callable -> "+res1.get());
   System.out.println("result from callable -> "+res2.get());
   System.out.println("result from callable -> "+res3.get());
   System.out.println("result from callable -> "+res4.get());
  } catch (InterruptedException e) {
   e.printStackTrace();
  } catch (ExecutionException e) {
   e.printStackTrace();
  }
  
  service.shutdown();
 }
 
 static class Task implements Runnable{

  @Override
  public void run() {
   System.out.println("Enter");
   String threadName = Thread.currentThread().getName();
   System.out.println(threadName);
   
   try {
    Thread.sleep(10000);
   } catch (InterruptedException e) {
    e.printStackTrace();
   }
   
   
   System.out.println("Exit");
  }
  
 }
 
 static class Task1 implements Callable<Integer>{

  @Override
  public Integer call() throws Exception {
   System.out.println("Enter");
   String threadName = Thread.currentThread().getName();
   System.out.println(threadName);
   
   Thread.sleep(10000);
   
   System.out.println("Exit");
   return new Random().nextInt(100);
  }
  
 }
}