1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Tema [17]
4 years ago
11

Write a function that implements another stack function, peek. Peek returns the value of the first element on the stack without

removing the element from the stack. Peek should also do underflow error checking. (Why is overflow error checking unnecessary
Computers and Technology
1 answer:
devlian [24]4 years ago
3 0

Answer:

See explaination

Explanation:

StackExample.java

public class StackExample<T> {

private final static int DEFAULT_CAPACITY = 100;

private int top;

private T[] stack = (T[])(new Object[DEFAULT_CAPACITY]);

/**

* Returns a reference to the element at the top of this stack.

* The element is not removed from the stack.

* atreturn element on top of stack

* atthrows EmptyCollectionException if stack is empty

*/

public T peek() throws EmptyCollectionException

{

if (isEmpty())

throw new EmptyCollectionException("stack");

return stack[top-1];

}

/**

* Returns true if this stack is empty and false otherwise.

* atreturn true if this stack is empty

*/

public boolean isEmpty()

{

return top < 0;

}

}

//please replace "at" with the at symbol

Note:

peek() method will always pick the first element from stack. While calling peek() method when stack is empty then it will throw stack underflow error. Since peek() method will always look for first element ffrom stack there is no chance for overflow of stack. So overflow error checking is not required. In above program we handled underflow error in peek() method by checking whether stack is an empty or not.

You might be interested in
Susan is in charge of the inventory reports for her company.She will need to find specific inventory items as well as project in
Nezavi [6.7K]

Answer:

lookup function

Explanation:

We can use the lookup function to find some values or reference in a range, we can use this syntax: LOOKUP( value, lookup_range, [result_range] ), where value is what we are going to look for, lookup_range is the single row or column is the range, and result_range is an optional part, in this range we're going to get the value.

8 0
4 years ago
What is a wiki website?
expeople1 [14]

Answer:

A wiki website is a website we're people share ideas and information.

7 0
3 years ago
Which of the following information should be included in audit documentation? a. Procedures performed. b. Audit evidence examine
irinina [24]

Answer:

This standard establishes general requirements for documentation the auditor should prepare and retain in connection with engagements conducted pursuant to the standards of the Public Company Accounting Oversight Board (\"PCAOB\"). Such engagements include an audit of financial statements, an audit of internal control over financial reporting, and a review of interim financial information. This standard does not replace specific documentation requirements of other standards of the PCAOB.

Explanation:

hope this helps

you out ok

and have a blessed day

Your welcome

8 0
3 years ago
Claire writes a letter to her grandmother, in which she describes an amusement park she visited last week. She adds pictures of
alexgriva [62]

Claire uses the <u>Crop option</u> from the Format tab to remove unwanted parts of the pictures.  

<u>Explanation:</u>

In Microsoft Word, after inserting a picture, when we click on the picture to select it, the ribbon shows the format options. Various options are available for formatting a picture, however, in order to cut out the unwanted portion Claire needs to use the crop option.

Crop options allow the user to cut resize an image by cutting out the part of the picture user decides.

<u>To crop the picture follow the procedure given below:</u>

  • Double click on the image
  • Click the format tab to size the image
  • Click crop, perform cropping using the handles appearing at the edge of image.
  • Drag handles to crop and save them.
7 0
3 years ago
Binary is best interpreted by a computer because?
Tomtit [17]
The answer is d. The hardware has a terrible time translating binary into decimal. Computers in general don't like "talking"  to people. D is wrong.

bits are part of bytes.You use bits to make up bytes, not the other way around. Bit's are what computers use to construct their "speech." Bytes make it more convenient to convert from Hex(or binary) to decimal. C is wrong.

A is wrong. There are only two numbers in the binary system -- one and zero. Not three.

B is the correct answer.

4 0
4 years ago
Read 2 more answers
Other questions:
  • Write a program to help you feed your friends at a party by doing some math about square pizzas. Assume the grader defines a str
    12·1 answer
  • To type the letter address, _________ space from the dateline
    9·2 answers
  • Ryan has created a Word document to be used as a review quiz for students in a classroom setting. The document contains both que
    6·1 answer
  • Question 16 (2 points) Question 16 Unsaved
    11·1 answer
  • Differences between Quality of Services and a Service of Quality approach
    9·1 answer
  • Cpu coolers are typically made using what two different types of materials?
    6·1 answer
  • Sergio needs to tell his team about some negative feedback from a client. The team has been
    14·1 answer
  • Cómo surge y cuál es el objetivo del observatorio de radio y televisión
    11·1 answer
  • Which of these is an example of output?
    13·2 answers
  • Your development team is planning to host a development environment on the cloud. This consists of EC2 and RDS instances. This e
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!