Friday, January 25, 2013

Finding Path in the tree


Below are the code used to find the path in the Tree

I have verified most of the cases , May be experts can give batter solution than this . As always suggestions are welcome

#include <iostream>
#include <conio.h>

using namespace std;
class node
{
public:
 int data ;
 node(int in)
 {data = in;
   left = NULL ;
   right = NULL;
 }
 node* left ;
 node* right;
};


node* findpathrootnode(int a ,int b ,node* root)
{
 if(root->data > a && root->data < b)
 {
  return root;
 }
 else
 {
  findpathrootnode(a,b,root->right);
 }
 
}

void findleftpath(int a ,node * root)
{
 if(root!= NULL &&  root->data > a)
    findleftpath(a,root->left);
 else if(root!= NULL && root->data < a)
   findleftpath(a,root->right);
 
   cout<<root->data << endl;

}

void findrightpath(int b , node * root)
{
 cout<<root->data<<endl;

 if(root!= NULL &&  root->data > b)
    findrightpath(b,root->left);
 else if(root!= NULL && root->data < b)
   findrightpath(b,root->right);

}


main()
 {

  node * obj1 = new node(5);
  node * obj2 = new node(6);
  node * obj3 = new node(4);
  node * obj4 = new node(7);
  node * obj5 = new node(8);
  node * obj6 = new node(9);

  // make tree

  obj1->left  = obj3;
  obj1->right = obj5;

  obj2->left = NULL;
  obj2->right = NULL;

  obj4->left = obj2;
  obj4->right = NULL;

  obj3->left = NULL;
  obj3->right = NULL;

  obj5->left = obj4;
  obj5->right = obj6;

  obj6->left = NULL;
  obj6->right = NULL;

  //tree in done

  node * newroot = findpathrootnode(4,7,obj1);
  findleftpath(4,newroot);
  findrightpath(7,newroot->right);
  getch();
 }

Wednesday, January 16, 2013

Logs from android

How to get Logcat logs in terminal

$  su
$  logcat -f /sdcard/logcat.txt


How to get kernel logs

$  su
$ dmesg > /sdcard/dmesg.txt

 Or run "cat /proc/kmsg > /sdcard/kmsg.txt"

of-course , when you need kernel logs you can use this .


How to get last_kmsg log

$  su
$  cat /proc/last_kmsg > /sdcard/last_kmsg.txt

This is really helpful when you phone is rebooted and you want to save last_kmsg log .

Thursday, January 3, 2013

“???????????? no permissions” when you do "adb devices"


$ adb devices
List of devices attached
????????????    no permissions

fix:
sudo -s
adb kill-server
adb start-server
adb devices

Thursday, November 8, 2012

Adding logs in android Middleware

Changes in .mk file :

 LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv1_CM



changes in file :

 #include <android/log.h>
 #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "webkit_test", __VA_ARGS__))

  addings logs
    LOGI("Test logs");

Friday, October 26, 2012

Queue


Another important DS we are going to discuss

QUEUE …

What is queue
    

See the above Image ,  peoples are standing in the queue and guy in the counter giving tickets or serving something …
Now think , if counter guy able to give ticket  in an ignore time , then do we require queue anymore … No absolutely not .
 But in practical situation, service provider(counter guy) not able to  serve the request (ppl standing in the queue) in an ignore time. So, we need queue in order to serve all the request.

 Queue has a sequence of the request, where which request comes first that will be processed first. And of-course there are some priority queue (this we will discuss later )

Lets see the implementation of the queue (C++)   .. it is under construction .. I'll post this soon

Tuesday, October 9, 2012

Adding your application in android source code



1. Paste your project in "Packages/apps/" folder
2. Add Android.mk file in your project (you can refer the other app make file)
3. have to add your project name in  generic_no_telephony.mk & large_emu_hw.mk file (available in build/target/product/)

thats all . build the source code and launch the emulator ,you can see your application in Emulator