careerCupguy10
BAN USER
- 1of 1 vote
AnswersWrite a method to print output of a^b
- careerCupguy10 in United States| Report Duplicate | Flag | PURGE
PayPal Software Engineer / Developer Algorithm
class Stack{
int top;
int[] stack;
MinimumStack miniStack;
// constructor for stack
Stack(int capacity){
top=0;
stack=new int[capacity];
miniStack = new MinimumStack(capacity);
}
boolean isFull(){
return(top==stack.length);
}
public void push(int val){
if(!isFull()){
stack[top++]=val;
miniStack.push(val);
}else{
System.out.println("The stack is full");
}
}
public Object pop(){
if(top!=0){
miniStack.pop(stack[top-1]);
return stack[top--];
}else{
return null;
}
}
public void displayStack(){
for(int i=0;i<top;i++){
System.out.println(stack[i]);
}
}
public void displayMinimum(){
System.out.println("The current minimum is"+miniStack.getMinimum());
}
}
class MinimumStack{
int topMin;
int[] Ministack;
public MinimumStack(int capacity) {
// TODO Auto-generated constructor stub
topMin=0;
Ministack=new int[capacity];
}
public int getMinimum() {
// TODO Auto-generated method stub
if(topMin!=0){
return Ministack[topMin-1];
}
return (Integer)null;
}
boolean isMinStackFull(){
return(topMin==Ministack.length);
}
public void push(int val){
if(!isMinStackFull()){
if(topMin!=0){
if(val<Ministack[topMin-1])
Ministack[topMin++]=val;
}
else{
if(topMin==0)
Ministack[topMin++]=val;
}
}else{
System.out.println("The stack is full");
}
}
public void pop(int val){
if(Ministack[topMin]==val){
int Minval=Ministack[topMin--];
}
}
}
I have thise as an answer to your question. Only problem in this solution is I am failing to guess where EOF file is encountering.
{{
public void serializeBinaryTree(BTNode root, ObjectOutputStream oos) throws IOException{
//if nde is null then put some #
String s = "#";
if(root==null){
oos.writeObject("#");
}else{
oos.writeObject(" "+root.data);
serializeBinaryTree(root.left,oos);
serializeBinaryTree(root.right,oos);
}
}
public void dserializeBinaryTree() throws IOException, ClassNotFoundException{
//if nde is null then put some #
String node = null;
FileInputStream fin = new FileInputStream("Tree.ser");
ObjectInputStream ois = new ObjectInputStream(fin);
Scanner input = new Scanner("Tree.ser");
while(true){
System.out.println((String) ois.readObject());
}
}
}}
what do you mean by greater nodes ? Please give detail example of it.
- careerCupguy10 January 27, 2014This works with +ve as well as -ve Numbers{{
public static double getPower(double a, double b){
if(b==0) return 1;
//if b is negative
if(b<0){
return 1/a*(getPower(a,b+1));
}
return a*getPower(a,b-1);
}
}
}}
public static double getPower(double a, double b){
if(b==0) return 1;
//if b is negative
if(b<0){
return 1/a*(getPower(a,b+1));
}
return a*getPower(a,b-1);
}
}
you need to right customized hash function to decide index of an array where you wants to insert such value. The trick is to write such hash function o that you will not waste space and retrieve value in O(1) time.
- careerCupguy10 January 25, 2014{{
public static boolean isStringIsoMorphic(String str1, String str2){
if(str1.length()!=str2.length())
return false;
int len=str1.length();
//declaring two arrays to keep count of position of each char encountered
int[] str1arr = new int[256];
Arrays.fill(str1arr, -1);
int[] str2arr = new int[256];
Arrays.fill(str2arr, -1);
for(int i=0;i<len;i++){
if(str1arr[str1.charAt(i)]==-1){
if(str2arr[str2.charAt(i)]!=-1){
return false;
}else{
str1arr[str1.charAt(i)]=i;
str2arr[str2.charAt(i)]=i;
}
}else{ // if char in first string has already occurred somewhere
// then look for the char present at same index in str2 previous occurance
System.out.println(str1arr[str1.charAt(i)]);
System.out.println(str2arr[str2.charAt(i)]);
if(str1arr[str1.charAt(i)]!=str2arr[str2.charAt(i)])
return false;
}
}
return true;
}
}}
Replcarton941, Android test engineer at 8x8
My name is Lilly. I grew up in Somerset and currently live in the US. One desire that has always ...
Repmendezleah216, Analyst at Bosch
Hello,everybody,I'm Leah Mendez.I want to make some friends here.I’m a woman with ambition and ...
RepTaylahMacge, Consultant at Accenture
Assigned to manage the requirements of foreign clients specifically those from the Chinese, Arabic, and French-speaking markets.I am passionate ...
Repjanistbennett, Blockchain Developer at AMD
I am JanisBennett working as a journalist, having years of experience in my career. I have covered various stories.Great ...
Repsujijaa565, AT&T Customer service email at ABC TECH SUPPORT
My name is suji. I am working as a Suadela Investment in Tulsa USA . I identify and establish a new ...
Repcharlesndouglass, Employee at VANS
I am Michael from Nantucket USA. I am working as a Power plant dispatcher in Matrix Design company. I am ...
RepHi, I am Maria from Worcester, USA. I have been working as a Blogger in Enticing Express from last 2 ...
Reparlinenwalters, Software Analyst at ASAPInfosystemsPvtLtd
I Performed extensive web research to collect pertinent data and gather images related to the assigned articleIts act of writing ...
Repalinehchavez, SHOT 1500 NIGHT 5000 Call girls in Munirka Metro 9711794795 at Apple
Hi, I am Aline From New York USA. I am working as a Real estate rental agent in an Energy ...
Repharrylseay, Aghori Mahakal Tantrik at ASAPInfosystemsPvtLtd
I am Harry and I live in the USA but basically I am from Bangor. I live my life very ...
RepHi, I am Alisa from Southfield, USA, I am working as a Toolmaker in an Audio-Visions company. I am also ...
RepSaraLopez, abc at ADP
Experienced in all aspects of business formation, operation, finance, and management. Visionary product developer with deep education in research and ...
Reptaylorjose221, Production Engineer at BT
Graphic designer with a strong background in marketing design.Having a day off during the week to do whatever I ...
Repdianamowery95, Consultant at Delve Networks
My Name is Diana Mowery. I am from St. Louis and received a Bachelor Degree and My Masters Degree from ...
Repjosephcday6, Android Engineer at Absolute Softech Ltd
I am SEO Executive in Elek-Tek company. I live in Morgantown USA. I won’t write any details about Best ...
Repmarthavmoody, Consultant at Dell
Spent 2002-2010 investing in toy elephants in Pensacola, FL. Earned praised for my work testing the market for squirt guns ...
Repsusiejcrider, Member Technical Staff at Accolite software
I was a Communications Consultant with experience in working across various clients .technology, consumer, hospitality, financial services and corporate social ...
Repkathimhoke, Product Security Engineer at Argus
Hi, I am Kathi from Mineola. I am working as an Identification clerk in a Tradewell company. I spent over ...
Repkarinkwalton, Backend Developer at Broadsoft
I am working as a Support clerk in an MVP Sports company. I love traveling and exploring facts about technology ...
Repnnatashanaomi, Android test engineer at 247quickbookshelp
I am Marketing managers who play a crucial role in helping a business to promote and its customers. I manage ...
wrong solution
- careerCupguy10 March 21, 2014