Skip to main content

Posts

Showing posts with the label code

Problems importing Android Source Code into Eclipse

Errors on the project build path when using Eclipse When I debug the framework source using Eclipse, there are some errors on the project build path. Error messages I saw are the following : Project 'Android' is missing required library: 'out/target/common/obj/JAVA_LIBRARIES/google-common_intermediates/javalib.jar' Project 'Android' is missing required library: 'out/target/common/obj/JAVA_LIBRARIES/gsf-client_intermediates/javalib.jar' Solution: Goto Project>Properties and libraries section and edit first one to "out/target/common/obj/JAVA_LIBRARIES/android-common_intermediates/javalib.jar"  and remove second one. Missing required library when import the android source 4.0 to Eclipse After this, the build path errors were gone, but I got about 200 errors referring to missing types. This could only be another classpath problem for Eclipse. Here are the extra libraries, that we have to add to the .classpath file: <c...

Shortest Job First Scheduling using HEAP

// Input is from the file "input.txt" in the form (a1,t1),(a2,t2),(a3,t3)  (arrival time, time to complete ie, burst time) import java.io.*; import java.util.*; public class SJFHeap {     static class point {         double time;         double run;         int no;         double total;         point(int i, double a, double b) {             no = i;             time = a;             run = b;             total = 0;         }     }     static class MHeap {         private point[] Heap;         p...

Anagram search from a file

// All the words are in the file Dictionary.txt import java.io.*; import java.util.*; public class Anag {     static String[] words;     public static void main(String args[]) throws IOException     {         Hashtable<String, List> ht;         try {             FileInputStream fstream = new FileInputStream("Dictionary.txt");             DataInputStream in = new DataInputStream(fstream);             BufferedReader br = new BufferedReader(new InputStreamReader(in));             List<String> lines = new ArrayList<String>();             String ele;             while ((ele = br.readLine...

Josephus Problem using Queue

//Josephus.java //Out of  n members, every m'th person will be eliminated import java.io.*; //Stack--------------- class Node<T> {     T value;     Node<T> link; } class Stack<T> {     Node<T> top;     public Stack() {         top = null;     }     public void push(T item) {         Node<T> n = new Node<T>();         n.value = item;         n.link = top;         top = n;     }     public T pop() {         T item;         item = top.value;         Node<T> n = top;         n = null;         top = top.l...

Queue using Stack

import java.io.*; //Node--------------- class Node<T> {     T value;     Node<T> link; } // Stack--------------- class Stack<T> {     Node<T> top;     public Stack() {         top = null;     }     public void push(T item) {         Node<T> n = new Node<T>();         n.value = item;         n.link = top;         top = n;     }     public T pop() {         T item;         item = top.value;         Node<T> n = top;         n = null;         top = top.link;         return item; ...

Generic Stack

import java.io.*; class Node<T> {     T value;     Node<T> link; } class Stack<T> {     Node<T> top;     public Stack() {         top = null;     }     public void push(T item) {         Node<T> n = new Node<T>();         n.value = item;         n.link = top;         top = n;     }     public T pop() {         T item;         item = top.value;         Node<T> n = top;         n = null;         top = top.link;         return item;     }     p...

Nearest Neighbor Search Using KdTree

//Input should be in input.txt file //10(2.1,4.3)(3.3,1.5)(4.7,11.1)(4.9,1.6)(5.0,12.3)(5.1,1.2)(6.7,3.3)(19.2,5.4)(20.5,7.9)(100.3,52) //The first number is the number of points, n, and following it are the coordinates of the n points in ascending order of the x-coordinate. import java.util.*; import java.lang.*; import java.io.*; import java.util.StringTokenizer; class KDNode {     int axis;     double[] x;     int id;     boolean checked;     boolean orientation;     KDNode Parent;     KDNode Left;     KDNode Right;     public KDNode(double[] x0, int axis0) {         x = new double[2];         axis = axis0;         for (int k = 0; k < 2; k++)             x[k] = x0[k];         Left = Right = Parent = null;         checked = false; ...