Palindrome

A Palindrome is a text, number or sentence which can be read the same phrase or value backwards and forwards. For instance: Anna(forward)    annA (backwards)  We implement our code ignoring the lower and uppercase words because our word has the same meaning. This may be prevented by adding to  palindrom.toLowerCase() to our  String. Source Code: DOWNLOAD

How to write a file in Android

First, we need to define a path. We can’t save files everywhere because of the different permissions. We write our file to the project path. Create Empty Project  Start emulator or your device Go to View ->Tool Windows->Device File Explorer Select directory Data->Data  6.Select your project folder and copy path(right mouse click) My path is /data/data/learn.hq.readwritefiles/textFile.txt Well, this […]

Android Custom ViewList with onItemClickListener

Android Custom ViewList with onItemClickListener If you want to create a custom List you have to implement BaseAdapter (Observable pattern) making modifications with a help of getView() method  . BaseAdapter is a common based class providing an Adapter an implemantation.Generally you use it in Listview and SpinnerAdapter.The most important method is notifyDataSetChanged().The method refresh the modifications of the […]

Quicksort

Quicksort is an efficient sorting algorithm, developed by British computer scientist Tony Hoare in 1959. Algorithm:  find Pivot element (it may be the first, last or random value in array) put elements in order. The elements on the Left side are lesser than the pivot element. The elements on the Right side are greater than the pivot element […]

Java Collections

Collections are a set of data performing administration of all abstract datatypes. ( e.g searching,sorting,inserting,delete).Collections are very helpful by providing useful data structures and reduce programming effort. The disadvantages are casting to correct type of object and compile-time type checking is not possible. Simple List example: Now we want to represent our data as output. I want you […]

binary search tree

A binary tree is an abstract data type(ADT) in computer science. conditions of BST: Every tree has only 1 root(head) each node has 2 children If the node is greater than other, then it will go to the right child. if the node is smaller than other, then it will go to the left child. Advantage: low complexity […]

Bubble sort

Bubblesort Principle Bubblesort is the easiest sorting algorithm to implement. Bubblesort algorithm runs from left to right. If the value is greater than the neighbour, the values will swap with each other. The disadvantage of this algorithm is high complexity( O(n²)). Example: sorting following array 6 8 3 6 2   Algorithm: Source Code: BubbleSort

Linked List

Programming C tutorial: List Prerequisite: Call by Value, Call by reference, pointers In this chapter, you will learn more complex programming skills. I assume you understand the basic concept of programming C. The basic reason for the list is storing specific information for instance: name, first name, number. Every list has a Head,and tail. How do we start? […]

Recursion

Recursion Recursion is a function that always repeats a specific number of executions over time until abort criteria(s) of execution(s) has(have) reached. 1. Abort critera is a condition when you reached your objective. example: if(n== 1) { //Do nothing } 2.Recursive function: void Dosomething(int n){ if(n== 1) { //Do nothing } Dosomething(n-1); } Exercise: Recursive Decimal to Dual Converter […]

Simple Calculator (Android)

How to start: 1. Install Android Studio and create empty Activity 2. We will be using class EvaluateEngine from Rhino  3. Click on build.gradle(Module: app) and set the following parameters: implementation ‘io.apisense:rhino-android:1.0’ testImplementation ‘junit:junit:4.12’ 4.Change the MainActivity Class to the following class: package learn.hq.myapplication; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; public class MainActivity extends […]