Question about Sun Java Programming Language (cdj-275)

1 Answer

Adding and deleting an element in a stack and queue

In adding into stack top is the current top of the stack and n is its maximum size
the pseudocode is

begin
if top= n then stackfull;
top:=top+1;
stack(top) := item;
end:


in the deletion of stack remove top element from the stack stack and put it in the item
the pseudocode is

begin
if top = 0 then stackempty;
item := stack(top);
top := top-1;
end;

Posted by on

1 Answer

  • Level 1:

    An expert who has achieved level 1.

  • Contributor
  • 1 Answer

Yes it is correct.

Posted on Feb 17, 2009

1 Suggested Answer

6ya6ya
  • 2 Answers

SOURCE: I have freestanding Series 8 dishwasher. Lately during the filling cycle water hammer is occurring. How can this be resolved

Hi,
a 6ya expert can help you resolve that issue over the phone in a minute or two.
best thing about this new service is that you are never placed on hold and get to talk to real repairmen in the US.
the service is completely free and covers almost anything you can think of (from cars to computers, handyman, and even drones).
click here to download the app (for users in the US for now) and get all the help you need.
goodluck!

Posted on Jan 02, 2017

Add Your Answer

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

1 Answer

Write a pseudocode declaration for a string array initialized with the following strings einstein newton


the nice thing about pseudocode is that there's many ways to do it
E.g 1;
String str = new Array["einstein',"newton"];
E.g 2;
myStringArray = new Array{'einstein','newton'}

BOTH of the above are correct, because they are pseudocode

Oct 19, 2014 | Computers & Internet

1 Answer

Microsoft Visual Basic Run-time error ' 28' Out of stack space How to fix it?


Hello and Welcome to FixYa!
Out of stack space means something is continuously loading the data onto the stack and when the stack gets full the it has no more space and throws the exception.
Run-time error '28' is the error code for Stack overflow.
There may be many reasons behind this, it depends on your coding.
You should see this article my Microsoft to get hands on the issue.
I hope you will have a clearer picture after reading that, If you have any Confusion, questions or issues regarding your problem do tell me.
Thank you for using FixYa!, Keep visiting..

If you think I was of help, your token of appreciation in the form of rating and a testimonial will be esteemed.
Concerned, Nooh: FixYa Team.

Jul 13, 2011 | Microsoft Visual Basic

1 Answer

Cant scan


Try to scan with Preview or Image Capture apps (in your Applications folder).

If that does not work, try deleting and re-adding the printer in the print queue:

- Sys Prefs, Print & Fax
- Select the printer in question and click the minus sign at the bottom of the list
- Select the plus sign to re-add it. Look for the printer, select it and wait until the "Add" button becomes available. Click it.

If this does not work, do the same thing, only instead of the second step, right (control) click the print queue area and select Reset Printing System

Jul 12, 2010 | HP Computers & Internet

1 Answer

How to convert infix to postfix using stacks in java programming?


u can try the follwing coding
import java.io.*;
import java.util.*;
//begin coding for the stack interface
interface Stack<E>
{
public boolean isEmpty();//tests is current stack is empty. Returns true if so, and false if not.
public E top() throws StackException;//retrieves value at the top of the stack. Stack cannot be empty.
public void push(E value) throws StackException;//pushes a value on the top of the stack.
public void pop() throws StackException;//removes a value from the top of the stack. Stack cannot be empty.
}//terminates coding of Stack interface

//begin coding for the objArrayStack class
class objArrayStack<E> implements Stack<E>
{
//constructor
public objArrayStack()
{
topValue=-1;
}//terminates constructor
public void push(E value)throws StackException
{
if(topValue<ArraySize-1)//currrent stack is not full
{
++topValue;
Info[topValue]=value;
}//terminates if
else //current stack is full
throw new StackException("Error: Overflow");
}//terminates push method
public void pop() throws StackException
{
if(!isEmpty())//current stack is not empty
--topValue;
else //stack is empty
throw new StackException("Error: Underflow");
}//terminates pop method
public boolean isEmpty()
{
return topValue==-1;
}//terminates isEmpty method
public E top() throws StackException
{
if(!isEmpty())//stack is not empty
return (E)Info[topValue];
else //stack is empty
throw new StackException("Error: Underflow");
}//terminates top method
//declare instance variables
final int ArraySize=10;
private Object Info[]=new Object[ArraySize];
private int topValue;

//begins coding for the StackException class
class StackException extends RuntimeException
{
//constructor
public StackException(String str)
{
super(str);
}//terminates text of constructor
}//terminates text of StackException class

//method to convert from infix to postfix notation
public static String InToPost(String infixString)
{
//operator stack initialized
objArrayStack<Character> operatorStack = new objArrayStack<Character>();
//postfix string initialized as empty
String postfixString = " ";
//scan infix string and take appropriate action
for(int index = 0; index < infixString.length(); ++index)
{
char chValue = infixString.charAt(index);
if(chValue == '(')
operatorStack.push('(');
else if(chValue == ')')
{
Character oper = operatorStack.top();
while(!(oper.equals('(')) && !(operatorStack.isEmpty()))
{
postfixString += oper.charValue();
operatorStack.pop();
oper = operatorStack.top();
}//end while loop
operatorStack.pop();
}//end else if
else if(chValue == '+' || chValue == '-')
{
if(operatorStack.isEmpty()) //operatorStack is empty
operatorStack.push(chValue);
else //current operatorStack is not empty
{
Character oper = operatorStack.top();
while(!(operatorStack.isEmpty() || oper.equals(new Character('(')) || oper.equals(new Character(')'))))
{
operatorStack.pop();
postfixString += oper.charValue();
}//ends while loop
operatorStack.push(chValue);
}//end else
}//end else if
else if(chValue == '*' || chValue == '/')
{
if(operatorStack.isEmpty())
operatorStack.push(chValue);
else
{
Character oper = operatorStack.top();
while(!oper.equals(new Character('+')) && !oper.equals(new Character('-')) && !operatorStack.isEmpty())
{
operatorStack.pop();
postfixString += oper.charValue();
}//end while loop
operatorStack.push(chValue);
}//end else
}//end else if
else
postfixString += chValue;
}//end for loop
while(!operatorStack.isEmpty())
{
Character oper = operatorStack.top();
if(!oper.equals(new Character('(')))
{
operatorStack.pop();
postfixString += oper.charValue();
}//end if
}//end while
return postfixString ;
}//terminates text of InToPost method

public static void main(String[]args)
{
objArrayStack mystack = new objArrayStack();
System.out.println("Enter a string");
Scanner scan = new Scanner(System.in);
scan.nextLine();
String str = scan.nextLine();
InToPost(str);
}//terminates text of main method
}//terminates text of objArrayStack class

Mar 16, 2010 | Sun Java Programming Language (cdj-275)

2 Answers

How to reformat a pc?


Hi,

Please go through the below instructions, I have sent you the instructions for how to reformat a PC /laptop and I hope this will help you in understanding as well as learning.
If you have windows XP, 95, 98, or ME:-
How to Format a Computer with Windows XP:-
  1. The first step in learning how to format a computer with Windows XP or 2000 is to insert Windows CD and restart your computer.
  2. Your computer should automatically boot from the CD to the Windows Setup Main Menu.
  3. At the Welcome to Setup page, press ENTER.
  4. Press F8 to accept the Windows XP Licensing Agreement.
  5. If an existing Windows XP installation is detected, you are prompted to repair it. To bypass the repair, press ESC.
  6. Use the ARROW keys to select the partition or the unpartitioned space where you want to create a new partition. Press D to delete an existing partition, or press C to create a new partition.
  7. Type the size in megabytes (MB) that you want to use for the new partition, and then press ENTER, or just press ENTER to create the partition with the maximum size.
  8. Select the format option that you want to use for the partition (Recommended: NTFS), and then press ENTER.
  9. After the Windows Setup program formats the partition, follow the instructions that appear on the screen to continue installing Windows.
I have no clue which windows are you using ,i have sent you one post for Windows XP and will also sent you the post for Windows 95,98 or ME.

Please let us know if that was helpful enough.
Good Luck & Thanks,
Shiv.

Aug 20, 2009 | Computers & Internet

1 Answer

I need open gl source code to make a point move along the circumference of the circle.


Hi
 I'm studying Physics, not CS, but I've had a few brushes with OpenGL.
 I'll use a Basic-like pseudocode syntax since I don't know what language you're using, and basic is very easy to read:

'Constants - Radius is radius of the circle
Const PI = 3.14159, Radius = 10

'Current angle, and angular velocity (dTheta / dt)
Dim Shared Theta as Single, Omega as Single

'Frame is called when you want to draw a new frame
Sub Frame(dt as Single)
  'dt is number of seconds passed since last frame (typically less than one, since you want several frames per second)

 'Initialize the frame (clear buffers, set up projection, etc)
 InitFrame

 'Increase angle
 Theta = Theta + (Omega * dt)

 'Calculate co-ordinates of point
 X = Radius * Cos(Theta)
 Y = Radius * Sin(Theta)

 glBegin(GL_POINTS)

  'Set the colour of the point
  glColor(<r>, <g>, <b>, <a>)


  'Draw the point
  glVertex2f(X, Y)

 glEnd()

 'Display the frame
 RenderFrame

End Sub

May 16, 2009 | Advanced Graphics Programming Using OpenGL...

5 Answers

Source code for stack using arrays in c++


stack in c using arrays
/* Program of stack using array*/
#include

Dec 05, 2008 | Computers & Internet

2 Answers

C++ program for insertion, deletion in linked list and 2d array pls send the details for linked list so that i can understand it the best..considering me as a beginner.


program for deletion


#include<iostream.h>
void main()
{
int a[10],i,n,x;
cout<<"\n\t\tPROGRAM TO DELETE AN NUMBER FROM AN ARRAY";
cout<<"\nEnter the size of the array:";
cin>>n;
for(i=0;i<n;i++)
{
cout<<"\nEnter the number:";
cin>>a[i];
}
cout<<"\nEnter the position to be deleted:";
cin>>x;
for(i=x;i<n;i++)
a[i]=a[i+1];
for(i=0;i<n-1;i++)
cout<<a[i]<<" ";
}

Oct 13, 2008 | Computers & Internet

2 Answers

Tally 9 data was deleted by mistake


use acronis software to retrieve it

Aug 26, 2008 | Computers & Internet

Not finding what you are looking for?
Computers & Internet Logo

Related Topics:

326 people viewed this question

Ask a Question

Usually answered in minutes!

Top Sun Computers & Internet Experts

Les Dickinson
Les Dickinson

Level 3 Expert

18333 Answers

Brian Sullivan
Brian Sullivan

Level 3 Expert

27725 Answers

Cosma Papouis
Cosma Papouis

Level 3 Expert

404 Answers

Are you a Sun Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...