Tuesday, February 18, 2014

Difference between LinkedList and ArrayList

ArrayList and LinkedList both implements List interface and their methods and results are almost identical. However there are few differences between them which make one better over another depending on the requirement.
ArrayList Vs LinkedList
  1. Both ArrayList and LinkedList are implementation of List interface.
  2. They both maintain the elements insertion order which means while displaying ArrayList and LinkedList elements the result set would be having the same order in which the elements got inserted into the List.
  3. Both these classes are non-synchronized and can be made synchronized explicitly by using Collections.synchronizedList method.
  4. The iterator and listIterator returned by these classes are fail-fast (if list is structurally modified at any time after the iterator is created, in any way except through the iterator’s own remove or add methods, the iterator will throw a ConcurrentModificationException).
When to use LinkedList and when to use ArrayList?

1. Search: ArrayList search operation is pretty fast compared to the LinkedList search operation. get(int index) in ArrayList gives the performance of O(1) while LinkedList performance is O(n).
Reason: ArrayList maintains index based system for its elements as it uses array data structure implicitly which makes it faster for searching an element in the list. On the other side LinkedList implements doubly linked list which requires the traversal through all the elements for searching an element.
2. Deletion: LinkedList remove operation gives O(1) performance while ArrayList gives variable performance: O(n) in worst case (while removing first element) and O(1) in best case (While removing last element).
Conclusion: LinkedList element deletion is faster compared to ArrayList.
Reason: LinkedList’s each element maintains two pointers (addresses) which points to the both neighbor elements in the list. Hence removal only requires change in the pointer location in the two neighbor nodes (elements) of the node which is going to be removed. While In ArrayList all the elements need to be shifted to fill out the space created by removed element.
3. Inserts Performance: LinkedList add method gives O(1) performance while ArrayList gives O(n)in worst case. Reason is same as explained for remove.
4. Memory Overhead: ArrayList maintains indexes and element data while LinkedList maintains element data and two pointers for neighbor nodes hence the memory consumption is high in LinkedList comparatively.
There are few similarities between these classes which are as follows:
  1. As explained above the insert and remove operations give good performance (O(1)) in LinkedList compared to ArrayList(O(n)). Hence if there is a requirement of frequent addition and deletion in application then LinkedList is a best choice.
  2. Search (get method) operations are fast in Arraylist (O(1)) but not in LinkedList (O(n)) so If there are less add and remove operations and more search operations requirement, ArrayList would be your best bet.
Courtesy of: http://beginnersbook.com/
References:
Below is an example of ArrayList in Java

import java.util.ArrayList;
import java.util.List;

public class SampleArrayList {    
  public static void main(String[] args){          
ArrayList arrList = new ArrayList();
        //adding elements to the end
        arrList.add("Froilan");
        arrList.add("Jillian");
        arrList.add("Mary Ann");
        arrList.add("Kawangis");        
        System.out.println("Actual ArrayList:" + arrList);     
        List list = new ArrayList();
        list.add("Bong");
        list.add("Christian");
        arrList.addAll(list);
        System.out.println("After Copy: " + arrList);

}

}

Below is an example of LinkedList in Java

import java.util.LinkedList;

public class TestClass {
     /**
      * @param args
      */
     public static void main(String[] args) {     
          LinkedList lnkList = new LinkedList();
          lnkList.add("Froilan");
          lnkList.add("Mary Ann");
          lnkList.add("Jillian");
          lnkList.add("Benito");
          System.out.println(lnkList);                 
     }
}

Thursday, December 5, 2013

Kawangis Year Long Events

Recently, our group Kawangis had successfully organized a year long event. The event was dubbed as "Battle of the generation" which means each generation of the Kawangis participates by organizing an event of their choice. It started when Generation 1 & 2 launched a kick-off event that was held last May 2013, climbing Mt. San Cristobal Traverse. The purpose of the events is to bring up the fire that was long gone and also to relived the camaraderie that was built through the years of it's existence. I will not type any longer, i will let the pictures and videos tell the rest of the story. So here it is, enjoy viewing.


Kawangis "Battle of the Generation" Year Long Event 
Pictures and Videos:


Kick-off - Mt San Cristobal Traverse 
via Rizal Tala to Dolores Quezon 
(May 25-26, 2013)

Group picture @ ridge campsite
Group picture along the trail while resting
Another batch of group picture
Final group picture before descending to Dolores, Quezon



Kawangis 3rd Generation "Chillax sa Cagbalete" 
Cagbalete Island, Mauban Quezon
(June 29-30, 2013)

Group picture inside the bus
Socials
Playing the games
Group picture with the guest and organizers
Literally chillax sa Cagbalete


For more pictures please visit https://www.facebook.com/narriel.ceribo/media_set?set=a.10202184308548621.1073741838.1216398311&type=3


Kawangis 4th Generation - Malabrigo Beach and 
Basic Mountaineering Course 1 & 2 Seminar
(August 10-11, 2013)


Basic Mountaineering Course 1&2 seminar in action
Our 4th generation's organizers
Group picture before BMC
Basic Mountaineering Course
Group picture after the event

For more pictures please visit https://www.facebook.com/narriel.ceribo/media_set?set=a.10202185871147685.1073741839.1216398311&type=3

Kawangis 5th Generation - Mt. Pico De Loro 
Dayhike & Beacheering For A Cause
(October 19-20, 2013)


Day hiking Mt. Pico de Loro

5th Generation's organizers

Kawangis 5th generation tarpaulin

Socials




There you go, hope the pictures and videos shows the whole story of the event. 

Photos and Videos courtesy of Narriel Ceribo

Next: Kawangis 7th Anniversary...


Thursday, October 24, 2013

Jillian first ever climb - Unfinished business

Just recently, our group Kawangis organized a day hike climb to Mt. Pico De Loro in Ternate, Cavite. The plan was to bring our daughter up in the mountain, however, we failed to bring her to the campsite because of a sudden rain and also my daughter won't allow me to carry her all through out the hike. As i'm worried to my wife carrying my daughter up to the campsite and that she might get injured as we go along. We decided that She and my daughter together with 2 companions would stay at the base camp and wait for us to comeback from the hike to the summit. My cousin and I proceeded to hike up until the summit. We were running on the trail so we can lessen the time spent walking and for us to be able to come back early to the base camp and we can be able to accompany my wife and daughter back to the jumpoff. The hike did well as we planned. We arrived at the jumpoff point on time before it gets dark. The hike was successfully however it leaves us an unfinished business, so for the next climb, we were planning of bringing our daughter once again and hopefully it will be successful. Until then, wait for my next write up on our next climb.

My wife and daughter


My cousin, Ali and I @ summit

Tuesday, March 5, 2013

Alcatel OT-997D



I bought this mobile phone for Mheann last December, 2012 for only PHP11,990 at Samsung Mobile, SM Southmall. Please see below specifications:

GENERAL2G NetworkGSM 850 / 900 / 1800 / 1900 - SIM 1 & SIM 2
3G NetworkHSDPA 900 / 2100
SIMDual SIM (Mini-SIM, dual stand-by)
Announced2012, July
StatusAvailable. Released 2012, September
BODYDimensions129.8 x 68 x 11 mm (5.11 x 2.68 x 0.43 in)
Weight143 g (5.04 oz)
DISPLAYTypeTFT capacitive touchscreen, 16M colors
Size480 x 800 pixels, 4.3 inches (~217 ppi pixel density)
MultitouchYes
SOUNDAlert typesVibration; MP3 ringtones
LoudspeakerYes
3.5mm jackYes
MEMORYCard slotmicroSD, up to 32 GB
Internal1 GB RAM
DATAGPRSYes
EDGEYes
SpeedHSDPA, 7.2 Mbps; HSUPA, 5.76 Mbps
WLANWi-Fi 802.11 b/g/n, Wi-Fi hotspot
BluetoothYes, v4.0 with A2DP
USBYes, microUSB v2.0
CAMERAPrimary8 MP, 3264 x 2448 pixels, autofocus, LED flash
FeaturesGeo-tagging, touch focus, face detection
VideoYes, 720p@30fps
SecondaryYes, VGA
FEATURESOSAndroid OS, v4.0 (Ice Cream Sandwich)
ChipsetMTK 6577
CPUDual-core 1 GHz
SensorsAccelerometer, proximity, compass
MessagingSMS(threaded view), MMS, Email, IM
BrowserHTML
RadioStereo FM radio with RDS
GPSYes, with A-GPS support
JavaYes, via Java MIDP emulator
ColorsBlack, White
- SNS integration
- MP3/AAC+/WAV/WMA player
- MP4/H.264 player
- Document viewer
- Photo viewer/editor
- Organizer
- Voice memo
- Predictive text input
BATTERYLi-Ion 1800 mAh battery
Stand-byUp to 400 h (2G) / Up to 350 h (3G)
Talk timeUp to 16 h (2G) / Up to 8 h 30 min (3G)
MISCSAR US0.50 W/kg (head)     0.74 W/kg (body)    
Related Posts Plugin for WordPress, Blogger...

Blog List