Quicksort is a sorting algorithm which applies divide and conquer paradigm. Quicksort has a worst case running time of , however, it has running time of on average which makes quicksort very efficient. Moreover, it works in-place but not stable. The performance of quicksort depends on selecting the pivot, and starting to partition around it. […]

Selection sort is an in-place comparison sort algorithm which has running time complexity in both best and worst case. Even though its logic is similar to insertion sort, it’s a very inefficient sorting algorithm. List is both divided into two parts as sorted and unsorted where initially sorted part is empty. Every turn, algorithm finds […]

Merge sort is another comparison based sort algorithm. It closely follows divide-and-conquer paradigm, and provides run time complexity in worst and average cases, however, in space complexity. Merge sort can be used for sorting huge data sets that can not fit into memory. It is also a stable sort which preserves the order of equal […]

Binary search is a searching algorithm which works on a sorted (ascending or descending) array. In each turn, the given key is compared with the key at the middle of the array, if it is equal to it then its index is returned. Otherwise, if the given key is less than key at the middle […]

The binary heap data structure is an array object that represents a nearly complete binary tree. Thus, each element of the array corresponds to a node of the tree. Heaps are useful data structures for heapsort ,and they are underlying data structure of priority queues. So for simplicity we can say priority queue is a […]

A Binary Search Tree (BST) is a tree data structure that supports many dynamic operations includes ; Search Minimum Maximum Insert Delete Predecessor Successor Basic operations in a binary search tree take time proportional to to the height of the tree. For a complete binary tree with n nodes, such operations run in worst-case time. […]

Insertion sort is an efficient algorithm for sorting a small number of elements, however, it is less efficient on large lists than more advanced sorting algorithms. On the other hand, it has several advantages which are; It is adaptive; Sorting performance adapts to the initial order of elements. It is online; New elements can be […]

Bubble sort is one of the simplest sorting algorithm which pairs are repeatedly compared and swapped if they are in wrong order. This process continues until no swaps are needed means that list is sorted. It takes its name from the fact that necessary elements bubble up to their correct position. Even though bubble sort […]

In this tutorial we will implement a Jersey client example with JSON support. The tools and technologies that I have used are; Eclipse 4.3.0 JBoss AS 7.1.1.Final Maven 3.1.1 JDK 1.7 Project Structure Our project structure will look like below; Dependencies There are two dependencies to use Jersey client and JSON support

1 2 3 4 5 6 7 8 9 10 11 |
<dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-client</artifactId> <version>1.18.1</version> </dependency> <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-json</artifactId> <version>1.18.1</version> </dependency> |

jersey-client dependency […]

Sometimes we might want to export only a specific part of our collection with query support of mongoexport. Suppose this is our notebook collection, and each document refers to a notebook with their production date.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
{ "_id" : ObjectId("531ce460000000019b9643bc"), "company" : "Samsung", "date" : ISODate("2014-03-09T22:00:00Z"), "price" : 2000, "brand" : "Ultrabook", } { "_id" : ObjectId("531ce460000000019b9643ba"), "company" : "Sony", "date" : ISODate("2014-03-08T22:00:00Z"), "price" : 1500, "brand" : "Vaio", } { "_id" : ObjectId("531ce460000000019b9643bd"), "company" : "Apple", "date" : ISODate("2014-03-07T22:00:00Z"), "price" : 2250, "brand" : "MacbookPro", } { "_id" : ObjectId("531ce460000000019b9643be"), "company" : "Apple", "date" : ISODate("2014-03-06T22:00:00Z"), "price" : 1200, "brand" : "MacbookAir", } { "_id" : ObjectId("531ce460000000019b9643bf"), "company" : "Samsung", "date" : ISODate("2014-03-05T22:00:00Z"), "price" : 1000, "brand" : "Ultrabook", } |

The original way of mongoexport is defined by

1 |
mongoexport --db <database> --collection <collection> --query <JSON query> --out <file> |

The major problem is we can not use ISODate(“”) objects […]